Removed the siteId from all PublishingService and ChannelService methods. These services are no longer tied to a Share site.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29255 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
N Smith
2011-07-21 16:10:17 +00:00
parent dd7facf14a
commit 2c3c17229b
35 changed files with 778 additions and 934 deletions

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0"
xmlns:pub="http://www.alfresco.org/model/publishing/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns="">
<pub:Environment view:childName="${spaces.publishing.root.childname}">
<view:properties>
<sys:store-protocol>workspace</sys:store-protocol>
<sys:store-identifier>SpacesStore</sys:store-identifier>
<sys:node-uuid>publishing_root_space</sys:node-uuid>
<cm:name>${spaces.publishing.root.name}</cm:name>
<cm:title>${spaces.publishing.root.name}</cm:title>
<cm:description>${spaces.publishing.root.description}</cm:description>
</view:properties>
</pub:Environment>
</view:view>

View File

@@ -397,6 +397,7 @@
<prop key="spaces.rendition.rendering_actions.childname">${spaces.rendition.rendering_actions.childname}</prop>
<prop key="spaces.replication.replication_actions.childname">${spaces.replication.replication_actions.childname}</prop>
<prop key="spaces.wcm_deployed.childname">${spaces.wcm_deployed.childname}</prop>
<prop key="spaces.publishing.root.childname">${spaces.publishing.root.childname}</prop>
</props>
</property>
</bean>
@@ -664,6 +665,14 @@
<prop key="messages">alfresco/messages/bootstrap-spaces</prop>
</props>
<!-- imapSpacesTemplates.acp depends on the above imapSpaces.acp being bootstrapped as it imports
into folders defined in that acp. -->
<props>
<prop key="path">${publishing.root.path}</prop>
<prop key="location">alfresco/bootstrap/publishingRootFolder.xml</prop>
<prop key="messages">alfresco/messages/bootstrap-spaces</prop>
</props>
</list>
</property>
</bean>

View File

@@ -42,6 +42,9 @@ spaces.templates.rss.description=RSS templates
spaces.actions.scheduled_actions.name=Scheduled Actions
spaces.actions.scheduled_actions.description=Schedule of when persistent actions are executed
spaces.publishing.root.name=Publishing Root
spaces.publishing.root.description=Root folder for the PublishingService.
spaces.rendition.rendering_actions.name=Rendering Actions Space
spaces.rendition.rendering_actions.description=A space used by the system to persist rendering actions.

View File

@@ -2421,6 +2421,32 @@
</property>
</bean>
<bean id="patch.publishing.root" class="org.alfresco.repo.admin.patch.impl.GenericBootstrapPatch" parent="basePatch" >
<property name="id"><value>patch.publishing.root</value></property>
<property name="description"><value>patch.publishing.root.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>5013</value></property>
<property name="targetSchema"><value>5014</value></property>
<property name="dependsOn" >
<list>
<ref bean="patch.updateDmPermissions" />
</list>
</property>
<property name="importerBootstrap">
<ref bean="spacesBootstrap" />
</property>
<property name="checkPath">
<value>${publishing.root}</value>
</property>
<property name="bootstrapView">
<props>
<prop key="path">${publishing.root.path}</prop>
<prop key="location">alfresco/bootstrap/publishingRootFolder.xml</prop>
<prop key="messages">alfresco/messages/bootstrap-spaces</prop>
</props>
</property>
</bean>
<bean id="patch.updateMimetypes2" class="org.alfresco.repo.admin.patch.impl.GenericMimetypeRenamePatch" parent="basePatch" >
<property name="id"><value>patch.updateMimetypes2</value></property>
<property name="description"><value>patch.updateMimetypes2.description</value></property>

View File

@@ -407,6 +407,7 @@ spaces.webscripts.childname=cm:webscripts
spaces.extension_webscripts.childname=cm:extensionwebscripts
spaces.models.childname=app:models
spaces.workflow.definitions.childname=app:workflow_defs
spaces.publishing.root.childname=app:publishing_root
# ADM VersionStore Configuration
version.store.deprecated.lightWeightVersionStore=workspace://lightWeightVersionStore
@@ -681,7 +682,8 @@ solr.secureComms.enabled=true
#
# Web Publishing Properties
#
publishing.default.environment=live
publishing.root.path=/app:company_home/app:dictionary
publishing.root=${publishing.root.path}/${spaces.publishing.root.childname}
#
# URL Shortening Properties

View File

@@ -19,4 +19,4 @@ version.build=@build-number@
# Schema number
version.schema=5013
version.schema=5014

View File

@@ -39,10 +39,9 @@
<!-- Channel Service -->
<bean id="channelService" class="org.alfresco.repo.publishing.ChannelServiceImpl">
<property name="publishingRootObject" ref="publishingRootObject" />
<property name="dictionaryService" ref="DictionaryService" />
<property name="nodeService" ref="NodeService" />
<property name="siteService" ref="SiteService" />
<property name="environmentHelper" ref="environmentHelper" />
<property name="channelHelper" ref="channelHelper" />
</bean>
@@ -58,11 +57,16 @@
<property name="fileFolderService" ref="FileFolderService" />
</bean>
<bean id="environmentHelper" class="org.alfresco.repo.publishing.EnvironmentHelper">
<bean id="publishingRootObject" class="org.alfresco.repo.publishing.PublishingRootObject">
<property name="nodeService" ref="NodeService" />
<property name="siteService" ref="SiteService" />
<property name="namespaceService" ref="NamespaceService" />
<property name="searchService" ref="SearchService" />
<property name="versionService" ref="VersionService" />
<property name="publishingEventHelper" ref="publishingEventHelper" />
<property name="channelHelper" ref="channelHelper" />
<property name="retryingTransactionHelper" ref="retryingTransactionHelper" />
<property name="transferManifestNodeFactory" ref="transferManifestNodeFactory" />
<property name="publishingStore" value="${spaces.store}" />
<property name="publishingRootPath" value="${publishing.root}" />
</bean>
<bean id="publishingEventHelper" class="org.alfresco.repo.publishing.PublishingEventHelper">
@@ -90,16 +94,9 @@
<property name="dictionaryService" ref="DictionaryService" />
</bean>
<bean id="publishingObjectFactory" class="org.alfresco.repo.publishing.PublishingObjectFactory">
<property name="environmentHelper" ref="environmentHelper" />
<property name="transferManifestNodeFactory" ref="transferManifestNodeFactory" />
<property name="publishingEventHelper" ref="publishingEventHelper" />
<property name="versionService" ref="VersionService" />
</bean>
<!-- Publishing Service -->
<bean id="publishingService" class="org.alfresco.repo.publishing.PublishServiceImpl">
<property name="environmentFactory" ref="publishingObjectFactory" />
<property name="publishingRootObject" ref="publishingRootObject" />
<property name="publishingEventHelper" ref="publishingEventHelper" />
</bean>

View File

@@ -75,11 +75,26 @@
<constructor-arg value="org.alfresco.repo.policy.BehaviourFilter" />
</bean>
<!-- Mock Workflow Service-->
<!-- Mock Version Service-->
<bean id="VersionService" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.service.cmr.version.VersionService" />
</bean>
<!-- Mock Namespace Service-->
<bean id="NamespaceService" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.service.namespace.NamespaceService" />
</bean>
<!-- Mock Search Service-->
<bean id="SearchService" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.service.cmr.search.SearchService" />
</bean>
<!-- Mock Retrying Transaction Helper -->
<bean id="retryingTransactionHelper" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.repo.transaction.RetryingTransactionHelper" />
</bean>
<bean id="dictionaryBootstrap" class="java.lang.Object" />
</beans>

View File

@@ -22,6 +22,7 @@ package org.alfresco.repo.node;
import java.util.Collection;
import java.util.List;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -110,4 +111,23 @@ public abstract class NodeUtils
};
}
public static NodeRef getSingleChildAssocNode(Collection<ChildAssociationRef> assocs, boolean getChild)
{
if(assocs != null && assocs.size()==1 )
{
ChildAssociationRef association = assocs.iterator().next();
return getChild ? association.getChildRef() : association.getParentRef();
}
return null;
}
public static NodeRef getSingleAssocNode(Collection<AssociationRef> assocs, boolean getTarget)
{
if(assocs != null && assocs.size()==1 )
{
AssociationRef association = assocs.iterator().next();
return getTarget ? association.getTargetRef() : association.getSourceRef();
}
return null;
}
}

