Implemented publishing-queue.post REST API method.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28632 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
N Smith
2011-06-27 20:30:37 +00:00
parent ba4fb00961
commit a1549380bf
8 changed files with 218 additions and 79 deletions

View File

@@ -652,4 +652,9 @@ encryption.keystore.password=mp6yc0UD9e
# The password protecting the alias: metadata # The password protecting the alias: metadata
encryption.keystore.password.metadata=oKIWzVdEdA encryption.keystore.password.metadata=oKIWzVdEdA
# The password protecting the alias: solr # The password protecting the alias: solr
encryption.keystore.password.solr=TxHTtOnrwQ encryption.keystore.password.solr=TxHTtOnrwQ
#
# Web Publishing Properties
#
publishing.default.environment=live

View File

@@ -2,7 +2,7 @@
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans> <beans>
<bean id="publishingService_dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap"> <bean id="publishingService_dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models"> <property name="models">
<list> <list>
<value>alfresco/model/publishingModel.xml</value> <value>alfresco/model/publishingModel.xml</value>
@@ -10,7 +10,7 @@
</property> </property>
</bean> </bean>
<!-- Bootstrap the publishing process definition --> <!-- Bootstrap the publishing process definition -->
<bean parent="workflowDeployer"> <bean parent="workflowDeployer">
<property name="workflowDefinitions"> <property name="workflowDefinitions">
<list> <list>
@@ -29,80 +29,83 @@
</property> </property>
</bean> </bean>
<bean id="publishingResourceBundles" class="org.alfresco.i18n.ResourceBundleBootstrapComponent"> <bean id="publishingResourceBundles" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
<property name="resourceBundles"> <property name="resourceBundles">
<list> <list>
<value>alfresco.messages.publishing-service</value> <value>alfresco.messages.publishing-service</value>
</list> </list>
</property> </property>
</bean> </bean>
<!-- Channel Service --> <!-- Channel Service -->
<bean id="channelService" class="org.alfresco.repo.publishing.ChannelServiceImpl"> <bean id="channelService" class="org.alfresco.repo.publishing.ChannelServiceImpl">
<property name="dictionaryService" ref="DictionaryService" /> <property name="dictionaryService" ref="DictionaryService" />
<property name="nodeService" ref="NodeService" /> <property name="nodeService" ref="NodeService" />
<property name="siteService" ref="SiteService" /> <property name="siteService" ref="SiteService" />
<property name="environmentHelper" ref="environmentHelper" /> <property name="environmentHelper" ref="environmentHelper" />
<property name="channelHelper" ref="channelHelper" /> <property name="channelHelper" ref="channelHelper" />
</bean> </bean>
<!-- Channel Type Implementations --> <!-- Channel Type Implementations -->
<bean id="baseChannelType" class="org.alfresco.repo.publishing.AbstractChannelType" abstract="true"> <bean id="baseChannelType" class="org.alfresco.repo.publishing.AbstractChannelType" abstract="true" >
<property name="channelService" ref="channelService" /> <property name="channelService" ref="channelService" />
<property name="serviceRegistry" ref="ServiceRegistry" /> <property name="serviceRegistry" ref="ServiceRegistry" />
</bean> </bean>
<bean id="channelHelper" class="org.alfresco.repo.publishing.ChannelHelper"> <bean id="channelHelper" class="org.alfresco.repo.publishing.ChannelHelper">
<property name="nodeService" ref="NodeService" /> <property name="nodeService" ref="NodeService" />
<property name="dictionaryService" ref="DictionaryService" /> <property name="dictionaryService" ref="DictionaryService" />
<property name="fileFolderService" ref="FileFolderService" /> <property name="fileFolderService" ref="FileFolderService" />
</bean> </bean>
<bean id="environmentHelper" class="org.alfresco.repo.publishing.EnvironmentHelper"> <bean id="environmentHelper" class="org.alfresco.repo.publishing.EnvironmentHelper">
<property name="nodeService" ref="NodeService" /> <property name="nodeService" ref="NodeService" />
<property name="siteService" ref="SiteService" /> <property name="siteService" ref="SiteService" />
<property name="publishingEventHelper" ref="publishingEventHelper" /> <property name="publishingEventHelper" ref="publishingEventHelper" />
<property name="channelHelper" ref="channelHelper" /> <property name="channelHelper" ref="channelHelper" />
</bean> </bean>
<bean id="publishingEventHelper" class="org.alfresco.repo.publishing.PublishingEventHelper"> <bean id="publishingEventHelper" class="org.alfresco.repo.publishing.PublishingEventHelper">
<property name="nodeService" ref="NodeService" /> <property name="nodeService" ref="NodeService" />
<property name="contentService" ref="ContentService" /> <property name="contentService" ref="ContentService" />
<property name="serializer" ref="publishingPackageSerializer" /> <property name="serializer" ref="publishingPackageSerializer" />
<property name="workflowService" ref="WorkflowService" /> <property name="workflowService" ref="WorkflowService" />
<property name="workflowEngineId" value="jbpm" /> <property name="workflowEngineId" value="jbpm" />
</bean> </bean>
<!-- Check Publishing Dependencies Action --> <!-- Check Publishing Dependencies Action -->
<bean id="pub_checkPublishingDependencies" class="org.alfresco.repo.publishing.CheckPublishingDependenciesAction" /> <bean id="pub_checkPublishingDependencies"
class="org.alfresco.repo.publishing.CheckPublishingDependenciesAction" >
<property name="nodeService" ref="NodeService" />
</bean>
<!-- Publish Event Action --> <!-- Publish Event Action -->
<bean id="pub_publishEvent" class="org.alfresco.repo.publishing.PublishEventAction"> <bean id="pub_publishEvent" class="org.alfresco.repo.publishing.PublishEventAction" >
<property name="publishingEventProcessor" ref="publishingEventProcessor" /> <property name="publishingEventProcessor" ref="publishingEventProcessor" />
</bean> </bean>
<!-- Publishing Event Processor --> <!-- Publishing Event Processor -->
<bean id="publishingEventProcessor" class="org.alfresco.repo.publishing.PublishingEventProcessor"> <bean id="publishingEventProcessor" class="org.alfresco.repo.publishing.PublishingEventProcessor">
<property name="channelHelper" ref="channelHelper" /> <property name="channelHelper" ref="channelHelper" />
<property name="channelService" ref="channelService" /> <property name="channelService" ref="channelService" />
<property name="publishingEventHelper" ref="publishingEventHelper" /> <property name="publishingEventHelper" ref="publishingEventHelper" />
<property name="nodeService" ref="NodeService" /> <property name="nodeService" ref="NodeService" />
<property name="behaviourFilter" ref="policyBehaviourFilter" /> <property name="behaviourFilter" ref="policyBehaviourFilter" />
</bean> </bean>
<bean id="publishingObjectFactory" class="org.alfresco.repo.publishing.PublishingObjectFactory"> <bean id="publishingObjectFactory" class="org.alfresco.repo.publishing.PublishingObjectFactory">
<property name="environmentHelper" ref="environmentHelper" /> <property name="environmentHelper" ref="environmentHelper" />
<property name="transferManifestNodeFactory" ref="transferManifestNodeFactory" /> <property name="transferManifestNodeFactory" ref="transferManifestNodeFactory" />
<property name="publishingEventHelper" ref="publishingEventHelper" /> <property name="publishingEventHelper" ref="publishingEventHelper" />
</bean> </bean>
<!-- Publishing Service -->
<bean id="publishingService" class="org.alfresco.repo.publishing.PublishServiceImpl">
<property name="environmentFactory" ref="publishingObjectFactory" />
<property name="publishingEventHelper" ref="publishingEventHelper" />
</bean>
<bean id="publishingPackageSerializer" class="org.alfresco.repo.publishing.StandardPublishingPackageSerializer" />
<!-- Publishing Service -->
<bean id="publishingService" class="org.alfresco.repo.publishing.PublishServiceImpl">
<property name="environmentFactory" ref="publishingObjectFactory" />
<property name="publishingEventHelper" ref="publishingEventHelper" />
</bean>
<bean id="publishingPackageSerializer" class="org.alfresco.repo.publishing.StandardPublishingPackageSerializer" />
<import resource="classpath:alfresco/youtube-publishing-context.xml" />
</beans> </beans>

