cancel
Showing results for 
Search instead for 
Did you mean: 

Générer un site à partir d'un modèle de site

dorra87
Champ in-the-making
Champ in-the-making
Bonjour tous le monde,
Bon j'ai essayé de créer un site Share en utilisant un modèle de site mais quand je crée le site j'obtiens url est déja utilisé,alors que j'ai pas d'autre site avec la même URL.
voila le code de shared/classes/alfresco/extension/behaviour-bean-context.xml
<?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.
Une autre question comment je peux savoir s'il y a une erreur dans le javascript,sachant que j'ai essayé d'utiliser le débogueur javascript de Share mais la page m'affiche une erreur status 500.
J’espère avoir d'aide la dessous car je suis bloquée la dessous depuis une semaine et j'en ai bien besoin.
Merci d'avance de votre aide
12 REPLIES 12

dorra87
Champ in-the-making
Champ in-the-making
Bonjour,
T' as raison j'ai du faire attention aux majuscules. Smiley Surprisedops:
Maintenant il me crée un site mais il ne copie pas les dossiers se trouvant sous Space Templates sous le dossier document library du site crée.En plus,j'ai pas d'erreurs dans le log.
voila le code :
// 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

cleseach
Star Contributor
Star Contributor
Bonjour,

Sur le wiki, on peut lire :
Array luceneSearch(string query)
    Returns an array of ScriptNode objects that were found by the Alfresco repository full-text search, for example: var nodes = search.luceneSearch("TEXT:alfresco");
Dans votre code templateNode est donc un tableau. L'appel templateFolder.children ne correspond donc à rien.

Cordialement,
Charles Le Seac'h

dorra87
Champ in-the-making
Champ in-the-making
Bonjour,
ça marche bien maintenant,voila le code pour ceux qui ont besoins
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.