Added a new REST method, publishing-events-query.post which allows you to query for publishing events based on id or published nodes.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28846 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
N Smith
2011-07-07 11:53:12 +00:00
parent 32938984cb
commit 0138ee4a45
17 changed files with 156 additions and 32 deletions

View File

@@ -6,8 +6,15 @@
<start-state name="start"> <start-state name="start">
<task name="pubwf:startPublish" /> <task name="pubwf:startPublish" />
<transition name="" to="waitForScheduledTime" /> <transition name="" to="checkForScheduledTime" />
</start-state> </start-state>
<decision name="checkForScheduledTime">
<transition name="toCheckDependencies" to="checkDependencies">
<condition>#{pubwf_scheduledPublishDate == null}</condition>
</transition>
<transition name="toWaitForScheduledTime" to="waitForScheduledTime" />
</decision>
<task-node name="waitForScheduledTime" end-tasks="true" > <task-node name="waitForScheduledTime" end-tasks="true" >
<task name="pubwf:wait" > <task name="pubwf:wait" >

View File

@@ -24,8 +24,7 @@
<mandatory>true</mandatory> <mandatory>true</mandatory>
</property> </property>
<property name="pubwf:scheduledPublishDate"> <property name="pubwf:scheduledPublishDate">
<type>d:datetime</type> <type>d:any</type>
<mandatory>true</mandatory>
</property> </property>
</properties> </properties>
</type> </type>

View File

@@ -657,7 +657,7 @@ public abstract class AbstractScheduledAction implements ScheduledActionDefiniti
SECOND second; SECOND second;
Pair(FIRST first, SECOND second) public Pair(FIRST first, SECOND second)
{ {
this.first = first; this.first = first;
this.second = second; this.second = second;

View File

@@ -19,9 +19,13 @@
package org.alfresco.repo.node; 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.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.util.collections.CollectionUtils;
import org.alfresco.util.collections.Filter; import org.alfresco.util.collections.Filter;
import org.alfresco.util.collections.Function; import org.alfresco.util.collections.Function;
@@ -43,6 +47,11 @@ public abstract class NodeUtils
}; };
} }
public static List<NodeRef> toNodeRefs(Collection<String> nodeIds)
{
return CollectionUtils.transform(nodeIds, toNodeRef());
}
public static Function<ChildAssociationRef, NodeRef> toChildRef() public static Function<ChildAssociationRef, NodeRef> toChildRef()
{ {
return new Function<ChildAssociationRef, NodeRef>() return new Function<ChildAssociationRef, NodeRef>()
@@ -54,6 +63,11 @@ public abstract class NodeUtils
}; };
} }
public static List<NodeRef> toChildRefs(Collection<ChildAssociationRef> assocRefs)
{
return CollectionUtils.transform(assocRefs, toChildRef());
}
public static Function<ChildAssociationRef, NodeRef> toParentRef() public static Function<ChildAssociationRef, NodeRef> toParentRef()
{ {
return new Function<ChildAssociationRef, NodeRef>() return new Function<ChildAssociationRef, NodeRef>()
@@ -64,6 +78,11 @@ public abstract class NodeUtils
} }
}; };
} }
public static List<NodeRef> toParentRefs(Collection<ChildAssociationRef> assocRefs)
{
return CollectionUtils.transform(assocRefs, toParentRef());
}
public static Function<String, NodeRef> toNodeRefQueitly() public static Function<String, NodeRef> toNodeRefQueitly()
{ {
@@ -91,5 +110,4 @@ public abstract class NodeUtils
}; };
} }
} }

View File