View File

@@ -70,7 +70,7 @@
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript"> <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script> <script>
var publishEventAction = actions.create("pub_publishEvent"); var publishEventAction = actions.create("pub_publishEvent");
publishEventAction.execute(bpm_package); publishEventAction.execute(pubwf_publishingEvent);
</script> </script>
</action> </action>
</event> </event>

View File

@@ -0,0 +1,95 @@
/*
* 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.node;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.util.collections.Filter;
import org.alfresco.util.collections.Function;
/**
* @author Nick Smith
* @since 4.0
*
*/
public abstract class NodeUtils
{
public static Function<String, NodeRef> toNodeRef()
{
return new Function<String, NodeRef>()
{
public NodeRef apply(String value)
{
return new NodeRef(value);
}
};
}
public static Function<ChildAssociationRef, NodeRef> toChildRef()
{
return new Function<ChildAssociationRef, NodeRef>()
{
public NodeRef apply(ChildAssociationRef value)
{
return value.getChildRef();
}
};
}
public static Function<ChildAssociationRef, NodeRef> toParentRef()
{
return new Function<ChildAssociationRef, NodeRef>()
{
public NodeRef apply(ChildAssociationRef value)
{
return value.getParentRef();
}
};
}
public static Function<String, NodeRef> toNodeRefQueitly()
{
return new Function<String, NodeRef>()
{
public NodeRef apply(String value)
{
if(value!=null && NodeRef.isNodeRef(value))
{
return new NodeRef(value);
}
return null;
}
};
}
public static Filter<NodeRef> exists(final NodeService nodeService)
{
return new Filter<NodeRef>()
{
public Boolean apply(NodeRef value)
{
return nodeService.exists(value);
}
};
}
}

