mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Working implementation of basic WCM submit workflow.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4444 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,23 +1,17 @@
|
||||
package org.alfresco.repo.avm.wf;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.workflow.jbpm.JBPMNode;
|
||||
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncException;
|
||||
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;
|
||||
@@ -60,38 +54,48 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
|
||||
*/
|
||||
public void execute(ExecutionContext executionContext) throws Exception
|
||||
{
|
||||
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("package")).getNodeRef();
|
||||
List<ChildAssociationRef> children = fNodeService.getChildAssocs(pkg);
|
||||
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
|
||||
Map<String, String> storesHit = new HashMap<String, String>();
|
||||
for (ChildAssociationRef child : children)
|
||||
{
|
||||
NodeRef childRef = child.getChildRef();
|
||||
if (!fNodeService.hasAspect(childRef, ContentModel.ASPECT_REFERENCES_NODE))
|
||||
{
|
||||
throw new AVMSyncException("Package node does not have cm:referencesnode.");
|
||||
}
|
||||
NodeRef toSubmit = (NodeRef)fNodeService.getProperty(childRef, ContentModel.PROP_NODE_REF);
|
||||
Pair<Integer, String> versionPath = AVMNodeConverter.ToAVMVersionPath(toSubmit);
|
||||
String avmPath = versionPath.getSecond();
|
||||
String [] storePath = avmPath.split(":");
|
||||
String websiteName = fAVMService.getStoreProperty(storePath[0],
|
||||
QName.createQName(null, ".website.name")).
|
||||
getStringValue();
|
||||
String stagingName = websiteName + "-staging";
|
||||
AVMDifference diff =
|
||||
new AVMDifference(-1, avmPath,
|
||||
-1, stagingName + ":" + storePath[1],
|
||||
AVMDifference.NEWER);
|
||||
diffs.add(diff);
|
||||
storesHit.put(storePath[0], stagingName);
|
||||
}
|
||||
// TODO fix update comments if needed.
|
||||
fAVMSyncService.update(diffs, true, true, false, false, null, null);
|
||||
for (Map.Entry<String, String> entry : storesHit.entrySet())
|
||||
{
|
||||
fAVMSyncService.flatten(entry.getKey() + ":/appBase",
|
||||
entry.getValue() + ":/appBase");
|
||||
}
|
||||
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
|
||||
Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
|
||||
|
||||
AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
|
||||
String targetPath = pkgDesc.getIndirection();
|
||||
List<AVMDifference> diff = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath);
|
||||
fAVMSyncService.update(diff, true, true, false, false, null, null);
|
||||
|
||||
String from = (String)executionContext.getContextInstance().getVariable("wf_from");
|
||||
fAVMSyncService.flatten(from, targetPath);
|
||||
|
||||
// List<ChildAssociationRef> children = fNodeService.getChildAssocs(pkg);
|
||||
// List<AVMDifference> diffs = new ArrayList<AVMDifference>();
|
||||
// Map<String, String> storesHit = new HashMap<String, String>();
|
||||
// for (ChildAssociationRef child : children)
|
||||
// {
|
||||
// NodeRef childRef = child.getChildRef();
|
||||
// if (!fNodeService.hasAspect(childRef, ContentModel.ASPECT_REFERENCES_NODE))
|
||||
// {
|
||||
// throw new AVMSyncException("Package node does not have cm:referencesnode.");
|
||||
// }
|
||||
// NodeRef toSubmit = (NodeRef)fNodeService.getProperty(childRef, ContentModel.PROP_NODE_REF);
|
||||
// Pair<Integer, String> versionPath = AVMNodeConverter.ToAVMVersionPath(toSubmit);
|
||||
// String avmPath = versionPath.getSecond();
|
||||
// String [] storePath = avmPath.split(":");
|
||||
// String websiteName = fAVMService.getStoreProperty(storePath[0],
|
||||
// QName.createQName(null, ".website.name")).
|
||||
// getStringValue();
|
||||
// String stagingName = websiteName + "-staging";
|
||||
// AVMDifference diff =
|
||||
// new AVMDifference(-1, avmPath,
|
||||
// -1, stagingName + ":" + storePath[1],
|
||||
// AVMDifference.NEWER);
|
||||
// diffs.add(diff);
|
||||
// storesHit.put(storePath[0], stagingName);
|
||||
// }
|
||||
// // TODO fix update comments if needed.
|
||||
// fAVMSyncService.update(diffs, true, true, false, false, null, null);
|
||||
// for (Map.Entry<String, String> entry : storesHit.entrySet())
|
||||
// {
|
||||
// fAVMSyncService.flatten(entry.getKey() + ":/appBase",
|
||||
// entry.getValue() + ":/appBase");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user