mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Publishing: Added "publish-content" action to provide easy access to the publishing service.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31057 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -119,4 +119,93 @@
|
||||
<property name="apiKey" value="${urlshortening.bitly.api.key}" />
|
||||
</bean>
|
||||
|
||||
<bean id="PublishingService_security"
|
||||
class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
|
||||
|
||||
<bean id="PublishingService_transaction"
|
||||
class="org.alfresco.repo.transaction.RetryingTransactionInterceptor">
|
||||
<property name="transactionService" ref="TransactionService" />
|
||||
<property name="transactionManager">
|
||||
<ref bean="transactionManager" />
|
||||
</property>
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="get*">${server.transaction.mode.readOnly}</prop>
|
||||
<prop key="*">${server.transaction.mode.default}</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="PublishingService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.service.cmr.publishing.PublishingService</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="publishingService" />
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref local="PublishingService_transaction" />
|
||||
<idref bean="AuditMethodInterceptor" />
|
||||
<idref bean="exceptionTranslator" />
|
||||
<idref local="PublishingService_security" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="ChannelService_security"
|
||||
class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
|
||||
|
||||
<bean id="ChannelService_transaction"
|
||||
class="org.alfresco.repo.transaction.RetryingTransactionInterceptor">
|
||||
<property name="transactionService" ref="TransactionService" />
|
||||
<property name="transactionManager">
|
||||
<ref bean="transactionManager" />
|
||||
</property>
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="get*">${server.transaction.mode.readOnly}</prop>
|
||||
<prop key="*">${server.transaction.mode.default}</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="ChannelService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.service.cmr.publishing.channels.ChannelService</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="channelService" />
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref local="ChannelService_transaction" />
|
||||
<idref bean="AuditMethodInterceptor" />
|
||||
<idref bean="exceptionTranslator" />
|
||||
<idref local="ChannelService_security" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="publish-content" class="org.alfresco.repo.publishing.PublishContentActionExecuter" parent="action-executer">
|
||||
<property name="channelService" ref="ChannelService" />
|
||||
<property name="publishingService" ref="PublishingService" />
|
||||
<property name="ignoreLock" value="true" />
|
||||
<property name="applicableTypes">
|
||||
<list>
|
||||
<value>{http://www.alfresco.org/model/content/1.0}content</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="ac-publishing-channels" class="org.alfresco.repo.publishing.PublishingChannelParameterConstraint"
|
||||
parent="action-constraint">
|
||||
<property name="channelService" ref="ChannelService" />
|
||||
</bean>
|
||||
|
||||
<bean id="ac-status-update-channels" class="org.alfresco.repo.publishing.StatusUpdateChannelParameterConstraint"
|
||||
parent="action-constraint">
|
||||
<property name="channelService" ref="ChannelService" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
@@ -1 +1,15 @@
|
||||
# Publish service externalised display strings
|
||||
publishing.channelNotFound=Unable to find specified publishing channel: {0}
|
||||
publishing.neitherNameNorIdSpecified=Neither channel name nor identifier has been specified
|
||||
|
||||
publish-content.title=Publish
|
||||
publish-content.description=Publish content to a publishing channel
|
||||
publish-content.publish-channel-name.display-label=Channel to publish content to
|
||||
publish-content.publish-channel-id.display-label=Channel to publish content to
|
||||
publish-content.unpublish.display-label=Unpublish
|
||||
publish-content.status-update.display-label=Status update
|
||||
publish-content.include-link-in-status-update.display-label=Append link to status update
|
||||
publish-content.status-update-channel-names.display-label=Channels to post status update to
|
||||
publish-content.status-update-channel-ids.display-label=Channels to post status update to
|
||||
publish-content.scheduled-time.display-label=Time to publish
|
||||
publish-content.comment.display-label=Comment
|
||||
|
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* 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 java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.action.ParameterizedItem;
|
||||
import org.alfresco.service.cmr.action.ParameterizedItemDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.publishing.PublishingDetails;
|
||||
import org.alfresco.service.cmr.publishing.PublishingService;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.rule.RuleServiceException;
|
||||
|
||||
/**
|
||||
* This class defines an action that publishes or unpublishes the acted-upon
|
||||
* node to a specified publishing channel.
|
||||
*
|
||||
* @author Brian
|
||||
* @since 4.0
|
||||
*/
|
||||
public class PublishContentActionExecuter extends ActionExecuterAbstractBase
|
||||
{
|
||||
public final static String NAME = "publish_content";
|
||||
|
||||
/**
|
||||
* A single-valued, optional text parameter that names the publishing
|
||||
* channel to which the specified content is to be published. Although this
|
||||
* is optional, one of either "publish-channel-name" or "publish-channel-id"
|
||||
* MUST be specified. If both are specified then "publish-channel-id" takes
|
||||
* precedence.
|
||||
*
|
||||
* @see PublishContentActionExecuter#PARAM_PUBLISH_CHANNEL_ID
|
||||
*/
|
||||
public final static String PARAM_PUBLISH_CHANNEL_NAME = "publish-channel-name";
|
||||
|
||||
/**
|
||||
* A single-valued, optional text parameter that identifies the publishing
|
||||
* channel to which the specified content is to be published. Although this
|
||||
* is optional, one of either "publish-channel-name" or "publish-channel-id"
|
||||
* MUST be specified. If both are specified then "publish-channel-id" takes
|
||||
* precedence.
|
||||
*
|
||||
* @see PublishContentActionExecuter#PARAM_PUBLISH_CHANNEL_NAME
|
||||
*/
|
||||
public final static String PARAM_PUBLISH_CHANNEL_ID = "publish-channel-id";
|
||||
|
||||
/**
|
||||
* A single-valued, optional boolean parameter that indicates whether the
|
||||
* node being acted on should be unpublished (true) or published (false, the
|
||||
* default).
|
||||
*/
|
||||
public final static String PARAM_UNPUBLISH = "unpublish";
|
||||
|
||||
/**
|
||||
* A single-valued, optional text parameter that specifies the text of a
|
||||
* status update that is to be sent to the specified channels upon
|
||||
* successful publication
|
||||
*
|
||||
* @see PublishContentActionExecuter#PARAM_STATUS_UPDATE_CHANNEL_NAMES
|
||||
*/
|
||||
public final static String PARAM_STATUS_UPDATE = "status-update";
|
||||
|
||||
/**
|
||||
* A single-valued, optional boolean parameter that specifies whether a link
|
||||
* to the published content should be appended (in shortened form) to the
|
||||
* status update. Defaults to true if not set.
|
||||
*
|
||||
* @see PublishContentActionExecuter#PARAM_STATUS_UPDATE_CHANNEL_NAMES
|
||||
* @see PublishContentActionExecuter#PARAM_STATUS_UPDATE
|
||||
*/
|
||||
public final static String PARAM_INCLUDE_LINK_IN_STATUS_UPDATE = "include-link-in-status-update";
|
||||
|
||||
/**
|
||||
* A multi-valued, optional text parameter that identifies by name the
|
||||
* publishing channels to which the status update (if any) should be sent.
|
||||
* If both this parameter and the "status-update-channel-ids" parameter are
|
||||
* given values then they are combined.
|
||||
*
|
||||
* @see PublishContentActionExecuter#PARAM_STATUS_UPDATE
|
||||
* @see PublishContentActionExecuter#PARAM_STATUS_UPDATE_CHANNEL_IDS
|
||||
*/
|
||||
public final static String PARAM_STATUS_UPDATE_CHANNEL_NAMES = "status-update-channel-names";
|
||||
|
||||
/**
|
||||
* A multi-valued, optional text parameter that identifies the publishing
|
||||
* channels to which the status update (if any) should be sent. If both this
|
||||
* parameter and the "status-update-channel-names" parameter are given
|
||||
* values then they are combined.
|
||||
*
|
||||
* @see PublishContentActionExecuter#PARAM_STATUS_UPDATE
|
||||
* @see PublishContentActionExecuter#PARAM_STATUS_UPDATE_CHANNEL_NAMES
|
||||
*/
|
||||
public final static String PARAM_STATUS_UPDATE_CHANNEL_IDS = "status-update-channel-ids";
|
||||
|
||||
/**
|
||||
* A single-valued, optional datetime parameter that specifies when the
|
||||
* publish should happen.
|
||||
*/
|
||||
public final static String PARAM_SCHEDULED_TIME = "scheduled-time";
|
||||
|
||||
/**
|
||||
* A single-valued, optional text parameter that is stored on the publishing
|
||||
* event that is created by this action.
|
||||
*/
|
||||
public final static String PARAM_COMMENT = "comment";
|
||||
|
||||
private static final String MSG_CHANNEL_NOT_FOUND = "publishing.channelNotFound";
|
||||
private static final String MSG_NEITHER_CHANNEL_NAME_NOR_ID_SPECIFIED = "publishing.neitherNameNorIdSpecified";
|
||||
|
||||
private PublishingService publishingService;
|
||||
private ChannelService channelService;
|
||||
|
||||
public void setPublishingService(PublishingService publishingService)
|
||||
{
|
||||
this.publishingService = publishingService;
|
||||
}
|
||||
|
||||
public void setChannelService(ChannelService channelService)
|
||||
{
|
||||
this.channelService = channelService;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
Boolean isUnpublish = (Boolean) action.getParameterValue(PARAM_UNPUBLISH);
|
||||
boolean unpublish = ((isUnpublish == null) || isUnpublish);
|
||||
String publishChannelId = (String) action.getParameterValue(PARAM_PUBLISH_CHANNEL_ID);
|
||||
String publishChannelName = (String) action.getParameterValue(PARAM_PUBLISH_CHANNEL_NAME);
|
||||
String statusUpdate = (String) action.getParameterValue(PARAM_STATUS_UPDATE);
|
||||
List<String> statusUpdateChannelNames = buildStringList(action.getParameterValue(PARAM_STATUS_UPDATE_CHANNEL_NAMES));
|
||||
List<String> statusUpdateChannelIds = buildStringList(action.getParameterValue(PARAM_STATUS_UPDATE_CHANNEL_IDS));
|
||||
Boolean includeLinkInStatusUpdate = (Boolean) action.getParameterValue(PARAM_INCLUDE_LINK_IN_STATUS_UPDATE);
|
||||
boolean appendLink = ((includeLinkInStatusUpdate == null) || includeLinkInStatusUpdate);
|
||||
Date scheduledTime = (Date) action.getParameterValue(PARAM_SCHEDULED_TIME);
|
||||
String comment = (String) action.getParameterValue(PARAM_COMMENT);
|
||||
|
||||
Channel publishChannel = publishChannelId == null ? channelService.getChannelByName(publishChannelName) :
|
||||
channelService.getChannelById(publishChannelId);
|
||||
if (publishChannel != null)
|
||||
{
|
||||
PublishingDetails details = publishingService.createPublishingDetails();
|
||||
details.setPublishChannelId(publishChannel.getId());
|
||||
if (unpublish)
|
||||
{
|
||||
details.addNodesToUnpublish(actionedUponNodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
details.addNodesToPublish(actionedUponNodeRef);
|
||||
}
|
||||
if (statusUpdateChannelNames != null)
|
||||
{
|
||||
for (String statusUpdateChannelName : statusUpdateChannelNames)
|
||||
{
|
||||
Channel statusUpdateChannel = channelService.getChannelByName(statusUpdateChannelName);
|
||||
if (statusUpdateChannel != null)
|
||||
{
|
||||
details.addStatusUpdateChannels(statusUpdateChannel.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (statusUpdateChannelIds != null)
|
||||
{
|
||||
for (String statusUpdateChannelId : statusUpdateChannelIds)
|
||||
{
|
||||
Channel statusUpdateChannel = channelService.getChannelById(statusUpdateChannelId);
|
||||
if (statusUpdateChannel != null)
|
||||
{
|
||||
details.addStatusUpdateChannels(statusUpdateChannel.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!details.getStatusUpdateChannels().isEmpty())
|
||||
{
|
||||
details.setStatusMessage(statusUpdate);
|
||||
if (appendLink)
|
||||
{
|
||||
details.setStatusNodeToLinkTo(actionedUponNodeRef);
|
||||
}
|
||||
}
|
||||
if (scheduledTime != null)
|
||||
{
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(scheduledTime);
|
||||
details.setSchedule(cal);
|
||||
}
|
||||
details.setComment(comment);
|
||||
publishingService.scheduleNewEvent(details);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(MSG_CHANNEL_NOT_FOUND, new Object[] { publishChannelId == null ? publishChannelName : publishChannelId});
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> buildStringList(Serializable parameterValue)
|
||||
{
|
||||
List<String> result = null;
|
||||
if (parameterValue != null && String.class.isAssignableFrom(parameterValue.getClass()))
|
||||
{
|
||||
String[] split = ((String)parameterValue).split(",");
|
||||
result = Arrays.asList(split);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_PUBLISH_CHANNEL_NAME, DataTypeDefinition.TEXT, false,
|
||||
getParamDisplayLabel(PARAM_PUBLISH_CHANNEL_NAME), false));
|
||||
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_PUBLISH_CHANNEL_ID, DataTypeDefinition.TEXT, false,
|
||||
getParamDisplayLabel(PARAM_PUBLISH_CHANNEL_ID), false, "ac-publishing-channels"));
|
||||
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_UNPUBLISH, DataTypeDefinition.BOOLEAN, false,
|
||||
getParamDisplayLabel(PARAM_UNPUBLISH), false));
|
||||
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_STATUS_UPDATE, DataTypeDefinition.TEXT, false,
|
||||
getParamDisplayLabel(PARAM_STATUS_UPDATE), false));
|
||||
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_INCLUDE_LINK_IN_STATUS_UPDATE, DataTypeDefinition.BOOLEAN,
|
||||
false, getParamDisplayLabel(PARAM_INCLUDE_LINK_IN_STATUS_UPDATE), false));
|
||||
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_STATUS_UPDATE_CHANNEL_NAMES, DataTypeDefinition.TEXT, false,
|
||||
getParamDisplayLabel(PARAM_STATUS_UPDATE_CHANNEL_NAMES), true));
|
||||
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_STATUS_UPDATE_CHANNEL_IDS, DataTypeDefinition.TEXT, false,
|
||||
getParamDisplayLabel(PARAM_STATUS_UPDATE_CHANNEL_IDS), true, "ac-status-update-channels"));
|
||||
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_SCHEDULED_TIME, DataTypeDefinition.DATETIME, false,
|
||||
getParamDisplayLabel(PARAM_SCHEDULED_TIME), false));
|
||||
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_COMMENT, DataTypeDefinition.TEXT, false,
|
||||
getParamDisplayLabel(PARAM_COMMENT), false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkMandatoryProperties(ParameterizedItem ruleItem, ParameterizedItemDefinition ruleItemDefinition)
|
||||
{
|
||||
super.checkMandatoryProperties(ruleItem, ruleItemDefinition);
|
||||
String publishChannelName = (String) ruleItem.getParameterValue(PARAM_PUBLISH_CHANNEL_NAME);
|
||||
String publishChannelId = (String) ruleItem.getParameterValue(PARAM_PUBLISH_CHANNEL_ID);
|
||||
if (publishChannelId == null && publishChannelName == null)
|
||||
{
|
||||
throw new RuleServiceException(MSG_NEITHER_CHANNEL_NAME_NOR_ID_SPECIFIED);
|
||||
}
|
||||
}
|
||||
}
|
@@ -406,7 +406,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest
|
||||
private NodeRef publishNode(NodeRef source, String message, boolean publish)
|
||||
{
|
||||
PublishingDetails details = publishingService.createPublishingDetails();
|
||||
details.setPublishChannel(channel.getId());
|
||||
details.setPublishChannelId(channel.getId());
|
||||
if (publish)
|
||||
{
|
||||
details.addNodesToPublish(source);
|
||||
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2009-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.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||
|
||||
/**
|
||||
* Action parameter constraint that constrains to list of publishing channels
|
||||
*
|
||||
* @see PublishContentActionExecuter
|
||||
* @author Brian
|
||||
* @since 4.0
|
||||
*/
|
||||
public class PublishingChannelParameterConstraint extends BaseParameterConstraint
|
||||
{
|
||||
public static final String NAME = "ac-publishing-channels";
|
||||
|
||||
private ChannelService channelService;
|
||||
|
||||
public void setChannelService(ChannelService channelService)
|
||||
{
|
||||
this.channelService = channelService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
|
||||
*/
|
||||
protected Map<String, String> getAllowableValuesImpl()
|
||||
{
|
||||
List<Channel> channels = channelService.getPublishingChannels(false);
|
||||
Map<String, String> result = new TreeMap<String, String>();
|
||||
for (Channel channel : channels)
|
||||
{
|
||||
result.put(channel.getId(), channel.getName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -84,7 +84,7 @@ public class PublishingDetailsImpl implements PublishingDetails
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public PublishingDetails setPublishChannel(String publishChannelId)
|
||||
public PublishingDetails setPublishChannelId(String publishChannelId)
|
||||
{
|
||||
this.publishChannelId = publishChannelId;
|
||||
return this;
|
||||
|
@@ -194,7 +194,7 @@ public class PublishingEventHelperTest
|
||||
|
||||
PublishingDetails details = new PublishingDetailsImpl()
|
||||
.setSchedule(schedule)
|
||||
.setPublishChannel(channelId)
|
||||
.setPublishChannelId(channelId)
|
||||
.setComment(comment);
|
||||
|
||||
NodeRef result = helper.createNode(queue, details);
|
||||
|
@@ -89,7 +89,7 @@ public class PublishingIntegratedTest extends BaseSpringTest
|
||||
|
||||
PublishingDetails details = publishingService.createPublishingDetails()
|
||||
.addNodesToPublish(nodes)
|
||||
.setPublishChannel(channel.getId())
|
||||
.setPublishChannelId(channel.getId())
|
||||
.setSchedule(schedule);
|
||||
|
||||
String eventId = publishingService.scheduleNewEvent(details);
|
||||
@@ -124,7 +124,7 @@ public class PublishingIntegratedTest extends BaseSpringTest
|
||||
|
||||
PublishingDetails details = publishingService.createPublishingDetails()
|
||||
.addNodesToPublish(nodes)
|
||||
.setPublishChannel(channel.getId())
|
||||
.setPublishChannelId(channel.getId())
|
||||
.setSchedule(schedule);
|
||||
String eventId = publishingService.scheduleNewEvent(details);
|
||||
PublishingEvent event = publishingService.getPublishingEvent(eventId);
|
||||
|
@@ -77,7 +77,7 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest
|
||||
|
||||
PublishingDetails details = publishingService.createPublishingDetails()
|
||||
.addNodesToPublish(firstNode, secondNode)
|
||||
.setPublishChannel(channelId)
|
||||
.setPublishChannelId(channelId)
|
||||
.setSchedule(schedule)
|
||||
.setComment(comment);
|
||||
|
||||
@@ -143,7 +143,7 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest
|
||||
List<String> statusChannels = Arrays.asList("test://channel/Channel1", "test://channel/Channel2", "test://channel/Channel3" );
|
||||
String message = "The message";
|
||||
PublishingDetails details = publishingService.createPublishingDetails()
|
||||
.setPublishChannel(channelId)
|
||||
.setPublishChannelId(channelId)
|
||||
.addNodesToPublish(firstNode, secondNode)
|
||||
.setStatusMessage(message)
|
||||
.setStatusNodeToLinkTo(secondNode)
|
||||
@@ -182,7 +182,7 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest
|
||||
// Publish an event
|
||||
PublishingDetails details = publishingService.createPublishingDetails();
|
||||
details.addNodesToPublish(firstNode, secondNode);
|
||||
details.setPublishChannel(publishChannel.getId());
|
||||
details.setPublishChannelId(publishChannel.getId());
|
||||
try
|
||||
{
|
||||
testHelper.scheduleEvent1Year(details);
|
||||
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2009-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.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
|
||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||
|
||||
/**
|
||||
* Action parameter constraint that constrains value to a list of publishing channels that support status updates
|
||||
*
|
||||
* @see PublishContentActionExecuter
|
||||
* @author Brian
|
||||
* @since 4.0
|
||||
*/
|
||||
public class StatusUpdateChannelParameterConstraint extends BaseParameterConstraint
|
||||
{
|
||||
public static final String NAME = "ac-status-update-channels";
|
||||
|
||||
private ChannelService channelService;
|
||||
|
||||
public void setChannelService(ChannelService channelService)
|
||||
{
|
||||
this.channelService = channelService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
|
||||
*/
|
||||
protected Map<String, String> getAllowableValuesImpl()
|
||||
{
|
||||
List<Channel> channels = channelService.getStatusUpdateChannels(false);
|
||||
Map<String, String> result = new TreeMap<String, String>();
|
||||
for (Channel channel : channels)
|
||||
{
|
||||
result.put(channel.getId(), channel.getName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -42,7 +42,7 @@ public interface PublishingDetails
|
||||
|
||||
PublishingDetails addNodesToPublish(Collection<NodeRef> nodesToPublish);
|
||||
|
||||
PublishingDetails setPublishChannel(String channelId);
|
||||
PublishingDetails setPublishChannelId(String channelId);
|
||||
|
||||
PublishingDetails setComment(String comment);
|
||||
|
||||
|
@@ -20,6 +20,8 @@ package org.alfresco.service.cmr.publishing;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.Auditable;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
@@ -36,6 +38,7 @@ public interface PublishingService
|
||||
* identifier or <code>null</code> if no such publishing event can
|
||||
* be located
|
||||
*/
|
||||
@NotAuditable
|
||||
PublishingEvent getPublishingEvent(String id);
|
||||
|
||||
/**
|
||||
@@ -43,6 +46,7 @@ public interface PublishingService
|
||||
* @param publishedNode The node that was published.
|
||||
* @return A list of {@link PublishingEvent}s.
|
||||
*/
|
||||
@NotAuditable
|
||||
List<PublishingEvent> getPublishEventsForNode(NodeRef publishedNode);
|
||||
|
||||
/**
|
||||
@@ -50,6 +54,7 @@ public interface PublishingService
|
||||
* @param unpublishedNode The node that was unpublished.
|
||||
* @return A list of {@link PublishingEvent}s.
|
||||
*/
|
||||
@NotAuditable
|
||||
List<PublishingEvent> getUnpublishEventsForNode(NodeRef unpublishedNode);
|
||||
|
||||
/**
|
||||
@@ -60,6 +65,7 @@ public interface PublishingService
|
||||
*
|
||||
* @param id The identifier of the publishing event that is to be cancelled.
|
||||
*/
|
||||
@Auditable(parameters={"id"})
|
||||
void cancelPublishingEvent(String id);
|
||||
|
||||
/**
|
||||
@@ -67,6 +73,7 @@ public interface PublishingService
|
||||
* a call to the {@link PublishingQueue#scheduleNewEvent(PublishingDetails)} operation.
|
||||
* @return A publishing package that can be populated before being placed on the publishing queue.
|
||||
*/
|
||||
@NotAuditable
|
||||
PublishingDetails createPublishingDetails();
|
||||
|
||||
/**
|
||||
@@ -74,5 +81,6 @@ public interface PublishingService
|
||||
* @param publishingDetails The publishing package that is to be enqueued
|
||||
* @return The identifier of the newly scheduled event
|
||||
*/
|
||||
@Auditable
|
||||
String scheduleNewEvent(PublishingDetails publishingDetails);
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.publishing.AbstractChannelType;
|
||||
import org.alfresco.service.Auditable;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
@@ -39,6 +41,7 @@ public interface ChannelService
|
||||
* @param channelType The channel type to be registered.
|
||||
* @throws IllegalArgumentException if a channel type is already registered that has the same identifier as the supplied one
|
||||
*/
|
||||
@NotAuditable
|
||||
void register(AbstractChannelType channelType);
|
||||
|
||||
/**
|
||||
@@ -46,12 +49,14 @@ public interface ChannelService
|
||||
* @param id The identifier of the channel type to be retrieved
|
||||
* @return A ChannelType object that represents the channel type with the specified identifier
|
||||
*/
|
||||
@NotAuditable
|
||||
ChannelType getChannelType(String id);
|
||||
|
||||
/**
|
||||
* Retrieve all the registered channel types
|
||||
* @return A list of ChannelType objects, each representing a channel type registered with this channel service
|
||||
*/
|
||||
@NotAuditable
|
||||
List<ChannelType> getChannelTypes();
|
||||
|
||||
/**
|
||||
@@ -62,12 +67,14 @@ public interface ChannelService
|
||||
* @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.
|
||||
*/
|
||||
@Auditable(parameters={"channelTypeId", "name"})
|
||||
Channel createChannel(String channelTypeId, String name, Map<QName, Serializable> properties);
|
||||
|
||||
/**
|
||||
* Remove the specified channel.
|
||||
* @param channel The channel to delete.
|
||||
*/
|
||||
@Auditable
|
||||
void deleteChannel(Channel channel);
|
||||
|
||||
/**
|
||||
@@ -75,6 +82,7 @@ public interface ChannelService
|
||||
* @param channel The channel that is to be renamed.
|
||||
* @param newName The new name of the channel
|
||||
*/
|
||||
@Auditable(parameters={"newName"})
|
||||
void renameChannel(Channel channel, String newName);
|
||||
|
||||
/**
|
||||
@@ -83,12 +91,14 @@ public interface ChannelService
|
||||
* @param properties The properties to set on the channel. These are blended with the current properties
|
||||
* on the channel. Any that aren't currently set will be added, others will be updated.
|
||||
*/
|
||||
@Auditable
|
||||
void updateChannel(Channel channel, Map<QName,Serializable> properties);
|
||||
|
||||
/**
|
||||
* Retrieve all the channels.
|
||||
* @return A list of Channel objects, each one representing a channel that exists within the specified Share site.
|
||||
*/
|
||||
@NotAuditable
|
||||
List<Channel> getChannels();
|
||||
|
||||
/**
|
||||
@@ -96,6 +106,7 @@ public interface ChannelService
|
||||
* @param channelName The name of the channel
|
||||
* @return The specified Channel objects or <code>null</code> if the specified channel does not exist.
|
||||
*/
|
||||
@NotAuditable
|
||||
Channel getChannelByName(String channelName);
|
||||
|
||||
/**
|
||||
@@ -103,6 +114,7 @@ public interface ChannelService
|
||||
* @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.
|
||||
*/
|
||||
@NotAuditable
|
||||
Channel getChannelById(String id);
|
||||
|
||||
/**
|
||||
@@ -110,20 +122,25 @@ public interface ChannelService
|
||||
* @param nodeToPublish
|
||||
* @return
|
||||
*/
|
||||
@NotAuditable
|
||||
List<Channel> getRelevantPublishingChannels(NodeRef nodeToPublish);
|
||||
|
||||
/**
|
||||
* Returns a list of all the channels that are capable of publishing in the specified Share site.
|
||||
* @param filterByPublishPermission TODO
|
||||
* @param filterByPublishPermission If true then the returned channels are filtered to include only those
|
||||
* to which the authenticated user can publish
|
||||
* @return
|
||||
*/
|
||||
@NotAuditable
|
||||
List<Channel> getPublishingChannels(boolean filterByPublishPermission);
|
||||
|
||||
/**
|
||||
* Returns all {@link Channel}s cpaable of performing a status update for the given Share Site.
|
||||
* @param filterByPublishPermission TODO
|
||||
* @param filterByPublishPermission If true then the returned channels are filtered to include only those
|
||||
* to which the authenticated user can post status updates
|
||||
* @return
|
||||
*/
|
||||
@NotAuditable
|
||||
List<Channel> getStatusUpdateChannels(boolean filterByPublishPermission);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user