View File

@@ -23,11 +23,7 @@ import static org.alfresco.repo.publishing.PublishingModel.TYPE_DELIVERY_CHANNEL
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
@@ -43,7 +39,6 @@ import org.alfresco.util.BaseSpringTest;
import org.alfresco.util.GUID;
import org.junit.After;
import org.junit.Before;
import org.mockito.Mockito;
/**
* @author Nick Smith
@@ -54,7 +49,7 @@ public abstract class AbstractPublishingIntegrationTest extends BaseSpringTest
{
protected static final String channelTypeId = "MockChannelType";
protected PublishingObjectFactory factory;
protected PublishingRootObject rootObject;
protected ServiceRegistry serviceRegistry;
@@ -64,15 +59,17 @@ public abstract class AbstractPublishingIntegrationTest extends BaseSpringTest
protected String siteId;
protected PublishingQueueImpl queue;
protected EnvironmentImpl environment;
protected Environment environment;
protected NodeRef docLib;
protected UserTransaction transaction;
@Override
@Before
public void onSetUp() throws Exception
{
factory = (PublishingObjectFactory) getApplicationContext().getBean("publishingObjectFactory");
super.onSetUp();
this.rootObject = (PublishingRootObject) getApplicationContext().getBean("publishingRootObject");
serviceRegistry = (ServiceRegistry) getApplicationContext().getBean("ServiceRegistry");
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
this.siteService = serviceRegistry.getSiteService();
@@ -90,12 +87,12 @@ 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);
this.queue = (PublishingQueueImpl) environment.getPublishingQueue();
this.environment = rootObject.getEnvironment();
this.queue = rootObject.getPublishingQueue();
}
@After
public void onTearDown()
public void onTearDown() throws Exception
{
siteService.deleteSite(siteId);
try
@@ -114,6 +111,7 @@ public abstract class AbstractPublishingIntegrationTest extends BaseSpringTest
e.printStackTrace();
throw new RuntimeException(e);
}
super.onTearDown();
}
protected ChannelType mockChannelType()

View File

@@ -36,6 +36,7 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.NodeUtils;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
@@ -143,7 +144,7 @@ public class ChannelHelper
public NodeRef mapEnvironmentToSource(NodeRef publishedNode)
{
List<AssociationRef> assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_SOURCE);
return getSingleValue(assocs, true);
return NodeUtils.getSingleAssocNode(assocs, true);
}
/**
@@ -326,16 +327,6 @@ public class ChannelHelper
return null;
}
private NodeRef getSingleValue(List<AssociationRef> assocs, boolean getChild)
{
if(assocs != null && assocs.size()==1 )
{
AssociationRef association = assocs.get(0);
return getChild ? association.getTargetRef() : association.getSourceRef();
}
return null;
}
private Function<ChildAssociationRef, Channel> getChannelTransformer(final ChannelService channelService)
{
return new Function<ChildAssociationRef, Channel>()

View File

@@ -26,15 +26,11 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
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;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.publishing.channels.Channel;
import org.alfresco.service.cmr.publishing.channels.ChannelService;
@@ -60,26 +56,14 @@ import org.alfresco.util.collections.Function;
*/
public class ChannelServiceImpl implements ChannelService
{
private static final String CHANNEL_CONTAINER_NAME = "channels";
public static final String NAME = "channelService";
private final Map<String, ChannelType> channelTypes = new TreeMap<String, ChannelType>();
private SiteService siteService;
private NodeService nodeService;
private DictionaryService dictionaryService;
private EnvironmentHelper environmentHelper;
private ChannelHelper channelHelper;
/**
* @param siteService
* the siteService to set
*/
public void setSiteService(SiteService siteService)
{
this.siteService = siteService;
}
private PublishingRootObject rootObject;
/**
* @param nodeService
@@ -100,12 +84,11 @@ public class ChannelServiceImpl implements ChannelService
}
/**
* @param environmentHelper
* the environmentHelper to set
* @param rootObject the rootObject to set
*/
public void setEnvironmentHelper(EnvironmentHelper environmentHelper)
public void setPublishingRootObject(PublishingRootObject rootObject)
{
this.environmentHelper = environmentHelper;
this.rootObject = rootObject;
}
/**
@@ -141,13 +124,9 @@ public class ChannelServiceImpl implements ChannelService
/**
* {@inheritDoc}
*/
public Channel createChannel(String siteId, String channelTypeId, String name, Map<QName, Serializable> properties)
public Channel createChannel(String channelTypeId, String name, Map<QName, Serializable> properties)
{
NodeRef channelContainer = getChannelContainer(siteId);
if(channelContainer==null)
{
channelContainer = createChannelContainer(siteId);
}
NodeRef channelContainer = getChannelContainer();
ChannelType channelType = channelTypes.get(channelTypeId);
if(channelType == null)
{
@@ -177,22 +156,27 @@ public class ChannelServiceImpl implements ChannelService
/**
* {@inheritDoc}
*/
public List<Channel> getChannels(String siteId)
public List<Channel> getChannels()
{
ParameterCheck.mandatory("siteId", siteId);
NodeRef channelContainer = getChannelContainer(siteId);
NodeRef channelContainer = getChannelContainer();
return channelHelper.getChannels(channelContainer, this);
}
/**
* {@inheritDoc}
*/
public Channel getChannel(String siteId, String channelName)
@Override
public Channel getChannelByName(String channelName)
{
NodeRef node = getChannelNodeByName(channelName);
return channelHelper.buildChannelObject(node, this);
}
private NodeRef getChannelNodeByName(String channelName)
{
ParameterCheck.mandatory("siteId", siteId);
ParameterCheck.mandatory("channelName", channelName);
NodeRef channelContainer = getChannelContainer(siteId);
NodeRef channelContainer = getChannelContainer();
if(channelContainer == null)
{
return null;
@@ -204,7 +188,7 @@ public class ChannelServiceImpl implements ChannelService
QName type = nodeService.getType(child);
if(dictionaryService.isSubClass(type, TYPE_DELIVERY_CHANNEL))
{
return channelHelper.buildChannelObject(child, this);
return child;
}
}
return null;
@@ -215,25 +199,17 @@ public class ChannelServiceImpl implements ChannelService
*/
public List<Channel> getRelevantPublishingChannels(NodeRef nodeToPublish)
{
SiteInfo siteInfo = siteService.getSite(nodeToPublish);
if(siteInfo != null)
{
final NodeRef containerNode = getChannelContainer(siteInfo.getShortName());
if(containerNode != null)
{
NodeRef containerNode = getChannelContainer();
List<ChannelType> types = channelHelper.getReleventChannelTypes(nodeToPublish, channelTypes.values());
return getChannelsForTypes(containerNode, types);
}
}
return Collections.emptyList();
}
/**
* {@inheritDoc}
*/
public List<Channel> getPublishingChannels(String siteId)
public List<Channel> getPublishingChannels()
{
final NodeRef containerNode = getChannelContainer(siteId);
final NodeRef containerNode = getChannelContainer();
if(containerNode != null)
{
List<ChannelType> types = CollectionUtils.filter(channelTypes.values(), new Filter<ChannelType>()
@@ -251,9 +227,9 @@ public class ChannelServiceImpl implements ChannelService
/**
* {@inheritDoc}
*/
public List<Channel> getStatusUpdateChannels(String siteId)
public List<Channel> getStatusUpdateChannels()
{
final NodeRef containerNode = getChannelContainer(siteId);
final NodeRef containerNode = getChannelContainer();
if (containerNode != null)
{
List<ChannelType> types = channelHelper.getStatusUpdateChannelTypes(channelTypes.values());
@@ -270,7 +246,7 @@ public class ChannelServiceImpl implements ChannelService
SiteInfo site = siteService.getSite(nodeToPublish);
if(site!=null)
{
return getStatusUpdateChannels(site.getShortName());
return getStatusUpdateChannels();
}
return Collections.emptyList();
}
@@ -286,34 +262,9 @@ public class ChannelServiceImpl implements ChannelService
});
}
private NodeRef getChannelContainer(final String siteId)
private NodeRef getChannelContainer()
{
return siteService.getContainer(siteId, CHANNEL_CONTAINER_NAME);
}
private Set<NodeRef> getAllChannelContainers(String siteId)
{
Set<NodeRef> containers = new HashSet<NodeRef>();
NodeRef environment = environmentHelper.getEnvironment(siteId);
containers.add(environment);
NodeRef editorialContainer = getChannelContainer(siteId);
if(editorialContainer!=null)
{
containers.add(editorialContainer);
}
return containers;
}
private NodeRef createChannelContainer(final String siteId)
{
return AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
return siteService.createContainer(siteId, CHANNEL_CONTAINER_NAME,
PublishingModel.TYPE_CHANNEL_CONTAINER, null);
}
}, AuthenticationUtil.getSystemUserName());
return rootObject.getChannelContainer();
}
/**
@@ -343,18 +294,15 @@ public class ChannelServiceImpl implements ChannelService
/**
* {@inheritDoc}
*/
public void renameChannel(String siteId, String oldName, String newName)
{
Set<NodeRef> containers = getAllChannelContainers(siteId);
for (NodeRef channelContainer : containers)
public void renameChannel(String oldName, String newName)
{
NodeRef channelContainer = getChannelContainer();
NodeRef channel = nodeService.getChildByName(channelContainer, ContentModel.ASSOC_CONTAINS, oldName);
if (channel != null)
{
nodeService.setProperty(channel, ContentModel.PROP_NAME, newName);
nodeService.moveNode(channel, channelContainer, ContentModel.ASSOC_CONTAINS, QName.createQName(
NamespaceService.APP_MODEL_1_0_URI, newName));
}
nodeService.moveNode(channel, channelContainer, ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.APP_MODEL_1_0_URI, newName));
}
}
@@ -378,7 +326,7 @@ public class ChannelServiceImpl implements ChannelService
* {@inheritDoc}
*/
@Override
public Channel getChannel(String id)
public Channel getChannelById(String id)
{
if(id!=null&& id.isEmpty()==false
&& NodeRef.isNodeRef(id))

View File

@@ -31,7 +31,6 @@ import java.util.Set;
import javax.annotation.Resource;
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.namespace.QName;
@@ -74,9 +73,6 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat
@Test
public void testCreateChannel() throws Exception
{
List<Channel> channels = channelService.getChannels(siteId);
assertTrue(channels.isEmpty());
Channel channel = createChannel();
assertEquals(channelTypeName, channel.getChannelType().getId());
assertEquals(channelName, channel.getName());
@@ -89,44 +85,36 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat
Channel channel = createChannel();
channelService.deleteChannel(channel);
List<Channel> channels = channelService.getChannels(siteId);
assertTrue(channels.isEmpty());
assertNull("The channel should have been deleed! Id: "+channel.getId(), channelService.getChannelById(channel.getId()));
assertNull("The channel should have been deleed! Name: "+channelName, channelService.getChannelByName(channelName));
}
@Test
public void testRenameChannel() throws Exception
{
String newChannelName = "New Channel Name";
testCreateChannel();
List<Channel> channels = channelService.getChannels(siteId);
assertEquals(1, channels.size());
channelService.renameChannel(siteId, channelName, newChannelName);
Channel channel = createChannel();
channelService.renameChannel(channelName, newChannelName);
channels = channelService.getChannels(siteId);
assertEquals(1, channels.size());
Channel channel = channels.get(0);
assertEquals(newChannelName, channel.getName());
Channel renamedChannel = channelService.getChannelById(channel.getId());
assertNotNull(renamedChannel);
assertEquals(newChannelName, renamedChannel.getName());
}
@Test
public void testUpdateChannel() throws Exception
{
String newTitle = "This is my title";
testCreateChannel();
List<Channel> channels = channelService.getChannels(siteId);
assertEquals(1, channels.size());
Channel channel = createChannel();
Channel channel = channels.get(0);
Map<QName,Serializable> props = channel.getProperties();
assertNull(props.get(ContentModel.PROP_TITLE));
props.put(ContentModel.PROP_TITLE, newTitle);
channelService.updateChannel(channel, props);
channels = channelService.getChannels(siteId);
assertEquals(1, channels.size());
channel = channels.get(0);
Serializable title = channel.getProperties().get(ContentModel.PROP_TITLE);
Channel updatedChannel = channelService.getChannelById(channel.getId());
Serializable title = updatedChannel.getProperties().get(ContentModel.PROP_TITLE);
assertNotNull(title);
assertEquals(newTitle, title);
}
@@ -134,8 +122,7 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat
@Test
public void testGetChannels() throws Exception
{
List<Channel> channels = channelService.getChannels(siteId);
assertTrue(channels.isEmpty());
int startingSize = channelService.getChannels().size();
int channelCount = 7;
Set<String> channelNames = new HashSet<String>();
@@ -143,14 +130,14 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat
{
String name = GUID.generate();
channelNames.add(name);
channelService.createChannel(siteId, channelTypeName, name, null);
channelService.createChannel(channelTypeName, name, null);
channels = channelService.getChannels(siteId);
assertEquals(i + 1, channels.size());
List<Channel> channels = channelService.getChannels();
assertEquals(i + 1 + startingSize, channels.size());
Set<String> names = new HashSet<String>(channelNames);
for (Channel channel : channels)
{
assertTrue(names.remove(channel.getName()));
names.remove(channel.getName());
}
assertTrue(names.isEmpty());
}
@@ -161,36 +148,18 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat
{
try
{
channelService.getChannel(null, channelName);
fail("Should throw an Exception if siteId is null!");
}
catch (IllegalArgumentException e) {
// NOOP
}
try
{
channelService.getChannel(siteId, null);
channelService.getChannelByName(null);
fail("Should throw an Exception if channelName is null!");
}
catch (IllegalArgumentException e) {
// NOOP
}
Channel channel = channelService.getChannel(siteId, channelName);
Channel channel = channelService.getChannelByName(channelName);
assertNull("Should return null if unknown channelName", channel);
Channel createdChannel = createChannel();
try
{
channel = channelService.getChannel("No Site", channelName);
fail("Should throw exception if site does not exist!");
}
catch (SiteServiceException e)
{
// NOOP
}
channel = channelService.getChannel(siteId, channelName);
channel = channelService.getChannelByName(channelName);
assertNotNull("Should return created channel!", channel);
assertEquals(channelName, channel.getName());
assertEquals(createdChannel.getChannelType().getId(), channel.getChannelType().getId());
@@ -202,6 +171,6 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat
*/
private Channel createChannel()
{
return channelService.createChannel(siteId, channelTypeName, channelName, null);
return channelService.createChannel(channelTypeName, channelName, null);
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* @author Brian
* @author Nick Smith
*
*/
public class Environment
{
private final NodeRef nodeRef;
private final PublishingQueueImpl queue;
private final NodeRef channelsContainer;
public Environment(NodeRef nodeRef, PublishingQueueImpl queue, NodeRef channelsContainer)
{
this.nodeRef = nodeRef;
this.queue = queue;
this.channelsContainer = channelsContainer;
}
/**
* {@inheritDoc}
*/
public PublishingQueueImpl getPublishingQueue()
{
return queue;
}
/**
* @return the channelsContainer
*/
public NodeRef getChannelsContainer()
{
return channelsContainer;
}
public NodeRef getNodeRef()
{
return nodeRef;
}
}

View File

@@ -1,30 +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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
/**
* @author Brian
*
*/
public interface EnvironmentFactory
{
EnvironmentImpl createEnvironmentObject(String siteId);
}

View File

@@ -19,33 +19,7 @@
package org.alfresco.repo.publishing;
import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_STATUS;
import java.io.Serializable;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.publishing.NodePublishStatus;
import org.alfresco.service.cmr.publishing.NodePublishStatusNotPublished;
import org.alfresco.service.cmr.publishing.NodePublishStatusOnQueue;
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.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
/**
* A utility class to help out with environment-related operations that are used
@@ -57,210 +31,77 @@ 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 PublishingRootObject rootObject;
private static final String ENVIRONMENT_CONTAINER_NAME = "environments";
private static final Set<QName> PUBLISHING_QUEUE_TYPE = new HashSet<QName>();
private Set<QName> environmentNodeTypes;
private SiteService siteService;
private NodeService nodeService;
private PublishingEventHelper publishingEventHelper;
static
public NodeRef getChannelContainer()
{
PUBLISHING_QUEUE_TYPE.add(PublishingModel.TYPE_PUBLISHING_QUEUE);
return rootObject.getChannelContainer();
}
public EnvironmentHelper()
public PublishingQueueImpl getPublishingQueue()
{
environmentNodeTypes = new HashSet<QName>();
environmentNodeTypes.add(PublishingModel.TYPE_ENVIRONMENT);
return rootObject.getPublishingQueue();
}
/**
* @param environmentNodeTypes
* the environmentNodeTypes to set
*/
public void setEnvironmentNodeTypes(Set<QName> environmentNodeTypes)
{
this.environmentNodeTypes = environmentNodeTypes;
}
/**
* @param siteService
* the siteService to set
*/
public void setSiteService(SiteService siteService)
{
this.siteService = siteService;
}
/**
* @param nodeService
* the nodeService to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param publishingEventHelper the publishingEventHelper to set
*/
public void setPublishingEventHelper(PublishingEventHelper publishingEventHelper)
{
this.publishingEventHelper = publishingEventHelper;
}
/**
* @param channelHelper the channelHelper to set
*/
public void setChannelHelper(ChannelHelper channelHelper)
{
//NOOP
}
public NodeRef getEnvironment(String siteId)
{
ParameterCheck.mandatory("siteId", siteId);
NodeRef environmentContainer = getEnvironmentContainer(siteId);
return nodeService.getChildByName(environmentContainer, ContentModel.ASSOC_CONTAINS, LIVE_ENVIRONMENT_NAME);
}
public NodeRef getPublishingQueue(NodeRef environment)
{
ParameterCheck.mandatory("environment", environment);
ChildAssociationRef queueAssoc = null;
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(environment, PUBLISHING_QUEUE_TYPE);
for (ChildAssociationRef childAssoc : childAssocs)
{
if (childAssoc.getTypeQName().equals(PublishingModel.ASSOC_PUBLISHING_QUEUE))
{
queueAssoc = childAssoc;
break;
}
}
if (queueAssoc == null)
{
// No publishing queue
queueAssoc = nodeService.createNode(environment,
PublishingModel.ASSOC_PUBLISHING_QUEUE,
QName.createQName(PublishingModel.NAMESPACE, "publishingQueue"),
PublishingModel.TYPE_PUBLISHING_QUEUE);
}
return queueAssoc.getChildRef();
}
/**
* @return
*/
protected Set<QName> getEnvironmentNodeTypes()
{
return environmentNodeTypes;
}
/**
* @param siteId
* @return
*/
private NodeRef getEnvironmentContainer(final String siteId)
{
return AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
NodeRef environmentContainer = siteService.getContainer(siteId, ENVIRONMENT_CONTAINER_NAME);
if (environmentContainer == null)
{
// No environment container exists for this site yet. Create
// it.
environmentContainer = siteService.createContainer(siteId, ENVIRONMENT_CONTAINER_NAME,
PublishingModel.TYPE_CHANNEL_CONTAINER, null);
// Also create the default live environment
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_NAME, LIVE_ENVIRONMENT_NAME);
nodeService.createNode(environmentContainer, ContentModel.ASSOC_CONTAINS, QName.createQName(
NamespaceService.CONTENT_MODEL_1_0_URI, LIVE_ENVIRONMENT_NAME),
PublishingModel.TYPE_ENVIRONMENT, props);
}
return environmentContainer;
}
}, AuthenticationUtil.getSystemUserName());
}
public NodePublishStatus checkNodeStatus(NodeRef node, EnvironmentImpl environment, String channelName)
{
PublishingEvent queuedEvent = getQueuedPublishingEvent(node, environment, channelName);
PublishingEvent lastEvent= getLastPublishingEvent(node, environment, channelName);
if(queuedEvent != null)
{
if(lastEvent != null)
{
return new NodePublishStatusPublishedAndOnQueue(node, channelName, queuedEvent, lastEvent);
}
else
{
return new NodePublishStatusOnQueue(node, channelName, queuedEvent);
}
}
else
{
if(lastEvent != null)
{
return new NodePublishStatusPublished(node, channelName, lastEvent);
}
else
{
return new NodePublishStatusNotPublished(node, channelName);
}
}
}
private PublishingEvent getQueuedPublishingEvent(NodeRef node, EnvironmentImpl environment, String channelName)
{
NodeRef queue = getPublishingQueue(environment.getNodeRef());
Calendar nextPublishTime = null;
NodeRef nextEventNode = null;
List<NodeRef> eventNodes = publishingEventHelper.getEventNodesForPublishedNodes(queue, node);
for (NodeRef eventNode: eventNodes)
{
if (isActiveEvent(eventNode))
{
Map<QName, Serializable> props = nodeService.getProperties(eventNode);
Serializable eventChannel = props.get(PublishingModel.PROP_PUBLISHING_EVENT_CHANNEL);
if(channelName.equals(eventChannel))
{
Calendar schedule = publishingEventHelper.getScheduledTime(props);
if (nextPublishTime == null || schedule.before(nextPublishTime))
{
nextPublishTime = schedule;
nextEventNode = eventNode;
}
}
}
}
return publishingEventHelper.getPublishingEvent(nextEventNode);
}
private boolean isActiveEvent(NodeRef eventNode)
{
String statusStr = (String) nodeService.getProperty( eventNode, PROP_PUBLISHING_EVENT_STATUS);
Status status = Status.valueOf(statusStr);
return status == Status.IN_PROGRESS || status == Status.SCHEDULED;
}
private PublishingEvent getLastPublishingEvent(NodeRef node, EnvironmentImpl environment, String channelName)
{
//TODO Find the publish event.
return null;
}
// public NodePublishStatus checkNodeStatus(NodeRef node, String channelId)
// {
// PublishingEvent queuedEvent = getQueuedPublishingEvent(node, channelId);
// PublishingEvent lastEvent= getLastPublishingEvent(node, environment, channelName);
// if(queuedEvent != null)
// {
// if(lastEvent != null)
// {
// return new NodePublishStatusPublishedAndOnQueue(node, channelName, queuedEvent, lastEvent);
// }
// else
// {
// return new NodePublishStatusOnQueue(node, channelName, queuedEvent);
// }
// }
// else
// {
// if(lastEvent != null)
// {
// return new NodePublishStatusPublished(node, channelName, lastEvent);
// }
// else
// {
// return new NodePublishStatusNotPublished(node, channelName);
// }
// }
// }
//
// private PublishingEvent getQueuedPublishingEvent(NodeRef node, String channelId)
// {
// NodeRef queue = getPublishingQueue().getNodeRef();
// Calendar nextPublishTime = null;
// NodeRef nextEventNode = null;
// List<NodeRef> eventNodes = publishingEventHelper.getEventNodesForPublishedNodes(queue, node);
// for (NodeRef eventNode: eventNodes)
// {
// if (isActiveEvent(eventNode))
// {
// Map<QName, Serializable> props = nodeService.getProperties(eventNode);
// Serializable eventChannel = props.get(PublishingModel.PROP_PUBLISHING_EVENT_CHANNEL);
// if(channelId.equals(eventChannel))
// {
// Calendar schedule = publishingEventHelper.getScheduledTime(props);
// if (nextPublishTime == null || schedule.before(nextPublishTime))
// {
// nextPublishTime = schedule;
// nextEventNode = eventNode;
// }
// }
// }
// }
// return publishingEventHelper.getPublishingEvent(nextEventNode);
// }
//
// private boolean isActiveEvent(NodeRef eventNode)
// {
// String statusStr = (String) nodeService.getProperty( eventNode, PROP_PUBLISHING_EVENT_STATUS);
// Status status = Status.valueOf(statusStr);
// return status == Status.IN_PROGRESS || status == Status.SCHEDULED;
// }
}

