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,9 +6,16 @@
<start-state name="start">
<task name="pubwf:startPublish" />
<transition name="" to="waitForScheduledTime" />
<transition name="" to="checkForScheduledTime" />
</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 name="pubwf:wait" >
<timer duedate="#{pubwf_scheduledPublishDate}" transition="toCheckDependencies" >

View File

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

View File

@@ -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;

View File

@@ -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<NodeRef> toNodeRefs(Collection<String> nodeIds)
{
return CollectionUtils.transform(nodeIds, toNodeRef());
}
public static Function<ChildAssociationRef, NodeRef> toChildRef()
{
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()
{
return new Function<ChildAssociationRef, NodeRef>()
@@ -65,6 +79,11 @@ public abstract class NodeUtils
};
}
public static List<NodeRef> toParentRefs(Collection<ChildAssociationRef> assocRefs)
{
return CollectionUtils.transform(assocRefs, toParentRef());
}
public static Function<String, NodeRef> toNodeRefQueitly()
{
return new Function<String, NodeRef>()
@@ -91,5 +110,4 @@ public abstract class NodeUtils
};
}
}

View File

@@ -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<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> nodesToUnpublish= new HashSet<NodeRef>();
@@ -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<PublishingPackageEntry> getEntries()
{
return entries;
return entryMap.values();
}
/**
@@ -123,4 +123,13 @@ public class MutablePublishingPackageImpl implements MutablePublishingPackage
{
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
{
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;
}
}

View File

@@ -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;

View File

@@ -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<String> ids = new HashSet<String>();
private Set<NodeRef> publishedNodes = new HashSet<NodeRef>();
private Set<String> ids = Collections.emptySet();
private Set<NodeRef> publishedNodes = Collections.emptySet();
private Set<NodeRef> 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<String>(Arrays.asList(ids));
}
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}
*/
@@ -62,9 +76,21 @@ 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<NodeRef>(Arrays.asList(publishedNodes));
}
return this;
}
/**
* {@inheritDoc}
*/
public PublishingEventFilter setPublishedNodes(Collection<NodeRef> publishedNodes)
{
if(publishedNodes != null && publishedNodes.isEmpty() == false)
{
this.publishedNodes = new HashSet<NodeRef>(publishedNodes);
}
return this;
}
@@ -74,8 +100,39 @@ public class PublishingEventFilterImpl implements PublishingEventFilter
*/
public Set<NodeRef> 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<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>();
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);

View File

@@ -74,6 +74,7 @@ class PublishingPackageEntryImpl implements PublishingPackageEntry
*/
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 Nick Smith
*
*/
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)
{
if(schedule == null)
{
schedule = Calendar.getInstance();
}
try
{
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());
Map<QName, Serializable> 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

View File

@@ -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
{

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
*/
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;
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<String> ids);
Set<String> getIds();
PublishingEventFilter setPublishedNodes(NodeRef... publishedNodes);
PublishingEventFilter setPublishedNodes(Collection<NodeRef> publishedNodes);
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;
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 <code>null</code>.
*/
Collection<PublishingPackageEntry> getEntries();
Map<NodeRef,PublishingPackageEntry> getEntryMap();
Set<NodeRef> getNodesToPublish();
Set<NodeRef> getNodesToUnpublish();
}