From 13763498f59c85e7d45438dedd0c1d5b80e3ab93 Mon Sep 17 00:00:00 2001 From: Brian Remmington Date: Tue, 27 Sep 2011 11:23:19 +0000 Subject: [PATCH] Fixed ALF-10333: Publishing: Multiple publishing events are processed sequentially rather than in parallel Publishing: Remove some operations from the Channel and ChannelType interface that really shouldn't be exposed. Also removed the PublishingQueue interface - the two operations it had are now on the PublishingService. WQS: Removed obsolete references to publishing channels. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30794 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web/scripts/publishing/PublishingJsonParser.java | 7 ++++--- .../web/scripts/publishing/PublishingQueuePost.java | 2 +- .../web/scripts/publishing/PublishingRestApiTest.java | 11 ++++++----- .../web/scripts/publishing/PublishingWebScript.java | 5 ----- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/source/java/org/alfresco/repo/web/scripts/publishing/PublishingJsonParser.java b/source/java/org/alfresco/repo/web/scripts/publishing/PublishingJsonParser.java index c95d622d9c..cec5ca1bed 100644 --- a/source/java/org/alfresco/repo/web/scripts/publishing/PublishingJsonParser.java +++ b/source/java/org/alfresco/repo/web/scripts/publishing/PublishingJsonParser.java @@ -29,6 +29,7 @@ import java.util.List; import org.alfresco.repo.node.NodeUtils; import org.alfresco.service.cmr.publishing.PublishingDetails; import org.alfresco.service.cmr.publishing.PublishingQueue; +import org.alfresco.service.cmr.publishing.PublishingService; import org.alfresco.service.cmr.publishing.channels.Channel; import org.alfresco.service.cmr.publishing.channels.ChannelService; import org.alfresco.service.cmr.repository.NodeRef; @@ -64,10 +65,10 @@ public class PublishingJsonParser implements PublishingWebScriptConstants } } - public String schedulePublishingEvent(PublishingQueue queue, String jsonStr) throws ParseException, JSONException + public String schedulePublishingEvent(PublishingService publishingService, String jsonStr) throws ParseException, JSONException { JSONObject json = getJson(jsonStr); - PublishingDetails details = queue.createPublishingDetails() + PublishingDetails details = publishingService.createPublishingDetails() .setPublishChannel(json.optString(CHANNEL_ID)) .setComment(json.optString(COMMENT)) .setSchedule(getCalendar(json.optJSONObject(SCHEDULED_TIME))) @@ -75,7 +76,7 @@ public class PublishingJsonParser implements PublishingWebScriptConstants .addNodesToUnpublish(toNodes(json.optJSONArray(UNPUBLISH_NODES))); details = setStatusUpdate(details, json.optJSONObject(STATUS_UPDATE)); - return queue.scheduleNewEvent(details); + return publishingService.scheduleNewEvent(details); } public PublishingDetails setStatusUpdate(PublishingDetails details, JSONObject json) diff --git a/source/java/org/alfresco/repo/web/scripts/publishing/PublishingQueuePost.java b/source/java/org/alfresco/repo/web/scripts/publishing/PublishingQueuePost.java index f6589da9e9..c3da064ab9 100644 --- a/source/java/org/alfresco/repo/web/scripts/publishing/PublishingQueuePost.java +++ b/source/java/org/alfresco/repo/web/scripts/publishing/PublishingQueuePost.java @@ -50,7 +50,7 @@ public class PublishingQueuePost extends PublishingWebScript { throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "No publishing event was posted!"); } - String eventId = jsonParser.schedulePublishingEvent(getQueue(), content); + String eventId = jsonParser.schedulePublishingEvent(publishingService, content); PublishingEvent event = publishingService.getPublishingEvent(eventId); Map eventModel = builder.buildPublishingEvent(event, channelService); return WebScriptUtil.createBaseModel(eventModel); diff --git a/source/java/org/alfresco/repo/web/scripts/publishing/PublishingRestApiTest.java b/source/java/org/alfresco/repo/web/scripts/publishing/PublishingRestApiTest.java index 5013cc4e38..7d8ab26c6a 100644 --- a/source/java/org/alfresco/repo/web/scripts/publishing/PublishingRestApiTest.java +++ b/source/java/org/alfresco/repo/web/scripts/publishing/PublishingRestApiTest.java @@ -72,6 +72,7 @@ import java.util.Set; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.transform.AbstractContentTransformerTest; +import org.alfresco.repo.publishing.AbstractChannelType; import org.alfresco.repo.publishing.ChannelHelper; import org.alfresco.repo.publishing.ChannelServiceImpl; import org.alfresco.repo.publishing.PublishServiceImpl; @@ -329,8 +330,8 @@ public class PublishingRestApiTest extends BaseWebScriptTest // Wait for Publishing Event to execute asynchronously Thread.sleep(5000); - ChannelType publishAnyChannelType = channelService.getChannelType(publishAnyType); - ChannelType statusUpdateChannelType = channelService.getChannelType(statusUpdateType); + AbstractChannelType publishAnyChannelType = (AbstractChannelType) channelService.getChannelType(publishAnyType); + AbstractChannelType statusUpdateChannelType = (AbstractChannelType) channelService.getChannelType(statusUpdateType); NodeRef mappedTextNode = channelHelper.mapSourceToEnvironment(textNode, publishChannel.getNodeRef()); @@ -341,12 +342,12 @@ public class PublishingRestApiTest extends BaseWebScriptTest // Check updateStatus is called correctly. ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); verify(statusUpdateChannelType) - .updateStatus(any(Channel.class), captor.capture(), anyMap()); + .sendStatusUpdate(any(Channel.class), captor.capture()); String actualStatusMessage = captor.getValue(); assertTrue(actualStatusMessage.startsWith(statusMessage)); verify(statusUpdateChannelType, never()).publish(any(NodeRef.class), anyMap()); - verify(publishAnyChannelType, never()).updateStatus(any(Channel.class), anyString(), anyMap()); + verify(publishAnyChannelType, never()).sendStatusUpdate(any(Channel.class), anyString()); JSONObject status = json.optJSONObject(STATUS_UPDATE); status.remove(NODE_REF); @@ -425,7 +426,7 @@ public class PublishingRestApiTest extends BaseWebScriptTest // Create publishing event for textNode1. String comment = "This is a comment"; - PublishingDetails details = publishingService.getPublishingQueue().createPublishingDetails() + PublishingDetails details = publishingService.createPublishingDetails() .setPublishChannel(publishChannel.getId()) .addNodesToPublish(textNode1) .setComment(comment); diff --git a/source/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScript.java b/source/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScript.java index 829ce0cde5..27e09d2ae0 100644 --- a/source/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/publishing/PublishingWebScript.java @@ -36,11 +36,6 @@ public abstract class PublishingWebScript extends DeclarativeWebScript protected PublishingService publishingService; protected ChannelService channelService; - protected PublishingQueue getQueue() - { - return publishingService.getPublishingQueue(); - } - /** * @param publishingService the publishingService to set */