View File

@@ -64,6 +64,8 @@ import org.alfresco.util.collections.Function;
*/ */
public class ChannelHelper public class ChannelHelper
{ {
public static final String NAME = "channelHelper";
private NodeService nodeService; private NodeService nodeService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
private FileFolderService fileFolderService; private FileFolderService fileFolderService;

View File

@@ -19,13 +19,19 @@
package org.alfresco.repo.publishing; package org.alfresco.repo.publishing;
import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_STATUS;
import static org.alfresco.repo.publishing.PublishingModel.TYPE_PUBLISHING_EVENT;
import java.util.List; import java.util.List;
import org.alfresco.repo.action.executer.ActionExecuter; import org.alfresco.repo.action.executer.ActionExecuter;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition; import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.publishing.PublishingEvent.Status;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
/** /**
* This {@link ActionExecuter} checks the status of the publishing event * This {@link ActionExecuter} checks the status of the publishing event
@@ -37,15 +43,19 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/ */
public class CheckPublishingDependenciesAction extends ActionExecuterAbstractBase public class CheckPublishingDependenciesAction extends ActionExecuterAbstractBase
{ {
private NodeService nodeService;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) protected void executeImpl(Action action, NodeRef node)
{ {
// TODO Implement execute method. QName nodeType = nodeService.getType(node);
if(TYPE_PUBLISHING_EVENT.equals(nodeType))
{
nodeService.setProperty(node, PROP_PUBLISHING_EVENT_STATUS, Status.IN_PROGRESS);
}
} }
/** /**
@@ -54,8 +64,14 @@ public class CheckPublishingDependenciesAction extends ActionExecuterAbstractBas
@Override @Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{ {
// TODO Implement parameter definitions. //NOOP
} }
/**
* @param nodeService the nodeService to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
} }

View File

@@ -52,6 +52,7 @@ import java.util.TimeZone;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.NodeUtils;
import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.publishing.PublishingEvent; import org.alfresco.service.cmr.publishing.PublishingEvent;
import org.alfresco.service.cmr.publishing.PublishingEvent.Status; import org.alfresco.service.cmr.publishing.PublishingEvent.Status;
@@ -69,7 +70,10 @@ import org.alfresco.service.cmr.workflow.WorkflowPath;
import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask; import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.GUID; import org.alfresco.util.GUID;
import org.alfresco.util.collections.CollectionUtils;
import org.alfresco.util.collections.Filter;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -243,27 +247,36 @@ public class PublishingEventHelper
return results; return results;
} }
public List<NodeRef> findPublishingEventNodes(NodeRef queue, PublishingEventFilter filter) public List<NodeRef> findPublishingEventNodes(final NodeRef queue, PublishingEventFilter filter)
{ {
List<NodeRef> results = new ArrayList<NodeRef>();
Set<String> ids = filter.getIds(); Set<String> ids = filter.getIds();
if(ids != null) if(ids != null && ids.isEmpty() == false)
{ {
for (String id : ids) List<NodeRef> nodes = CollectionUtils.transform(ids, NodeUtils.toNodeRefQueitly());
// Filter out nodes that are not Publishing Events on the specified queue.
return CollectionUtils.filter(nodes, new Filter<NodeRef>()
{ {
NodeRef eventNode = new NodeRef(id); public Boolean apply(NodeRef node)
if (nodeService.exists(eventNode))
{ {
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(eventNode); if(nodeService.exists(node))
if (parentAssoc.getParentRef().equals(queue)
&& ASSOC_PUBLISHING_EVENT.equals(parentAssoc.getTypeQName()))
{ {
results.add(eventNode); ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(node);
if (parentAssoc.getParentRef().equals(queue)
&& ASSOC_PUBLISHING_EVENT.equals(parentAssoc.getTypeQName()))
{
return true;
}
} }
return false;
} }
} });
}
else
{
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(queue,
ASSOC_PUBLISHING_EVENT, RegexQNamePattern.MATCH_ALL);
return CollectionUtils.transform(assocs, NodeUtils.toChildRef());
} }
return results;
} }
public List<PublishingEvent> findPublishingEvents(NodeRef queue, PublishingEventFilter filter) public List<PublishingEvent> findPublishingEvents(NodeRef queue, PublishingEventFilter filter)

View File

@@ -72,6 +72,11 @@ public class PublishingQueueImpl implements PublishingQueue
*/ */
public String scheduleNewEvent(PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate) public String scheduleNewEvent(PublishingPackage publishingPackage, String channelName, Calendar schedule, String comment, StatusUpdate statusUpdate)
{ {
if(schedule == null)
{
schedule = Calendar.getInstance();
schedule.add(Calendar.SECOND, 1);
}
try try
{ {
NodeRef eventNode = publishingEventHelper.createNode(nodeRef, publishingPackage, channelName, schedule, comment, statusUpdate); NodeRef eventNode = publishingEventHelper.createNode(nodeRef, publishingPackage, channelName, schedule, comment, statusUpdate);