@@ -19,11 +19,11 @@
package org.alfresco.repo.publishing; package org.alfresco.repo.publishing;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.alfresco.repo.transfer.manifest.TransferManifestNode; import org.alfresco.repo.transfer.manifest.TransferManifestNode;
@@ -41,7 +41,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
public class MutablePublishingPackageImpl implements MutablePublishingPackage public class MutablePublishingPackageImpl implements MutablePublishingPackage
{ {
private final TransferManifestNodeFactory transferManifestNodeFactory; private final TransferManifestNodeFactory transferManifestNodeFactory;
private final List<PublishingPackageEntry> entries = new ArrayList<PublishingPackageEntry>(); private final Map<NodeRef, PublishingPackageEntry> entryMap = new HashMap<NodeRef, PublishingPackageEntry>();
private final Set<NodeRef> nodesToPublish = new HashSet<NodeRef>(); private final Set<NodeRef> nodesToPublish = new HashSet<NodeRef>();
private final Set<NodeRef> nodesToUnpublish= new HashSet<NodeRef>(); private final Set<NodeRef> nodesToUnpublish= new HashSet<NodeRef>();
@@ -71,7 +71,7 @@ public class MutablePublishingPackageImpl implements MutablePublishingPackage
TransferManifestNode payload = transferManifestNodeFactory.createTransferManifestNode(nodeRef, null); TransferManifestNode payload = transferManifestNodeFactory.createTransferManifestNode(nodeRef, null);
if (TransferManifestNormalNode.class.isAssignableFrom(payload.getClass())) 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); nodesToPublish.addAll(nodesToAdd);
@@ -92,7 +92,7 @@ public class MutablePublishingPackageImpl implements MutablePublishingPackage
{ {
for (NodeRef nodeRef : nodesToRemove) for (NodeRef nodeRef : nodesToRemove)
{ {
entries.add(new PublishingPackageEntryImpl(false, nodeRef, null)); entryMap.put(nodeRef, new PublishingPackageEntryImpl(false, nodeRef, null));
} }
nodesToUnpublish.addAll(nodesToRemove); nodesToUnpublish.addAll(nodesToRemove);
} }
@@ -103,7 +103,7 @@ public class MutablePublishingPackageImpl implements MutablePublishingPackage
@Override @Override
public Collection<PublishingPackageEntry> getEntries() public Collection<PublishingPackageEntry> getEntries()
{ {
return entries; return entryMap.values();
} }
/** /**
@@ -123,4 +123,13 @@ public class MutablePublishingPackageImpl implements MutablePublishingPackage
{ {
return nodesToUnpublish; return nodesToUnpublish;
} }
/**
* {@inheritDoc}
*/
@Override
public Map<NodeRef, PublishingPackageEntry> getEntryMap()
{
return entryMap;
}
} }

View File

