From 0fc71b8d68b27ac85ffa41e0e737b1ff4e4f1575 Mon Sep 17 00:00:00 2001 From: Britt Park Date: Mon, 2 Oct 2006 19:42:56 +0000 Subject: [PATCH] Checkpoint of WCM workflow package support. Setting titled and uifacets via AVMService instead of through AVMNodeService. 1000 file import takes ~5 minutes. Awful but better than before. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3995 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/public-services-context.xml | 1 + config/alfresco/workflow/wcmSubmit.xml | 6 +- config/alfresco/workflow/wcmSubmitModel.xml | 4 +- .../org/alfresco/repo/avm/AVMServiceImpl.java | 18 ++++ .../alfresco/repo/avm/hibernate/AVM.hbm.xml | 5 +- .../repo/avm/wf/AVMSubmitPackageHandler.java | 84 +++++++++++++++++++ .../alfresco/service/cmr/avm/AVMService.java | 7 ++ 7 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java diff --git a/config/alfresco/public-services-context.xml b/config/alfresco/public-services-context.xml index 30f41312df..9138bd9d63 100644 --- a/config/alfresco/public-services-context.xml +++ b/config/alfresco/public-services-context.xml @@ -1045,6 +1045,7 @@ ${server.transaction.mode.readOnly} ${server.transaction.mode.default} ${server.transaction.mode.default} + ${server.transaction.mode.default} ${server.transaction.mode.readOnly} ${server.transaction.mode.readOnly} ${server.transaction.mode.default} diff --git a/config/alfresco/workflow/wcmSubmit.xml b/config/alfresco/workflow/wcmSubmit.xml index 709f67285a..c8b7348f30 100644 --- a/config/alfresco/workflow/wcmSubmit.xml +++ b/config/alfresco/workflow/wcmSubmit.xml @@ -12,7 +12,8 @@ - + + @@ -27,7 +28,8 @@ - + + diff --git a/config/alfresco/workflow/wcmSubmitModel.xml b/config/alfresco/workflow/wcmSubmitModel.xml index bedcbbd8b5..f2d4538240 100644 --- a/config/alfresco/workflow/wcmSubmitModel.xml +++ b/config/alfresco/workflow/wcmSubmitModel.xml @@ -22,8 +22,8 @@ d:text - - Source Sandbox Path + + Sandbox Store Name d:text diff --git a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java index f98a64218d..02edc9ab35 100644 --- a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java +++ b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java @@ -51,6 +51,8 @@ import org.apache.log4j.Logger; */ public class AVMServiceImpl implements AVMService { + public static final String SYSTEM = "system"; + private static Logger fgLogger = Logger.getLogger(AVMServiceImpl.class); /** @@ -741,6 +743,22 @@ public class AVMServiceImpl implements AVMService } } + /** + * Get (and create if necessary) the system store. This store houses things + * like workflow packages. + * @return The descriptor. + */ + public AVMStoreDescriptor getAVMSystemStore() + { + AVMStoreDescriptor store = getAVMStore(SYSTEM); + if (store == null) + { + createAVMStore(SYSTEM); + return getAVMStore(SYSTEM); + } + return store; + } + /** * Get a descriptor for the specified AVMStore root. * @param version The version to get. diff --git a/source/java/org/alfresco/repo/avm/hibernate/AVM.hbm.xml b/source/java/org/alfresco/repo/avm/hibernate/AVM.hbm.xml index 8c904f648a..4a3cb1bf7a 100644 --- a/source/java/org/alfresco/repo/avm/hibernate/AVM.hbm.xml +++ b/source/java/org/alfresco/repo/avm/hibernate/AVM.hbm.xml @@ -100,10 +100,7 @@ - + diff --git a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java new file mode 100644 index 0000000000..8f108b7cd0 --- /dev/null +++ b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java @@ -0,0 +1,84 @@ +package org.alfresco.repo.avm.wf; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.repo.avm.AVMNodeConverter; +import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.avmsync.AVMDifference; +import org.alfresco.service.cmr.avmsync.AVMSyncService; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; +import org.jbpm.graph.exe.ExecutionContext; +import org.springframework.beans.factory.BeanFactory; + +public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements + Serializable +{ + private static final long serialVersionUID = 4113360751217684995L; + + /** + * The AVMService instance. + */ + private AVMService fAVMService; + + /** + * The AVMSyncService instance. + */ + private AVMSyncService fAVMSyncService; + + /** + * The NodeService reference. + */ + private NodeService fNodeService; + + /** + * Initialize service references. + * @param factory The BeanFactory to get references from. + */ + @Override + protected void initialiseHandler(BeanFactory factory) + { + fAVMService = (AVMService)factory.getBean("AVMService"); + fAVMSyncService = (AVMSyncService)factory.getBean("AVMSyncService"); + fNodeService = (NodeService)factory.getBean("NodeService"); + } + + /** + * Do the actual work. + * @param executionContext The context to get stuff from. + */ + public void execute(ExecutionContext executionContext) throws Exception + { + String srcStoreName = (String)executionContext.getContextInstance().getVariable("storeName"); + NodeRef pkg = (NodeRef)executionContext.getContextInstance().getVariable("package"); + String webSiteName = + fAVMService.getStoreProperty(srcStoreName, QName.createQName(null, ".website.name")).getStringValue(); + String stagingName = webSiteName + "-staging"; + List children = fNodeService.getChildAssocs(pkg); + List diffs = new ArrayList(); + for (ChildAssociationRef child : children) + { + NodeRef childRef = child.getChildRef(); + Pair childPath = AVMNodeConverter.ToAVMVersionPath(childRef); + List> possiblePaths = + fAVMService.getPathsInStoreHead(fAVMService.lookup(childPath.getFirst(), childPath.getSecond()), + srcStoreName); + Pair actualPath = possiblePaths.get(0); + String [] pathParts = actualPath.getSecond().split(":"); + AVMDifference diff = + new AVMDifference(-1, srcStoreName + ":" + pathParts[1], + -1, stagingName + ":" + pathParts[1], + AVMDifference.NEWER); + diffs.add(diff); + } + fAVMSyncService.update(diffs, true, true, false, false); + fAVMSyncService.flatten(srcStoreName + ":/appBase", + stagingName + ":/appBase"); + } +} diff --git a/source/java/org/alfresco/service/cmr/avm/AVMService.java b/source/java/org/alfresco/service/cmr/avm/AVMService.java index 95cca6067b..843bf67000 100644 --- a/source/java/org/alfresco/service/cmr/avm/AVMService.java +++ b/source/java/org/alfresco/service/cmr/avm/AVMService.java @@ -346,6 +346,13 @@ public interface AVMService */ public List getAVMStores(); + /** + * Get (and create if necessary) the system store. This store houses things + * like workflow packages. + * @return The descriptor. + */ + public AVMStoreDescriptor getAVMSystemStore(); + /** * Get a descriptor for an AVMStore. * @param name The AVMStore's name.