02-27-2012 03:03 AM
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="onCreateNode_Site" class="org.alfresco.repo.policy.registration.ClassPolicyRegistration" parent="policyRegistration">
<property name="policyName">
<value>{http://www.alfresco.org}onCreateNode</value>
</property>
<property name="className">
<value>{http://www.alfresco.org/model/site/1.0}site</value>
</property>
<property name="behaviour">
<bean class="org.alfresco.repo.jscript.ScriptBehaviour" parent="scriptBehaviour">
<property name="notificationFrequency">
<value>TRANSACTION_COMMIT</value>
</property>
<property name="location">
<bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">
<constructor-arg>
<value>alfresco/extension/script/onCreateSite_addSpaceTemplate.js</value>
</constructor-arg>
</bean>
</property>
</bean>
</property>
</bean>
</beans>et le js shared/classes/alfresco/extension/script/onCreateSite_addSpaceTemplate.js// execute onCreate of a Site
var site = document;
if (site.properties["st:sitePreset"]=="prj-dashboard"){
logger.log("### Prepping to get Templates folder");
var templates = companyhome.childByNamePath("/Data Dictionary/Space Templates/Projet").children;
var docLib = site.childByNamePath("documentLibrary");
if (!docLib){
docLib = site.createFolder("documentLibrary");
}
if (docLib) {
for (var i in templates){
var child = templates[i];
child.copy(docLib, true);
} // end for
} // end if
} // end ifet j'ai ajouté dans le fichier presets.xml ça :<preset id="prj-dashboard">
<components>
<!– title –>
<component>
<scope>page</scope>
<region-id>title</region-id>
<source-id>site/${siteid}/dashboard</source-id>
<url>/components/title/collaboration-title</url>
</component>
<!– navigation –>
<component>
<scope>page</scope>
<region-id>navigation</region-id>
<source-id>site/${siteid}/dashboard</source-id>
<url>/components/navigation/collaboration-navigation</url>
</component>
<!– dashboard components –>
<component>
<scope>page</scope>
<region-id>full-width-dashlet</region-id>
<source-id>site/${siteid}/dashboard</source-id>
<url>/components/dashlets/dynamic-welcome</url>
<properties>
<dashboardType>site</dashboardType>
</properties>
</component>
<component>
<scope>page</scope>
<region-id>component-1-1</region-id>
<source-id>site/${siteid}/dashboard</source-id>
<url>/components/dashlets/colleagues</url>
<properties>
<height>504</height>
</properties>
</component>
<component>
<scope>page</scope>
<region-id>component-2-1</region-id>
<source-id>site/${siteid}/dashboard</source-id>
<url>/components/dashlets/docsummary</url>
</component>
<component>
<scope>page</scope>
<region-id>component-2-2</region-id>
<source-id>site/${siteid}/dashboard</source-id>
<url>/components/dashlets/activityfeed</url>
</component>
</components>
<pages>
<page id="site/${siteid}/dashboard">
<title>Collaboration Site Dashboard</title>
<title-id>page.siteDashboard.title</title-id>
<description>Collaboration site's dashboard page</description>
<description-id>page.siteDashboard.description</description-id>
<template-instance>dashboard-2-columns-wide-right</template-instance>
<authentication>user</authentication>
<properties>
<sitePages>[{"pageId":"documentlibrary"}]</sitePages>
</properties>
</page>
</pages>
</preset>J'ai essayé de faire ça avec alfresco 4.0.c et 4.0.d mais toujours le même résultat.02-29-2012 07:43 AM
// execute onCreate of a Site
var childAssoc = behaviour.args[0];
var site = childAssoc.getChild();
//var site = args[0];
logger.log("### avant template");
//if (site.properties["st:sitePreset"]=="prj-dashboard"){
logger.log("### Prepping to get Templates folder");
var templateFolder = search.luceneSearch('PATH:"/app:company_home/app:dictionary/app:space_templates"');
var docLib = site.childByNamePath("documentlibrary");
if (!docLib){
docLib = site.createFolder("documentlibrary");
}
if (docLib) {
for (var i in templateFolder.children){
var child = templateFolder.children[i];
child.copy(docLib, true);
}
}
//}
Encore merci de votre aide
02-29-2012 08:22 AM
Array luceneSearch(string query)Dans votre code templateNode est donc un tableau. L'appel templateFolder.children ne correspond donc à rien.
Returns an array of ScriptNode objects that were found by the Alfresco repository full-text search, for example: var nodes = search.luceneSearch("TEXT:alfresco");
02-29-2012 11:16 AM
var childAssoc = behaviour.args[0];
var site = childAssoc.getChild();
var templateFolder = search.luceneSearch('PATH:"/app:company_home/app:dictionary/app:models"');
var docLib = site.childByNamePath("documentlibrary");
if (!docLib){
docLib = site.createFolder("documentlibrary");
}
if (docLib) {
for(var i=0;i< templateFolder.length;i++)
{
for(j=0;j< templateFolder[i].children.length;j++)
{
templateFolder[i].children[j].copy(docLib,true);
}
}
}
Merci infiniment Charles.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.