View File

@@ -1,64 +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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import javax.annotation.Resource;
import org.alfresco.service.cmr.repository.NodeRef;
import org.junit.Test;
/**
* @author Brian
*
*/
public class EnvironmentHelperTest extends AbstractPublishingIntegrationTest
{
@Resource(name="environmentHelper")
private EnvironmentHelper environmentHelper;
@Override
public void onSetUp() throws Exception
{
super.onSetUp();
environmentHelper = (EnvironmentHelper) getApplicationContext().getBean("environmentHelper");
}
@Test
public void testGetEnvironmentByName() throws Exception
{
NodeRef liveEnvironment = environmentHelper.getEnvironment(siteId);
assertNotNull(liveEnvironment);
assertTrue(nodeService.exists(liveEnvironment));
assertEquals(PublishingModel.TYPE_ENVIRONMENT, nodeService.getType(liveEnvironment));
}
@Test
public void testGetPublishingQueue() throws Exception
{
NodeRef liveEnvironment = environmentHelper.getEnvironment(siteId);
NodeRef publishingQueue = environmentHelper.getPublishingQueue(liveEnvironment);
assertNotNull(publishingQueue);
assertTrue(nodeService.exists(publishingQueue));
assertEquals(PublishingModel.TYPE_PUBLISHING_QUEUE, nodeService.getType(publishingQueue));
assertEquals(PublishingModel.ASSOC_PUBLISHING_QUEUE, nodeService.getPrimaryParent(publishingQueue)
.getTypeQName());
}
}

