From db158066a0f224528685f8f1b67919e3ab37e726 Mon Sep 17 00:00:00 2001 From: N Smith Date: Tue, 12 Jul 2011 14:41:36 +0000 Subject: [PATCH] Removed Environment from the Publishing Foundation API. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28957 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../AbstractPublishingIntegrationTest.java | 3 +- .../repo/publishing/ChannelServiceImpl.java | 16 ++-- .../ChannelServiceImplIntegratedTest.java | 34 +++----- .../repo/publishing/EnvironmentFactory.java | 7 +- .../repo/publishing/EnvironmentHelper.java | 40 +++------ .../publishing/EnvironmentHelperTest.java | 22 +---- .../repo/publishing/EnvironmentImpl.java | 32 +------- .../repo/publishing/EnvironmentImplTest.java | 3 - .../repo/publishing/PublishServiceImpl.java | 81 +++++++++++++------ .../publishing/PublishingIntegratedTest.java | 10 +-- .../repo/publishing/PublishingModel.java | 4 +- .../publishing/PublishingObjectFactory.java | 34 ++------ .../publishing/PublishingQueueFactory.java | 2 +- .../repo/publishing/PublishingQueueImpl.java | 19 +++++ .../cmr/publishing/BaseNodePublishStatus.java | 12 +-- .../service/cmr/publishing/Environment.java | 69 ---------------- .../cmr/publishing/NodePublishStatus.java | 8 +- .../NodePublishStatusNotPublished.java | 5 +- .../publishing/NodePublishStatusOnQueue.java | 4 +- .../NodePublishStatusPublished.java | 4 +- .../NodePublishStatusPublishedAndOnQueue.java | 6 +- .../cmr/publishing/PublishingQueue.java | 13 +++ .../cmr/publishing/PublishingService.java | 47 +++++------ 23 files changed, 164 insertions(+), 311 deletions(-) delete mode 100644 source/java/org/alfresco/service/cmr/publishing/Environment.java diff --git a/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java b/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java index b63a4a515a..f42b258866 100644 --- a/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java +++ b/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java @@ -34,7 +34,6 @@ import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.publishing.PublishingService; import org.alfresco.service.cmr.publishing.channels.ChannelType; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -90,7 +89,7 @@ public abstract class AbstractPublishingIntegrationTest extends BaseSpringTest SiteVisibility.PUBLIC); this.docLib = siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null); - this.environment = (EnvironmentImpl) factory.createEnvironmentObject(siteId, PublishingService.LIVE_ENVIRONMENT_NAME); + this.environment = (EnvironmentImpl) factory.createEnvironmentObject(siteId); this.queue = (PublishingQueueImpl) environment.getPublishingQueue(); } diff --git a/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java b/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java index d372955ac8..ff9a0ba830 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java +++ b/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java @@ -165,15 +165,9 @@ public class ChannelServiceImpl implements ChannelService NodeRef channelNode = channelHelper.createChannelNode(channelContainer, channelType, name, actualProps); Channel channel = channelHelper.buildChannelObject(channelNode, this); - // Now create the corresponding channel nodes in each of the - // configured environments - // FIXME: BJR: 20110506: Should we provide a means for supplying - // separate properties for each environment? - Map environments = environmentHelper.getEnvironments(siteId); - for (NodeRef environment : environments.values()) - { - channelHelper.addChannelToEnvironment(environment, channel, actualProps); - } + // Now create the corresponding channel nodes in the environment + NodeRef environment = environmentHelper.getEnvironment(siteId); + channelHelper.addChannelToEnvironment(environment, channel, actualProps); return channel; } @@ -313,8 +307,8 @@ public class ChannelServiceImpl implements ChannelService private Set getAllChannelContainers(String siteId) { Set containers = new HashSet(); - Map environments = environmentHelper.getEnvironments(siteId); - containers.addAll(environments.values()); + NodeRef environment = environmentHelper.getEnvironment(siteId); + containers.add(environment); NodeRef editorialContainer = getChannelContainer(siteId); if(editorialContainer!=null) { diff --git a/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java b/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java index da60bc19da..be595a7e17 100644 --- a/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java +++ b/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java @@ -19,11 +19,6 @@ package org.alfresco.repo.publishing; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -92,12 +87,9 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat assertEquals(channelName, channel.getName()); assertTrue(nodeService.exists(channel.getNodeRef())); - Map environments = environmentHelper.getEnvironments(siteId); - assertTrue(environments.size() > 0); - for (NodeRef envNodeRef : environments.values()) - { - assertNotNull(nodeService.getChildByName(envNodeRef, ContentModel.ASSOC_CONTAINS, channelName)); - } + NodeRef environmentNode = environmentHelper.getEnvironment(siteId); + assertNotNull(environmentNode); + assertNotNull(nodeService.getChildByName(environmentNode, ContentModel.ASSOC_CONTAINS, channelName)); } @Test @@ -110,12 +102,9 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat List channels = channelService.getChannels(siteId); assertTrue(channels.isEmpty()); - Map environments = environmentHelper.getEnvironments(siteId); - assertTrue(environments.size() > 0); - for (NodeRef envNodeRef : environments.values()) - { - assertNull(nodeService.getChildByName(envNodeRef, ContentModel.ASSOC_CONTAINS, channelName)); - } + NodeRef environmentNode = environmentHelper.getEnvironment(siteId); + assertNotNull(environmentNode); + assertNull(nodeService.getChildByName(environmentNode, ContentModel.ASSOC_CONTAINS, channelName)); } @Test @@ -131,13 +120,10 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat assertEquals(1, channels.size()); Channel channel = channels.get(0); assertEquals(newChannelName, channel.getName()); - Map environments = environmentHelper.getEnvironments(siteId); - assertTrue(environments.size() > 0); - for (NodeRef envNodeRef : environments.values()) - { - assertNull(nodeService.getChildByName(envNodeRef, ContentModel.ASSOC_CONTAINS, channelName)); - assertNotNull(nodeService.getChildByName(envNodeRef, ContentModel.ASSOC_CONTAINS, newChannelName)); - } + NodeRef environmentNode = environmentHelper.getEnvironment(siteId); + assertNotNull(environmentNode); + assertNull(nodeService.getChildByName(environmentNode, ContentModel.ASSOC_CONTAINS, channelName)); + assertNotNull(nodeService.getChildByName(environmentNode, ContentModel.ASSOC_CONTAINS, newChannelName)); } @Test diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentFactory.java b/source/java/org/alfresco/repo/publishing/EnvironmentFactory.java index 92fb4aa995..76f4f3e666 100644 --- a/source/java/org/alfresco/repo/publishing/EnvironmentFactory.java +++ b/source/java/org/alfresco/repo/publishing/EnvironmentFactory.java @@ -19,9 +19,6 @@ package org.alfresco.repo.publishing; -import java.util.List; - -import org.alfresco.service.cmr.publishing.Environment; /** * @author Brian @@ -29,7 +26,5 @@ import org.alfresco.service.cmr.publishing.Environment; */ public interface EnvironmentFactory { - Environment createEnvironmentObject(String siteId, String environmentName); - - List createEnvironmentObjects(String siteId); + EnvironmentImpl createEnvironmentObject(String siteId); } diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java b/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java index 4041e9ddb4..cc62bb685d 100644 --- a/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java +++ b/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java @@ -40,7 +40,6 @@ import org.alfresco.service.cmr.publishing.NodePublishStatusPublished; import org.alfresco.service.cmr.publishing.NodePublishStatusPublishedAndOnQueue; import org.alfresco.service.cmr.publishing.PublishingEvent; import org.alfresco.service.cmr.publishing.PublishingEvent.Status; -import org.alfresco.service.cmr.publishing.PublishingService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -59,6 +58,11 @@ import org.alfresco.util.ParameterCheck; */ public class EnvironmentHelper { + /** + * The name of the live environment. This environment is always available. + */ + private static final String LIVE_ENVIRONMENT_NAME = "live"; + private static final String ENVIRONMENT_CONTAINER_NAME = "environments"; private static final Set PUBLISHING_QUEUE_TYPE = new HashSet(); private Set environmentNodeTypes; @@ -122,29 +126,11 @@ public class EnvironmentHelper this.channelHelper = channelHelper; } - public Map getEnvironments(String siteId) - { - Map results = new TreeMap(); - NodeRef environmentContainer = getEnvironmentContainer(siteId); - List envAssocs = nodeService.getChildAssocs(environmentContainer, - getEnvironmentNodeTypes()); - for (ChildAssociationRef envAssoc : envAssocs) - { - NodeRef environment = envAssoc.getChildRef(); - String name = (String) nodeService.getProperty(environment, ContentModel.PROP_NAME); - results.put(name, environment); - } - return results; - } - - - public NodeRef getEnvironment(String siteId, String name) + public NodeRef getEnvironment(String siteId) { ParameterCheck.mandatory("siteId", siteId); - ParameterCheck.mandatory("name", name); - NodeRef environmentContainer = getEnvironmentContainer(siteId); - return nodeService.getChildByName(environmentContainer, ContentModel.ASSOC_CONTAINS, name); + return nodeService.getChildByName(environmentContainer, ContentModel.ASSOC_CONTAINS, LIVE_ENVIRONMENT_NAME); } public NodeRef getPublishingQueue(NodeRef environment) @@ -201,9 +187,9 @@ public class EnvironmentHelper // Also create the default live environment Map props = new HashMap(); - props.put(ContentModel.PROP_NAME, PublishingService.LIVE_ENVIRONMENT_NAME); + props.put(ContentModel.PROP_NAME, LIVE_ENVIRONMENT_NAME); nodeService.createNode(environmentContainer, ContentModel.ASSOC_CONTAINS, QName.createQName( - NamespaceService.CONTENT_MODEL_1_0_URI, PublishingService.LIVE_ENVIRONMENT_NAME), + NamespaceService.CONTENT_MODEL_1_0_URI, LIVE_ENVIRONMENT_NAME), PublishingModel.TYPE_ENVIRONMENT, props); } return environmentContainer; @@ -220,22 +206,22 @@ public class EnvironmentHelper { if(lastEvent != null) { - return new NodePublishStatusPublishedAndOnQueue(node, environment, channelName, queuedEvent, lastEvent); + return new NodePublishStatusPublishedAndOnQueue(node, channelName, queuedEvent, lastEvent); } else { - return new NodePublishStatusOnQueue(node, environment, channelName, queuedEvent); + return new NodePublishStatusOnQueue(node, channelName, queuedEvent); } } else { if(lastEvent != null) { - return new NodePublishStatusPublished(node, environment, channelName, lastEvent); + return new NodePublishStatusPublished(node, channelName, lastEvent); } else { - return new NodePublishStatusNotPublished(node, environment, channelName); + return new NodePublishStatusNotPublished(node, channelName); } } } diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentHelperTest.java b/source/java/org/alfresco/repo/publishing/EnvironmentHelperTest.java index 034c4346ec..a7ddb0ccbf 100644 --- a/source/java/org/alfresco/repo/publishing/EnvironmentHelperTest.java +++ b/source/java/org/alfresco/repo/publishing/EnvironmentHelperTest.java @@ -19,15 +19,8 @@ package org.alfresco.repo.publishing; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; - -import java.util.Map; - import javax.annotation.Resource; -import org.alfresco.service.cmr.publishing.PublishingService; import org.alfresco.service.cmr.repository.NodeRef; import org.junit.Test; @@ -47,21 +40,10 @@ public class EnvironmentHelperTest extends AbstractPublishingIntegrationTest environmentHelper = (EnvironmentHelper) getApplicationContext().getBean("environmentHelper"); } - @Test - public void testGetEnvironments() throws Exception - { - Map environments = environmentHelper.getEnvironments(siteId); - assertTrue(environments.size() == 1); - NodeRef liveEnvironment = environments.get(PublishingService.LIVE_ENVIRONMENT_NAME); - assertNotNull(liveEnvironment); - assertTrue(nodeService.exists(liveEnvironment)); - assertEquals(PublishingModel.TYPE_ENVIRONMENT, nodeService.getType(liveEnvironment)); - } - @Test public void testGetEnvironmentByName() throws Exception { - NodeRef liveEnvironment = environmentHelper.getEnvironment(siteId, PublishingService.LIVE_ENVIRONMENT_NAME); + NodeRef liveEnvironment = environmentHelper.getEnvironment(siteId); assertNotNull(liveEnvironment); assertTrue(nodeService.exists(liveEnvironment)); assertEquals(PublishingModel.TYPE_ENVIRONMENT, nodeService.getType(liveEnvironment)); @@ -70,7 +52,7 @@ public class EnvironmentHelperTest extends AbstractPublishingIntegrationTest @Test public void testGetPublishingQueue() throws Exception { - NodeRef liveEnvironment = environmentHelper.getEnvironment(siteId, PublishingService.LIVE_ENVIRONMENT_NAME); + NodeRef liveEnvironment = environmentHelper.getEnvironment(siteId); NodeRef publishingQueue = environmentHelper.getPublishingQueue(liveEnvironment); assertNotNull(publishingQueue); assertTrue(nodeService.exists(publishingQueue)); diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentImpl.java b/source/java/org/alfresco/repo/publishing/EnvironmentImpl.java index 32d8efc975..0d7912a644 100644 --- a/source/java/org/alfresco/repo/publishing/EnvironmentImpl.java +++ b/source/java/org/alfresco/repo/publishing/EnvironmentImpl.java @@ -22,13 +22,9 @@ package org.alfresco.repo.publishing; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; -import org.alfresco.service.cmr.publishing.Environment; import org.alfresco.service.cmr.publishing.NodePublishStatus; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingEventFilter; import org.alfresco.service.cmr.publishing.PublishingQueue; import org.alfresco.service.cmr.repository.NodeRef; @@ -37,13 +33,12 @@ import org.alfresco.service.cmr.repository.NodeRef; * @author Nick Smith * */ -public class EnvironmentImpl implements Environment +public class EnvironmentImpl { private PublishingQueueFactory publishingQueueFactory; private NodeRef nodeRef; private String id; private EnvironmentHelper environmentHelper; - private PublishingEventHelper publishingEventHelper; /** * {@inheritDoc} @@ -78,15 +73,6 @@ public class EnvironmentImpl implements Environment return id; } - /** - * {@inheritDoc} - */ - public List getPublishingEvents(PublishingEventFilter filter) - { - NodeRef queue = environmentHelper.getPublishingQueue(nodeRef); - return publishingEventHelper.findPublishingEvents(queue, filter); - } - /** * {@inheritDoc} */ @@ -95,14 +81,6 @@ public class EnvironmentImpl implements Environment return publishingQueueFactory.createPublishingQueueObject(nodeRef); } - /** - * {@inheritDoc} - */ - public PublishingEventFilter createPublishingEventFilter() - { - return new PublishingEventFilterImpl(); - } - public NodeRef getNodeRef() { return nodeRef; @@ -132,13 +110,5 @@ public class EnvironmentImpl implements Environment { this.environmentHelper = environmentHelper; } - - /** - * @param publishingEventHelper the publishingEventHelper to set - */ - public void setPublishingEventHelper(PublishingEventHelper publishingEventHelper) - { - this.publishingEventHelper = publishingEventHelper; - } } diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java b/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java index ae91b41484..83d26bb451 100644 --- a/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java +++ b/source/java/org/alfresco/repo/publishing/EnvironmentImplTest.java @@ -19,8 +19,6 @@ package org.alfresco.repo.publishing; -import static junit.framework.Assert.assertEquals; - import java.util.Calendar; import java.util.Map; @@ -79,7 +77,6 @@ public class EnvironmentImplTest extends AbstractPublishingIntegrationTest private void checkNodeStatus(NodeRef node, Status expStatus, Map results) { NodePublishStatus nodeStatus = results.get(node); - assertEquals(environment, nodeStatus.getEnvironment()); assertEquals(node, nodeStatus.getNodeRef()); assertEquals(expStatus, nodeStatus.getStatus()); } diff --git a/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java b/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java index 64e7646719..2446c3d919 100644 --- a/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishServiceImpl.java @@ -19,11 +19,14 @@ package org.alfresco.repo.publishing; -import java.util.List; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; import java.util.Set; -import org.alfresco.service.cmr.publishing.Environment; +import org.alfresco.service.cmr.publishing.NodePublishStatus; import org.alfresco.service.cmr.publishing.PublishingEvent; +import org.alfresco.service.cmr.publishing.PublishingQueue; import org.alfresco.service.cmr.publishing.PublishingService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.util.ParameterCheck; @@ -36,6 +39,7 @@ import org.alfresco.util.ParameterCheck; public class PublishServiceImpl implements PublishingService { public static final String NAME = "publishingService"; + private EnvironmentFactory environmentFactory; private PublishingEventHelper publishingEventHelper; @@ -55,24 +59,6 @@ public class PublishServiceImpl implements PublishingService this.publishingEventHelper = publishingEventHelper; } - /** - * - * {@inheritDoc} - */ - public Environment getEnvironment(String siteId, String environmentName) - { - return environmentFactory.createEnvironmentObject(siteId, environmentName); - } - - /** - * - * {@inheritDoc} - */ - public List getEnvironments(String siteId) - { - return environmentFactory.createEnvironmentObjects(siteId); - } - /** * * {@inheritDoc} @@ -91,13 +77,58 @@ public class PublishServiceImpl implements PublishingService return publishingEventHelper.getPublishingEvent(id); } - /* (non-Javadoc) - * @see org.alfresco.service.cmr.publishing.PublishingService#cancelPublishingEvent(java.lang.String) - */ - @Override + /** + * {@inheritDoc} + */ public void cancelPublishingEvent(String id) { ParameterCheck.mandatory("id", id); publishingEventHelper.cancelEvent(id); } -} + + /** + * {@inheritDoc} + */ + public PublishingQueue getPublishingQueue(String siteId) + { + EnvironmentImpl environment = getEnvironment(siteId); + if(environment!=null) + { + return environment.getPublishingQueue(); + } + return null; + } + + /** + * {@inheritDoc} + */ + public Map checkPublishStatus(String siteId, String channelName, + Collection nodes) + { + EnvironmentImpl environment = getEnvironment(siteId); + if(environment !=null ) + { + return environment.checkPublishStatus(channelName, nodes); + } + return Collections.emptyMap(); + } + + /** + * {@inheritDoc} + */ + public Map checkPublishStatus(String siteId, String channelName, NodeRef... nodes) + { + EnvironmentImpl environment = getEnvironment(siteId); + if(environment !=null ) + { + return environment.checkPublishStatus(channelName, nodes); + } + return Collections.emptyMap(); + } + + private EnvironmentImpl getEnvironment(String siteId) + { + return environmentFactory.createEnvironmentObject(siteId); + } + +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java b/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java index 858d7e6f00..35b65e6d2b 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java @@ -34,12 +34,10 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.publishing.Environment; import org.alfresco.service.cmr.publishing.MutablePublishingPackage; import org.alfresco.service.cmr.publishing.PublishingEvent; import org.alfresco.service.cmr.publishing.PublishingPackageEntry; 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.ChannelType; import org.alfresco.service.cmr.repository.NodeRef; @@ -79,6 +77,7 @@ public class PublishingIntegratedTest extends BaseSpringTest /** * @throws java.lang.Exception */ + @Override @Before public void onSetUp() throws Exception { @@ -119,8 +118,7 @@ public class PublishingIntegratedTest extends BaseSpringTest NamespaceService.CONTENT_MODEL_1_0_URI, Integer.toString(i)), ContentModel.TYPE_CONTENT).getChildRef()); } - Environment liveEnvironment = publishingService.getEnvironment(siteId, PublishingService.LIVE_ENVIRONMENT_NAME); - PublishingQueue liveQueue = liveEnvironment.getPublishingQueue(); + PublishingQueue liveQueue = publishingService.getPublishingQueue(siteId); MutablePublishingPackage publishingPackage = liveQueue.createPublishingPackage(); publishingPackage.addNodesToPublish(nodes); @@ -153,9 +151,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()); } - - Environment liveEnvironment = publishingService.getEnvironment(siteId, PublishingService.LIVE_ENVIRONMENT_NAME); - PublishingQueue liveQueue = liveEnvironment.getPublishingQueue(); + PublishingQueue liveQueue = publishingService.getPublishingQueue(siteId); MutablePublishingPackage publishingPackage = liveQueue.createPublishingPackage(); publishingPackage.addNodesToPublish(nodes); diff --git a/source/java/org/alfresco/repo/publishing/PublishingModel.java b/source/java/org/alfresco/repo/publishing/PublishingModel.java index 89917b8667..88c8d6739b 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingModel.java +++ b/source/java/org/alfresco/repo/publishing/PublishingModel.java @@ -91,5 +91,5 @@ public interface PublishingModel // Workflow Properties public static final QName PROP_WF_PUBLISHING_EVENT= QName.createQName(WF_NAMESPACE, "publishingEvent"); public static final QName PROP_WF_SCHEDULED_PUBLISH_DATE= QName.createQName(WF_NAMESPACE, "scheduledPublishDate"); - -} + +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/publishing/PublishingObjectFactory.java b/source/java/org/alfresco/repo/publishing/PublishingObjectFactory.java index 00931fc00f..f5688630c6 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingObjectFactory.java +++ b/source/java/org/alfresco/repo/publishing/PublishingObjectFactory.java @@ -19,12 +19,7 @@ package org.alfresco.repo.publishing; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - import org.alfresco.repo.transfer.manifest.TransferManifestNodeFactory; -import org.alfresco.service.cmr.publishing.Environment; import org.alfresco.service.cmr.publishing.PublishingQueue; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.version.VersionService; @@ -77,10 +72,9 @@ public class PublishingObjectFactory implements EnvironmentFactory, PublishingQu /* (non-Javadoc) * @see org.alfresco.repo.publishing.EnvironmentFactory#createEnvironmentObject(java.lang.String, java.lang.String) */ - @Override - public Environment createEnvironmentObject(String siteId, String environmentName) + public EnvironmentImpl createEnvironmentObject(String siteId) { - NodeRef node = environmentHelper.getEnvironment(siteId, environmentName); + NodeRef node = environmentHelper.getEnvironment(siteId); return createEnvironmentFromNode(node); } @@ -88,45 +82,27 @@ public class PublishingObjectFactory implements EnvironmentFactory, PublishingQu * @param node * @return */ - private Environment createEnvironmentFromNode(NodeRef node) + private EnvironmentImpl createEnvironmentFromNode(NodeRef node) { EnvironmentImpl environment = new EnvironmentImpl(); environment.setNodeRef(node); environment.setPublishingQueueFactory(this); environment.setEnvironmentHelper(environmentHelper); - environment.setPublishingEventHelper(publishingEventHelper); return environment; } - /* (non-Javadoc) - * @see org.alfresco.repo.publishing.EnvironmentFactory#createEnvironmentObjects(java.lang.String) - */ - @Override - public List createEnvironmentObjects(String siteId) - { - Map environmentMap = environmentHelper.getEnvironments(siteId); - List environments = new ArrayList(environmentMap.size()); - for (NodeRef node : environmentMap.values()) - { - environments.add(createEnvironmentFromNode(node)); - } - return environments; - } - /* (non-Javadoc) * @see org.alfresco.repo.publishing.PublishingQueueFactory#createPublishingQueueObject(java.lang.String, java.lang.String) */ - @Override - public PublishingQueue createPublishingQueueObject(String siteId, String environmentName) + public PublishingQueue createPublishingQueueObject(String siteId) { - NodeRef environmentNode = environmentHelper.getEnvironment(siteId, environmentName); + NodeRef environmentNode = environmentHelper.getEnvironment(siteId); return createPublishingQueueObject(environmentNode); } /* (non-Javadoc) * @see org.alfresco.repo.publishing.PublishingQueueFactory#createPublishingQueueObject(org.alfresco.service.cmr.repository.NodeRef) */ - @Override public PublishingQueue createPublishingQueueObject(NodeRef environmentNodeRef) { NodeRef queueNode = environmentHelper.getPublishingQueue(environmentNodeRef); diff --git a/source/java/org/alfresco/repo/publishing/PublishingQueueFactory.java b/source/java/org/alfresco/repo/publishing/PublishingQueueFactory.java index 7b5ca7fcea..2af4f74b54 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingQueueFactory.java +++ b/source/java/org/alfresco/repo/publishing/PublishingQueueFactory.java @@ -28,7 +28,7 @@ import org.alfresco.service.cmr.repository.NodeRef; */ public interface PublishingQueueFactory { - PublishingQueue createPublishingQueueObject(String siteId, String environmentName); + PublishingQueue createPublishingQueueObject(String siteId); PublishingQueue createPublishingQueueObject(NodeRef environmentNodeRef); } diff --git a/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java b/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java index 5f12cb6587..57c11b8524 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java +++ b/source/java/org/alfresco/repo/publishing/PublishingQueueImpl.java @@ -22,10 +22,13 @@ package org.alfresco.repo.publishing; import java.util.Arrays; import java.util.Calendar; import java.util.Collection; +import java.util.List; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.transfer.manifest.TransferManifestNodeFactory; import org.alfresco.service.cmr.publishing.MutablePublishingPackage; +import org.alfresco.service.cmr.publishing.PublishingEvent; +import org.alfresco.service.cmr.publishing.PublishingEventFilter; import org.alfresco.service.cmr.publishing.PublishingPackage; import org.alfresco.service.cmr.publishing.PublishingQueue; import org.alfresco.service.cmr.publishing.StatusUpdate; @@ -119,4 +122,20 @@ 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/service/cmr/publishing/BaseNodePublishStatus.java b/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java index 13a49d9654..00b242e369 100644 --- a/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java +++ b/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java @@ -29,13 +29,11 @@ import org.alfresco.service.cmr.repository.NodeRef; public abstract class BaseNodePublishStatus implements NodePublishStatus { private final NodeRef nodeRef; - private final Environment environment; private final String channelName; - public BaseNodePublishStatus(NodeRef nodeRef, Environment environment, String channelName) + public BaseNodePublishStatus(NodeRef nodeRef, String channelName) { this.nodeRef = nodeRef; - this.environment = environment; this.channelName = channelName; } @@ -47,14 +45,6 @@ public abstract class BaseNodePublishStatus implements NodePublishStatus return nodeRef; } - /** - * {@inheritDoc} - */ - public Environment getEnvironment() - { - return environment; - } - /** * {@inheritDoc} */ diff --git a/source/java/org/alfresco/service/cmr/publishing/Environment.java b/source/java/org/alfresco/service/cmr/publishing/Environment.java deleted file mode 100644 index 77446c2c16..0000000000 --- a/source/java/org/alfresco/service/cmr/publishing/Environment.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.service.cmr.publishing; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * An interface that describes a publishing environment. - * @author Brian - * - */ -public interface Environment -{ - /** - * Retrieve the identifier of this publishing environment - * @return The identifier of this publishing environment - */ - String getId(); - - /** - * Retrieve the publishing queue associated with this publishing environment - * @return A PublishingQueue object corresponding tho this environment's publishing queue - */ - PublishingQueue getPublishingQueue(); - - /** - * Discover the publishing status of each of the specified nodes - * @param channelName TODO - * @param nodes The identifiers of the nodes whose publishing status is being sought - * @return A map associating a NodePublishStatus object with each of the supplied NodeRef objects - */ - Map checkPublishStatus(String channelName, Collection nodes); - - Map checkPublishStatus(String channelName, NodeRef... nodes); - - /** - * Retrieve a list of publishing events associated with this publishing environment, filtering them using the - * supplied PublishingEventFilter object (optional - may be null) - * @param filter The filter that is to be applied to the publishing events on this environment - * @return A list of PublishingEvent objects representing the publishing events that matched the supplied filter on this publishing environment - */ - List getPublishingEvents(PublishingEventFilter filter); - - /** - * A factory method that creates a {@link PublishingEventFilter} object. - * @return a new {@link PublishingEventFilter}. - */ - PublishingEventFilter createPublishingEventFilter(); -} diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java index 566c5ef362..c712fce942 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java @@ -23,7 +23,7 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * @author Brian - * + * @author Nick Smith */ public interface NodePublishStatus { @@ -35,11 +35,5 @@ public interface NodePublishStatus Status getStatus(); - /** - * Obtain the environment related to this status - * @return - */ - Environment getEnvironment(); - String getChannelName(); } diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java index b103a2e60b..bf8893a867 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java @@ -27,15 +27,14 @@ import org.alfresco.service.cmr.repository.NodeRef; */ public class NodePublishStatusNotPublished extends BaseNodePublishStatus { - /** * @param node * @param environment * @param channelName TODO */ - public NodePublishStatusNotPublished(NodeRef node, Environment environment, String channelName) + public NodePublishStatusNotPublished(NodeRef node, String channelName) { - super(node, environment, channelName); + super(node, channelName); } /** diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java index 2663897130..96735ea21f 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java @@ -30,9 +30,9 @@ public class NodePublishStatusOnQueue extends BaseNodePublishStatus { private final PublishingEvent queuedEvent; - public NodePublishStatusOnQueue(NodeRef nodeRef, Environment environment, String channelName, PublishingEvent queuedEvent) + public NodePublishStatusOnQueue(NodeRef nodeRef, String channelName, PublishingEvent queuedEvent) { - super(nodeRef, environment, channelName); + super(nodeRef, channelName); this.queuedEvent =queuedEvent; } diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java index abe7368f8f..e3979358a3 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java @@ -30,9 +30,9 @@ public class NodePublishStatusPublished extends BaseNodePublishStatus private final PublishingEvent lastEvent; - public NodePublishStatusPublished(NodeRef node, Environment environment, String channelName, PublishingEvent lastEvent) + public NodePublishStatusPublished(NodeRef node, String channelName, PublishingEvent lastEvent) { - super(node, environment, channelName); + super(node, channelName); this.lastEvent = lastEvent; } diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java index 1e2bf42cf2..09d22c329b 100644 --- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java +++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java @@ -38,10 +38,10 @@ public class NodePublishStatusPublishedAndOnQueue extends BaseNodePublishStatus * @param queuedPublishingEvent The next scheduled {@link PublishingEvent} on the {@link PublishingQueue} * @param latestPublishingEvent The last {@link PublishingEvent} to successfully publish the node. */ - public NodePublishStatusPublishedAndOnQueue(NodeRef nodeRef, Environment environment, - String channelName, PublishingEvent queuedPublishingEvent, PublishingEvent latestPublishingEvent) + public NodePublishStatusPublishedAndOnQueue(NodeRef nodeRef, String channelName, + PublishingEvent queuedPublishingEvent, PublishingEvent latestPublishingEvent) { - super(nodeRef, environment, channelName); + super(nodeRef, channelName); this.queuedPublishingEvent = queuedPublishingEvent; this.latestPublishingEvent = latestPublishingEvent; } diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java b/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java index 0f213a61b7..35b5543270 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingQueue.java @@ -21,6 +21,7 @@ package org.alfresco.service.cmr.publishing; import java.util.Calendar; import java.util.Collection; +import java.util.List; import org.alfresco.service.cmr.repository.NodeRef; @@ -47,5 +48,17 @@ public interface PublishingQueue */ String scheduleNewEvent(PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate); + /** + * Retrieve a list of publishing events associated with this publishing environment, filtering them using the + * supplied PublishingEventFilter object (optional - may be null) + * @param filter The filter that is to be applied to the publishing events on this environment + * @return A list of PublishingEvent objects representing the publishing events that matched the supplied filter on this publishing environment + */ + List getPublishingEvents(PublishingEventFilter filter); + /** + * A factory method that creates a {@link PublishingEventFilter} object. + * @return a new {@link PublishingEventFilter}. + */ + PublishingEventFilter createPublishingEventFilter(); } diff --git a/source/java/org/alfresco/service/cmr/publishing/PublishingService.java b/source/java/org/alfresco/service/cmr/publishing/PublishingService.java index b79bc91e16..684c8e40bc 100644 --- a/source/java/org/alfresco/service/cmr/publishing/PublishingService.java +++ b/source/java/org/alfresco/service/cmr/publishing/PublishingService.java @@ -18,35 +18,14 @@ */ package org.alfresco.service.cmr.publishing; -import java.util.List; +import java.util.Collection; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; + public interface PublishingService { - /** - * The name of the live environment. This environment is always available. - */ - public static final String LIVE_ENVIRONMENT_NAME = "live"; - - /** - * Retrieve a list of all the target publishing environments defined on the - * specified Share site - * - * @param siteId - * The identifier of the Share site - * @return - */ - List getEnvironments(String siteId); - - /** - * Retrieve the named publishing environment on the specified Share site - * - * @param siteId - * The identifier of the Share site - * @param environmentName - * The name of the required publishing environment - * @return - */ - Environment getEnvironment(String siteId, String environmentName); /** * Retrieve the publishing event that has the specified identifier @@ -67,4 +46,20 @@ public interface PublishingService * @param id The identifier of the publishing event that is to be cancelled. */ void cancelPublishingEvent(String id); + + /** + * Retrieve the publishing queue associated with this publishing environment + * @return A PublishingQueue object corresponding tho this environment's publishing queue + */ + PublishingQueue getPublishingQueue(String siteId); + + /** + * Discover the publishing status of each of the specified nodes + * @param channelName TODO + * @param nodes The identifiers of the nodes whose publishing status is being sought + * @return A map associating a NodePublishStatus object with each of the supplied NodeRef objects + */ + Map checkPublishStatus(String siteId, String channelName, Collection nodes); + + Map checkPublishStatus(String siteId, String channelName, NodeRef... nodes); }