AnsweredAssumed Answered

Dévelopement de module

Question asked by huberd on Apr 26, 2010
Latest reply on Apr 27, 2010 by bertrandf
Bonjour,

j'ai développé un module qui m'a permis de mettre à niveau les aspects de mes documents. Ce module devait être executé une seule fois sur mon repository et au démarrage d'Alfresco.

Pour réaliser cela, j'ai développé un module qui se nomme UpgradeContentAspects comme suit :

public class UpgradeContentAspects extends AbstractModuleComponent {

   private NodeService nodeService;
   private SearchService searchService;
   private CheckOutCheckInService checkOutCheckInService;
   private PermissionService permissionService;

   public void setNodeService(NodeService nodeService)
   {
      this.nodeService = nodeService;
   }

   public void setSearchService(SearchService searchService)
   {
      this.searchService = searchService;
   }

   public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService)
   {
      this.checkOutCheckInService = checkOutCheckInService;
   }   

   public void setPermissionService(PermissionService permissionService)
   {
      this.permissionService = permissionService;
   }

   @Override
   protected void executeInternal() throws Throwable
   {
      info("Upgrade is being processing…", null);
      StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");

      DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
      //namespacePrefixResolver.registerNamespace(NamespaceService.SYSTEM_MODEL_PREFIX, NamespaceService.SYSTEM_MODEL_1_0_URI);
      namespacePrefixResolver.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, NamespaceService.CONTENT_MODEL_1_0_URI);
      namespacePrefixResolver.registerNamespace(OldContentModel.LPR_CONTENT_PREFIX, OldContentModel.NAMESPACE);

      NodeRef rootNodeRef = nodeService.getRootNode(storeRef);

      //
      // Upgrade Draft
      //
      ContentUpgrade(rootNodeRef, namespacePrefixResolver, CommunityConstante.STATUS_DRAFT);

      //
      // Upgrade Approval
      //
      ContentUpgrade(rootNodeRef, namespacePrefixResolver, CommunityConstante.STATUS_APPROVAL);

      //
      // Upgrade Approved
      //
      ContentUpgrade(rootNodeRef, namespacePrefixResolver, CommunityConstante.STATUS_APPROVED);        

      //
      // Upgrade Archived
      //
      ContentUpgrade(rootNodeRef, namespacePrefixResolver, CommunityConstante.STATUS_ARCHIVED);        

      //
      // Upgrade Quality
      //
      ContentUpgrade(rootNodeRef, namespacePrefixResolver, CommunityConstante.STATUS_QUALITY);   
      
      info("Upgrade completed.", null);
   }

   …

}

Ce module est déclaré en version 1.0 comme suit :

module\upgradeContentAspects\module-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>
   
    <import resource="classpath:alfresco/module/upgradeContentAspects/context/service-context.xml" />
   
</beans>

module\upgradeContentAspects\module.properties
# Upgrade Aspects module
module.id=upgradeContentAspects
module.title=upgrade Content Aspects AMP Project
module.description=Upgrade Content Aspects on repository
module.version=1.0

module\upgradeContentAspects\context\service-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>

    <!– Import the Alfresco nitty gritty –>
    <!–import resource="classpath:alfresco/application-context.xml" /–>

    <!– A simple module component that will be executed once –>
    <bean id="upgradeContentAspect.upgradeComponent" class="org.alfresco.community.module.upgradecontent.UpgradeContentAspects" parent="module.baseComponent" >
        <property name="moduleId" value="upgradeContentAspects" />  <!– See module.properties –>
        <property name="name" value="upgradeComponent" />
        <property name="description" value="An upgrade component" />
        <property name="sinceVersion" value="1.0" />
        <property name="appliesFromVersion" value="1.0" />
        <property name="nodeService">
          <ref bean="nodeService" />
       </property>
       <property name="searchService">
          <ref bean="searchService" />
       </property>
       <property name="checkOutCheckInService">
          <ref bean="checkOutCheckInService" />
       </property>
       <property name="permissionService">
          <ref bean="permissionService" />
       </property>
    </bean>

</beans>

A ce jour, je me rend compte que j'ai oublié certaines mise à jour et souhaiterais executer à nouveau mon module en 1.1.

Comment est-ce possible ?

Merci pour votre aide.

Outcomes