mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixed unpublishing events.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29696 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -103,7 +103,7 @@
|
|||||||
<property name="publishingEventHelper" ref="publishingEventHelper" />
|
<property name="publishingEventHelper" ref="publishingEventHelper" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="publishingPackageSerializer" class="org.alfresco.repo.publishing.StandardPublishingPackageSerializer" />
|
<bean id="publishingPackageSerializer" class="org.alfresco.repo.publishing.StandardNodeSnapshotSerializer" />
|
||||||
|
|
||||||
<bean id="urlShortener" class="org.alfresco.repo.urlshortening.BitlyUrlShortenerImpl" >
|
<bean id="urlShortener" class="org.alfresco.repo.urlshortening.BitlyUrlShortenerImpl" >
|
||||||
<property name="username" value="${urlshortening.bitly.username}" />
|
<property name="username" value="${urlshortening.bitly.username}" />
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
package org.alfresco.repo.publishing;
|
package org.alfresco.repo.publishing;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -42,7 +43,6 @@ import org.alfresco.service.namespace.QName;
|
|||||||
public class NodeSnapshotTransferImpl implements NodeSnapshot
|
public class NodeSnapshotTransferImpl implements NodeSnapshot
|
||||||
{
|
{
|
||||||
private final TransferManifestNormalNode transferNode;
|
private final TransferManifestNormalNode transferNode;
|
||||||
private final String version;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param transferNode
|
* @param transferNode
|
||||||
@@ -50,88 +50,107 @@ public class NodeSnapshotTransferImpl implements NodeSnapshot
|
|||||||
public NodeSnapshotTransferImpl(TransferManifestNormalNode transferNode)
|
public NodeSnapshotTransferImpl(TransferManifestNormalNode transferNode)
|
||||||
{
|
{
|
||||||
this.transferNode = transferNode;
|
this.transferNode = transferNode;
|
||||||
Map<QName, Serializable> props = transferNode.getProperties();
|
|
||||||
this.version = (String) props.get(ContentModel.PROP_VERSION_LABEL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.alfresco.service.cmr.publishing.NodeSnapshot#getAllParentAssocs()
|
|
||||||
*/
|
|
||||||
public List<ChildAssociationRef> getAllParentAssocs()
|
public List<ChildAssociationRef> getAllParentAssocs()
|
||||||
{
|
{
|
||||||
|
if(transferNode==null)
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
return transferNode.getParentAssocs();
|
return transferNode.getParentAssocs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.service.cmr.publishing.NodeSnapshot#getAspects()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Set<QName> getAspects()
|
public Set<QName> getAspects()
|
||||||
{
|
{
|
||||||
|
if(transferNode==null)
|
||||||
|
{
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
return transferNode.getAspects();
|
return transferNode.getAspects();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.service.cmr.publishing.NodeSnapshot#getNodeRef()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public NodeRef getNodeRef()
|
public NodeRef getNodeRef()
|
||||||
{
|
{
|
||||||
|
if(transferNode==null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return transferNode.getNodeRef();
|
return transferNode.getNodeRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.service.cmr.publishing.NodeSnapshot#getOutboundPeerAssociations()
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public List<AssociationRef> getOutboundPeerAssociations()
|
public List<AssociationRef> getOutboundPeerAssociations()
|
||||||
{
|
{
|
||||||
|
if(transferNode==null)
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
return transferNode.getTargetAssocs();
|
return transferNode.getTargetAssocs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.service.cmr.publishing.NodeSnapshot#getPrimaryParentAssoc()
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public ChildAssociationRef getPrimaryParentAssoc()
|
public ChildAssociationRef getPrimaryParentAssoc()
|
||||||
{
|
{
|
||||||
|
if(transferNode==null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return transferNode.getPrimaryParentAssoc();
|
return transferNode.getPrimaryParentAssoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.service.cmr.publishing.NodeSnapshot#getPrimaryPath()
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Path getPrimaryPath()
|
public Path getPrimaryPath()
|
||||||
{
|
{
|
||||||
|
if(transferNode==null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return transferNode.getParentPath();
|
return transferNode.getParentPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.service.cmr.publishing.NodeSnapshot#getProperties()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Map<QName, Serializable> getProperties()
|
public Map<QName, Serializable> getProperties()
|
||||||
{
|
{
|
||||||
|
if(transferNode==null)
|
||||||
|
{
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
return transferNode.getProperties();
|
return transferNode.getProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.service.cmr.publishing.NodeSnapshot#getType()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public QName getType()
|
public QName getType()
|
||||||
{
|
{
|
||||||
|
if(transferNode==null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return transferNode.getType();
|
return transferNode.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getVersion()
|
public String getVersion()
|
||||||
{
|
{
|
||||||
return version;
|
return (String) getProperties().get(ContentModel.PROP_VERSION_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -46,7 +46,12 @@ import javax.annotation.Resource;
|
|||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.service.cmr.publishing.NodeSnapshot;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingDetails;
|
import org.alfresco.service.cmr.publishing.PublishingDetails;
|
||||||
|
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
||||||
|
import org.alfresco.service.cmr.publishing.PublishingPackage;
|
||||||
|
import org.alfresco.service.cmr.publishing.PublishingPackageEntry;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingService;
|
import org.alfresco.service.cmr.publishing.PublishingService;
|
||||||
import org.alfresco.service.cmr.publishing.Status;
|
import org.alfresco.service.cmr.publishing.Status;
|
||||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||||
@@ -215,12 +220,30 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest
|
|||||||
assertTrue(nodeService.exists(publishedNode));
|
assertTrue(nodeService.exists(publishedNode));
|
||||||
|
|
||||||
// Unpublish source node.
|
// Unpublish source node.
|
||||||
publishNode(source, null, false);
|
NodeRef eventNode = publishNode(source, null, false);
|
||||||
|
|
||||||
// Check the published node no longer exists.
|
// Check the published node no longer exists.
|
||||||
assertFalse(nodeService.exists(publishedNode));
|
assertFalse(nodeService.exists(publishedNode));
|
||||||
publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode);
|
publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode);
|
||||||
assertNull(publishedNode);
|
assertNull(publishedNode);
|
||||||
|
|
||||||
|
// Check can generate a valid snapshot for the unpublish entry.
|
||||||
|
PublishingEvent event = publishingService.getPublishingEvent(eventNode.toString());
|
||||||
|
PublishingPackage packg = event.getPackage();
|
||||||
|
|
||||||
|
Set<NodeRef> toUnpublish = packg.getNodesToUnpublish();
|
||||||
|
assertEquals(1, toUnpublish.size());
|
||||||
|
assertTrue(toUnpublish.contains(source));
|
||||||
|
|
||||||
|
PublishingPackageEntry entry = packg.getEntryMap().get(source);
|
||||||
|
assertEquals(false, entry.isPublish());
|
||||||
|
|
||||||
|
NodeSnapshot snapshot = entry.getSnapshot();
|
||||||
|
assertEquals(source, snapshot.getNodeRef());
|
||||||
|
assertEquals(ContentModel.TYPE_CONTENT, snapshot.getType());
|
||||||
|
Serializable name = nodeService.getProperty(source, ContentModel.PROP_NAME);
|
||||||
|
assertEquals(name, snapshot.getProperties().get(ContentModel.PROP_NAME));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@@ -42,7 +42,6 @@ import static org.alfresco.util.collections.CollectionUtils.isEmpty;
|
|||||||
import static org.alfresco.util.collections.CollectionUtils.toListOfStrings;
|
import static org.alfresco.util.collections.CollectionUtils.toListOfStrings;
|
||||||
import static org.alfresco.util.collections.CollectionUtils.transform;
|
import static org.alfresco.util.collections.CollectionUtils.transform;
|
||||||
import static org.alfresco.util.collections.CollectionUtils.transformFlat;
|
import static org.alfresco.util.collections.CollectionUtils.transformFlat;
|
||||||
import static org.alfresco.util.collections.CollectionUtils.transformToMap;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@@ -90,7 +89,6 @@ 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.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.alfresco.util.collections.Filter;
|
||||||
import org.alfresco.util.collections.Function;
|
import org.alfresco.util.collections.Function;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -506,7 +504,9 @@ public class PublishingEventHelper
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
NodeRef channelNode = new NodeRef(details.getPublishChannelId());
|
||||||
List<NodeSnapshot> snapshots = createPublishSnapshots(details.getNodesToPublish());
|
List<NodeSnapshot> snapshots = createPublishSnapshots(details.getNodesToPublish());
|
||||||
|
snapshots.addAll(createUnpublishSnapshots(details.getNodesToUnpublish(), channelNode));
|
||||||
ContentWriter contentWriter = contentService.getWriter(eventNode,
|
ContentWriter contentWriter = contentService.getWriter(eventNode,
|
||||||
PROP_PUBLISHING_EVENT_PAYLOAD, true);
|
PROP_PUBLISHING_EVENT_PAYLOAD, true);
|
||||||
contentWriter.setEncoding("UTF-8");
|
contentWriter.setEncoding("UTF-8");
|
||||||
@@ -522,31 +522,24 @@ public class PublishingEventHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PublishingPackage getPublishingPackage(NodeRef eventNode, String channelId) throws AlfrescoRuntimeException
|
private List<NodeSnapshot> createUnpublishSnapshots(Set<NodeRef> nodes, final NodeRef channelNode)
|
||||||
{
|
{
|
||||||
Map<NodeRef, PublishingPackageEntry> publishEntires = getPublishEntries(eventNode);
|
return transform(nodes, new Function<NodeRef, NodeSnapshot>()
|
||||||
Map<NodeRef, PublishingPackageEntry> allEntries = getUnpublishEntries(eventNode, channelId);
|
|
||||||
allEntries.putAll(publishEntires);
|
|
||||||
return new PublishingPackageImpl(allEntries);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<NodeRef, PublishingPackageEntry> createPublishEntries(Collection<NodeRef> nodesToAdd)
|
|
||||||
{
|
{
|
||||||
return transformToMap(nodesToAdd, new Function<NodeRef, PublishingPackageEntry>()
|
public NodeSnapshot apply(NodeRef node)
|
||||||
{
|
{
|
||||||
public PublishingPackageEntry apply(NodeRef node)
|
return createUnpublishSnapshot(node, channelNode);
|
||||||
{
|
|
||||||
return createPublishEntry(node);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private PublishingPackageEntry createPublishEntry(NodeRef node)
|
private PublishingPackage getPublishingPackage(NodeRef eventNode, String channelId) throws AlfrescoRuntimeException
|
||||||
{
|
{
|
||||||
NodeSnapshotTransferImpl snapshot = createPublishSnapshot(node);
|
Map<NodeRef, PublishingPackageEntry> entries = getPublishingPackageEntries(eventNode);
|
||||||
return new PublishingPackageEntryImpl(true, node, snapshot);
|
return new PublishingPackageImpl(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<NodeSnapshot> createPublishSnapshots(final Collection<NodeRef> nodes)
|
private List<NodeSnapshot> createPublishSnapshots(final Collection<NodeRef> nodes)
|
||||||
{
|
{
|
||||||
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<List<NodeSnapshot>>()
|
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<List<NodeSnapshot>>()
|
||||||
@@ -572,8 +565,11 @@ public class PublishingEventHelper
|
|||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<NodeRef, PublishingPackageEntry> getPublishEntries(NodeRef eventNode)
|
@SuppressWarnings("unchecked")
|
||||||
|
private Map<NodeRef, PublishingPackageEntry> getPublishingPackageEntries(NodeRef eventNode)
|
||||||
{
|
{
|
||||||
|
List<String> idsToUnpublish = (List<String>) nodeService.getProperty(eventNode, PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH);
|
||||||
|
List<NodeRef> nodesToUnpublish = NodeUtils.toNodeRefs(idsToUnpublish);
|
||||||
ContentReader contentReader = contentService.getReader(eventNode, PROP_PUBLISHING_EVENT_PAYLOAD);
|
ContentReader contentReader = contentService.getReader(eventNode, PROP_PUBLISHING_EVENT_PAYLOAD);
|
||||||
InputStream input = contentReader.getContentInputStream();
|
InputStream input = contentReader.getContentInputStream();
|
||||||
try
|
try
|
||||||
@@ -583,7 +579,8 @@ public class PublishingEventHelper
|
|||||||
for (NodeSnapshot snapshot : snapshots)
|
for (NodeSnapshot snapshot : snapshots)
|
||||||
{
|
{
|
||||||
NodeRef node = snapshot.getNodeRef();
|
NodeRef node = snapshot.getNodeRef();
|
||||||
PublishingPackageEntryImpl entry = new PublishingPackageEntryImpl(true, node, snapshot);
|
boolean isPublish = false == nodesToUnpublish.contains(node);
|
||||||
|
PublishingPackageEntryImpl entry = new PublishingPackageEntryImpl(isPublish, node, snapshot);
|
||||||
entries.put(node, entry);
|
entries.put(node, entry);
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
@@ -595,40 +592,18 @@ public class PublishingEventHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<NodeRef, PublishingPackageEntry> getUnpublishEntries(NodeRef eventNode, String channelId)
|
|
||||||
{
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<String> entries= (List<String>) nodeService.getProperty(eventNode, PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH);
|
|
||||||
if(CollectionUtils.isEmpty(entries))
|
|
||||||
{
|
|
||||||
return new HashMap<NodeRef, PublishingPackageEntry>();
|
|
||||||
}
|
|
||||||
final NodeRef channelNode = new NodeRef(channelId);
|
|
||||||
List<NodeRef> nodes = NodeUtils.toNodeRefs(entries);
|
|
||||||
return transformToMap(nodes, new Function<NodeRef, PublishingPackageEntry>()
|
|
||||||
{
|
|
||||||
public PublishingPackageEntry apply(NodeRef node)
|
|
||||||
{
|
|
||||||
if(NodeUtils.exists(node, nodeService))
|
|
||||||
{
|
|
||||||
return makeUnpublishEntry(node, channelNode);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private PublishingPackageEntry makeUnpublishEntry(NodeRef source, NodeRef channelNode)
|
private NodeSnapshot createUnpublishSnapshot(NodeRef source, NodeRef channelNode)
|
||||||
{
|
{
|
||||||
NodeRef lastEvent = getLastPublishEvent(source, channelNode);
|
NodeRef lastEvent = getLastPublishEvent(source, channelNode);
|
||||||
NodeSnapshot snapshot = null;
|
if(lastEvent==null)
|
||||||
if(lastEvent!=null)
|
|
||||||
{
|
{
|
||||||
Map<NodeRef, PublishingPackageEntry> entries = getPublishEntries(lastEvent);
|
String msg = "Cannot create unpublish snapshot as last publishing event does not exist! Source node: "+ source + " channelId: "+channelNode;
|
||||||
PublishingPackageEntry entry = entries.get(source);
|
throw new AlfrescoRuntimeException(msg);
|
||||||
snapshot = entry.getSnapshot();
|
|
||||||
}
|
}
|
||||||
return new PublishingPackageEntryImpl(false, source, snapshot);
|
Map<NodeRef, PublishingPackageEntry> entries = getPublishingPackageEntries(lastEvent);
|
||||||
|
PublishingPackageEntry entry = entries.get(source);
|
||||||
|
return entry.getSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeRef getLastPublishEvent(NodeRef source, NodeRef channelNode)
|
public NodeRef getLastPublishEvent(NodeRef source, NodeRef channelNode)
|
||||||
@@ -684,55 +659,8 @@ public class PublishingEventHelper
|
|||||||
return nodeService.createAssociation(publishedNode, eventNode, ASSOC_LAST_PUBLISHING_EVENT);
|
return nodeService.createAssociation(publishedNode, eventNode, ASSOC_LAST_PUBLISHING_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PublishingDetails createPublishingPackageBuilder()
|
public PublishingDetails createPublishingDetails()
|
||||||
{
|
{
|
||||||
return new PublishingDetailsImpl();
|
return new PublishingDetailsImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -55,7 +55,7 @@ import org.junit.Test;
|
|||||||
public class PublishingPackageSerializerTest extends AbstractPublishingIntegrationTest
|
public class PublishingPackageSerializerTest extends AbstractPublishingIntegrationTest
|
||||||
{
|
{
|
||||||
@Resource(name="publishingPackageSerializer")
|
@Resource(name="publishingPackageSerializer")
|
||||||
private StandardPublishingPackageSerializer serializer;
|
private StandardNodeSnapshotSerializer serializer;
|
||||||
|
|
||||||
private TransferManifestNormalNode normalNode1;
|
private TransferManifestNormalNode normalNode1;
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ public class PublishingPackageSerializerTest extends AbstractPublishingIntegrati
|
|||||||
public void onSetUp() throws Exception
|
public void onSetUp() throws Exception
|
||||||
{
|
{
|
||||||
super.onSetUp();
|
super.onSetUp();
|
||||||
serializer = (StandardPublishingPackageSerializer) getApplicationContext().getBean("publishingPackageSerializer");
|
serializer = (StandardNodeSnapshotSerializer) getApplicationContext().getBean("publishingPackageSerializer");
|
||||||
normalNode1 = new TransferManifestNormalNode();
|
normalNode1 = new TransferManifestNormalNode();
|
||||||
normalNode1.setAccessControl(null);
|
normalNode1.setAccessControl(null);
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ public class PublishingQueueImpl implements PublishingQueue
|
|||||||
*/
|
*/
|
||||||
public PublishingDetails createPublishingDetails()
|
public PublishingDetails createPublishingDetails()
|
||||||
{
|
{
|
||||||
return publishingEventHelper.createPublishingPackageBuilder();
|
return publishingEventHelper.createPublishingDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -33,7 +33,10 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.service.cmr.publishing.NodeSnapshot;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingDetails;
|
import org.alfresco.service.cmr.publishing.PublishingDetails;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingPackage;
|
import org.alfresco.service.cmr.publishing.PublishingPackage;
|
||||||
@@ -69,7 +72,6 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest
|
|||||||
{
|
{
|
||||||
NodeRef firstNode = createContent("First");
|
NodeRef firstNode = createContent("First");
|
||||||
NodeRef secondNode = createContent("second");
|
NodeRef secondNode = createContent("second");
|
||||||
NodeRef thirdNode = createContent("third");
|
|
||||||
|
|
||||||
assertNull(nodeService.getProperty(firstNode, PROP_VERSION_LABEL));
|
assertNull(nodeService.getProperty(firstNode, PROP_VERSION_LABEL));
|
||||||
assertNull(nodeService.getProperty(firstNode, PROP_VERSION_LABEL));
|
assertNull(nodeService.getProperty(firstNode, PROP_VERSION_LABEL));
|
||||||
@@ -79,7 +81,6 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest
|
|||||||
|
|
||||||
PublishingDetails details = publishingService.getPublishingQueue().createPublishingDetails()
|
PublishingDetails details = publishingService.getPublishingQueue().createPublishingDetails()
|
||||||
.addNodesToPublish(firstNode, secondNode)
|
.addNodesToPublish(firstNode, secondNode)
|
||||||
.addNodesToUnpublish(thirdNode)
|
|
||||||
.setPublishChannel(channelId)
|
.setPublishChannel(channelId)
|
||||||
.setSchedule(schedule)
|
.setSchedule(schedule)
|
||||||
.setComment(comment);
|
.setComment(comment);
|
||||||
@@ -119,8 +120,7 @@ public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest
|
|||||||
assertTrue(toPublish.contains(firstNode));
|
assertTrue(toPublish.contains(firstNode));
|
||||||
assertTrue(toPublish.contains(secondNode));
|
assertTrue(toPublish.contains(secondNode));
|
||||||
|
|
||||||
assertEquals(1, toUnpublish.size());
|
assertEquals(0, toUnpublish.size());
|
||||||
assertTrue(toUnpublish.contains(thirdNode));
|
|
||||||
|
|
||||||
// Check the correct version is recorded in the entry.
|
// Check the correct version is recorded in the entry.
|
||||||
PublishingPackageEntry entry = pckg.getEntryMap().get(firstNode);
|
PublishingPackageEntry entry = pckg.getEntryMap().get(firstNode);
|
||||||
|
@@ -38,10 +38,14 @@ import java.util.Map;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingDetails;
|
import org.alfresco.service.cmr.publishing.PublishingDetails;
|
||||||
|
import org.alfresco.service.cmr.publishing.PublishingEvent;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
import org.alfresco.service.cmr.publishing.PublishingQueue;
|
||||||
import org.alfresco.service.cmr.publishing.PublishingService;
|
import org.alfresco.service.cmr.publishing.PublishingService;
|
||||||
|
import org.alfresco.service.cmr.publishing.Status;
|
||||||
import org.alfresco.service.cmr.publishing.channels.Channel;
|
import org.alfresco.service.cmr.publishing.channels.Channel;
|
||||||
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
import org.alfresco.service.cmr.publishing.channels.ChannelService;
|
||||||
import org.alfresco.service.cmr.publishing.channels.ChannelType;
|
import org.alfresco.service.cmr.publishing.channels.ChannelType;
|
||||||
@@ -272,4 +276,31 @@ public class PublishingTestHelper
|
|||||||
writer.putContent(theContent);
|
writer.putContent(theContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PublishingEvent publishAndWait(final PublishingDetails details, RetryingTransactionHelper transactionHelper) throws InterruptedException
|
||||||
|
{
|
||||||
|
RetryingTransactionCallback<String> startWorkflowCallback = new RetryingTransactionCallback<String>()
|
||||||
|
{
|
||||||
|
public String execute() throws Throwable
|
||||||
|
{
|
||||||
|
return scheduleEvent(details);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
String eventId = transactionHelper.doInTransaction(startWorkflowCallback);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while(i<100)
|
||||||
|
{
|
||||||
|
Thread.sleep(200);
|
||||||
|
PublishingEvent event = publishingService.getPublishingEvent(eventId);
|
||||||
|
Status status = event.getStatus();
|
||||||
|
if(Status.IN_PROGRESS!=status && Status.SCHEDULED!=status)
|
||||||
|
{
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("The publishing event did not complete after 20s!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,6 @@ package org.alfresco.repo.publishing;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -32,6 +31,7 @@ import java.util.List;
|
|||||||
import javax.xml.parsers.SAXParser;
|
import javax.xml.parsers.SAXParser;
|
||||||
import javax.xml.parsers.SAXParserFactory;
|
import javax.xml.parsers.SAXParserFactory;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.transfer.manifest.TransferManifestDeletedNode;
|
import org.alfresco.repo.transfer.manifest.TransferManifestDeletedNode;
|
||||||
import org.alfresco.repo.transfer.manifest.TransferManifestHeader;
|
import org.alfresco.repo.transfer.manifest.TransferManifestHeader;
|
||||||
import org.alfresco.repo.transfer.manifest.TransferManifestNormalNode;
|
import org.alfresco.repo.transfer.manifest.TransferManifestNormalNode;
|
||||||
@@ -39,13 +39,12 @@ import org.alfresco.repo.transfer.manifest.TransferManifestProcessor;
|
|||||||
import org.alfresco.repo.transfer.manifest.XMLTransferManifestReader;
|
import org.alfresco.repo.transfer.manifest.XMLTransferManifestReader;
|
||||||
import org.alfresco.repo.transfer.manifest.XMLTransferManifestWriter;
|
import org.alfresco.repo.transfer.manifest.XMLTransferManifestWriter;
|
||||||
import org.alfresco.service.cmr.publishing.NodeSnapshot;
|
import org.alfresco.service.cmr.publishing.NodeSnapshot;
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brian
|
* @author Brian
|
||||||
* @author Nick Smith
|
* @author Nick Smith
|
||||||
*/
|
*/
|
||||||
public class StandardPublishingPackageSerializer implements NodeSnapshotSerializer
|
public class StandardNodeSnapshotSerializer implements NodeSnapshotSerializer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
@@ -94,14 +93,9 @@ public class StandardPublishingPackageSerializer implements NodeSnapshotSerializ
|
|||||||
transferManifestWriter.endTransferManifest();
|
transferManifestWriter.endTransferManifest();
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
catch (SAXException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated catch block
|
throw new AlfrescoRuntimeException("Failed to serialize node snapshots.", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException e)
|
|
||||||
{
|
|
||||||
//UTF-8 must be supported, so this is not going to happen
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user