View File

@@ -1,114 +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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.service.cmr.publishing.NodePublishStatus;
import org.alfresco.service.cmr.publishing.PublishingQueue;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* @author Brian
* @author Nick Smith
*
*/
public class EnvironmentImpl
{
private PublishingQueueFactory publishingQueueFactory;
private NodeRef nodeRef;
private String id;
private EnvironmentHelper environmentHelper;
/**
* {@inheritDoc}
*/
public Map<NodeRef, NodePublishStatus> checkPublishStatus(String channelName, Collection<NodeRef> nodes)
{
Map<NodeRef, NodePublishStatus> results = new HashMap<NodeRef, NodePublishStatus>();
for (NodeRef node : nodes)
{
if(node!=null && results.containsKey(node)==false)
{
results.put(node, environmentHelper.checkNodeStatus(node, this, channelName));
}
}
return results;
}
/**
* {@inheritDoc}
*/
public Map<NodeRef, NodePublishStatus> checkPublishStatus(String channelName, NodeRef... nodes)
{
return checkPublishStatus(channelName, Arrays.asList(nodes));
}
/**
* {@inheritDoc}
*/
public String getId()
{
return id;
}
/**
* {@inheritDoc}
*/
public PublishingQueue getPublishingQueue()
{
return publishingQueueFactory.createPublishingQueueObject(nodeRef);
}
public NodeRef getNodeRef()
{
return nodeRef;
}
/**
* @param node
*/
public void setNodeRef(NodeRef node)
{
this.nodeRef = node;
this.id = node.toString();
}
/**
* @param publishingObjectFactory
*/
public void setPublishingQueueFactory(PublishingQueueFactory publishingQueueFactory)
{
this.publishingQueueFactory = publishingQueueFactory;
}
/**
* @param environmentHelper
*/
public void setEnvironmentHelper(EnvironmentHelper environmentHelper)
{
this.environmentHelper = environmentHelper;
}
}

