Publishing: Tidied PublishingService and ChannelService interface to remove obsolete operations.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30437 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2011-09-12 15:38:47 +00:00
parent a48be26668
commit b94e282177
13 changed files with 6 additions and 410 deletions

View File

@@ -54,7 +54,6 @@
<!-- Channel Type Implementations -->
<bean id="baseChannelType" class="org.alfresco.repo.publishing.AbstractChannelType" abstract="true" >
<property name="channelService" ref="channelService" />
<property name="serviceRegistry" ref="ServiceRegistry" />
</bean>
<bean id="channelHelper" class="org.alfresco.repo.publishing.ChannelHelper">

View File

@@ -20,24 +20,14 @@
package org.alfresco.repo.publishing;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.repo.transfer.CompositeNodeFilter;
import org.alfresco.repo.transfer.CompositeNodeFinder;
import org.alfresco.repo.transfer.PrimaryParentNodeFinder;
import org.alfresco.service.ServiceRegistry;
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.transfer.NodeFilter;
import org.alfresco.service.cmr.transfer.NodeFinder;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
@@ -45,11 +35,8 @@ import org.springframework.core.io.Resource;
* @author Nick Smith
* @since 4.0
*/
public abstract class AbstractChannelType implements ChannelType, InitializingBean
public abstract class AbstractChannelType implements ChannelType
{
private ServiceRegistry serviceRegistry;
protected NodeFinder nodeFinder;
protected NodeFilter nodeFilter;
private ChannelService channelService;
public void setChannelService(ChannelService channelService)
@@ -63,75 +50,6 @@ public abstract class AbstractChannelType implements ChannelType, InitializingBe
return channelService;
}
/**
* @param serviceRegistry
* the serviceRegistry to set
*/
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.serviceRegistry = serviceRegistry;
}
/**
* {@inheritDoc}
*/
@Override
public void afterPropertiesSet() throws Exception
{
Collection<NodeFinder> finders = getAllNodeFInders();
CompositeNodeFinder finder = new CompositeNodeFinder(finders);
finder.setServiceRegistry(serviceRegistry);
finder.init();
this.nodeFinder = finder;
Collection<NodeFilter> filters = getAllNodeFIlters();
CompositeNodeFilter filter = new CompositeNodeFilter(filters);
filter.setServiceRegistry(serviceRegistry);
finder.init();
this.nodeFilter = filter;
}
/**
* @return a collection of {@link NodeFilter}s to be included in the
* {@link CompositeNodeFilter} returned by the getNodeFilter()
* method.
*/
protected Collection<NodeFilter> getAllNodeFIlters()
{
return Collections.emptyList();
}
/**
* @return a collection of {@link NodeFinder}s to be included in the
* {@link CompositeNodeFinder} returned by the getNodeFinder()
* method.
*/
protected Collection<NodeFinder> getAllNodeFInders()
{
// TODO Add dependency node finder.
NodeFinder parentFinder = new PrimaryParentNodeFinder();
return Arrays.asList(parentFinder);
}
/**
* {@inheritDoc}
*/
@Override
public NodeFilter getNodeFilter()
{
return nodeFilter;
}
/**
* {@inheritDoc}
*/
@Override
public NodeFinder getNodeFinder()
{
return nodeFinder;
}
/**
* {@inheritDoc}
*/

View File

