onCreateNode script for app:project type now deep copies contents of Project space template when a New Project is created via the action in the Projects space

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7609 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-12-09 11:58:34 +00:00
parent 1d33b43f2e
commit 61252359f1
2 changed files with 31 additions and 11 deletions

View File

@@ -1,15 +1,35 @@
// onCreateNode policy code for app:projectfolder
var project = behaviour.args[0];
var results = search.luceneSearch("+PATH:\"" + project.qnamePath + "/*\" +ASPECT:\"{http://www.alfresco.org/model/emailserver/1.0}aliasable\"");
if (results.length == 1)
logger.log("onCreateNode policy code for app:projectfolder");
var project = behaviour.args[0].child;
if (project.children.length == 0)
{
// perform deep copy of Project template contents into this node
var templates = search.luceneSearch("+PATH:\"/app:company_home/app:dictionary/app:space_templates/*\" +TYPE:\"{http://www.alfresco.org/model/application/1.0}projectfolder\"");
if (templates.length == 0)
{
logger.log("No app:project templates found to copy!");
}
else
{
logger.log("Copying app:project template into new project...");
for each (var child in templates[0].children)
{
child.copy(project, true);
}
// search for the email archive child folder
var results = search.luceneSearch("+PATH:\"" + project.qnamePath + "/*\" +ASPECT:\"{http://www.alfresco.org/model/emailserver/1.0}aliasable\"");
if (results.length == 1)
{
results[0].properties["emailserver:alias"] = normalise(project.name);
results[0].save();
logger.log("Applied email alias of: " + normalise(project.name));
}
else
{
logger.log("No email folder found!");
}
else
{
logger.log("No email archive folder found!");
}
}
}
function normalise(s)

View File

@@ -6,7 +6,7 @@
<!-- Project behaviour registration -->
<bean id="app_projectfolder_onCreateNode" class="org.alfresco.repo.policy.registration.ClassPolicyRegistration" parent="policyRegistration">
<property name="policyName">
<value>{http://www.alfresco.org}onUpdateNode</value>
<value>{http://www.alfresco.org}onCreateNode</value>
</property>
<property name="className">
<value>{http://www.alfresco.org/model/application/1.0}projectfolder</value>