<?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 if
et 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. 2012-02-27 10:56:10,236 ERROR [extensions.webscripts.AbstractRuntime] [http-8080-1] Exception from executeScript - redirecting to status template error: 01270011 Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnCreateNodePolicy.onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) in transaction fce514ba-51ef-447c-9fa5-84589ee0410f
org.alfresco.error.AlfrescoRuntimeException: 01270011 Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnCreateNodePolicy.onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) in transaction fce514ba-51ef-447c-9fa5-84589ee0410f
at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(TransactionBehaviourQueue.java:257)
at org.alfresco.repo.policy.TransactionBehaviourQueue.beforeCommit(TransactionBehaviourQueue.java:134)
at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:747)
at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:727)
at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.beforeCommit(AlfrescoTransactionSupport.java:687)
at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:95)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:927)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:737)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:472)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:410)
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:462)
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:500)
at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:316)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:372)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.alfresco.scripts.ScriptException: 01270010 Failed to execute script 'alfresco/extension/script/onCreateSite_addSpaceTemplate.js': 01270009 ReferenceError: "document" n'est pas défini (alfresco/extension/script/onCreateSite_addSpaceTemplate.js#2)
at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:195)
at org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:212)
at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy264.executeScript(Unknown Source)
at org.alfresco.repo.jscript.ScriptBehaviour$JavaScriptInvocationHandler.invokeScript(ScriptBehaviour.java:161)
at org.alfresco.repo.jscript.ScriptBehaviour$JavaScriptInvocationHandler.invoke(ScriptBehaviour.java:144)
at $Proxy20.onCreateNode(Unknown Source)
at sun.reflect.GeneratedMethodAccessor316.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(TransactionBehaviourQueue.java:245)
… 34 more
Caused by: org.alfresco.error.AlfrescoRuntimeException: 01270009 ReferenceError: "document" n'est pas défini (alfresco/extension/script/onCreateSite_addSpaceTemplate.js#2)
at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:499)
at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:191)
… 60 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "document" n'est pas défini (alfresco/extension/script/onCreateSite_addSpaceTemplate.js#2)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3413)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1612)
at org.mozilla.javascript.gen.c8._c0(alfresco/extension/script/onCreateSite_addSpaceTemplate.js:2)
at org.mozilla.javascript.gen.c8.call(alfresco/extension/script/onCreateSite_addSpaceTemplate.js)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
at org.mozilla.javascript.gen.c8.call(alfresco/extension/script/onCreateSite_addSpaceTemplate.js)
at org.mozilla.javascript.gen.c8.exec(alfresco/extension/script/onCreateSite_addSpaceTemplate.js)
at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:483)
… 61 more
var site = document;
Comme le dit votre log : ReferenceError: "document" n'est pas défini
Lorsque vous utilisez le behaviours en JavaScript, le noeud à l'origine de l'évènement est disponible dans le tableau de paramètres. Essayez-donc avec ;var site = args[0];
var childAssoc = behaviour.args[0];
var site = childAssoc.getChild();
mais maintenant j'ai un autre problème :Caused by: org.alfresco.error.AlfrescoRuntimeException: 01270007 ReferenceError: "companyhome" n'est pas défini (alfresco/extension/script/onCreateSite_addSpaceTemplate.js#8)
at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:499)
at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:191)
… 60 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "companyhome" n'est pas défini (alfresco/extension/script/onCreateSite_addSpaceTemplate.js#8)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3413)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1612)
at org.mozilla.javascript.gen.c8._c0(alfresco/extension/script/onCreateSite_addSpaceTemplate.js:8)
at org.mozilla.javascript.gen.c8.call(alfresco/extension/script/onCreateSite_addSpaceTemplate.js)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
at org.mozilla.javascript.gen.c8.call(alfresco/extension/script/onCreateSite_addSpaceTemplate.js)
at org.mozilla.javascript.gen.c8.exec(alfresco/extension/script/onCreateSite_addSpaceTemplate.js)
at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:483)
Es que companyHome n'est pas défini par défaut?Comment par recherche pouvez vous m'expliquer plus.Oui, c'est possible ;-)
var templates = companyhome.childByNamePath("/Data Dictionary/Space Templates/Projet").children;
Or, companyhome n'est pas un objet JavaScript disponible (et la méthode childByNamePath n'est pas forcément des plus optimale).PATH:"/app:company_home/app:dictionary/app:space_templates/cmrojet/*"
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.