Removed all references to Site from publishing REST API. Replaced publishing-events-query.post with publishing-events-for-node.get.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29301 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
N Smith
2011-07-25 09:30:08 +00:00
parent 0ec0b0939e
commit a6d7fef35a
8 changed files with 153 additions and 27 deletions

View File

@@ -20,6 +20,7 @@
package org.alfresco.repo.publishing;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.publishing.NodePublishStatus;
@@ -65,6 +66,26 @@ public class PublishServiceImpl implements PublishingService
return publishingEventHelper.getPublishingEvent(id);
}
/**
* {@inheritDoc}
*/
public List<PublishingEvent> getEventsForPublishedNode(NodeRef publishedNode)
{
NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef();
List<NodeRef> eventNodes = publishingEventHelper.getEventNodesForPublishedNode(queueNode, publishedNode);
return publishingEventHelper.getPublishingEvents(eventNodes);
}
/**
* {@inheritDoc}
*/
public List<PublishingEvent> getEventsForUnpublishedNode(NodeRef unpublishedNode)
{
NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef();
List<NodeRef> eventNodes = publishingEventHelper.getEventNodesForUnpublishedNode(queueNode, unpublishedNode);
return publishingEventHelper.getPublishingEvents(eventNodes);
}
/**
* {@inheritDoc}
*/
@@ -77,7 +98,7 @@ public class PublishServiceImpl implements PublishingService
/**
* {@inheritDoc}
*/
public PublishingQueue getPublishingQueue(String siteId)
public PublishingQueue getPublishingQueue()
{
return rootObject.getPublishingQueue();
}

View File

@@ -307,16 +307,63 @@ public class PublishingEventHelper
*/
public List<NodeRef> getEventNodesForPublishedNodes(final NodeRef queue, Collection<NodeRef> publishedNodes)
{
Function<NodeRef, Collection<NodeRef>> transformer = new Function<NodeRef, Collection<NodeRef>>()
return getEventNodesForNodeProperty(queue, PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH, publishedNodes);
}
/**
* Returns a {@link List} of the {@link NodeRef}s representing PublishingEvents that were scheduled to unpublish at least one of the specified <code>unpublishedNodes</code>.
* @param queue
* @param unpublishedNodes
* @return
*/
public List<NodeRef> getEventNodesForUnpublishedNodes(final NodeRef queue, Collection<NodeRef> unpublishedNodes)
{
return getEventNodesForNodeProperty(queue, PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH, unpublishedNodes);
}
/**
* Returns a {@link List} of the {@link NodeRef}s representing PublishingEvents that were scheduled to publish the specified <code>publishedNode</code>.
* @param queue
* @param publishedNode
* @return
*/
public List<NodeRef> getEventNodesForPublishedNode(final NodeRef queue, NodeRef publishedNode)
{
Function<NodeRef, List<NodeRef>> transformer = eventNodeForNodePropertyFinder(queue, PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH);
return transformer.apply(publishedNode);
}
/**
* Returns a {@link List} of the {@link NodeRef}s representing PublishingEvents that were scheduled to unpublish the specified <code>unpublishedNode</code>.
* @param queue
* @param unpublishedNode
* @return
*/
public List<NodeRef> getEventNodesForUnpublishedNode(final NodeRef queue, NodeRef unpublishedNode)
{
Function<NodeRef, List<NodeRef>> transformer = eventNodeForNodePropertyFinder(queue, PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH);
return transformer.apply(unpublishedNode);
}
private List<NodeRef> getEventNodesForNodeProperty(final NodeRef queue, final QName propertyKey, Collection<NodeRef> publishedNodes)
{
Function<NodeRef, List<NodeRef>> transformer = eventNodeForNodePropertyFinder(queue, propertyKey);
return transformFlat(publishedNodes, transformer);
}
private Function<NodeRef, List<NodeRef>> eventNodeForNodePropertyFinder(final NodeRef queue,
final QName propertyKey)
{
return new Function<NodeRef, List<NodeRef>>()
{
public Collection<NodeRef> apply(NodeRef publishedNode)
public List<NodeRef> apply(NodeRef publishedNode)
{
List<ChildAssociationRef> assocs = nodeService.getChildAssocsByPropertyValue(queue, PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH, publishedNode.toString());
String nodeString = publishedNode.toString();
List<ChildAssociationRef> assocs =
nodeService.getChildAssocsByPropertyValue(queue, propertyKey, nodeString);
return transform(assocs, NodeUtils.toChildRef());
}
};
List<NodeRef> nodes = transformFlat(publishedNodes, transformer);
return nodes;
}
public List<PublishingEvent> findPublishingEvents(NodeRef queue, PublishingEventFilter filter)

View File

@@ -183,4 +183,22 @@ public class PublishingEventImpl implements PublishingEvent
return new MutablePublishingEventImpl(this);
}
/**
* {@inheritDoc}
*/
@Override
public int compareTo(PublishingEvent event)
{
if(event == null)
{
return 1;
}
Date eventTime = event.getCreatedTime();
if(eventTime == null)
{
return 1;
}
return (int)(createdTime.getTime() - eventTime.getTime());
}
}

View File

@@ -84,7 +84,7 @@ public class PublishingIntegratedTest extends BaseSpringTest
NamespaceService.CONTENT_MODEL_1_0_URI, Integer.toString(i)), ContentModel.TYPE_CONTENT).getChildRef());
}
PublishingQueue liveQueue = publishingService.getPublishingQueue(siteId);
PublishingQueue liveQueue = publishingService.getPublishingQueue();
MutablePublishingPackage publishingPackage = liveQueue.createPublishingPackage();
publishingPackage.addNodesToPublish(nodes);
@@ -117,7 +117,7 @@ public class PublishingIntegratedTest extends BaseSpringTest
nodes.add(nodeService.createNode(channel.getNodeRef(), ContentModel.ASSOC_CONTAINS, QName.createQName(
NamespaceService.CONTENT_MODEL_1_0_URI, Integer.toString(i)), ContentModel.TYPE_CONTENT).getChildRef());
}
PublishingQueue liveQueue = publishingService.getPublishingQueue(siteId);
PublishingQueue liveQueue = publishingService.getPublishingQueue();
MutablePublishingPackage publishingPackage = liveQueue.createPublishingPackage();
publishingPackage.addNodesToPublish(nodes);