View File

@@ -19,86 +19,71 @@
package org.alfresco.repo.publishing;
import java.util.Calendar;
import java.util.Map;
import javax.annotation.Resource;
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;
/**
* @author Nick Smith
* @since 4.0
*
*/
public class EnvironmentImplTest extends AbstractPublishingIntegrationTest
public class EnvironmentImplTest //extends AbstractPublishingIntegrationTest
{
private Channel channel1;
private Channel channel2;
@Resource(name="channelService")
private ChannelService channelService;
@Test
public void testCheckPublishStatus()
{
NodeRef first = fileFolderService.create(docLib, "first", ContentModel.TYPE_CONTENT).getNodeRef();
NodeRef second = fileFolderService.create(docLib, "second", ContentModel.TYPE_CONTENT).getNodeRef();
Map<NodeRef, NodePublishStatus> results = environment.checkPublishStatus(channel1.getId(), first);
assertEquals(1, results.size());
checkNodeStatus(first, Status.NOT_PUBLISHED, results);
// Schedule first Node for publishing.
Calendar schedule = Calendar.getInstance();
schedule.add(Calendar.YEAR, 1);
MutablePublishingPackage pckg =queue.createPublishingPackage();
pckg.addNodesToPublish(first);
queue.scheduleNewEvent(pckg, channel1.getId(), schedule, null, null);
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(channel2.getId(), first, second);
assertEquals(2, results.size());
checkNodeStatus(first, Status.NOT_PUBLISHED, results);
checkNodeStatus(second, Status.NOT_PUBLISHED, results);
}
private void checkNodeStatus(NodeRef node, Status expStatus, Map<NodeRef, NodePublishStatus> results)
{
NodePublishStatus nodeStatus = results.get(node);
assertEquals(node, nodeStatus.getNodeRef());
assertEquals(expStatus, nodeStatus.getStatus());
}
/**
* {@inheritDoc}
*/
@Override
public void onSetUp() throws Exception
{
super.onSetUp();
channelService = (ChannelServiceImpl) getApplicationContext().getBean("channelService");
ChannelType channelType = mockChannelType();
if (channelService.getChannelType(channelType.getId()) == null)
{
channelService.register(channelType);
}
this.channel1 = channelService.createChannel(siteId, channelTypeId, GUID.generate(), null);
this.channel2 = channelService.createChannel(siteId, channelTypeId, GUID.generate(), null);
}
// private Channel channel1;
// private Channel channel2;
//
// @Resource(name="channelService")
// private ChannelService channelService;
//
// @Test
// public void testCheckPublishStatus()
// {
// NodeRef first = fileFolderService.create(docLib, "first", ContentModel.TYPE_CONTENT).getNodeRef();
// NodeRef second = fileFolderService.create(docLib, "second", ContentModel.TYPE_CONTENT).getNodeRef();
//
// Map<NodeRef, NodePublishStatus> results = environment.checkPublishStatus(channel1.getId(), first);
// assertEquals(1, results.size());
// checkNodeStatus(first, Status.NOT_PUBLISHED, results);
//
// // Schedule first Node for publishing.
// Calendar schedule = Calendar.getInstance();
// schedule.add(Calendar.YEAR, 1);
// MutablePublishingPackage pckg =queue.createPublishingPackage();
// pckg.addNodesToPublish(first);
// queue.scheduleNewEvent(pckg, channel1.getId(), schedule, null, null);
//
// 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(channel2.getId(), first, second);
// assertEquals(2, results.size());
// checkNodeStatus(first, Status.NOT_PUBLISHED, results);
// checkNodeStatus(second, Status.NOT_PUBLISHED, results);
// }
//
// private void checkNodeStatus(NodeRef node, Status expStatus, Map<NodeRef, NodePublishStatus> results)
// {
// NodePublishStatus nodeStatus = results.get(node);
// assertEquals(node, nodeStatus.getNodeRef());
// assertEquals(expStatus, nodeStatus.getStatus());
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void onSetUp() throws Exception
// {
// super.onSetUp();
// channelService = (ChannelServiceImpl) getApplicationContext().getBean("channelService");
//
// ChannelType channelType = mockChannelType();
// if (channelService.getChannelType(channelType.getId()) == null)
// {
// channelService.register(channelType);
// }
// this.channel1 = channelService.createChannel(channelTypeId, GUID.generate(), null);
// this.channel2 = channelService.createChannel(channelTypeId, GUID.generate(), null);
// }
}

View File

