mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Implemented channel.put Rest method for renaming channels. Also renamed publishing-events-for-node.get to publishing-events.get.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29312 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -294,14 +294,14 @@ public class ChannelServiceImpl implements ChannelService
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void renameChannel(String oldName, String newName)
|
||||
public void renameChannel(Channel channel, String newName)
|
||||
{
|
||||
NodeRef channelNode = channel.getNodeRef();
|
||||
if (channelNode != null && nodeService.exists(channelNode))
|
||||
{
|
||||
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,
|
||||
nodeService.setProperty(channelNode, ContentModel.PROP_NAME, newName);
|
||||
nodeService.moveNode(channelNode, channelContainer, ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.APP_MODEL_1_0_URI, newName));
|
||||
}
|
||||
}
|
||||
@@ -331,8 +331,7 @@ public class ChannelServiceImpl implements ChannelService
|
||||
@Override
|
||||
public Channel getChannelById(String id)
|
||||
{
|
||||
if(id!=null&& id.isEmpty()==false
|
||||
&& NodeRef.isNodeRef(id))
|
||||
if(id!=null&& NodeRef.isNodeRef(id))
|
||||
{
|
||||
NodeRef node = new NodeRef(id);
|
||||
return channelHelper.buildChannelObject(node, this);
|
||||
|
@@ -94,7 +94,7 @@ public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrat
|
||||
{
|
||||
String newChannelName = "New Channel Name";
|
||||
Channel channel = createChannel();
|
||||
channelService.renameChannel(channelName, newChannelName);
|
||||
channelService.renameChannel(channel, newChannelName);
|
||||
|
||||
Channel renamedChannel = channelService.getChannelById(channel.getId());
|
||||
assertNotNull(renamedChannel);
|
||||
|
@@ -1,107 +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.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* A utility class to help out with environment-related operations that are used
|
||||
* by both the channel service and the publishing service.
|
||||
*
|
||||
* @author Brian
|
||||
* @author Nick Smith
|
||||
*
|
||||
*/
|
||||
public class EnvironmentHelper
|
||||
{
|
||||
private PublishingRootObject rootObject;
|
||||
|
||||
public NodeRef getChannelContainer()
|
||||
{
|
||||
return rootObject.getChannelContainer();
|
||||
}
|
||||
|
||||
public PublishingQueueImpl getPublishingQueue()
|
||||
{
|
||||
return rootObject.getPublishingQueue();
|
||||
}
|
||||
|
||||
// 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;
|
||||
// }
|
||||
|
||||
}
|
@@ -509,15 +509,7 @@ public class PublishingEventHelper
|
||||
}
|
||||
}
|
||||
|
||||
public NodeRef getEnvironmentNodeForPublishingEvent(NodeRef publishingEvent)
|
||||
{
|
||||
ChildAssociationRef queueAssoc = nodeService.getPrimaryParent(publishingEvent);
|
||||
ChildAssociationRef environmentAssoc = nodeService.getPrimaryParent(queueAssoc.getParentRef());
|
||||
NodeRef environment = environmentAssoc.getParentRef();
|
||||
return environment;
|
||||
}
|
||||
|
||||
public AssociationRef linkeToLastEvent(NodeRef publishedNode, NodeRef eventNode)
|
||||
public AssociationRef linkToLastEvent(NodeRef publishedNode, NodeRef eventNode)
|
||||
{
|
||||
List<AssociationRef> assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT);
|
||||
if(isEmpty(assocs)==false)
|
||||
@@ -528,4 +520,51 @@ public class PublishingEventHelper
|
||||
}
|
||||
return nodeService.createAssociation(publishedNode, eventNode, ASSOC_LAST_PUBLISHING_EVENT);
|
||||
}
|
||||
|
||||
// public NodePublishStatus checkNodeStatus(NodeRef node, String channelId, NodeRef queue)
|
||||
// {
|
||||
// PublishingEvent queuedEvent = getQueuedPublishingEvent(node, channelId, queue);
|
||||
// PublishingEvent lastEvent= getLastPublishingEvent(node, channelId, queue);
|
||||
// if(queuedEvent != null)
|
||||
// {
|
||||
// if(lastEvent != null)
|
||||
// {
|
||||
// return new NodePublishStatusPublishedAndOnQueue(node, channelId, queuedEvent, lastEvent);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return new NodePublishStatusOnQueue(node, channelId, queuedEvent);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if(lastEvent != null)
|
||||
// {
|
||||
// return new NodePublishStatusPublished(node, channelId, lastEvent);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return new NodePublishStatusNotPublished(node, channelId);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private PublishingEvent getLastPublishingEvent(NodeRef node, String channelId, NodeRef queue)
|
||||
// {
|
||||
// getEventNodesForPublishedNode(queue, node);
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private PublishingEvent getQueuedPublishingEvent(NodeRef node, String channelId)
|
||||
// {
|
||||
// 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;
|
||||
// }
|
||||
|
||||
}
|
||||
|
@@ -74,7 +74,6 @@ public class PublishingEventProcessor
|
||||
String inProgressStatus = PublishingEvent.Status.IN_PROGRESS.name();
|
||||
nodeService.setProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS, inProgressStatus);
|
||||
PublishingEvent event = eventHelper.getPublishingEvent(eventNode);
|
||||
NodeRef environment = eventHelper.getEnvironmentNodeForPublishingEvent(eventNode);
|
||||
String channelName = event.getChannelId();
|
||||
Channel channel = channelService.getChannelById(channelName);
|
||||
if (channel == null)
|
||||
@@ -84,7 +83,7 @@ public class PublishingEventProcessor
|
||||
else
|
||||
{
|
||||
publishEvent(channel, event);
|
||||
updateStatus(channel, environment, event.getStatusUpdate());
|
||||
updateStatus(channel, event.getStatusUpdate());
|
||||
String completedStatus = PublishingEvent.Status.COMPLETED.name();
|
||||
nodeService.setProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS, completedStatus);
|
||||
}
|
||||
@@ -99,7 +98,7 @@ public class PublishingEventProcessor
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatus(Channel publishChannel, NodeRef environment, StatusUpdate update)
|
||||
public void updateStatus(Channel publishChannel, StatusUpdate update)
|
||||
{
|
||||
if(update == null)
|
||||
{
|
||||
@@ -166,7 +165,7 @@ public class PublishingEventProcessor
|
||||
{
|
||||
updatePublishedNode(publishedNode, entry);
|
||||
}
|
||||
eventHelper.linkeToLastEvent(publishedNode, eventNode);
|
||||
eventHelper.linkToLastEvent(publishedNode, eventNode);
|
||||
channel.publish(publishedNode);
|
||||
return publishedNode;
|
||||
}
|
||||
|
@@ -29,12 +29,12 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
public abstract class BaseNodePublishStatus implements NodePublishStatus
|
||||
{
|
||||
private final NodeRef nodeRef;
|
||||
private final String channelName;
|
||||
private final String channelId;
|
||||
|
||||
public BaseNodePublishStatus(NodeRef nodeRef, String channelName)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
this.channelName = channelName;
|
||||
this.channelId = channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,8 +48,8 @@ public abstract class BaseNodePublishStatus implements NodePublishStatus
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getChannelName()
|
||||
public String getChannelId()
|
||||
{
|
||||
return channelName;
|
||||
return channelId;
|
||||
}
|
||||
}
|
||||
|
@@ -35,5 +35,5 @@ public interface NodePublishStatus
|
||||
|
||||
Status getStatus();
|
||||
|
||||
String getChannelName();
|
||||
String getChannelId();
|
||||
}
|
||||
|
@@ -30,9 +30,9 @@ public class NodePublishStatusPublished extends BaseNodePublishStatus
|
||||
|
||||
private final PublishingEvent lastEvent;
|
||||
|
||||
public NodePublishStatusPublished(NodeRef node, String channelName, PublishingEvent lastEvent)
|
||||
public NodePublishStatusPublished(NodeRef node, String channelId, PublishingEvent lastEvent)
|
||||
{
|
||||
super(node, channelName);
|
||||
super(node, channelId);
|
||||
this.lastEvent = lastEvent;
|
||||
}
|
||||
|
||||
|
@@ -70,10 +70,10 @@ public interface ChannelService
|
||||
|
||||
/**
|
||||
* Rename the specified channel
|
||||
* @param oldName The current name of the channel that is to be renamed.
|
||||
* @param channel The current name of the channel that is to be renamed.
|
||||
* @param newName The new name of the channel
|
||||
*/
|
||||
void renameChannel(String oldName, String newName);
|
||||
void renameChannel(Channel channel, String newName);
|
||||
|
||||
/**
|
||||
* Update the properties of the specified channel.
|
||||
|
Reference in New Issue
Block a user