@@ -1,80 +0,0 @@
/*
* Copyright (C) 2005-2011 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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE;
import org.alfresco.repo.transfer.AbstractNodeFilter;
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.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.transfer.NodeFilter;
import org.alfresco.util.ParameterCheck;
/**
* @author Nick Smith
* @since 4.0
*/
public class ChannelDependancyNodeFilter extends AbstractNodeFilter
{
private final ChannelService channelService;
private NodeService nodeService;
/**
* @param channelService
*/
public ChannelDependancyNodeFilter(ChannelService channelService)
{
this.channelService = channelService;
}
/**
* {@inheritDoc}
*/
@Override
public void init()
{
super.init();
this.nodeService = serviceRegistry.getNodeService();
ParameterCheck.mandatory("channelService", channelService);
}
/**
* {@inheritDoc}
*/
public boolean accept(NodeRef thisNode)
{
String typeId = (String) nodeService.getProperty(thisNode, PROP_CHANNEL_TYPE);
if (typeId !=null)
{
ChannelType type = channelService.getChannelType(typeId);
if (type != null)
{
NodeFilter filter = type.getNodeFilter();
if (filter !=null)
{
return filter.accept(thisNode);
}
}
}
return true;
}
}

View File

@@ -1,83 +0,0 @@
/*
* Copyright (C) 2005-2011 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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE;
import java.util.Collections;
import java.util.Set;
import org.alfresco.repo.transfer.AbstractNodeFinder;
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.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.transfer.NodeFinder;
import org.alfresco.util.ParameterCheck;
/**
* @author Nick Smith
* @since 4.0
*/
public class ChannelDependancyNodeFinder extends AbstractNodeFinder
{
private final ChannelService channelService;
private NodeService nodeService;
/**
* @param channelService
*/
public ChannelDependancyNodeFinder(ChannelService channelService)
{
this.channelService = channelService;
}
/**
* {@inheritDoc}
*/
@Override
public void init()
{
super.init();
this.nodeService = serviceRegistry.getNodeService();
ParameterCheck.mandatory("channelService", channelService);
}
/**
* {@inheritDoc}
*/
public Set<NodeRef> findFrom(NodeRef thisNode)
{
String typeId = (String) nodeService.getProperty(thisNode, PROP_CHANNEL_TYPE);
if (typeId !=null)
{
ChannelType type = channelService.getChannelType(typeId);
if (type != null)
{
NodeFinder finder = type.getNodeFinder();
if (finder !=null)
{
return finder.findFrom(thisNode);
}
}
}
return Collections.emptySet();
}
}

View File

@@ -37,8 +37,6 @@ 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.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.transfer.NodeFilter;
import org.alfresco.service.cmr.transfer.NodeFinder;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
@@ -255,22 +253,6 @@ public class ChannelServiceImpl implements ChannelService
return channelTypes.get(id);
}
/**
* {@inheritDoc}
*/
public NodeFinder getChannelDependancyNodeFinder()
{
return new ChannelDependancyNodeFinder(this);
}
/**
* {@inheritDoc}
*/
public NodeFilter getChannelDependancyNodeFilter()
{
return new ChannelDependancyNodeFilter(this);
}
/**
* {@inheritDoc}
*/

View File