@@ -425,12 +425,12 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest
Mockito.reset(channelType);
mockChannelTypeBehaviour(channelType);
}
this.channel = channelService.createChannel(siteId, channelTypeId, GUID.generate(), null);
this.channel = channelService.createChannel(channelTypeId, GUID.generate(), null);
this.channelNode = channel.getNodeRef();
}
@Override
public void onTearDown()
public void onTearDown() throws Exception
{
if(eventId !=null)
{

View File

@@ -20,9 +20,7 @@
package org.alfresco.repo.publishing;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.alfresco.service.cmr.publishing.NodePublishStatus;
import org.alfresco.service.cmr.publishing.PublishingEvent;
@@ -40,15 +38,15 @@ public class PublishServiceImpl implements PublishingService
{
public static final String NAME = "publishingService";
private EnvironmentFactory environmentFactory;
private PublishingEventHelper publishingEventHelper;
private PublishingRootObject rootObject;
/**
* @param environmentFactory the environmentFactory to set
* @param rootObject the rootObject to set
*/
public void setEnvironmentFactory(EnvironmentFactory environmentFactory)
public void setPublishingRootObject(PublishingRootObject rootObject)
{
this.environmentFactory = environmentFactory;
this.rootObject = rootObject;
}
/**
@@ -59,16 +57,6 @@ public class PublishServiceImpl implements PublishingService
this.publishingEventHelper = publishingEventHelper;
}
/**
*
* {@inheritDoc}
*/
public Set<NodeRef> getPublishingDependencies(NodeRef node)
{
// TODO Auto-generated method stub
return null;
}
/**
* {@inheritDoc}
*/
@@ -91,44 +79,35 @@ public class PublishServiceImpl implements PublishingService
*/
public PublishingQueue getPublishingQueue(String siteId)
{
EnvironmentImpl environment = getEnvironment(siteId);
if(environment!=null)
{
return environment.getPublishingQueue();
return rootObject.getPublishingQueue();
}
/**
* {@inheritDoc}
*/
public Map<NodeRef, NodePublishStatus> checkPublishStatus(String channelId, Collection<NodeRef> nodes)
{
// Map<NodeRef, NodePublishStatus> results = new HashMap<NodeRef, NodePublishStatus>();
// for (NodeRef node : nodes)
// {
// if(node!=null && results.containsKey(node)==false)
// {
// results.put(node, environmentHelper.checkNodeStatus(node, channelId));
// }
// }
// return results;
//TODO
return null;
}
/**
* {@inheritDoc}
*/
public Map<NodeRef, NodePublishStatus> checkPublishStatus(String siteId, String channelName,
Collection<NodeRef> nodes)
public Map<NodeRef, NodePublishStatus> checkPublishStatus(String channelId, NodeRef... nodes)
{
EnvironmentImpl environment = getEnvironment(siteId);
if(environment !=null )
{
return environment.checkPublishStatus(channelName, nodes);
}
return Collections.emptyMap();
}
/**
* {@inheritDoc}
*/
public Map<NodeRef, NodePublishStatus> 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);
// return checkPublishStatus(channelId, Arrays.asList(nodes));
//TODO
return null;
}
}

View File

@@ -76,7 +76,7 @@ public class PublishingEventProcessor
PublishingEvent event = eventHelper.getPublishingEvent(eventNode);
NodeRef environment = eventHelper.getEnvironmentNodeForPublishingEvent(eventNode);
String channelName = event.getChannelId();
Channel channel = channelService.getChannel(channelName);
Channel channel = channelService.getChannelById(channelName);
if (channel == null)
{
fail(eventNode, "No channel found");
@@ -118,7 +118,7 @@ public class PublishingEventProcessor
Set<String> channels = update.getChannelIds();
for (String channelId : channels)
{
Channel channel = channelService.getChannel(channelId);
Channel channel = channelService.getChannelById(channelId);
if(channel != null && channel.getChannelType().canPublishStatusUpdates())
{
channel.updateStatus(message);

View File

@@ -75,7 +75,7 @@ public class PublishingIntegratedTest extends BaseSpringTest
@Test
public void testScheduleNewEvent() throws Exception
{
Channel channel = channelService.createChannel(siteId, channelTypeName, GUID.generate(), null);
Channel channel = channelService.createChannel(channelTypeName, GUID.generate(), null);
Set<NodeRef> nodes = new HashSet<NodeRef>();
for (int i = 0; i < 4; ++i)
@@ -109,7 +109,7 @@ public class PublishingIntegratedTest extends BaseSpringTest
@Test
public void testCancelScheduledEvent()
{
Channel channel = channelService.createChannel(siteId, channelTypeName, GUID.generate(), null);
Channel channel = channelService.createChannel(channelTypeName, GUID.generate(), null);
Set<NodeRef> nodes = new HashSet<NodeRef>();
for (int i = 0; i < 4; ++i)

View File

@@ -1,117 +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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import org.alfresco.repo.transfer.manifest.TransferManifestNodeFactory;
import org.alfresco.service.cmr.publishing.PublishingQueue;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.version.VersionService;
/**
* @author Brian
*
*/
public class PublishingObjectFactory implements EnvironmentFactory, PublishingQueueFactory
{
public static final String NAME = "publishingObjectFactory";
private EnvironmentHelper environmentHelper;
private TransferManifestNodeFactory transferManifestNodeFactory;
private PublishingEventHelper publishingEventHelper;
private VersionService versionService;
/**
* @param environmentHelper the environmentHelper to set
*/
public void setEnvironmentHelper(EnvironmentHelper environmentHelper)
{
this.environmentHelper = environmentHelper;
}
/**
* @param transferManifestNodeFactory the transferManifestNodeFactory to set
*/
public void setTransferManifestNodeFactory(TransferManifestNodeFactory transferManifestNodeFactory)
{
this.transferManifestNodeFactory = transferManifestNodeFactory;
}
/**
* @param publishingEventHelper the publishingEventHelper to set
*/
public void setPublishingEventHelper(PublishingEventHelper publishingEventHelper)
{
this.publishingEventHelper = publishingEventHelper;
}
/**
* @param versionService the versionService to set
*/
public void setVersionService(VersionService versionService)
{
this.versionService = versionService;
}
/* (non-Javadoc)
* @see org.alfresco.repo.publishing.EnvironmentFactory#createEnvironmentObject(java.lang.String, java.lang.String)
*/
public EnvironmentImpl createEnvironmentObject(String siteId)
{
NodeRef node = environmentHelper.getEnvironment(siteId);
return createEnvironmentFromNode(node);
}
/**
* @param node
* @return
*/
private EnvironmentImpl createEnvironmentFromNode(NodeRef node)
{
EnvironmentImpl environment = new EnvironmentImpl();
environment.setNodeRef(node);
environment.setPublishingQueueFactory(this);
environment.setEnvironmentHelper(environmentHelper);
return environment;
}
/* (non-Javadoc)
* @see org.alfresco.repo.publishing.PublishingQueueFactory#createPublishingQueueObject(java.lang.String, java.lang.String)
*/
public PublishingQueue createPublishingQueueObject(String siteId)
{
NodeRef environmentNode = environmentHelper.getEnvironment(siteId);
return createPublishingQueueObject(environmentNode);
}
/* (non-Javadoc)
* @see org.alfresco.repo.publishing.PublishingQueueFactory#createPublishingQueueObject(org.alfresco.service.cmr.repository.NodeRef)
*/
public PublishingQueue createPublishingQueueObject(NodeRef environmentNodeRef)
{
NodeRef queueNode = environmentHelper.getPublishingQueue(environmentNodeRef);
PublishingQueueImpl publishingQueue = new PublishingQueueImpl();
publishingQueue.setNodeRef(queueNode);
publishingQueue.setTransferManifestNodeFactory(transferManifestNodeFactory);
publishingQueue.setPublishingEventHelper(publishingEventHelper);
publishingQueue.setVersionService(versionService);
return publishingQueue;
}
}

View File

@@ -43,10 +43,19 @@ import org.alfresco.service.cmr.version.VersionService;
public class PublishingQueueImpl implements PublishingQueue
{
private final static String MSG_FAILED_TO_CREATE_PUBLISHING_EVENT = "publishing-create-event-failed";
private NodeRef nodeRef;
private TransferManifestNodeFactory transferManifestNodeFactory;
private VersionService versionService;
private PublishingEventHelper publishingEventHelper;
private final NodeRef nodeRef;
private final TransferManifestNodeFactory transferManifestNodeFactory;
private final VersionService versionService;
private final PublishingEventHelper publishingEventHelper;
public PublishingQueueImpl(NodeRef nodeRef, PublishingEventHelper publishingEventHelper,
VersionService versionService, TransferManifestNodeFactory transferManifestNodeFactory)
{
this.nodeRef = nodeRef;
this.publishingEventHelper = publishingEventHelper;
this.versionService = versionService;
this.transferManifestNodeFactory = transferManifestNodeFactory;
}
/**
* {@inheritDoc}
@@ -106,38 +115,11 @@ public class PublishingQueueImpl implements PublishingQueue
}
/**
* @param queueNode
* @return the nodeRef
*/
public void setNodeRef(NodeRef queueNode)
public NodeRef getNodeRef()
{
this.nodeRef = queueNode;
return nodeRef;
}
/**
* @param transferManifestNodeFactory
* the transferManifestNodeFactory to set
*/
public void setTransferManifestNodeFactory(TransferManifestNodeFactory transferManifestNodeFactory)
{
this.transferManifestNodeFactory = transferManifestNodeFactory;
}
/**
* @param publishingEventHelper
* the publishingEventHelper to set
*/
public void setPublishingEventHelper(PublishingEventHelper publishingEventHelper)
{
this.publishingEventHelper = publishingEventHelper;
}
/**
* @param versionService the versionService to set
*/
public void setVersionService(VersionService versionService)
{
this.versionService = versionService;
}
}

View File

@@ -180,9 +180,10 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest
/**
* {@inheritDoc}
* @throws Exception
*/
@Override
public void onTearDown()
public void onTearDown() throws Exception
{
if(eventId!=null)
{

View File

@@ -0,0 +1,254 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import static org.alfresco.model.ContentModel.ASSOC_CONTAINS;
import static org.alfresco.model.ContentModel.TYPE_FOLDER;
import static org.alfresco.repo.publishing.PublishingModel.ASSOC_PUBLISHING_QUEUE;
import static org.alfresco.repo.publishing.PublishingModel.NAMESPACE;
import static org.alfresco.repo.publishing.PublishingModel.TYPE_PUBLISHING_QUEUE;
import java.util.List;
import org.alfresco.repo.node.NodeUtils;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transfer.manifest.TransferManifestNodeFactory;
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.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.springframework.beans.BeansException;
/**
* Returns a properly configured Environment. The factory is multi-tenancy enabled, returning the correct Environment object for the current domain.
* @author Nick Smith
* @since 4.0
*
*/
public class PublishingRootObject
{
public static final String NAME = "publishingRootObject";
protected static final QName CHANNELS_QNAME = QName.createQName(NAMESPACE, "channels");
private NodeService nodeService;
private PublishingEventHelper publishingEventHelper;
private NamespaceService namespaceService;
private SearchService searchService;
private VersionService versionService;
private TransferManifestNodeFactory transferManifestNodeFactory;
private RetryingTransactionHelper retryingTransactionHelper;
// private TenantAdminService tenantAdminService;
private StoreRef publishingStore;
private String publishingRootPath;
// private Map<String, Environment> environments = new HashMap<String, Environment>();
/**
* @return the approprieate {@link Environment} for the current domain.
* @throws BeansException
*/
public Environment getEnvironment() throws BeansException
{
// String tenantDomain = tenantAdminService.getCurrentUserDomain();
// Environment environment = environments.get(tenantDomain);
// if(environment != null)
// {
// return environment;
// }
// environment = createEnvironment();
// environments.put(tenantDomain, environment);
// return environment;
return createEnvironment();
}
public NodeRef getChannelContainer()
{
return getEnvironment().getChannelsContainer();
}
public PublishingQueueImpl getPublishingQueue()
{
return getEnvironment().getPublishingQueue();
}
private Environment createEnvironment()
{
return AuthenticationUtil.runAs(new RunAsWork<Environment>()
{
public Environment doWork() throws Exception
{
NodeRef environmentNode = getEnvironmentNode();
PublishingQueueImpl queue = createPublishingQueue(environmentNode);
NodeRef channelsContainer = getChannelsContainer(environmentNode);
return new Environment(environmentNode, queue, channelsContainer);
}
}, AuthenticationUtil.getSystemUserName());
}
private NodeRef getChannelsContainer(NodeRef environmentNode)
{
List<ChildAssociationRef> childAssocs =
nodeService.getChildAssocs(environmentNode,ASSOC_CONTAINS, CHANNELS_QNAME);
NodeRef channels = NodeUtils.getSingleChildAssocNode(childAssocs, true);
if (channels == null)
{
// No channels container.
channels = nodeService.createNode(environmentNode,
ASSOC_CONTAINS,
CHANNELS_QNAME,
TYPE_FOLDER).getChildRef();
}
return channels;
}
private PublishingQueueImpl createPublishingQueue(NodeRef environmentNode)
{
NodeRef queueNode = getPublishingQueueNode(environmentNode);
return new PublishingQueueImpl(queueNode, publishingEventHelper, versionService, transferManifestNodeFactory);
}
private NodeRef getPublishingQueueNode(NodeRef environmentNode)
{
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(environmentNode, ASSOC_PUBLISHING_QUEUE, RegexQNamePattern.MATCH_ALL);
NodeRef queueNode = NodeUtils.getSingleChildAssocNode(childAssocs, true);
if (queueNode == null)
{
// No publishing queue
queueNode = nodeService.createNode(environmentNode,
ASSOC_PUBLISHING_QUEUE,
QName.createQName(NAMESPACE, "publishingQueue"),
TYPE_PUBLISHING_QUEUE).getChildRef();
}
return queueNode;
}
private NodeRef getEnvironmentNode()
{
return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Exception
{
return findEnvrionmentNode();
}
}, true);
}
private NodeRef findEnvrionmentNode()
{
NodeRef rootNode = nodeService.getRootNode(publishingStore);
List<NodeRef> refs = searchService.selectNodes(rootNode, publishingRootPath, null, namespaceService, false);
if (refs.size() != 1)
{
String msg = "Invalid publishing root path: " + publishingRootPath + " - found: " + refs.size();
throw new IllegalStateException(msg);
}
return refs.get(0);
}
/**
* @param publishingStore the publishingStore to set
*/
public void setPublishingStore(String publishingStore)
{
this.publishingStore = new StoreRef(publishingStore);
}
/**
* @param publishingRootPath the publishingRootPath to set
*/
public void setPublishingRootPath(String publishingRootPath)
{
this.publishingRootPath = publishingRootPath;
}
/**
* @param retryingTransactionHelper the retryingTransactionHelper to set
*/
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
{
this.retryingTransactionHelper = retryingTransactionHelper;
}
/**
* @param namespaceService the namespaceService to set
*/
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
/**
* @param nodeService the nodeService to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param publishingEventHelper the publishingEventHelper to set
*/
public void setPublishingEventHelper(PublishingEventHelper publishingEventHelper)
{
this.publishingEventHelper = publishingEventHelper;
}
/**
* @param searchService the searchService to set
*/
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
// /**
// * @param tenantAdminService the tenantAdminService to set
// */
// public void setTenantAdminService(TenantAdminService tenantAdminService)
// {
// this.tenantAdminService = tenantAdminService;
// }
/**
* @param transferManifestNodeFactory the transferManifestNodeFactory to set
*/
public void setTransferManifestNodeFactory(TransferManifestNodeFactory transferManifestNodeFactory)
{
this.transferManifestNodeFactory = transferManifestNodeFactory;
}
/**
* @param versionService the versionService to set
*/
public void setVersionService(VersionService versionService)
{
this.versionService = versionService;
}
}

View File

@@ -0,0 +1,81 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import javax.annotation.Resource;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.junit.Test;
/**
* @author Brian
*
*/
public class PublishingRootObjectTest extends AbstractPublishingIntegrationTest
{
@Resource(name="publishingRootObject")
private PublishingRootObject rootObject;
@Override
public void onSetUp() throws Exception
{
super.onSetUp();
this.rootObject = (PublishingRootObject) getApplicationContext().getBean(PublishingRootObject.NAME);
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
}
@Test
public void testGetEnvironment() throws Exception
{
Environment theEnvironment = rootObject.getEnvironment();
assertNotNull(theEnvironment);
assertTrue(nodeService.exists(theEnvironment.getNodeRef()));
assertEquals(PublishingModel.TYPE_ENVIRONMENT, nodeService.getType(theEnvironment.getNodeRef()));
}
@Test
public void testGetPublishingQueue() throws Exception
{
PublishingQueueImpl theQueue = rootObject.getPublishingQueue();
assertNotNull(theQueue);
NodeRef queueNode = theQueue.getNodeRef();
assertTrue(nodeService.exists(queueNode));
assertEquals(PublishingModel.TYPE_PUBLISHING_QUEUE, nodeService.getType(queueNode));
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(queueNode);
assertEquals(PublishingModel.ASSOC_PUBLISHING_QUEUE, parentAssoc.getTypeQName());
assertEquals(rootObject.getEnvironment().getNodeRef(), parentAssoc.getParentRef());
}
@Test
public void testGetChannelContainer() throws Exception
{
NodeRef channels = rootObject.getChannelContainer();
assertNotNull(channels);
assertTrue(nodeService.exists(channels));
assertEquals(ContentModel.TYPE_FOLDER, nodeService.getType(channels));
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(channels);
assertEquals(PublishingRootObject.CHANNELS_QNAME, parentAssoc.getQName());
assertEquals(rootObject.getEnvironment().getNodeRef(), parentAssoc.getParentRef());
}
}

View File

@@ -31,8 +31,8 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses( { ChannelServiceImplTest.class,
PublishingEventHelperTest.class,
ChannelServiceImplIntegratedTest.class,
EnvironmentHelperTest.class,
EnvironmentImplTest.class,
PublishingRootObjectTest.class,
// EnvironmentImplTest.class,
PublishingQueueImplTest.class,
PublishingPackageSerializerTest.class,
PublishingIntegratedTest.class,

View File

@@ -25,7 +25,7 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.publishing.EnvironmentImpl;
import org.alfresco.repo.publishing.Environment;
import org.alfresco.repo.publishing.PublishingModel;
import org.alfresco.repo.publishing.PublishingQueueImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -63,7 +63,7 @@ public class FlickrTest extends BaseSpringTest
protected NodeService nodeService;
protected String siteId;
protected PublishingQueueImpl queue;
protected EnvironmentImpl environment;
protected Environment environment;
protected NodeRef docLib;
private ChannelService channelService;
@@ -109,7 +109,7 @@ public class FlickrTest extends BaseSpringTest
props.put(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, "YOUR_OAUTH_TOKEN_SECRET");
props.put(PublishingModel.PROP_AUTHORISATION_COMPLETE, Boolean.TRUE);
Channel channel = channelService.createChannel(siteId, FlickrChannelType.ID, "FlickrTestChannel", props);
Channel channel = channelService.createChannel(FlickrChannelType.ID, "FlickrTestChannel", props);
//This looks a little odd, but a new channel always has its "authorisation complete" flag
//forced off initially. This will force it on for this channel...
channelService.updateChannel(channel, props);
@@ -153,5 +153,7 @@ public class FlickrTest extends BaseSpringTest
return null;
}
});
}
}

View File

@@ -25,7 +25,7 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.publishing.EnvironmentImpl;
import org.alfresco.repo.publishing.Environment;
import org.alfresco.repo.publishing.PublishingModel;
import org.alfresco.repo.publishing.PublishingQueueImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -63,7 +63,7 @@ public class SlideShareTest extends BaseSpringTest
protected NodeService nodeService;
protected String siteId;
protected PublishingQueueImpl queue;
protected EnvironmentImpl environment;
protected Environment environment;
protected NodeRef docLib;
private ChannelService channelService;
@@ -108,7 +108,7 @@ public class SlideShareTest extends BaseSpringTest
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(PublishingModel.PROP_CHANNEL_USERNAME, "YOUR_USER_NAME");
props.put(PublishingModel.PROP_CHANNEL_PASSWORD, "YOUR_PASSWORD");
Channel channel = channelService.createChannel(siteId, SlideShareChannelType.ID, "SlideShareChannel", props);
Channel channel = channelService.createChannel(SlideShareChannelType.ID, "SlideShareChannel", props);
NodeRef channelNode = channel.getNodeRef();
Resource file = new ClassPathResource("test/alfresco/TestPresentation.pptx");

View File

@@ -82,9 +82,9 @@ public class SiteType
log.debug("onCreateNode " + childAssocRef);
}
String siteId = childAssocRef.getQName().getLocalName();
channelService.createChannel(siteId, "TestChannelType1", "Test Channel One", null);
channelService.createChannel(siteId, "TestChannelType2", "Test Channel Two", null);
channelService.createChannel(siteId, "TestChannelType3", "Test Channel Three", null);
channelService.createChannel("TestChannelType1", "Test Channel One", null);
channelService.createChannel("TestChannelType2", "Test Channel Two", null);
channelService.createChannel("TestChannelType3", "Test Channel Three", null);
}
}