@@ -39,14 +39,15 @@ import org.alfresco.service.namespace.QName;
public class NodeSnapshotTransferImpl implements NodeSnapshot public class NodeSnapshotTransferImpl implements NodeSnapshot
{ {
private final TransferManifestNormalNode transferNode; private final TransferManifestNormalNode transferNode;
private final String version;
/** /**
* @param transferNode * @param transferNode
*/ */
public NodeSnapshotTransferImpl(TransferManifestNormalNode transferNode) public NodeSnapshotTransferImpl(TransferManifestNormalNode transferNode, String version)
{ {
super();
this.transferNode = transferNode; this.transferNode = transferNode;
this.version = version;
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -120,4 +121,13 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot
{ {
return transferNode.getType(); return transferNode.getType();
} }
/**
* {@inheritDoc}
*/
@Override
public String getVersion()
{
return version;
}
} }

View File

@@ -35,6 +35,7 @@ import org.alfresco.util.ParameterCheck;
*/ */
public class PublishServiceImpl implements PublishingService public class PublishServiceImpl implements PublishingService
{ {
public static final String NAME = "publishingService";
private EnvironmentFactory environmentFactory; private EnvironmentFactory environmentFactory;
private PublishingEventHelper publishingEventHelper; private PublishingEventHelper publishingEventHelper;

View File

@@ -20,6 +20,7 @@
package org.alfresco.repo.publishing; package org.alfresco.repo.publishing;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -34,8 +35,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/ */
public class PublishingEventFilterImpl implements PublishingEventFilter public class PublishingEventFilterImpl implements PublishingEventFilter
{ {
private Set<String> ids = new HashSet<String>(); private Set<String> ids = Collections.emptySet();
private Set<NodeRef> publishedNodes = new HashSet<NodeRef>(); private Set<NodeRef> publishedNodes = Collections.emptySet();
private Set<NodeRef> unpublishedNodes = Collections.emptySet();
/** /**
* {@inheritDoc} * {@inheritDoc}
@@ -44,11 +46,23 @@ public class PublishingEventFilterImpl implements PublishingEventFilter
{ {
if(ids != null && ids.length>0) if(ids != null && ids.length>0)
{ {
this.ids.addAll(Arrays.asList(ids)); this.ids = new HashSet<String>(Arrays.asList(ids));
} }
return this; return this;
} }
/**
* {@inheritDoc}
*/
@Override
public PublishingEventFilter setIds(Collection<String> ids)
{
if(ids != null && ids.isEmpty() == false)
{
this.ids = new HashSet<String>(ids);
}
return this;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -62,20 +76,63 @@ public class PublishingEventFilterImpl implements PublishingEventFilter
*/ */
public PublishingEventFilter setPublishedNodes(NodeRef... publishedNodes) 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<NodeRef>(Arrays.asList(publishedNodes));
} }
return this; return this;
} }
/**
* {@inheritDoc}
*/
public PublishingEventFilter setPublishedNodes(Collection<NodeRef> publishedNodes)
{
if(publishedNodes != null && publishedNodes.isEmpty() == false)
{
this.publishedNodes = new HashSet<NodeRef>(publishedNodes);
}
return this;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public Set<NodeRef> getPublishedNodes() public Set<NodeRef> getPublishedNodes()
{ {
// TODO Auto-generated method stub return Collections.unmodifiableSet(publishedNodes);
return null;
} }
/**
* {@inheritDoc}
*/
public PublishingEventFilter setUnpublishedNodes(NodeRef... unpublishedNodes)
{
if(unpublishedNodes != null && unpublishedNodes.length>0)
{
this.unpublishedNodes = new HashSet<NodeRef>(Arrays.asList(unpublishedNodes));
}
return this;
}
/**
* {@inheritDoc}
*/
public PublishingEventFilter setUnpublishedNodes(Collection<NodeRef> unpublishedNodes)
{
if(unpublishedNodes != null && unpublishedNodes.isEmpty() == false)
{
this.unpublishedNodes = new HashSet<NodeRef>(unpublishedNodes);
}
return this;
}
/**
* {@inheritDoc}
*/
public Set<NodeRef> getUnpublishedNodes()
{
return Collections.unmodifiableSet(unpublishedNodes);
}
} }

View File

@@ -348,8 +348,7 @@ public class PublishingEventHelper
Map<QName, Serializable> parameters = new HashMap<QName, Serializable>(); Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
parameters.put(PROP_WF_PUBLISHING_EVENT, eventNode); parameters.put(PROP_WF_PUBLISHING_EVENT, eventNode);
parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowService.createPackage(null)); parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowService.createPackage(null));
//TODO Will this handle the timezone? parameters.put(PROP_WF_SCHEDULED_PUBLISH_DATE, scheduledTime);
parameters.put(PROP_WF_SCHEDULED_PUBLISH_DATE, scheduledTime.getTime());
//Start workflow //Start workflow
WorkflowPath path = workflowService.startWorkflow(getPublshingWorkflowDefinitionId(), parameters); WorkflowPath path = workflowService.startWorkflow(getPublshingWorkflowDefinitionId(), parameters);

View File

@@ -74,6 +74,7 @@ class PublishingPackageEntryImpl implements PublishingPackageEntry
*/ */
public NodeSnapshot getSnapshot() public NodeSnapshot getSnapshot()
{ {
return new NodeSnapshotTransferImpl(payload); //TODO Add versioning information.
return new NodeSnapshotTransferImpl(payload, null);
} }
} }

View File

@@ -32,6 +32,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
/** /**
* @author Brian * @author Brian
* @author Nick Smith
* *
*/ */
public class PublishingPackageImpl implements PublishingPackage public class PublishingPackageImpl implements PublishingPackage