@@ -19,25 +19,16 @@
package org.alfresco.repo.publishing;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE;
import static org.mockito.Mockito.when;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.publishing.channels.ChannelType;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.transfer.NodeFilter;
import org.alfresco.service.cmr.transfer.NodeFinder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
@@ -91,67 +82,4 @@ public class ChannelServiceImplTest
}
}
@Test
public void testGetChannelDependancyNodeFinder() throws Exception
{
when(serviceRegistry.getNodeService()).thenReturn(nodeService);
NodeRef node = new NodeRef("test://foo/bar");
NodeRef parent = new NodeRef("test://foo/barParent");
ChildAssociationRef assoc = new ChildAssociationRef(null, parent, null, node);
NodeFinder nodeFinder = channelService.getChannelDependancyNodeFinder();
assertNotNull(nodeFinder);
// Initialize Node Finders
ChannelDependancyNodeFinder cdnf = (ChannelDependancyNodeFinder) nodeFinder;
cdnf.setServiceRegistry(serviceRegistry);
cdnf.init();
// Need to call afterPropertiesSet() again to pick up nodeService.
mockChannelType.afterPropertiesSet();
// Check no nodes found if NodeRef does not have a channel type.
Set<NodeRef> results = nodeFinder.findFrom(node);
assertTrue(results.isEmpty());
// Check no nodes found if NodeRef has an unregistered channel type.
when(nodeService.getProperty(node, PROP_CHANNEL_TYPE))
.thenReturn("Foo");
results = nodeFinder.findFrom(node);
assertTrue(results.isEmpty());
// Check returns parent if MockChannelType found.
when(nodeService.getProperty(node, PROP_CHANNEL_TYPE))
.thenReturn(MockChannelType.ID);
when(nodeService.getPrimaryParent(node))
.thenReturn(assoc);
results = nodeFinder.findFrom(node);
assertEquals(1, results.size());
assertTrue(results.contains(parent));
}
@Test
public void testGetChannelDependancyNodeFilter() throws Exception
{
when(serviceRegistry.getNodeService()).thenReturn(nodeService);
NodeRef node = new NodeRef("test://foo/bar");
NodeFilter nodeFinder = channelService.getChannelDependancyNodeFilter();
assertNotNull(nodeFinder);
// Initialize Node Finders
ChannelDependancyNodeFilter cdnf = (ChannelDependancyNodeFilter) nodeFinder;
cdnf.setServiceRegistry(serviceRegistry);
cdnf.init();
// Check no nodes filtered if NodeRef does not have a channel type.
assertTrue(nodeFinder.accept(node));
// Check no nodes filtered if NodeRef has an unregistered channel type.
when(nodeService.getProperty(node, PROP_CHANNEL_TYPE))
.thenReturn("Foo");
assertTrue(nodeFinder.accept(node));
// TODO Test other NodeFilter behaviour when added.
}
}

View File

