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

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

View File

@@ -74,7 +74,11 @@
</bean>
<!-- 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 -->
<bean id="pub_publishEvent" class="org.alfresco.repo.publishing.PublishEventAction" >
@@ -104,5 +108,4 @@
<bean id="publishingPackageSerializer" class="org.alfresco.repo.publishing.StandardPublishingPackageSerializer" />
<import resource="classpath:alfresco/youtube-publishing-context.xml" />
</beans>

View File

@@ -70,7 +70,7 @@
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var publishEventAction = actions.create("pub_publishEvent");
publishEventAction.execute(bpm_package);
publishEventAction.execute(pubwf_publishingEvent);
</script>
</action>
</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 static final String NAME = "channelHelper";
private NodeService nodeService;
private DictionaryService dictionaryService;
private FileFolderService fileFolderService;

View File

@@ -19,13 +19,19 @@
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 org.alfresco.repo.action.executer.ActionExecuter;
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.publishing.PublishingEvent.Status;
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
@@ -37,15 +43,19 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/
public class CheckPublishingDependenciesAction extends ActionExecuterAbstractBase
{
private NodeService nodeService;
/**
* {@inheritDoc}
*/
@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
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.model.ContentModel;
import org.alfresco.repo.node.NodeUtils;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.publishing.PublishingEvent;
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.WorkflowTask;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
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.LogFactory;
@@ -243,27 +247,36 @@ public class PublishingEventHelper
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();
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);
if (nodeService.exists(eventNode))
public Boolean apply(NodeRef node)
{
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(eventNode);
if(nodeService.exists(node))
{
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(node);
if (parentAssoc.getParentRef().equals(queue)
&& ASSOC_PUBLISHING_EVENT.equals(parentAssoc.getTypeQName()))
{
results.add(eventNode);
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)

View File

@@ -72,6 +72,11 @@ public class PublishingQueueImpl implements PublishingQueue
*/
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
{
NodeRef eventNode = publishingEventHelper.createNode(nodeRef, publishingPackage, channelName, schedule, comment, statusUpdate);