From 61252359f129579f1d43e25c508374242dc1dfc6 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Sun, 9 Dec 2007 11:58:34 +0000 Subject: [PATCH] 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 --- .../script/onCreateNode_app_projectfolder.js | 40 ++++++++++++++----- config/alfresco/projects-context.xml | 2 +- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/config/alfresco/module/projects/script/onCreateNode_app_projectfolder.js b/config/alfresco/module/projects/script/onCreateNode_app_projectfolder.js index 2af24ff432..18b50e5853 100644 --- a/config/alfresco/module/projects/script/onCreateNode_app_projectfolder.js +++ b/config/alfresco/module/projects/script/onCreateNode_app_projectfolder.js @@ -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) { - 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!"); + // 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 archive folder found!"); + } + } } function normalise(s) diff --git a/config/alfresco/projects-context.xml b/config/alfresco/projects-context.xml index 712fa00f02..2b744ed444 100644 --- a/config/alfresco/projects-context.xml +++ b/config/alfresco/projects-context.xml @@ -6,7 +6,7 @@ - {http://www.alfresco.org}onUpdateNode + {http://www.alfresco.org}onCreateNode {http://www.alfresco.org/model/application/1.0}projectfolder