diff --git a/config/alfresco/workflow/publish_web_content_processdefinition.xml b/config/alfresco/workflow/publish_web_content_processdefinition.xml index 45e5855729..8fb16dbc46 100644 --- a/config/alfresco/workflow/publish_web_content_processdefinition.xml +++ b/config/alfresco/workflow/publish_web_content_processdefinition.xml @@ -6,8 +6,15 @@ - + + + + + #{pubwf_scheduledPublishDate == null} + + + diff --git a/config/alfresco/workflow/publishingWorkflowModel.xml b/config/alfresco/workflow/publishingWorkflowModel.xml index 9df3a7c00c..1347b54f88 100644 --- a/config/alfresco/workflow/publishingWorkflowModel.xml +++ b/config/alfresco/workflow/publishingWorkflowModel.xml @@ -24,8 +24,7 @@ true - d:datetime - true + d:any diff --git a/source/java/org/alfresco/repo/action/scheduled/AbstractScheduledAction.java b/source/java/org/alfresco/repo/action/scheduled/AbstractScheduledAction.java index 2cb0866622..751eb2467e 100644 --- a/source/java/org/alfresco/repo/action/scheduled/AbstractScheduledAction.java +++ b/source/java/org/alfresco/repo/action/scheduled/AbstractScheduledAction.java @@ -657,7 +657,7 @@ public abstract class AbstractScheduledAction implements ScheduledActionDefiniti SECOND second; - Pair(FIRST first, SECOND second) + public Pair(FIRST first, SECOND second) { this.first = first; this.second = second; diff --git a/source/java/org/alfresco/repo/node/NodeUtils.java b/source/java/org/alfresco/repo/node/NodeUtils.java index 0dd9ada2a9..287c1f7336 100644 --- a/source/java/org/alfresco/repo/node/NodeUtils.java +++ b/source/java/org/alfresco/repo/node/NodeUtils.java @@ -19,9 +19,13 @@ package org.alfresco.repo.node; +import java.util.Collection; +import java.util.List; + import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.util.collections.CollectionUtils; import org.alfresco.util.collections.Filter; import org.alfresco.util.collections.Function; @@ -43,6 +47,11 @@ public abstract class NodeUtils }; } + public static List toNodeRefs(Collection nodeIds) + { + return CollectionUtils.transform(nodeIds, toNodeRef()); + } + public static Function toChildRef() { return new Function() @@ -54,6 +63,11 @@ public abstract class NodeUtils }; } + public static List toChildRefs(Collection assocRefs) + { + return CollectionUtils.transform(assocRefs, toChildRef()); + } + public static Function toParentRef() { return new Function() @@ -64,6 +78,11 @@ public abstract class NodeUtils } }; } + + public static List toParentRefs(Collection assocRefs) + { + return CollectionUtils.transform(assocRefs, toParentRef()); + } public static Function toNodeRefQueitly() { @@ -91,5 +110,4 @@ public abstract class NodeUtils }; } - } diff --git a/source/java/org/alfresco/repo/publishing/MutablePublishingPackageImpl.java b/source/java/org/alfresco/repo/publishing/MutablePublishingPackageImpl.java index 9a6b176bac..cc0b560d96 100644 --- a/source/java/org/alfresco/repo/publishing/MutablePublishingPackageImpl.java +++ b/source/java/org/alfresco/repo/publishing/MutablePublishingPackageImpl.java @@ -19,11 +19,11 @@ package org.alfresco.repo.publishing; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; -import java.util.List; +import java.util.Map; import java.util.Set; import org.alfresco.repo.transfer.manifest.TransferManifestNode; @@ -41,7 +41,7 @@ import org.alfresco.service.cmr.repository.NodeRef; public class MutablePublishingPackageImpl implements MutablePublishingPackage { private final TransferManifestNodeFactory transferManifestNodeFactory; - private final List entries = new ArrayList(); + private final Map entryMap = new HashMap(); private final Set nodesToPublish = new HashSet(); private final Set nodesToUnpublish= new HashSet(); @@ -71,7 +71,7 @@ public class MutablePublishingPackageImpl implements MutablePublishingPackage TransferManifestNode payload = transferManifestNodeFactory.createTransferManifestNode(nodeRef, null); if (TransferManifestNormalNode.class.isAssignableFrom(payload.getClass())) { - entries.add(new PublishingPackageEntryImpl(true, nodeRef, (TransferManifestNormalNode) payload)); + entryMap.put(nodeRef, new PublishingPackageEntryImpl(true, nodeRef, (TransferManifestNormalNode) payload)); } } nodesToPublish.addAll(nodesToAdd); @@ -92,7 +92,7 @@ public class MutablePublishingPackageImpl implements MutablePublishingPackage { for (NodeRef nodeRef : nodesToRemove) { - entries.add(new PublishingPackageEntryImpl(false, nodeRef, null)); + entryMap.put(nodeRef, new PublishingPackageEntryImpl(false, nodeRef, null)); } nodesToUnpublish.addAll(nodesToRemove); } @@ -103,7 +103,7 @@ public class MutablePublishingPackageImpl implements MutablePublishingPackage @Override public Collection getEntries() { - return entries; + return entryMap.values(); } /** @@ -123,4 +123,13 @@ public class MutablePublishingPackageImpl implements MutablePublishingPackage { return nodesToUnpublish; } + + /** + * {@inheritDoc} + */ + @Override + public Map getEntryMap() + { + return entryMap; + } } diff --git a/source/java/org/alfresco/repo/publishing/NodeSnapshotTransferImpl.java b/source/java/org/alfresco/repo/publishing/NodeSnapshotTransferImpl.java index 9effbe655f..0459505a78 100644 --- a/source/java/org/alfresco/repo/publishing/NodeSnapshotTransferImpl.java +++ b/source/java/org/alfresco/repo/publishing/NodeSnapshotTransferImpl.java @@ -39,14 +39,15 @@ import org.alfresco.service.namespace.QName; public class NodeSnapshotTransferImpl implements NodeSnapshot { private final TransferManifestNormalNode transferNode; - + private final String version; + /** * @param transferNode */ - public NodeSnapshotTransferImpl(TransferManifestNormalNode transferNode) + public NodeSnapshotTransferImpl(TransferManifestNormalNode transferNode, String version) { - super(); this.transferNode = transferNode; + this.version = version; } /* (non-Javadoc) @@ -120,4 +121,13 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot { return transferNode.getType(); } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() + { + return version; + } } diff --git a/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java b/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java index 387a9505d7..64e7646719 100644 --- a/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java @@ -35,6 +35,7 @@ import org.alfresco.util.ParameterCheck; */ public class PublishServiceImpl implements PublishingService { + public static final String NAME = "publishingService"; private EnvironmentFactory environmentFactory; private PublishingEventHelper publishingEventHelper; diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java b/source/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java index 87805e8313..70ee81467a 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java @@ -20,6 +20,7 @@ package org.alfresco.repo.publishing; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -34,8 +35,9 @@ import org.alfresco.service.cmr.repository.NodeRef; */ public class PublishingEventFilterImpl implements PublishingEventFilter { - private Set ids = new HashSet(); - private Set publishedNodes = new HashSet(); + private Set ids = Collections.emptySet(); + private Set publishedNodes = Collections.emptySet(); + private Set unpublishedNodes = Collections.emptySet(); /** * {@inheritDoc} @@ -44,11 +46,23 @@ public class PublishingEventFilterImpl implements PublishingEventFilter { if(ids != null && ids.length>0) { - this.ids.addAll(Arrays.asList(ids)); + this.ids = new HashSet(Arrays.asList(ids)); } return this; } + /** + * {@inheritDoc} + */ + @Override + public PublishingEventFilter setIds(Collection ids) + { + if(ids != null && ids.isEmpty() == false) + { + this.ids = new HashSet(ids); + } + return this; + } /** * {@inheritDoc} */ @@ -62,20 +76,63 @@ public class PublishingEventFilterImpl implements PublishingEventFilter */ public PublishingEventFilter setPublishedNodes(NodeRef... publishedNodes) { - if(ids != null && publishedNodes.length>0) + if(publishedNodes != null && publishedNodes.length>0) { - this.publishedNodes.addAll(Arrays.asList(publishedNodes)); + this.publishedNodes = new HashSet(Arrays.asList(publishedNodes)); } return this; } - + + /** + * {@inheritDoc} + */ + public PublishingEventFilter setPublishedNodes(Collection publishedNodes) + { + if(publishedNodes != null && publishedNodes.isEmpty() == false) + { + this.publishedNodes = new HashSet(publishedNodes); + } + return this; + } + /** * {@inheritDoc} */ public Set getPublishedNodes() { - // TODO Auto-generated method stub - return null; + return Collections.unmodifiableSet(publishedNodes); } + /** + * {@inheritDoc} + */ + public PublishingEventFilter setUnpublishedNodes(NodeRef... unpublishedNodes) + { + if(unpublishedNodes != null && unpublishedNodes.length>0) + { + this.unpublishedNodes = new HashSet(Arrays.asList(unpublishedNodes)); + } + return this; + } + + /** + * {@inheritDoc} + */ + public PublishingEventFilter setUnpublishedNodes(Collection unpublishedNodes) + { + if(unpublishedNodes != null && unpublishedNodes.isEmpty() == false) + { + this.unpublishedNodes = new HashSet(unpublishedNodes); + } + return this; + } + + /** + * {@inheritDoc} + */ + public Set getUnpublishedNodes() + { + return Collections.unmodifiableSet(unpublishedNodes); + } + } diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java index 6cc22b20c7..df57246a11 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java @@ -348,8 +348,7 @@ public class PublishingEventHelper Map parameters = new HashMap(); parameters.put(PROP_WF_PUBLISHING_EVENT, eventNode); parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowService.createPackage(null)); - //TODO Will this handle the timezone? - parameters.put(PROP_WF_SCHEDULED_PUBLISH_DATE, scheduledTime.getTime()); + parameters.put(PROP_WF_SCHEDULED_PUBLISH_DATE, scheduledTime); //Start workflow WorkflowPath path = workflowService.startWorkflow(getPublshingWorkflowDefinitionId(), parameters); diff --git a/source/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java b/source/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java index 979746892a..017b397231 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java @@ -74,6 +74,7 @@ class PublishingPackageEntryImpl implements PublishingPackageEntry */ public NodeSnapshot getSnapshot() { - return new NodeSnapshotTransferImpl(payload); + //TODO Add versioning information. + return new NodeSnapshotTransferImpl(payload, null); } } diff --git a/source/java/org/alfresco/repo/publishing/PublishingPackageImpl.java b/source/java/org/alfresco/repo/publishing/PublishingPackageImpl.java index 42f9b0189f..c95c876dd7 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingPackageImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingPackageImpl.java @@ -32,6 +32,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian + * @author Nick Smith * */ public class PublishingPackageImpl implements PublishingPackage diff --git a/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java b/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java index 9ad8109148..fc072dd337 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java @@ -72,10 +72,6 @@ public class PublishingQueueImpl implements PublishingQueue */ public String scheduleNewEvent(PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate) { - if(schedule == null) - { - schedule = Calendar.getInstance(); - } try { NodeRef eventNode = publishingEventHelper.createNode(nodeRef, publishingPackage, channelName, schedule, comment, statusUpdate); diff --git a/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java b/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java index 112c003b32..332fb36b93 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java @@ -129,7 +129,7 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest assertEquals(1, paths.size()); Map props = workflowService.getPathProperties(paths.get(0).getId()); assertEquals(eventNode, props.get(PROP_WF_PUBLISHING_EVENT)); - assertEquals(schedule.getTime(), props.get(PROP_WF_SCHEDULED_PUBLISH_DATE)); + assertEquals(schedule, props.get(PROP_WF_SCHEDULED_PUBLISH_DATE)); } public void testScheduleNewPublishingEventWithStatusUpdate() throws Exception diff --git a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoCreateTimerAction.java b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoCreateTimerAction.java index e49dd30fb3..a324eaf375 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoCreateTimerAction.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoCreateTimerAction.java @@ -18,6 +18,7 @@ */ package org.alfresco.repo.workflow.jbpm; +import java.util.Calendar; import java.util.Date; import org.alfresco.service.cmr.workflow.WorkflowException; @@ -55,11 +56,18 @@ public class AlfrescoCreateTimerAction extends CreateTimerAction if (dueDateExpression.startsWith("#{")) { Object result = JbpmExpressionEvaluator.evaluate(dueDateExpression, executionContext); - if (!(result instanceof Date)) + if (result instanceof Date) + { + dueDate = (Date)result; + } + else if(result instanceof Calendar) + { + dueDate = ((Calendar)result).getTime(); + } + else { throw new WorkflowException("duedate expression must evaluate to a date"); } - dueDate = (Date)result; } else { diff --git a/source/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java b/source/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java index 2a03905ba6..b33fa7d9d3 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java @@ -84,4 +84,9 @@ public interface NodeSnapshot * @return A set of QName objects, each identifying an aspect that is applied to the node */ Set getAspects(); + + /** + * @return the version of the node when the snapshot was taken. + */ + String getVersion(); } diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java b/source/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java index 23b0a34a31..327d487d35 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java @@ -19,6 +19,7 @@ package org.alfresco.service.cmr.publishing; +import java.util.Collection; import java.util.Set; import org.alfresco.service.cmr.repository.NodeRef; @@ -31,9 +32,19 @@ public interface PublishingEventFilter { PublishingEventFilter setIds(String... ids); + PublishingEventFilter setIds(Collection ids); + Set getIds(); PublishingEventFilter setPublishedNodes(NodeRef... publishedNodes); + PublishingEventFilter setPublishedNodes(Collection publishedNodes); + Set getPublishedNodes(); + + PublishingEventFilter setUnpublishedNodes(NodeRef... unpublishedNodes); + + PublishingEventFilter setUnpublishedNodes(Collection unpublishedNodes); + + Set getUnpublishedNodes(); } diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingPackage.java b/source/java/org/alfresco/service/cmr/publishing/PublishingPackage.java index 710915c4fb..1215f85562 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingPackage.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingPackage.java @@ -19,6 +19,7 @@ package org.alfresco.service.cmr.publishing; import java.util.Collection; +import java.util.Map; import java.util.Set; import org.alfresco.service.cmr.repository.NodeRef; @@ -30,6 +31,7 @@ public interface PublishingPackage * @return The collection of publishing package entries. Never null. */ Collection getEntries(); + Map getEntryMap(); Set getNodesToPublish(); Set getNodesToUnpublish(); }