diff --git a/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java b/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java
index c472b7bec1..729e89266e 100644
--- a/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java
+++ b/source/java/org/alfresco/repo/publishing/ChannelServiceImpl.java
@@ -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 channelContainer = getChannelContainer();
- NodeRef channel = nodeService.getChildByName(channelContainer, ContentModel.ASSOC_CONTAINS, oldName);
- if (channel != null)
+ NodeRef channelNode = channel.getNodeRef();
+ if (channelNode != null && nodeService.exists(channelNode))
{
- nodeService.setProperty(channel, ContentModel.PROP_NAME, newName);
- nodeService.moveNode(channel, channelContainer, ContentModel.ASSOC_CONTAINS,
+ NodeRef channelContainer = getChannelContainer();
+ 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);
diff --git a/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java b/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java
index 3eb8dbfa07..e7e86142b1 100644
--- a/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java
+++ b/source/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java
@@ -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);
diff --git a/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java b/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java
deleted file mode 100644
index fff0d01a37..0000000000
--- a/source/java/org/alfresco/repo/publishing/EnvironmentHelper.java
+++ /dev/null
@@ -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 .
- */
-
-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 eventNodes = publishingEventHelper.getEventNodesForPublishedNodes(queue, node);
-// for (NodeRef eventNode: eventNodes)
-// {
-// if (isActiveEvent(eventNode))
-// {
-// Map 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;
-// }
-
-}
diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java
index a17ac2fe7a..d017ff9350 100644
--- a/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java
+++ b/source/java/org/alfresco/repo/publishing/PublishingEventHelper.java
@@ -508,16 +508,8 @@ public class PublishingEventHelper
//Otherwise this event has already been processed or has already been cancelled. Do nothing.
}
}
-
- 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 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;
+// }
+
}
diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java b/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java
index a7d0b5cf6f..3ae050dd4b 100644
--- a/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java
+++ b/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java
@@ -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;
}
diff --git a/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java b/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java
index 00b242e369..d7a9a383b0 100644
--- a/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java
+++ b/source/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java
@@ -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;
}
}
diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java
index c712fce942..2d83262549 100644
--- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java
+++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java
@@ -35,5 +35,5 @@ public interface NodePublishStatus
Status getStatus();
- String getChannelName();
+ String getChannelId();
}
diff --git a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java
index e3979358a3..30e0c0a6e9 100644
--- a/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java
+++ b/source/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java
@@ -30,9 +30,9 @@ public class NodePublishStatusPublished extends BaseNodePublishStatus
private final PublishingEvent lastEvent;
- public NodePublishStatusPublished(NodeRef node, String channelName, PublishingEvent lastEvent)
+ public NodePublishStatusPublished(NodeRef node, String channelId, PublishingEvent lastEvent)
{
- super(node, channelName);
+ super(node, channelId);
this.lastEvent = lastEvent;
}
diff --git a/source/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java b/source/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java
index a46d074441..3ec6c3f46c 100644
--- a/source/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java
+++ b/source/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java
@@ -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.