Adding "xfer:transferred" aspect

Injecting the source system's repositoryId on transfer.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20845 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2010-06-28 15:10:12 +00:00
parent cd11a35e8f
commit 33cc621490
5 changed files with 71 additions and 5 deletions

View File

@@ -186,6 +186,19 @@
</property>
</properties>
</aspect>
<aspect name="trx:transferred">
<title>Nodes with this aspect are have been transferred from one repository to another
</title>
<properties>
<property name="trx:repositoryId">
<title>Source RepositoryId</title>
<type>d:text</type>
<mandatory enforced="false">true</mandatory>
</property>
</properties>
</aspect>
</aspects>
</model>

View File

@@ -51,6 +51,11 @@ import org.apache.commons.logging.LogFactory;
/**
* @author brian
*
* The primary manifest processor is responsible for the first parsing the snapshot
* file and writing nodes into the receiving repository.
*
* New nodes may be written into a "temporary" space if their primary parent node
* has not yet been transferred.
*/
public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorBase
{
@@ -77,6 +82,16 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
private DictionaryService dictionaryService;
private CorrespondingNodeResolver nodeResolver;
// State within this class
/**
* The header of the manifest
*/
TransferManifestHeader header;
/**
* The list of orphans, during processing orphans are added and removed from this list.
* If at the end of processing there are still orphans then an exception will be thrown.
*/
private Map<NodeRef, List<ChildAssociationRef>> orphans = new HashMap<NodeRef, List<ChildAssociationRef>>(89);
/**
@@ -277,6 +292,13 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
// Split out the content properties and sanitise the others
Map<QName, Serializable> contentProps = processProperties(null, props, true);
// inject transferred property here
if(!contentProps.containsKey(TransferModel.PROP_REPOSITORY_ID))
{
log.debug("injecting repositoryId property");
props.put(TransferModel.PROP_REPOSITORY_ID, header.getRepositoryId());
}
// Create the corresponding node...
ChildAssociationRef newNode = nodeService.createNode(parentNodeRef, parentAssocType, parentAssocName, node
.getType(), props);
@@ -369,6 +391,13 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
// First, create a shallow copy of the supplied property map...
Map<QName, Serializable> props = new HashMap<QName, Serializable>(node.getProperties());
// inject transferred property here
if(!props.containsKey(TransferModel.PROP_REPOSITORY_ID))
{
log.debug("injecting repositoryId property");
props.put(TransferModel.PROP_REPOSITORY_ID, header.getRepositoryId());
}
// Split out the content properties and sanitise the others
Map<QName, Serializable> contentProps = processProperties(nodeToUpdate, props, false);
@@ -391,6 +420,7 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
}
aspectsToRemove.removeAll(suppliedAspects);
aspectsToRemove.remove(TransferModel.ASPECT_TRANSFERRED);
suppliedAspects.removeAll(existingAspects);
// Now aspectsToRemove contains the set of aspects to remove
@@ -570,6 +600,8 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
protected void processHeader(TransferManifestHeader header)
{
// squirrel away the header for later use
this.header = header;
}
/*

View File

@@ -38,6 +38,13 @@ import org.alfresco.service.namespace.RegexQNamePattern;
/**
* @author brian
*
* The secondary manifest processor performs a second parse of the snapshot file.
*
* It is responsible for linking nodes together, moving them out of the temporary space
* into their final position in the repository. At the point that this processor runs both
* ends (source and target) of the nodes' associations should be available in the receiving
* repository.
*
*/
public class RepoSecondaryManifestProcessorImpl extends AbstractManifestProcessorBase
{

View File

@@ -33,6 +33,12 @@ public interface TransferModel
static final QName ASPECT_ENABLEABLE = QName.createQName(TRANSFER_MODEL_1_0_URI, "enableable");
// static final QName ASSOC_IMAP_ATTACHMENTS_FOLDER = QName.createQName(IMAP_MODEL_1_0_URI, "attachmentsFolder");
/**
* Aspect : transferred
*/
static final QName ASPECT_TRANSFERRED = QName.createQName(TRANSFER_MODEL_1_0_URI, "transferred");
static final QName PROP_REPOSITORY_ID = QName.createQName(TRANSFER_MODEL_1_0_URI, "repositoryId");
/*
* Type : Transfer Group
*/

View File

@@ -676,6 +676,10 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
// Now set up the next test which is to
nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE_UPDATED);
}
finally
@@ -690,11 +694,11 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
* Transfer our node again - so this is an update
*/
{
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
TransferDefinition definition = new TransferDefinition();
Set<NodeRef>nodes = new HashSet<NodeRef>();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
@@ -710,6 +714,10 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE_UPDATED);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
// Check injected transferred aspect.
assertNotNull("transferredAspect", (String)nodeService.getProperty(destNodeRef, TransferModel.PROP_REPOSITORY_ID));
}
finally
{