View File

@@ -72,10 +72,6 @@ public class PublishingQueueImpl implements PublishingQueue
*/ */
public String scheduleNewEvent(PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate) public String scheduleNewEvent(PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate)
{ {
if(schedule == null)
{
schedule = Calendar.getInstance();
}
try try
{ {
NodeRef eventNode = publishingEventHelper.createNode(nodeRef, publishingPackage, channelName, schedule, comment, statusUpdate); NodeRef eventNode = publishingEventHelper.createNode(nodeRef, publishingPackage, channelName, schedule, comment, statusUpdate);

View File

@@ -129,7 +129,7 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest
assertEquals(1, paths.size()); assertEquals(1, paths.size());
Map<QName, Serializable> props = workflowService.getPathProperties(paths.get(0).getId()); Map<QName, Serializable> props = workflowService.getPathProperties(paths.get(0).getId());
assertEquals(eventNode, props.get(PROP_WF_PUBLISHING_EVENT)); 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 public void testScheduleNewPublishingEventWithStatusUpdate() throws Exception

View File

@@ -18,6 +18,7 @@
*/ */
package org.alfresco.repo.workflow.jbpm; package org.alfresco.repo.workflow.jbpm;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import org.alfresco.service.cmr.workflow.WorkflowException; import org.alfresco.service.cmr.workflow.WorkflowException;
@@ -55,11 +56,18 @@ public class AlfrescoCreateTimerAction extends CreateTimerAction
if (dueDateExpression.startsWith("#{")) if (dueDateExpression.startsWith("#{"))
{ {
Object result = JbpmExpressionEvaluator.evaluate(dueDateExpression, executionContext); 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"); throw new WorkflowException("duedate expression must evaluate to a date");
} }
dueDate = (Date)result;
} }
else else
{ {

View File

@@ -84,4 +84,9 @@ public interface NodeSnapshot
* @return A set of QName objects, each identifying an aspect that is applied to the node * @return A set of QName objects, each identifying an aspect that is applied to the node
*/ */
Set<QName> getAspects(); Set<QName> getAspects();
/**
* @return the version of the node when the snapshot was taken.
*/
String getVersion();
} }

View File

@@ -19,6 +19,7 @@
package org.alfresco.service.cmr.publishing; package org.alfresco.service.cmr.publishing;
import java.util.Collection;
import java.util.Set; import java.util.Set;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -31,9 +32,19 @@ public interface PublishingEventFilter
{ {
PublishingEventFilter setIds(String... ids); PublishingEventFilter setIds(String... ids);
PublishingEventFilter setIds(Collection<String> ids);
Set<String> getIds(); Set<String> getIds();
PublishingEventFilter setPublishedNodes(NodeRef... publishedNodes); PublishingEventFilter setPublishedNodes(NodeRef... publishedNodes);
PublishingEventFilter setPublishedNodes(Collection<NodeRef> publishedNodes);
Set<NodeRef> getPublishedNodes(); Set<NodeRef> getPublishedNodes();
PublishingEventFilter setUnpublishedNodes(NodeRef... unpublishedNodes);
PublishingEventFilter setUnpublishedNodes(Collection<NodeRef> unpublishedNodes);
Set<NodeRef> getUnpublishedNodes();
} }

View File

@@ -19,6 +19,7 @@
package org.alfresco.service.cmr.publishing; package org.alfresco.service.cmr.publishing;
import java.util.Collection; import java.util.Collection;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -30,6 +31,7 @@ public interface PublishingPackage
* @return The collection of publishing package entries. Never <code>null</code>. * @return The collection of publishing package entries. Never <code>null</code>.
*/ */
Collection<PublishingPackageEntry> getEntries(); Collection<PublishingPackageEntry> getEntries();
Map<NodeRef,PublishingPackageEntry> getEntryMap();
Set<NodeRef> getNodesToPublish(); Set<NodeRef> getNodesToPublish();
Set<NodeRef> getNodesToUnpublish(); Set<NodeRef> getNodesToUnpublish();
} }