diff --git a/config/alfresco/model/publishingModel.xml b/config/alfresco/model/publishingModel.xml
index 527d68be98..06f97bc8b0 100644
--- a/config/alfresco/model/publishingModel.xml
+++ b/config/alfresco/model/publishingModel.xml
@@ -180,6 +180,19 @@
The Id of the associated Publishing Event Workflow Instance
d:text
+
+ The status update message
+ d:text
+
+
+ The status update NodeRef used to generate a URL
+ d:text
+
+
+ The names of the channels to be notified of this status update.
+ d:text
+ true
+
cm:auditable
diff --git a/source/java/org/alfresco/repo/publishing/ChannelHelper.java b/source/java/org/alfresco/repo/publishing/ChannelHelper.java
index ceb49b4c19..5e7784666d 100644
--- a/source/java/org/alfresco/repo/publishing/ChannelHelper.java
+++ b/source/java/org/alfresco/repo/publishing/ChannelHelper.java
@@ -109,6 +109,16 @@ public class ChannelHelper
return createChannelNode(environment, channelType, channelName, properties);
}
+ public Channel getChannel(NodeRef environment, String channelName, ChannelService channelService)
+ {
+ NodeRef channelNode = getChannelNodeForEnvironment(environment, channelName);
+ if(channelNode != null)
+ {
+ return buildChannelObject(channelNode, channelService);
+ }
+ return null;
+ }
+
public NodeRef getChannelNodeForEnvironment(NodeRef environment, String channelName)
{
QName channelQName = getChannelQName(channelName);
@@ -343,5 +353,5 @@ public class ChannelHelper
{
this.contentService = contentService;
}
-
+
}
diff --git a/source/java/org/alfresco/repo/publishing/ChannelImpl.java b/source/java/org/alfresco/repo/publishing/ChannelImpl.java
index 4e3e8d94cb..5db79ed209 100644
--- a/source/java/org/alfresco/repo/publishing/ChannelImpl.java
+++ b/source/java/org/alfresco/repo/publishing/ChannelImpl.java
@@ -111,8 +111,7 @@ public class ChannelImpl implements Channel
@Override
public void updateStatus(String status)
{
- // TODO Auto-generated method stub
-
+ channelType.updateStatus(status, getProperties());
}
}
diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java b/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java
index 66a419e0f7..6aad592fbf 100644
--- a/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java
+++ b/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java
@@ -63,7 +63,7 @@ public class EnvironmentImplTest extends AbstractPublishingIntegrationTest
schedule.add(Calendar.YEAR, 1);
MutablePublishingPackage pckg =queue.createPublishingPackage();
pckg.addNodesToPublish(first);
- queue.scheduleNewEvent(pckg, channel1Name, schedule, null);
+ queue.scheduleNewEvent(pckg, channel1Name, schedule, null, null);
results = environment.checkPublishStatus(channel1Name, first, second);
assertEquals(2, results.size());
diff --git a/source/java/org/alfresco/repo/publishing/MockChannelType.java b/source/java/org/alfresco/repo/publishing/MockChannelType.java
index 3f3bc5d754..34c546dd92 100644
--- a/source/java/org/alfresco/repo/publishing/MockChannelType.java
+++ b/source/java/org/alfresco/repo/publishing/MockChannelType.java
@@ -138,7 +138,15 @@ public class MockChannelType extends AbstractChannelType
@Override
public boolean canPublishStatusUpdates()
{
- // TODO Auto-generated method stub
return false;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getNodeUrl(NodeRef node)
+ {
+ return null;
+ }
+
}
diff --git a/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java b/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java
index 64b3974185..52dcdc20fb 100644
--- a/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java
+++ b/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java
@@ -32,7 +32,12 @@ import static org.alfresco.model.ContentModel.PROP_LONGITUDE;
import static org.alfresco.model.ContentModel.PROP_NAME;
import static org.alfresco.model.ContentModel.TYPE_CONTENT;
import static org.alfresco.repo.publishing.PublishingModel.ASSOC_LAST_PUBLISHING_EVENT;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.anyMap;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.io.Serializable;
import java.util.Calendar;
@@ -49,6 +54,7 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.publishing.MutablePublishingPackage;
import org.alfresco.service.cmr.publishing.PublishingPackage;
import org.alfresco.service.cmr.publishing.PublishingService;
+import org.alfresco.service.cmr.publishing.StatusUpdate;
import org.alfresco.service.cmr.publishing.channels.ChannelService;
import org.alfresco.service.cmr.publishing.channels.ChannelType;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -59,7 +65,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.junit.Test;
-import org.mockito.exceptions.verification.NeverWantedButInvoked;
import org.springframework.beans.factory.annotation.Autowired;
/**
@@ -228,6 +233,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest
verify(channelType, times(1)).publish(eq(publishedNode), anyMap());
}
+ @SuppressWarnings("unchecked")
public void testChannelTypePublishIsCalledOnUpdate() throws Exception
{
// Create content node with appropriate aspects added.
@@ -319,11 +325,33 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest
verify(channelType, times(1)).publish(eq(publishedNode), anyMap());
}
+ @SuppressWarnings("unchecked")
+ public void testStatusUpdate() throws Exception
+ {
+ NodeRef source = createContentNode(contentNodeName, content);
+
+ // Create Status Update
+ String message = "Here is the message ";
+ StatusUpdate status = queue.createStatusUpdate(message, source, channelName);
+
+ String url = "http://test/url";
+
+ publishNode(source, status);
+
+ String expMessage = message + url;
+ verify(channelType, times(1)).updateStatus(eq(expMessage), anyMap());
+ }
+
private NodeRef publishNode(NodeRef source)
+ {
+ return publishNode(source, null);
+ }
+
+ private NodeRef publishNode(NodeRef source, StatusUpdate statusUpdate)
{
MutablePublishingPackage pckg = queue.createPublishingPackage();
pckg.addNodesToPublish(source);
- scheduleEvent(pckg);
+ scheduleEvent(pckg, statusUpdate);
assertNotNull(eventId);
NodeRef eventNode = new NodeRef(eventId);
@@ -333,11 +361,11 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest
return eventNode;
}
- private void scheduleEvent(PublishingPackage publishPckg)
+ private void scheduleEvent(PublishingPackage publishPckg, StatusUpdate statusUpdate)
{
Calendar schedule = Calendar.getInstance();
schedule.add(Calendar.YEAR, 1);
- this.eventId = queue.scheduleNewEvent(publishPckg, channelName, schedule, null);
+ this.eventId = queue.scheduleNewEvent(publishPckg, channelName, schedule, null, statusUpdate);
}
private void addGeographicAspect(NodeRef source, double lattitude, double longtitude)
diff --git a/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java b/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java
index 3197673fb5..795d370ff3 100644
--- a/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java
+++ b/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java
@@ -104,7 +104,7 @@ public class PublishWebContentJbpmTest
public void testProcessTimers() throws Exception
{
final Calendar scheduledTime = Calendar.getInstance();
- scheduledTime.add(Calendar.SECOND, 10);
+ scheduledTime.add(Calendar.SECOND, 5);
startWorkflowAndCommit(scheduledTime);
@@ -112,7 +112,7 @@ public class PublishWebContentJbpmTest
checkNode("waitForScheduledTime");
// Wait for scheduled time to elapse.
- Thread.sleep(11000);
+ Thread.sleep(10000);
// Check the Publish Event Action was called
verify(checkPublishingDependenciesAction).execute(any(Action.class), any(NodeRef.class));
diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java
index e915067d41..33dde14ef0 100644
--- a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java
+++ b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java
@@ -30,6 +30,9 @@ import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT
import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_TIME;
import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_TIME_ZONE;
import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_WORKFLOW_ID;
+import static org.alfresco.repo.publishing.PublishingModel.PROP_STATUS_UPDATE_CHANNEL_NAMES;
+import static org.alfresco.repo.publishing.PublishingModel.PROP_STATUS_UPDATE_NODE_REF;
+import static org.alfresco.repo.publishing.PublishingModel.PROP_STATUS_UPDATE_MESSAGE;
import static org.alfresco.repo.publishing.PublishingModel.PROP_WF_PUBLISHING_EVENT;
import static org.alfresco.repo.publishing.PublishingModel.PROP_WF_SCHEDULED_PUBLISH_DATE;
import static org.alfresco.repo.publishing.PublishingModel.TYPE_PUBLISHING_EVENT;
@@ -54,6 +57,7 @@ import org.alfresco.service.cmr.publishing.PublishingEvent;
import org.alfresco.service.cmr.publishing.PublishingEvent.Status;
import org.alfresco.service.cmr.publishing.PublishingEventFilter;
import org.alfresco.service.cmr.publishing.PublishingPackage;
+import org.alfresco.service.cmr.publishing.StatusUpdate;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
@@ -150,10 +154,26 @@ public class PublishingEventHelper
Calendar scheduledTime = getScheduledTime(props);
String channel = (String) props.get(PROP_PUBLISHING_EVENT_CHANNEL);
+ StatusUpdate statusUpdate = buildStatusUpdate(props);
return new PublishingEventImpl(eventNode.toString(),
status, channel,
publishingPackage, createdTime,
- creator,modifiedTime, modifier, scheduledTime, comment);
+ creator,modifiedTime, modifier,
+ scheduledTime, comment, statusUpdate);
+ }
+
+ @SuppressWarnings("unchecked")
+ private StatusUpdate buildStatusUpdate(Map props)
+ {
+ String message = (String) props.get(PROP_STATUS_UPDATE_MESSAGE);
+ Collection channelNames = (Collection) props.get(PROP_STATUS_UPDATE_CHANNEL_NAMES);
+ if(channelNames == null || channelNames.isEmpty())
+ {
+ return null;
+ }
+ String nodeId = (String) props.get(PROP_STATUS_UPDATE_NODE_REF);
+ NodeRef nodeToLinkTo = nodeId==null ? null : new NodeRef(nodeId);
+ return new StatusUpdateImpl(message, nodeToLinkTo, channelNames);
}
public List getPublishingEvents(List eventNodes)
@@ -167,15 +187,29 @@ public class PublishingEventHelper
});
}
- public NodeRef createNode(NodeRef queueNode, PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment)
+ public NodeRef createNode(NodeRef queueNode, PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate)
throws Exception
{
if (schedule == null)
{
schedule = Calendar.getInstance();
}
- Map props = new HashMap();
String name = GUID.generate();
+ Map props =
+ buildPublishingEventProperties(publishingPackage, channelName, schedule, comment, statusUpdate, name);
+ ChildAssociationRef newAssoc = nodeService.createNode(queueNode,
+ ASSOC_PUBLISHING_EVENT,
+ QName.createQName(NAMESPACE, name),
+ TYPE_PUBLISHING_EVENT, props);
+ NodeRef eventNode = newAssoc.getChildRef();
+ setPayload(eventNode, publishingPackage);
+ return eventNode;
+ }
+
+ private Map buildPublishingEventProperties(PublishingPackage publishingPackage,
+ String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate, String name)
+ {
+ Map props = new HashMap();
props.put(ContentModel.PROP_NAME, name);
props.put(PROP_PUBLISHING_EVENT_STATUS, Status.IN_PROGRESS.name());
props.put(PROP_PUBLISHING_EVENT_TIME, schedule.getTime());
@@ -190,13 +224,13 @@ public class PublishingEventHelper
props.put(PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH, (Serializable) publshStrings);
Collection unpublshStrings = mapNodesToStrings(publishingPackage.getNodesToUnpublish());
props.put(PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH, (Serializable) unpublshStrings);
- ChildAssociationRef newAssoc = nodeService.createNode(queueNode,
- ASSOC_PUBLISHING_EVENT,
- QName.createQName(NAMESPACE, name),
- TYPE_PUBLISHING_EVENT, props);
- NodeRef eventNode = newAssoc.getChildRef();
- setPayload(eventNode, publishingPackage);
- return eventNode;
+ if(statusUpdate != null)
+ {
+ props.put(PROP_STATUS_UPDATE_MESSAGE, statusUpdate.getMessage());
+ props.put(PROP_STATUS_UPDATE_NODE_REF, statusUpdate.getNodeToLinkTo().toString());
+ props.put(PROP_STATUS_UPDATE_CHANNEL_NAMES, (Serializable) statusUpdate.getChannelNames());
+ }
+ return props;
}
private Collection mapNodesToStrings(Collection nodes)
diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java b/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java
index 4df368e4ca..c1e9d631fd 100644
--- a/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java
+++ b/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java
@@ -190,7 +190,7 @@ public class PublishingEventHelperTest
Calendar schedule = Calendar.getInstance();
String comment = "The comment";
- NodeRef result = helper.createNode(queue, pckg, channelName, schedule, comment);
+ NodeRef result = helper.createNode(queue, pckg, channelName, schedule, comment, null);
assertEquals(event, result);
ArgumentCaptor