@@ -69,7 +69,7 @@ public class PublishServiceImpl implements PublishingService
/**
* {@inheritDoc}
*/
public List<PublishingEvent> getEventsForPublishedNode(NodeRef publishedNode)
public List<PublishingEvent> getPublishEventsForNode(NodeRef publishedNode)
{
NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef();
List<NodeRef> eventNodes = publishingEventHelper.getEventNodesForPublishedNode(queueNode, publishedNode);
@@ -79,7 +79,7 @@ public class PublishServiceImpl implements PublishingService
/**
* {@inheritDoc}
*/
public List<PublishingEvent> getEventsForUnpublishedNode(NodeRef unpublishedNode)
public List<PublishingEvent> getUnpublishEventsForNode(NodeRef unpublishedNode)
{
NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef();
List<NodeRef> eventNodes = publishingEventHelper.getEventNodesForUnpublishedNode(queueNode, unpublishedNode);

View File

@@ -26,18 +26,14 @@ import org.alfresco.repo.publishing.flickr.springsocial.api.Flickr;
import org.alfresco.repo.publishing.flickr.springsocial.api.MediaOperations;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.tagging.TaggingService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.social.connect.Connection;
public class FlickrUnpublishAction extends ActionExecuterAbstractBase
{
private final static Log log = LogFactory.getLog(FlickrUnpublishAction.class);
public static final String NAME = "unpublish_flickr";
private NodeService nodeService;

View File

@@ -27,8 +27,6 @@ import org.alfresco.repo.publishing.AbstractChannelType;
import org.alfresco.repo.publishing.PublishingModel;
import org.alfresco.service.cmr.publishing.channels.Channel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.transfer.NodeFilter;
import org.alfresco.service.cmr.transfer.NodeFinder;
import org.alfresco.service.namespace.QName;
public class TestChannelType1 extends AbstractChannelType
@@ -70,18 +68,6 @@ public class TestChannelType1 extends AbstractChannelType
return 0;
}
@Override
public NodeFilter getNodeFilter()
{
return null;
}
@Override
public NodeFinder getNodeFinder()
{
return null;
}
@Override
public String getNodeUrl(NodeRef node)
{

View File

@@ -27,8 +27,6 @@ import org.alfresco.repo.publishing.AbstractChannelType;
import org.alfresco.repo.publishing.PublishingModel;
import org.alfresco.service.cmr.publishing.channels.Channel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.transfer.NodeFilter;
import org.alfresco.service.cmr.transfer.NodeFinder;
import org.alfresco.service.namespace.QName;
public class TestChannelType2 extends AbstractChannelType
@@ -70,18 +68,6 @@ public class TestChannelType2 extends AbstractChannelType
return 140;
}
@Override
public NodeFilter getNodeFilter()
{
return null;
}
@Override
public NodeFinder getNodeFinder()
{
return null;
}
@Override
public String getNodeUrl(NodeRef node)
{

View File

@@ -27,8 +27,6 @@ import org.alfresco.repo.publishing.AbstractChannelType;
import org.alfresco.repo.publishing.PublishingModel;
import org.alfresco.service.cmr.publishing.channels.Channel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.transfer.NodeFilter;
import org.alfresco.service.cmr.transfer.NodeFinder;
import org.alfresco.service.namespace.QName;
public class TestChannelType3 extends AbstractChannelType
@@ -70,18 +68,6 @@ public class TestChannelType3 extends AbstractChannelType
return 200;
}
@Override
public NodeFilter getNodeFilter()
{
return null;
}
@Override
public NodeFinder getNodeFinder()
{
return null;
}
@Override
public String getNodeUrl(NodeRef node)
{

View File

@@ -18,11 +18,8 @@
*/
package org.alfresco.service.cmr.publishing;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.publishing.channels.Channel;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -46,14 +43,14 @@ public interface PublishingService
* @param publishedNode The node that was published.
* @return A list of {@link PublishingEvent}s.
*/
List<PublishingEvent> getEventsForPublishedNode(NodeRef publishedNode);
List<PublishingEvent> getPublishEventsForNode(NodeRef publishedNode);
/**
* Retrieve a list of publishing events for which the specified <code>node</code> was unpublished.
* @param unpublishedNode The node that was unpublished.
* @return A list of {@link PublishingEvent}s.
*/
List<PublishingEvent> getEventsForUnpublishedNode(NodeRef unpublishedNode);
List<PublishingEvent> getUnpublishEventsForNode(NodeRef unpublishedNode);
/**
* Request that the specified publishing event be cancelled. This call will
@@ -70,20 +67,4 @@ public interface PublishingService
* @return A PublishingQueue object corresponding tho this environment's publishing queue
*/
PublishingQueue getPublishingQueue();
/**
* Discover the publishing status of each of the specified nodes
* @param channelId an identifier indicating which {@link Channel} to check the status for.
* @param nodes The nodes whose publishing status is being sought
* @return A map associating a NodePublishStatus object with each of the supplied NodeRef objects
*/
Map<NodeRef,NodePublishStatus> checkPublishStatus(String channelId, Collection<NodeRef> nodes);
/**
* Discover the publishing status of each of the specified nodes
* @param channelId an identifier indicating which {@link Channel} to check the status for.
* @param nodes The nodes whose publishing status is being sought
* @return A map associating a NodePublishStatus object with each of the supplied NodeRef objects
*/
Map<NodeRef,NodePublishStatus> checkPublishStatus(String channelId, NodeRef... nodes);
}

View File

@@ -24,8 +24,6 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.transfer.NodeFilter;
import org.alfresco.service.cmr.transfer.NodeFinder;
import org.alfresco.service.namespace.QName;
import org.springframework.core.io.Resource;
@@ -39,8 +37,7 @@ public interface ChannelType
String getId();
QName getChannelNodeType();
NodeFinder getNodeFinder();
NodeFilter getNodeFilter();
void publish(NodeRef nodeToPublish, Map<QName, Serializable> properties);
void unpublish(NodeRef nodeToUnpublish, Map<QName, Serializable> properties);
void updateStatus(Channel channel, String status, Map<QName, Serializable> properties);