diff --git a/config/alfresco/model/publishingModel.xml b/config/alfresco/model/publishingModel.xml index 79acd8a734..4a97c05fda 100644 --- a/config/alfresco/model/publishingModel.xml +++ b/config/alfresco/model/publishingModel.xml @@ -34,17 +34,6 @@ - - - false - false - - - pub:DeliveryChannel - false - false - - false @@ -275,11 +264,11 @@ - Channel Info + Published Applied to a published node cm:titled - + false true @@ -289,8 +278,8 @@ false false - - + + false false @@ -300,7 +289,18 @@ false true - + + + + false + false + + + pub:DeliveryChannel + false + true + + diff --git a/source/java/org/alfresco/repo/publishing/ChannelHelper.java b/source/java/org/alfresco/repo/publishing/ChannelHelper.java index 9de995017b..cd85863a05 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelHelper.java +++ b/source/java/org/alfresco/repo/publishing/ChannelHelper.java @@ -21,8 +21,8 @@ package org.alfresco.repo.publishing; import static org.alfresco.model.ContentModel.ASSOC_CONTAINS; import static org.alfresco.repo.publishing.PublishingModel.ASPECT_PUBLISHED; +import static org.alfresco.repo.publishing.PublishingModel.ASSOC_PUBLISHED_CHANNEL; import static org.alfresco.repo.publishing.PublishingModel.ASSOC_SOURCE; -import static org.alfresco.repo.publishing.PublishingModel.NAMESPACE; import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL; import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE; import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE_ID; @@ -44,14 +44,13 @@ import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.publishing.channels.Channel; import org.alfresco.service.cmr.publishing.channels.ChannelService; import org.alfresco.service.cmr.publishing.channels.ChannelType; +import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.GUID; import org.alfresco.util.Pair; import org.alfresco.util.collections.CollectionUtils; import org.alfresco.util.collections.Filter; @@ -99,82 +98,41 @@ public class ChannelHelper return null; } Map props = nodeService.getProperties(nodeRef); - String channelTypeId = (String) props.get(PublishingModel.PROP_CHANNEL_TYPE_ID); + String channelTypeId = (String) props.get(PROP_CHANNEL_TYPE_ID); ChannelType channelType = channelService.getChannelType(channelTypeId); String name = (String) props.get(ContentModel.PROP_NAME); return new ChannelImpl(channelType, nodeRef, name, this); } - public NodeRef addChannelToEnvironment(NodeRef environment, Channel channel, Map properties) - { - ChannelType channelType = channel.getChannelType(); - String channelName = channel.getName(); - NodeRef envChannel = createChannelNode(environment, channelType, channelName, properties); - nodeService.createAssociation(envChannel, channel.getNodeRef(), PublishingModel.ASSOC_EDITORIAL_CHANNEL); - return envChannel; - } - - 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); - List channelAssocs = nodeService.getChildAssocs(environment, ASSOC_CONTAINS, channelQName); - return getSingleValue(channelAssocs, true); - } - /** - * Given a noderef from the editorial space (e.g. the doclib), this returns the corresponding noderef in the specified channel and environment. + * Given a noderef from the editorial space (e.g. the doclib), this returns the corresponding noderef published to the specified channel. * @param source - * @param environment - * @param channelName + * @param channelNode * @return */ - public NodeRef mapSourceToEnvironment(NodeRef source, NodeRef environment, String channelName) + public NodeRef mapSourceToEnvironment(NodeRef source, final NodeRef channelNode) { - NodeRef channel = getChannelNodeForEnvironment(environment, channelName); - return mapSourceToEnvironmentInternal(source, channel); - } - /** - * Given a noderef from the editorial space (e.g. the doclib), this returns the corresponding noderef in the specified channelt - * @param source - * @param editorialChannel - * @return - */ - public NodeRef mapSourceToEnvironment(NodeRef source, NodeRef editorialChannel) - { -// NodeRef liveChannel = mapChannelNOde(editorialChannel); - return mapSourceToEnvironmentInternal(source, editorialChannel); - } - - private NodeRef mapSourceToEnvironmentInternal(NodeRef source, NodeRef liveChannel) - { - if(source == null || liveChannel == null) + if(source == null || channelNode == null) { return null; } - List parentAssocs = nodeService.getParentAssocs(source, ASSOC_SOURCE, RegexQNamePattern.MATCH_ALL); - if(parentAssocs != null) + List sourceAssocs = nodeService.getSourceAssocs(source, ASSOC_SOURCE); + Function acceptor = new Filter() { - for (ChildAssociationRef parentAssoc : parentAssocs) + public Boolean apply(AssociationRef assoc) { - NodeRef publishedNode = parentAssoc.getParentRef(); - NodeRef parent = nodeService.getPrimaryParent(publishedNode).getParentRef(); - if(liveChannel.equals(parent)) + NodeRef publishedNode = assoc.getSourceRef(); + List channelAssoc = nodeService.getTargetAssocs(publishedNode, ASSOC_PUBLISHED_CHANNEL); + if(CollectionUtils.isEmpty(channelAssoc)) { - return publishedNode; + return false; } + NodeRef target = channelAssoc.get(0).getTargetRef(); + return target.equals(channelNode); } - } - return null; + }; + AssociationRef assoc = CollectionUtils.findFirst(sourceAssocs, acceptor); + return assoc == null ? null : assoc.getSourceRef(); } /** @@ -184,29 +142,10 @@ public class ChannelHelper */ public NodeRef mapEnvironmentToSource(NodeRef publishedNode) { - List childAssocs = nodeService.getChildAssocs(publishedNode, ASSOC_SOURCE, RegexQNamePattern.MATCH_ALL); - return getSingleValue(childAssocs, true); + List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_SOURCE); + return getSingleValue(assocs, true); } - /** - * Returns the {@link NodeRef} for the live channel given the {@link NodeRef} for the editorial channel. - * @param editorialChannel - * @return - */ - public NodeRef mapChannelNOde(NodeRef editorialChannel) - { - List assocs = nodeService.getParentAssocs(editorialChannel, PublishingModel.ASSOC_EDITORIAL_CHANNEL, RegexQNamePattern.MATCH_ALL); - if(assocs.isEmpty()) - { - return null; - } - if(assocs.size()>1) - { - throw new IllegalStateException("There is more than one environment channel node!"); - } - return assocs.get(0).getParentRef(); - } - /** * Finds the {@link Channel} NodeRef and {@link ChannelType} id for a given node, if such a Channel exists. * @param node @@ -239,11 +178,9 @@ public class ChannelHelper return nodeService.getProperties(channel); } - public ChildAssociationRef createMapping(NodeRef source, NodeRef publishedNode) + public AssociationRef createMapping(NodeRef source, NodeRef publishedNode) { - QName qName = QName.createQName(NAMESPACE, GUID.generate()); - ChildAssociationRef assoc = nodeService.addChild(publishedNode, source, ASSOC_SOURCE, qName); - nodeService.addAspect(source, ASPECT_PUBLISHED, null); + AssociationRef assoc = nodeService.createAssociation(publishedNode, source, ASSOC_SOURCE); return assoc; } @@ -348,6 +285,16 @@ public class ChannelHelper }); } + public void addPublishedAspect(NodeRef publishedNode, NodeRef channelNode) + { + nodeService.addAspect(publishedNode, ASPECT_PUBLISHED, null); + List channelAssoc = nodeService.getTargetAssocs(publishedNode, ASSOC_PUBLISHED_CHANNEL); + if(CollectionUtils.isEmpty(channelAssoc)) + { + nodeService.createAssociation(publishedNode, channelNode, ASSOC_PUBLISHED_CHANNEL); + } + } + private List getChannelAssocs(NodeRef channelContainer) { if(channelContainer == null) @@ -379,12 +326,12 @@ public class ChannelHelper return null; } - private NodeRef getSingleValue(List assocs, boolean getChild) + private NodeRef getSingleValue(List assocs, boolean getChild) { if(assocs != null && assocs.size()==1 ) { - ChildAssociationRef association = assocs.get(0); - return getChild ? association.getChildRef() : association.getParentRef(); + AssociationRef association = assocs.get(0); + return getChild ? association.getTargetRef() : association.getSourceRef(); } return null; } @@ -425,4 +372,5 @@ public class ChannelHelper this.fileFolderService = fileFolderService; } + } diff --git a/source/java/org/alfresco/repo/publishing/ChannelImpl.java b/source/java/org/alfresco/repo/publishing/ChannelImpl.java index f38930f49c..738cfb8ac0 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelImpl.java +++ b/source/java/org/alfresco/repo/publishing/ChannelImpl.java @@ -51,6 +51,16 @@ public class ChannelImpl implements Channel this.channelHelper = channelHelper; } + /** + * {@inheritDoc} + */ + @Override + public String getId() + { + // TODO Auto-generated method stub + return nodeRef.toString(); + } + /** * {@inheritDoc} */ @@ -89,6 +99,7 @@ public class ChannelImpl implements Channel @Override public void publish(NodeRef nodeToPublish) { + channelHelper.addPublishedAspect(nodeToPublish, nodeRef); if(channelHelper.canPublish(nodeToPublish, channelType)) { channelType.publish(nodeToPublish, getProperties()); @@ -119,8 +130,7 @@ public class ChannelImpl implements Channel */ public String getUrl(NodeRef publishedNode) { - NodeRef mappedChannel = channelHelper.mapChannelNOde(nodeRef); - NodeRef mappedNode = channelHelper.mapSourceToEnvironment(publishedNode, mappedChannel); + NodeRef mappedNode = channelHelper.mapSourceToEnvironment(publishedNode, nodeRef); return channelType.getNodeUrl(mappedNode); } } diff --git a/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java b/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java index d66b3e7df0..5e90e11364 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java +++ b/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java @@ -39,7 +39,6 @@ import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.publishing.channels.Channel; import org.alfresco.service.cmr.publishing.channels.ChannelService; import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.site.SiteInfo; @@ -164,12 +163,7 @@ public class ChannelServiceImpl implements ChannelService actualProps.put(PROP_CHANNEL_TYPE_ID, channelType.getId()); actualProps.put(PublishingModel.PROP_AUTHORISATION_COMPLETE, Boolean.FALSE); NodeRef channelNode = channelHelper.createChannelNode(channelContainer, channelType, name, actualProps); - Channel channel = channelHelper.buildChannelObject(channelNode, this); - - // Now create the corresponding channel nodes in the environment - NodeRef environment = environmentHelper.getEnvironment(siteId); - channelHelper.addChannelToEnvironment(environment, channel, actualProps); - return channel; + return channelHelper.buildChannelObject(channelNode, this); } /** @@ -177,17 +171,7 @@ public class ChannelServiceImpl implements ChannelService */ public void deleteChannel(Channel channel) { - List allChannelNodes = new ArrayList(); - NodeRef editorialNode = channel.getNodeRef(); - allChannelNodes.add(editorialNode); - for (AssociationRef assoc : nodeService.getSourceAssocs(editorialNode, PublishingModel.ASSOC_EDITORIAL_CHANNEL)) - { - allChannelNodes.add(assoc.getSourceRef()); - } - for (NodeRef channelNode : allChannelNodes) - { - nodeService.deleteNode(channelNode); - } + nodeService.deleteNode(channel.getNodeRef()); } /** @@ -386,20 +370,8 @@ public class ChannelServiceImpl implements ChannelService { HashMap actualProps = new HashMap(properties); actualProps.remove(ContentModel.PROP_NODE_UUID); - List allChannelNodes = new ArrayList(); NodeRef editorialNode = channel.getNodeRef(); - allChannelNodes.add(editorialNode); - for (AssociationRef assoc : nodeService.getSourceAssocs(editorialNode, PublishingModel.ASSOC_EDITORIAL_CHANNEL)) - { - allChannelNodes.add(assoc.getSourceRef()); - } - for (NodeRef channelNode : allChannelNodes) - { - for (Map.Entry entry : actualProps.entrySet()) - { - nodeService.setProperty(channelNode, entry.getKey(), entry.getValue()); - } - } + nodeService.setProperties(editorialNode, actualProps); } /** @@ -408,7 +380,8 @@ public class ChannelServiceImpl implements ChannelService @Override public Channel getChannel(String id) { - if(id!=null) + if(id!=null&& id.isEmpty()==false + && NodeRef.isNodeRef(id)) { NodeRef node = new NodeRef(id); return channelHelper.buildChannelObject(node, this); diff --git a/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java b/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java index ab5aeee53f..24de16845a 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java +++ b/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java @@ -34,7 +34,6 @@ import org.alfresco.model.ContentModel; import org.alfresco.repo.site.SiteServiceException; import org.alfresco.service.cmr.publishing.channels.Channel; import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; import org.junit.Before; @@ -53,9 +52,6 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat @Resource(name="channelService") private ChannelServiceImpl channelService; - @Resource(name="environmentHelper") - private EnvironmentHelper environmentHelper; - private ChannelType mockedChannelType = mock(ChannelType.class); @Before @@ -64,7 +60,6 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat { super.onSetUp(); channelService = (ChannelServiceImpl) getApplicationContext().getBean("channelService"); - environmentHelper = (EnvironmentHelper) getApplicationContext().getBean("environmentHelper"); when(mockedChannelType.getId()).thenReturn(channelTypeName); when(mockedChannelType.getChannelNodeType()).thenReturn(PublishingModel.TYPE_DELIVERY_CHANNEL); @@ -82,30 +77,20 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat List channels = channelService.getChannels(siteId); assertTrue(channels.isEmpty()); - Channel channel = channelService.createChannel(siteId, channelTypeName, channelName, null); + Channel channel = createChannel(); assertEquals(channelTypeName, channel.getChannelType().getId()); assertEquals(channelName, channel.getName()); assertTrue(nodeService.exists(channel.getNodeRef())); - - NodeRef environmentNode = environmentHelper.getEnvironment(siteId); - assertNotNull(environmentNode); - assertNotNull(nodeService.getChildByName(environmentNode, ContentModel.ASSOC_CONTAINS, channelName)); } @Test public void testDeleteChannel() throws Exception { - testCreateChannel(); - - Channel channel = channelService.getChannel(siteId, channelName); + Channel channel = createChannel(); channelService.deleteChannel(channel); List channels = channelService.getChannels(siteId); assertTrue(channels.isEmpty()); - - NodeRef environmentNode = environmentHelper.getEnvironment(siteId); - assertNotNull(environmentNode); - assertNull(nodeService.getChildByName(environmentNode, ContentModel.ASSOC_CONTAINS, channelName)); } @Test @@ -121,10 +106,6 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat assertEquals(1, channels.size()); Channel channel = channels.get(0); assertEquals(newChannelName, channel.getName()); - NodeRef environmentNode = environmentHelper.getEnvironment(siteId); - assertNotNull(environmentNode); - assertNull(nodeService.getChildByName(environmentNode, ContentModel.ASSOC_CONTAINS, channelName)); - assertNotNull(nodeService.getChildByName(environmentNode, ContentModel.ASSOC_CONTAINS, newChannelName)); } @Test @@ -197,8 +178,7 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat Channel channel = channelService.getChannel(siteId, channelName); assertNull("Should return null if unknown channelName", channel); - // Create channel - Channel createdChannel = channelService.createChannel(siteId, channelTypeName, channelName, null); + Channel createdChannel = createChannel(); try { @@ -216,4 +196,12 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat assertEquals(createdChannel.getChannelType().getId(), channel.getChannelType().getId()); assertEquals(createdChannel.getNodeRef(), channel.getNodeRef()); } + + /** + * @return + */ + private Channel createChannel() + { + return channelService.createChannel(siteId, channelTypeName, channelName, null); + } } diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java b/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java index cc62bb685d..7d13dc5730 100644 --- a/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java +++ b/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java @@ -28,7 +28,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeMap; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationUtil; @@ -70,7 +69,6 @@ public class EnvironmentHelper private SiteService siteService; private NodeService nodeService; private PublishingEventHelper publishingEventHelper; - private ChannelHelper channelHelper; static { @@ -123,7 +121,7 @@ public class EnvironmentHelper */ public void setChannelHelper(ChannelHelper channelHelper) { - this.channelHelper = channelHelper; + //NOOP } public NodeRef getEnvironment(String siteId) @@ -261,11 +259,6 @@ public class EnvironmentHelper private PublishingEvent getLastPublishingEvent(NodeRef node, EnvironmentImpl environment, String channelName) { - NodeRef mappedNode = channelHelper.mapSourceToEnvironment(node, environment.getNodeRef(), channelName); - if(mappedNode==null || nodeService.exists(mappedNode)==false) - { - return null; // Node is not published. - } //TODO Find the publish event. return null; } diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java b/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java index 83d26bb451..d080bc6930 100644 --- a/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java +++ b/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java @@ -28,9 +28,11 @@ import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.publishing.MutablePublishingPackage; import org.alfresco.service.cmr.publishing.NodePublishStatus; import org.alfresco.service.cmr.publishing.NodePublishStatus.Status; +import org.alfresco.service.cmr.publishing.channels.Channel; import org.alfresco.service.cmr.publishing.channels.ChannelService; import org.alfresco.service.cmr.publishing.channels.ChannelType; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; import org.junit.Test; /** @@ -40,9 +42,9 @@ import org.junit.Test; */ public class EnvironmentImplTest extends AbstractPublishingIntegrationTest { - private static final String channel1Name = "Channel1"; - private static final String channel2Name = "Channel2"; - + private Channel channel1; + private Channel channel2; + @Resource(name="channelService") private ChannelService channelService; @@ -52,7 +54,7 @@ public class EnvironmentImplTest extends AbstractPublishingIntegrationTest NodeRef first = fileFolderService.create(docLib, "first", ContentModel.TYPE_CONTENT).getNodeRef(); NodeRef second = fileFolderService.create(docLib, "second", ContentModel.TYPE_CONTENT).getNodeRef(); - Map results = environment.checkPublishStatus(channel1Name, first); + Map results = environment.checkPublishStatus(channel1.getId(), first); assertEquals(1, results.size()); checkNodeStatus(first, Status.NOT_PUBLISHED, results); @@ -61,14 +63,14 @@ public class EnvironmentImplTest extends AbstractPublishingIntegrationTest schedule.add(Calendar.YEAR, 1); MutablePublishingPackage pckg =queue.createPublishingPackage(); pckg.addNodesToPublish(first); - queue.scheduleNewEvent(pckg, channel1Name, schedule, null, null); + queue.scheduleNewEvent(pckg, channel1.getId(), schedule, null, null); - results = environment.checkPublishStatus(channel1Name, first, second); + results = environment.checkPublishStatus(channel1.getId(), first, second); assertEquals(2, results.size()); checkNodeStatus(first, Status.ON_QUEUE, results); checkNodeStatus(second, Status.NOT_PUBLISHED, results); - results = environment.checkPublishStatus(channel2Name, first, second); + results = environment.checkPublishStatus(channel2.getId(), first, second); assertEquals(2, results.size()); checkNodeStatus(first, Status.NOT_PUBLISHED, results); checkNodeStatus(second, Status.NOT_PUBLISHED, results); @@ -95,8 +97,8 @@ public class EnvironmentImplTest extends AbstractPublishingIntegrationTest { channelService.register(channelType); } - channelService.createChannel(siteId, channelTypeId, channel1Name, null); - channelService.createChannel(siteId, channelTypeId, channel2Name, null); + this.channel1 = channelService.createChannel(siteId, channelTypeId, GUID.generate(), null); + this.channel2 = channelService.createChannel(siteId, channelTypeId, GUID.generate(), null); } } diff --git a/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java b/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java index fd712975d9..d40a7af853 100644 --- a/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java @@ -55,13 +55,13 @@ import org.alfresco.service.cmr.publishing.StatusUpdate; import org.alfresco.service.cmr.publishing.channels.Channel; import org.alfresco.service.cmr.publishing.channels.ChannelService; import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.GUID; import org.junit.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; @@ -73,7 +73,6 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class PublishEventActionTest extends AbstractPublishingIntegrationTest { - private static final String channelName = "Channel1"; private static final String contentNodeName = "TheName"; private static final String content = "The quick brown fox jumped over the lazy dog"; @@ -92,7 +91,8 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest @Autowired private PublishEventAction action; - private NodeRef channel; + private Channel channel; + private NodeRef channelNode; private String eventId; private ChannelType channelType; @@ -110,10 +110,10 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest NodeRef publishEventNode = publishNode(source); // Check published node exists and is in correct place. - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channel); + NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); assertNotNull(publishedNode); assertTrue(nodeService.exists(publishedNode)); - assertEquals(channel, nodeService.getPrimaryParent(publishedNode).getParentRef()); + assertEquals(channelNode, nodeService.getPrimaryParent(publishedNode).getParentRef()); // Check published node type and aspects assertEquals(TYPE_CONTENT, nodeService.getType(publishedNode)); @@ -131,9 +131,9 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest assertEquals(content, readContent(source)); // Check lastPublishingEvent association is created. - List assocs = nodeService.getChildAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT, RegexQNamePattern.MATCH_ALL); + List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); assertEquals(1, assocs.size()); - assertEquals(publishEventNode, assocs.get(0).getChildRef()); + assertEquals(publishEventNode, assocs.get(0).getTargetRef()); } public void testUpdatePublishedNode() throws Exception @@ -143,7 +143,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest NodeRef publishEventNode = publishNode(source); // Check published node exists - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channel); + NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); assertNotNull(publishedNode); assertTrue(nodeService.exists(publishedNode)); @@ -158,9 +158,9 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest assertFalse(aspects.contains(ASPECT_GEOGRAPHIC)); // Check lastPublishingEvent association is created. - List assocs = nodeService.getChildAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT, RegexQNamePattern.MATCH_ALL); + List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); assertEquals(1, assocs.size()); - assertEquals(publishEventNode, assocs.get(0).getChildRef()); + assertEquals(publishEventNode, assocs.get(0).getTargetRef()); // Modify source node double lattitude = 0.25; @@ -174,7 +174,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest // Update published node. publishEventNode = publishNode(source); - NodeRef newPublishNode = channelHelper.mapSourceToEnvironment(source, channel); + NodeRef newPublishNode = channelHelper.mapSourceToEnvironment(source, channelNode); assertEquals(publishedNode, newPublishNode); // Published node shoudl still exist. @@ -194,16 +194,16 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest assertEquals(newContent, readContent(source)); // Check lastPublishingEvent association has changed. - assocs = nodeService.getChildAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT, RegexQNamePattern.MATCH_ALL); + assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); assertEquals(1, assocs.size()); - assertEquals(publishEventNode, assocs.get(0).getChildRef()); + assertEquals(publishEventNode, assocs.get(0).getTargetRef()); // Remove aspect from source node. nodeService.removeAspect(source, ASPECT_GEOGRAPHIC); // Update publish node publishNode(source); - newPublishNode = channelHelper.mapSourceToEnvironment(source, channel); + newPublishNode = channelHelper.mapSourceToEnvironment(source, channelNode); assertEquals(publishedNode, newPublishNode); aspects = nodeService.getAspects(source); @@ -225,7 +225,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest when(channelType.canPublish()).thenReturn(true); publishNode(source); - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channel); + NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); // Check publish was called verify(channelType, times(1)).publish(eq(publishedNode), anyMap()); @@ -239,7 +239,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest // Publish source node but dont' call ChannelType.publish(). publishNode(source); - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channel); + NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); // Check publish was not called. verify(channelType, never()).publish(eq(publishedNode), anyMap()); @@ -270,7 +270,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest // Publish source node but don't call ChannelType.publish(). publishNode(source); - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channel); + NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); verify(channelType, never()).publish(eq(publishedNode), anyMap()); @@ -309,7 +309,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest // Publish source node but don't call ChannelType.publish(). publishNode(source); - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channel); + NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); verify(channelType, never()).publish(eq(publishedNode), anyMap()); @@ -330,7 +330,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest // Create Status Update String message = "Here is the message "; - StatusUpdate status = queue.createStatusUpdate(message, source, channelName); + StatusUpdate status = queue.createStatusUpdate(message, source, channel.getId()); String url = "http://test/url"; when(channelType.getNodeUrl(any(NodeRef.class))).thenReturn(url); @@ -372,7 +372,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest { Calendar schedule = Calendar.getInstance(); schedule.add(Calendar.YEAR, 1); - this.eventId = queue.scheduleNewEvent(publishPckg, channelName, schedule, null, statusUpdate); + this.eventId = queue.scheduleNewEvent(publishPckg, channel.getId(), schedule, null, statusUpdate); } private void addGeographicAspect(NodeRef source, double lattitude, double longtitude) @@ -425,9 +425,8 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest Mockito.reset(channelType); mockChannelTypeBehaviour(channelType); } - channelService.createChannel(siteId, channelTypeId, channelName, null); - - this.channel = channelHelper.getChannelNodeForEnvironment(environment.getNodeRef(), channelName); + this.channel = channelService.createChannel(siteId, channelTypeId, GUID.generate(), null); + this.channelNode = channel.getNodeRef(); } @Override diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java index df57246a11..8d45dc808d 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java @@ -19,6 +19,7 @@ package org.alfresco.repo.publishing; +import static org.alfresco.repo.publishing.PublishingModel.ASSOC_LAST_PUBLISHING_EVENT; import static org.alfresco.repo.publishing.PublishingModel.ASSOC_PUBLISHING_EVENT; import static org.alfresco.repo.publishing.PublishingModel.NAMESPACE; import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_CHANNEL; @@ -64,6 +65,7 @@ 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.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; @@ -193,7 +195,7 @@ public class PublishingEventHelper }); } - public NodeRef createNode(NodeRef queueNode, PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate) + public NodeRef createNode(NodeRef queueNode, PublishingPackage publishingPackage, String channelId, Calendar schedule, String comment, StatusUpdate statusUpdate) throws Exception { if (schedule == null) @@ -202,7 +204,7 @@ public class PublishingEventHelper } String name = GUID.generate(); Map props = - buildPublishingEventProperties(publishingPackage, channelName, schedule, comment, statusUpdate, name); + buildPublishingEventProperties(publishingPackage, channelId, schedule, comment, statusUpdate, name); ChildAssociationRef newAssoc = nodeService.createNode(queueNode, ASSOC_PUBLISHING_EVENT, QName.createQName(NAMESPACE, name), @@ -213,14 +215,14 @@ public class PublishingEventHelper } private Map buildPublishingEventProperties(PublishingPackage publishingPackage, - String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate, String name) + String channelId, 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()); props.put(PublishingModel.PROP_PUBLISHING_EVENT_TIME_ZONE, schedule.getTimeZone().getID()); - props.put(PublishingModel.PROP_PUBLISHING_EVENT_CHANNEL, channelName); + props.put(PublishingModel.PROP_PUBLISHING_EVENT_CHANNEL, channelId); props.put(PublishingModel.PROP_PUBLISHING_EVENT_STATUS, PublishingModel.PROPVAL_PUBLISHING_EVENT_STATUS_SCHEDULED); if (comment != null) { @@ -238,7 +240,7 @@ public class PublishingEventHelper { props.put(PROP_STATUS_UPDATE_NODE_REF, statusNode.toString()); } - props.put(PROP_STATUS_UPDATE_CHANNEL_NAMES, (Serializable) statusUpdate.getChannelNames()); + props.put(PROP_STATUS_UPDATE_CHANNEL_NAMES, (Serializable) statusUpdate.getChannelIds()); } return props; } @@ -467,4 +469,16 @@ public class PublishingEventHelper NodeRef environment = environmentAssoc.getParentRef(); return environment; } + + public AssociationRef linkeToLastEvent(NodeRef publishedNode, NodeRef eventNode) + { + List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); + if(isEmpty(assocs)==false) + { + // Remove old association. + AssociationRef assoc = assocs.get(0); + nodeService.removeAssociation(assoc.getSourceRef(), assoc.getTargetRef(), assoc.getTypeQName()); + } + return nodeService.createAssociation(publishedNode, eventNode, ASSOC_LAST_PUBLISHING_EVENT); + } } diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventImpl.java b/source/java/org/alfresco/repo/publishing/PublishingEventImpl.java index 6cd72d422e..9ec3d7adae 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventImpl.java @@ -36,7 +36,7 @@ public class PublishingEventImpl implements PublishingEvent { private final String id; private final Status status; - private final String channelName; + private final String channelId; private final PublishingPackage publishingPackage; private final Date createdTime; private final String creator; @@ -55,7 +55,7 @@ public class PublishingEventImpl implements PublishingEvent { this.id = id; this.status = status; - this.channelName = channelName; + this.channelId = channelName; this.publishingPackage = publishingPackage; this.createdTime = createdTime; this.creator = creator; @@ -69,7 +69,7 @@ public class PublishingEventImpl implements PublishingEvent public PublishingEventImpl(PublishingEvent event) { this(event.getId(), - event.getStatus(), event.getChannelName(), + event.getStatus(), event.getChannelId(), event.getPackage(), event.getCreatedTime(), event.getCreator(), event.getModifiedTime(), event.getModifier(), event.getScheduledTime(), event.getComment(), @@ -97,9 +97,9 @@ public class PublishingEventImpl implements PublishingEvent /** * {@inheritDoc} */ - public String getChannelName() + public String getChannelId() { - return channelName; + return channelId; } /** diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java b/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java index bc1586cd78..d947963019 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java @@ -73,11 +73,11 @@ public class PublishingEventProcessor nodeService.setProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS, inProgressStatus); PublishingEvent event = eventHelper.getPublishingEvent(eventNode); NodeRef environment = eventHelper.getEnvironmentNodeForPublishingEvent(eventNode); - String channelName = event.getChannelName(); - Channel channel = channelHelper.getChannel(environment, channelName, channelService); + String channelName = event.getChannelId(); + Channel channel = channelService.getChannel(channelName); if (channel == null) { - fail(event, "No channel found"); + fail(eventNode, "No channel found"); } else { @@ -87,6 +87,10 @@ public class PublishingEventProcessor nodeService.setProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS, completedStatus); } } + catch(Exception e) + { + fail(eventNode, e.getMessage()); + } finally { behaviourFilter.enableAllBehaviours(); @@ -109,10 +113,10 @@ public class PublishingEventProcessor message += urlShortener.shortenUrl(nodeUrl); } } - Set channels = update.getChannelNames(); - for (String channelName : channels) + Set channels = update.getChannelIds(); + for (String channelId : channels) { - Channel channel = channelHelper.getChannel(environment, channelName, channelService); + Channel channel = channelService.getChannel(channelId); if(channel != null && channel.getChannelType().canPublishStatusUpdates()) { channel.updateStatus(message); @@ -143,9 +147,10 @@ public class PublishingEventProcessor } - public void fail(PublishingEvent event, String msg) + public void fail(NodeRef eventNode, String msg) { - // TODO Auto-generated method stub + String completedStatus = PublishingEvent.Status.FAILED.name(); + nodeService.setProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS, completedStatus); } public NodeRef publishEntry(Channel channel, PublishingPackageEntry entry, NodeRef eventNode) @@ -159,8 +164,7 @@ public class PublishingEventProcessor { updatePublishedNode(publishedNode, entry); } - QName qName = QName.createQName(NAMESPACE, eventNode.getId()); - nodeService.addChild(publishedNode, eventNode, ASSOC_LAST_PUBLISHING_EVENT, qName); + eventHelper.linkeToLastEvent(publishedNode, eventNode); channel.publish(publishedNode); return publishedNode; } diff --git a/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java b/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java index 35b65e6d2b..f803e322f5 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java @@ -58,8 +58,6 @@ import org.junit.Test; */ public class PublishingIntegratedTest extends BaseSpringTest { - private static String channelName = "Test Channel - Name"; - protected ServiceRegistry serviceRegistry; protected RetryingTransactionHelper retryingTransactionHelper; protected NodeService nodeService; @@ -74,6 +72,65 @@ public class PublishingIntegratedTest extends BaseSpringTest private ChannelType mockedChannelType = mock(ChannelType.class); private String channelTypeName; + @Test + public void testScheduleNewEvent() throws Exception + { + Channel channel = channelService.createChannel(siteId, channelTypeName, GUID.generate(), null); + + Set nodes = new HashSet(); + for (int i = 0; i < 4; ++i) + { + 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); + MutablePublishingPackage publishingPackage = liveQueue.createPublishingPackage(); + publishingPackage.addNodesToPublish(nodes); + + Calendar scheduleTime = Calendar.getInstance(); + scheduleTime.add(Calendar.HOUR, 1); + String eventId = liveQueue.scheduleNewEvent(publishingPackage, channel.getId(), scheduleTime, null, null); + + PublishingEvent event = publishingService.getPublishingEvent(eventId); + + Assert.assertEquals(scheduleTime, event.getScheduledTime()); + Assert.assertEquals(eventId, event.getId()); + Collection entries = event.getPackage().getEntries(); + Assert.assertEquals(4, entries.size()); + for (PublishingPackageEntry entry : entries) + { + Assert.assertTrue(entry.isPublish()); + Assert.assertTrue(nodes.remove(entry.getNodeRef())); + } + Assert.assertTrue(nodes.isEmpty()); + } + + @Test + public void testCancelScheduledEvent() + { + Channel channel = channelService.createChannel(siteId, channelTypeName, GUID.generate(), null); + + Set nodes = new HashSet(); + for (int i = 0; i < 4; ++i) + { + 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); + MutablePublishingPackage publishingPackage = liveQueue.createPublishingPackage(); + publishingPackage.addNodesToPublish(nodes); + + Calendar scheduleTime = Calendar.getInstance(); + scheduleTime.add(Calendar.HOUR, 1); + String eventId = liveQueue.scheduleNewEvent(publishingPackage, channel.getId(), scheduleTime, null, null); + PublishingEvent event = publishingService.getPublishingEvent(eventId); + Assert.assertNotNull(event); + publishingService.cancelPublishingEvent(eventId); + event = publishingService.getPublishingEvent(eventId); + Assert.assertNull(event); + } + /** * @throws java.lang.Exception */ @@ -106,62 +163,4 @@ public class PublishingIntegratedTest extends BaseSpringTest } } - @Test - public void testScheduleNewEvent() throws Exception - { - Channel channel = channelService.createChannel(siteId, channelTypeName, channelName, null); - - Set nodes = new HashSet(); - for (int i = 0; i < 4; ++i) - { - 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); - MutablePublishingPackage publishingPackage = liveQueue.createPublishingPackage(); - publishingPackage.addNodesToPublish(nodes); - - Calendar scheduleTime = Calendar.getInstance(); - scheduleTime.add(Calendar.HOUR, 1); - String eventId = liveQueue.scheduleNewEvent(publishingPackage, channelName, scheduleTime, null, null); - - PublishingEvent event = publishingService.getPublishingEvent(eventId); - - Assert.assertEquals(scheduleTime, event.getScheduledTime()); - Assert.assertEquals(eventId, event.getId()); - Collection entries = event.getPackage().getEntries(); - Assert.assertEquals(4, entries.size()); - for (PublishingPackageEntry entry : entries) - { - Assert.assertTrue(entry.isPublish()); - Assert.assertTrue(nodes.remove(entry.getNodeRef())); - } - Assert.assertTrue(nodes.isEmpty()); - } - - @Test - public void testCancelScheduledEvent() - { - Channel channel = channelService.createChannel(siteId, channelTypeName, channelName, null); - - Set nodes = new HashSet(); - for (int i = 0; i < 4; ++i) - { - 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); - MutablePublishingPackage publishingPackage = liveQueue.createPublishingPackage(); - publishingPackage.addNodesToPublish(nodes); - - Calendar scheduleTime = Calendar.getInstance(); - scheduleTime.add(Calendar.HOUR, 1); - String eventId = liveQueue.scheduleNewEvent(publishingPackage, channelName, scheduleTime, null, null); - PublishingEvent event = publishingService.getPublishingEvent(eventId); - Assert.assertNotNull(event); - publishingService.cancelPublishingEvent(eventId); - event = publishingService.getPublishingEvent(eventId); - Assert.assertNull(event); - } -} +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/publishing/PublishingModel.java b/source/java/org/alfresco/repo/publishing/PublishingModel.java index 0210847b0a..51c773b413 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingModel.java +++ b/source/java/org/alfresco/repo/publishing/PublishingModel.java @@ -72,7 +72,6 @@ public interface PublishingModel public static final QName PROP_ASSET_ID = QName.createQName(NAMESPACE, "assetId"); public static final QName PROP_ASSET_URL = QName.createQName(NAMESPACE, "assetUrl"); - // Publishing Connection Properties public static final QName PROP_ACCOUNT_ID= QName.createQName(NAMESPACE, "accountId"); public static final QName PROP_PROVIDER_ID= QName.createQName(NAMESPACE, "providerId"); @@ -92,7 +91,7 @@ public interface PublishingModel public static final QName ASSOC_PUBLISHING_EVENT = QName.createQName(NAMESPACE, "publishingEventAssoc"); public static final QName ASSOC_SOURCE = QName.createQName(NAMESPACE, "source"); public static final QName ASSOC_LAST_PUBLISHING_EVENT= QName.createQName(NAMESPACE, "lastPublishingEvent"); - public static final QName ASSOC_EDITORIAL_CHANNEL= QName.createQName(NAMESPACE, "editorialChannel"); + public static final QName ASSOC_PUBLISHED_CHANNEL= QName.createQName(NAMESPACE, "publishedChannel"); // Workflow Properties public static final QName PROP_WF_PUBLISHING_EVENT= QName.createQName(WF_NAMESPACE, "publishingEvent"); diff --git a/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java b/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java index 57c11b8524..0c0ae4b6ce 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java @@ -47,7 +47,7 @@ public class PublishingQueueImpl implements PublishingQueue private TransferManifestNodeFactory transferManifestNodeFactory; private VersionService versionService; private PublishingEventHelper publishingEventHelper; - + /** * {@inheritDoc} */ @@ -73,13 +73,29 @@ public class PublishingQueueImpl implements PublishingQueue } /** + * {@inheritDoc} + */ + public List getPublishingEvents(PublishingEventFilter filter) + { + return publishingEventHelper.findPublishingEvents(nodeRef, filter); + } + + /** + * {@inheritDoc} + */ + public PublishingEventFilter createPublishingEventFilter() + { + return new PublishingEventFilterImpl(); + } + + /** * {@inheritDoc} */ - public String scheduleNewEvent(PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate) + public String scheduleNewEvent(PublishingPackage publishingPackage, String channelId, Calendar schedule, String comment, StatusUpdate statusUpdate) { try { - NodeRef eventNode = publishingEventHelper.createNode(nodeRef, publishingPackage, channelName, schedule, comment, statusUpdate); + NodeRef eventNode = publishingEventHelper.createNode(nodeRef, publishingPackage, channelId, schedule, comment, statusUpdate); publishingEventHelper.startPublishingWorkflow(eventNode, schedule); return eventNode.toString(); } @@ -123,19 +139,5 @@ public class PublishingQueueImpl implements PublishingQueue this.versionService = versionService; } - /** - * {@inheritDoc} - */ - public List getPublishingEvents(PublishingEventFilter filter) - { - return publishingEventHelper.findPublishingEvents(nodeRef, filter); - } - /** - * {@inheritDoc} - */ - public PublishingEventFilter createPublishingEventFilter() - { - return new PublishingEventFilterImpl(); - } } diff --git a/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java b/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java index d49226d142..b82308c593 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java @@ -55,7 +55,7 @@ import org.junit.Test; */ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest { - private static final String channelName = "TheChannel"; + private static final String channelId = "test://channel/node"; private static final String comment = "The Comment"; protected PublishingService publishingService; @@ -82,7 +82,7 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest Calendar schedule = Calendar.getInstance(); schedule.add(Calendar.HOUR, 2); - this.eventId = queue.scheduleNewEvent(publishingPackage, channelName, schedule, comment, null); + this.eventId = queue.scheduleNewEvent(publishingPackage, channelId, schedule, comment, null); //Check schedule triggered versioning. Serializable version = nodeService.getProperty(firstNode, PROP_VERSION_LABEL); @@ -94,7 +94,7 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest assertEquals(Status.SCHEDULED, event.getStatus()); assertEquals(AuthenticationUtil.getAdminUserName(), event.getCreator()); assertEquals(schedule, event.getScheduledTime()); - assertEquals(channelName, event.getChannelName()); + assertEquals(channelId, event.getChannelId()); assertNull(event.getStatusUpdate()); PublishingPackage pckg = event.getPackage(); @@ -151,13 +151,13 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest publishingPackage.addNodesToPublish(firstNode, secondNode); Calendar schedule = Calendar.getInstance(); schedule.add(Calendar.HOUR, 2); - this.eventId = queue.scheduleNewEvent(publishingPackage, channelName, schedule, comment, update); + this.eventId = queue.scheduleNewEvent(publishingPackage, channelId, schedule, comment, update); PublishingEvent event = publishingService.getPublishingEvent(eventId); StatusUpdate actualUpdate = event.getStatusUpdate(); assertEquals(message, actualUpdate.getMessage()); assertEquals(secondNode, actualUpdate.getNodeToLinkTo()); - Set names = actualUpdate.getChannelNames(); + Set names = actualUpdate.getChannelIds(); assertEquals(3, names.size()); assertTrue(names.containsAll(channelNames)); } diff --git a/source/java/org/alfresco/repo/publishing/StatusUpdateImpl.java b/source/java/org/alfresco/repo/publishing/StatusUpdateImpl.java index 8d93b9937c..724ce3831e 100644 --- a/source/java/org/alfresco/repo/publishing/StatusUpdateImpl.java +++ b/source/java/org/alfresco/repo/publishing/StatusUpdateImpl.java @@ -57,7 +57,7 @@ public class StatusUpdateImpl implements StatusUpdate /** * {@inheritDoc} */ - public Set getChannelNames() + public Set getChannelIds() { return channelNames; } diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingEvent.java b/source/java/org/alfresco/service/cmr/publishing/PublishingEvent.java index 9e740527c2..de0fe58208 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingEvent.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingEvent.java @@ -51,7 +51,7 @@ public interface PublishingEvent MutablePublishingEvent edit(); - String getChannelName(); + String getChannelId(); StatusUpdate getStatusUpdate(); } diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java b/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java index 35b5543270..4789dd416a 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java @@ -34,19 +34,19 @@ public interface PublishingQueue */ MutablePublishingPackage createPublishingPackage(); - StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, String... channelNames); - StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, Collection channelNames); + StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, String... channelIds); + StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, Collection channelIds); /** * Adds the supplied publishing package onto the queue. * @param publishingPackage The publishing package that is to be enqueued - * @param channelName The name of the channel that the package is to be published to + * @param channelId The name of the channel that the package is to be published to * @param schedule The time at which the new publishing event should be scheduled (optional - null indicates "as soon as possible") * @param comment A comment to be stored with this new event (optional - may be null) * @param statusUpdate TODO * @return The identifier of the newly scheduled event */ - String scheduleNewEvent(PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate); + String scheduleNewEvent(PublishingPackage publishingPackage, String channelId, Calendar schedule, String comment, StatusUpdate statusUpdate); /** * Retrieve a list of publishing events associated with this publishing environment, filtering them using the diff --git a/source/java/org/alfresco/service/cmr/publishing/StatusUpdate.java b/source/java/org/alfresco/service/cmr/publishing/StatusUpdate.java index cb43ea901f..86a0119843 100644 --- a/source/java/org/alfresco/service/cmr/publishing/StatusUpdate.java +++ b/source/java/org/alfresco/service/cmr/publishing/StatusUpdate.java @@ -31,6 +31,6 @@ import org.alfresco.service.cmr.repository.NodeRef; public interface StatusUpdate { String getMessage(); - Set getChannelNames(); + Set getChannelIds(); NodeRef getNodeToLinkTo(); } diff --git a/source/java/org/alfresco/service/cmr/publishing/channels/Channel.java b/source/java/org/alfresco/service/cmr/publishing/channels/Channel.java index 31e3877aa4..8d35e94597 100644 --- a/source/java/org/alfresco/service/cmr/publishing/channels/Channel.java +++ b/source/java/org/alfresco/service/cmr/publishing/channels/Channel.java @@ -31,6 +31,7 @@ import org.alfresco.service.namespace.QName; */ public interface Channel { + String getId(); ChannelType getChannelType(); /**