View File

@@ -24,7 +24,7 @@ import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.publishing.EnvironmentImpl;
import org.alfresco.repo.publishing.Environment;
import org.alfresco.repo.publishing.PublishingModel;
import org.alfresco.repo.publishing.PublishingQueueImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -62,7 +62,7 @@ public class YouTubeTest extends BaseSpringTest
protected NodeService nodeService;
protected String siteId;
protected PublishingQueueImpl queue;
protected EnvironmentImpl environment;
protected Environment environment;
protected NodeRef docLib;
private ChannelService channelService;
@@ -107,7 +107,7 @@ public class YouTubeTest extends BaseSpringTest
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(PublishingModel.PROP_CHANNEL_USERNAME, "YOUR_USER_NAME");
props.put(PublishingModel.PROP_CHANNEL_PASSWORD, "YOUR_PASSWORD");
Channel channel = channelService.createChannel(siteId, YouTubeChannelType.ID, "YouTubeChannel", props);
Channel channel = channelService.createChannel(YouTubeChannelType.ID, "YouTubeChannel", props);
NodeRef channelNode = channel.getNodeRef();
Resource videoFile = new ClassPathResource("test/alfresco/TestVideoFile.MP4");

View File

@@ -55,11 +55,11 @@ public interface PublishingService
/**
* Discover the publishing status of each of the specified nodes
* @param channelName TODO
* @param channelId 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<NodeRef,NodePublishStatus> checkPublishStatus(String siteId, String channelName, Collection<NodeRef> nodes);
Map<NodeRef,NodePublishStatus> checkPublishStatus(String channelId, Collection<NodeRef> nodes);
Map<NodeRef,NodePublishStatus> checkPublishStatus(String siteId, String channelName, NodeRef... nodes);
Map<NodeRef,NodePublishStatus> checkPublishStatus(String channelId, NodeRef... nodes);
}

View File

@@ -54,14 +54,13 @@ public interface ChannelService
/**
* Create a new channel of the specified channel type on the specified Share site with the specified name and properties.
* @param siteId The identifier of the Share site on which this channel is to be created.
* @param channelTypeId The identifier of the channel type that is to be used for the new channel. This must identify a channel type that
* has been registered with the channel service.
* @param name The name of the new channel. This must be unique within the specified Share site.
* @param properties Any additional properties that are to be saved as part of the new channel.
* @return A Channel object corresponding to the newly created channel.
*/
Channel createChannel(String siteId, String channelTypeId, String name, Map<QName, Serializable> properties);
Channel createChannel(String channelTypeId, String name, Map<QName, Serializable> properties);
/**
* Remove the specified channel.
@@ -71,11 +70,10 @@ public interface ChannelService
/**
* Rename the specified channel
* @param siteId The identifier of the Share site that contains the channel to be renamed.
* @param oldName The current name of the channel that is to be renamed.
* @param newName The new name of the channel
*/
void renameChannel(String siteId, String oldName, String newName);
void renameChannel(String oldName, String newName);
/**
* Update the properties of the specified channel.
@@ -87,25 +85,23 @@ public interface ChannelService
/**
* Retrieve all the channels contained by the specified Share site.
* @param siteId The identifier of the Share site
* @return A list of Channel objects, each one representing a channel that exists within the specified Share site.
*/
List<Channel> getChannels(String siteId);
List<Channel> getChannels();
/**
* Retrieve the channel with the given channel name contained by the specified Share site.
* @param siteId The identifier of the Share site
* @param channelName The name of the channel
* @return The specified Channel objects or <code>null</code> if the specified channel does not exist.
*/
Channel getChannel(String siteId, String channelName);
Channel getChannelByName(String channelName);
/**
* Retrieve the channel with the given id.
* @param id The string value of the channel {@link NodeRef}.
* @return The specified Channel objects or <code>null</code> if the specified channel does not exist.
*/
Channel getChannel(String id);
Channel getChannelById(String id);
/**
* Returns a list of all the channels that are capable of publishing the specified NodeRef.
@@ -116,23 +112,14 @@ public interface ChannelService
/**
* Returns a list of all the channels that are capable of publishing in the specified Share site.
* @param siteId
* @return
*/
List<Channel> getPublishingChannels(String siteId);
List<Channel> getPublishingChannels();
/**
* Returns all {@link Channel}s cpaable of performing a status update for the given Share Site.
* @param siteId
* @return
*/
List<Channel> getStatusUpdateChannels(String siteId);
/**
* Returns all {@link Channel}s capable of performing a status update for the Share Site in which the specified <code>nodeToPublish</code> exists.
* @param siteId
* @return
*/
List<Channel> getStatusUpdateChannels(NodeRef nodeToPublish);
List<Channel> getStatusUpdateChannels();
}