mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -186,6 +186,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
</aspect>
|
</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>
|
</aspects>
|
||||||
|
|
||||||
</model>
|
</model>
|
||||||
|
@@ -51,6 +51,11 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
/**
|
/**
|
||||||
* @author brian
|
* @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
|
public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorBase
|
||||||
{
|
{
|
||||||
@@ -76,7 +81,17 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
|||||||
private ContentService contentService;
|
private ContentService contentService;
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
private CorrespondingNodeResolver nodeResolver;
|
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);
|
private Map<NodeRef, List<ChildAssociationRef>> orphans = new HashMap<NodeRef, List<ChildAssociationRef>>(89);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -276,6 +291,13 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
|||||||
|
|
||||||
// Split out the content properties and sanitise the others
|
// Split out the content properties and sanitise the others
|
||||||
Map<QName, Serializable> contentProps = processProperties(null, props, true);
|
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...
|
// Create the corresponding node...
|
||||||
ChildAssociationRef newNode = nodeService.createNode(parentNodeRef, parentAssocType, parentAssocName, node
|
ChildAssociationRef newNode = nodeService.createNode(parentNodeRef, parentAssocType, parentAssocName, node
|
||||||
@@ -368,6 +390,13 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
|||||||
// We need to process content properties separately.
|
// We need to process content properties separately.
|
||||||
// First, create a shallow copy of the supplied property map...
|
// First, create a shallow copy of the supplied property map...
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(node.getProperties());
|
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
|
// Split out the content properties and sanitise the others
|
||||||
Map<QName, Serializable> contentProps = processProperties(nodeToUpdate, props, false);
|
Map<QName, Serializable> contentProps = processProperties(nodeToUpdate, props, false);
|
||||||
@@ -391,6 +420,7 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
|||||||
}
|
}
|
||||||
|
|
||||||
aspectsToRemove.removeAll(suppliedAspects);
|
aspectsToRemove.removeAll(suppliedAspects);
|
||||||
|
aspectsToRemove.remove(TransferModel.ASPECT_TRANSFERRED);
|
||||||
suppliedAspects.removeAll(existingAspects);
|
suppliedAspects.removeAll(existingAspects);
|
||||||
|
|
||||||
// Now aspectsToRemove contains the set of aspects to remove
|
// Now aspectsToRemove contains the set of aspects to remove
|
||||||
@@ -570,6 +600,8 @@ public class RepoPrimaryManifestProcessorImpl extends AbstractManifestProcessorB
|
|||||||
|
|
||||||
protected void processHeader(TransferManifestHeader header)
|
protected void processHeader(TransferManifestHeader header)
|
||||||
{
|
{
|
||||||
|
// squirrel away the header for later use
|
||||||
|
this.header = header;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -38,6 +38,13 @@ import org.alfresco.service.namespace.RegexQNamePattern;
|
|||||||
/**
|
/**
|
||||||
* @author brian
|
* @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
|
public class RepoSecondaryManifestProcessorImpl extends AbstractManifestProcessorBase
|
||||||
{
|
{
|
||||||
|
@@ -33,6 +33,12 @@ public interface TransferModel
|
|||||||
static final QName ASPECT_ENABLEABLE = QName.createQName(TRANSFER_MODEL_1_0_URI, "enableable");
|
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");
|
// 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
|
* Type : Transfer Group
|
||||||
*/
|
*/
|
||||||
|
@@ -676,6 +676,10 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
|
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
|
||||||
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
|
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);
|
nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE_UPDATED);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -690,11 +694,11 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
* Transfer our node again - so this is an update
|
* Transfer our node again - so this is an update
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
TransferDefinition definition = new TransferDefinition();
|
TransferDefinition definition = new TransferDefinition();
|
||||||
Set<NodeRef>nodes = new HashSet<NodeRef>();
|
Set<NodeRef>nodes = new HashSet<NodeRef>();
|
||||||
nodes.add(contentNodeRef);
|
nodes.add(contentNodeRef);
|
||||||
definition.setNodes(nodes);
|
definition.setNodes(nodes);
|
||||||
transferService.transfer(targetName, definition);
|
transferService.transfer(targetName, definition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -710,6 +714,10 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
|
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("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE_UPDATED);
|
||||||
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
|
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
|
finally
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user