mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Full Repository Export / Import Support - first checkpoint
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2591 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -39,6 +39,7 @@ import org.alfresco.service.cmr.view.ImporterBinding;
|
||||
import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.view.Location;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
@@ -202,6 +203,11 @@ public class ExportSourceImporter implements ImporterJobSPI
|
||||
return false;
|
||||
}
|
||||
|
||||
public QName[] getExcludedClasses()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -75,6 +75,14 @@ public interface Importer
|
||||
*/
|
||||
public NodeRef resolvePath(String path);
|
||||
|
||||
/**
|
||||
* Is excluded Content Model Class?
|
||||
*
|
||||
* @param QName the class name to test
|
||||
* @return true => the provided class is excluded from import
|
||||
*/
|
||||
public boolean isExcludedClass(QName className);
|
||||
|
||||
/**
|
||||
* Signal completion of node import
|
||||
*
|
||||
|
@@ -313,7 +313,7 @@ public class ImporterBootstrap implements ApplicationListener
|
||||
}
|
||||
|
||||
UserTransaction userTransaction = transactionService.getUserTransaction();
|
||||
authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -550,7 +550,7 @@ public class ImporterBootstrap implements ApplicationListener
|
||||
public UUID_BINDING getUUIDBinding()
|
||||
{
|
||||
// always use create new strategy for bootstrap import
|
||||
return UUID_BINDING.CREATE_NEW;
|
||||
return UUID_BINDING.CREATE_NEW_WITH_UUID;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -561,6 +561,16 @@ public class ImporterBootstrap implements ApplicationListener
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ImporterBinding#getExcludedClasses()
|
||||
*/
|
||||
public QName[] getExcludedClasses()
|
||||
{
|
||||
// Note: Do not exclude any classes, we want to import all
|
||||
return new QName[] {};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -401,6 +401,7 @@ public class ImporterComponent
|
||||
private ImportPackageHandler streamHandler;
|
||||
private NodeImporterStrategy importStrategy;
|
||||
private UpdateExistingNodeImporterStrategy updateStrategy;
|
||||
private QName[] excludedClasses;
|
||||
|
||||
// Import tracking
|
||||
private List<ImportedNodeRef> nodeRefs = new ArrayList<ImportedNodeRef>();
|
||||
@@ -422,6 +423,16 @@ public class ImporterComponent
|
||||
this.streamHandler = streamHandler;
|
||||
this.importStrategy = createNodeImporterStrategy(binding == null ? null : binding.getUUIDBinding());
|
||||
this.updateStrategy = new UpdateExistingNodeImporterStrategy();
|
||||
|
||||
// initialise list of content models to exclude from import
|
||||
if (binding == null || binding.getExcludedClasses() == null)
|
||||
{
|
||||
this.excludedClasses = new QName[] { ContentModel.ASPECT_REFERENCEABLE, ContentModel.ASPECT_VERSIONABLE };
|
||||
}
|
||||
else
|
||||
{
|
||||
this.excludedClasses = binding.getExcludedClasses();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,6 +451,10 @@ public class ImporterComponent
|
||||
{
|
||||
return new CreateNewNodeImporterStrategy(true);
|
||||
}
|
||||
else if (uuidBinding.equals(UUID_BINDING.CREATE_NEW_WITH_UUID))
|
||||
{
|
||||
return new CreateNewNodeImporterStrategy(false);
|
||||
}
|
||||
else if (uuidBinding.equals(UUID_BINDING.REMOVE_EXISTING))
|
||||
{
|
||||
return new RemoveExistingNodeImporterStrategy();
|
||||
@@ -652,6 +667,22 @@ public class ImporterComponent
|
||||
}
|
||||
return referencedRef;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.importer.Importer#isExcludedClass(org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
public boolean isExcludedClass(QName className)
|
||||
{
|
||||
for (QName excludedClass : excludedClasses)
|
||||
{
|
||||
if (excludedClass.equals(className))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.importer.Importer#end()
|
||||
@@ -670,13 +701,16 @@ public class ImporterComponent
|
||||
List<NodeRef> resolvedRefs = new ArrayList<NodeRef>(unresolvedRefs.size());
|
||||
for (String unresolvedRef : unresolvedRefs)
|
||||
{
|
||||
NodeRef nodeRef = resolveImportedNodeRef(importedRef.context.getNodeRef(), unresolvedRef);
|
||||
if (nodeRef == null)
|
||||
if (unresolvedRef != null)
|
||||
{
|
||||
// TODO: Probably need an alternative mechanism here e.g. report warning
|
||||
throw new ImporterException("Failed to find item referenced (in property " + importedRef.property + ") as " + importedRef.value);
|
||||
NodeRef nodeRef = resolveImportedNodeRef(importedRef.context.getNodeRef(), unresolvedRef);
|
||||
if (nodeRef == null)
|
||||
{
|
||||
// TODO: Probably need an alternative mechanism here e.g. report warning
|
||||
throw new ImporterException("Failed to find item referenced (in property " + importedRef.property + ") as " + importedRef.value);
|
||||
}
|
||||
resolvedRefs.add(nodeRef);
|
||||
}
|
||||
resolvedRefs.add(nodeRef);
|
||||
}
|
||||
refProperty = (Serializable)resolvedRefs;
|
||||
}
|
||||
@@ -998,19 +1032,11 @@ public class ImporterComponent
|
||||
}
|
||||
catch(XPathException e)
|
||||
{
|
||||
// attempt to resolve as a node reference
|
||||
try
|
||||
{
|
||||
NodeRef directRef = new NodeRef(importedRef);
|
||||
if (nodeService.exists(directRef))
|
||||
{
|
||||
nodeRef = directRef;
|
||||
}
|
||||
}
|
||||
catch(AlfrescoRuntimeException e1)
|
||||
{
|
||||
// Note: Invalid reference format
|
||||
}
|
||||
nodeRef = new NodeRef(importedRef);
|
||||
}
|
||||
catch(AlfrescoRuntimeException e1)
|
||||
{
|
||||
// Note: Invalid reference format - try path search instead
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -459,8 +459,7 @@ public class NodeContext extends ElementContext
|
||||
*/
|
||||
private boolean isImportableClass(QName className)
|
||||
{
|
||||
return !(className.equals(ContentModel.ASPECT_REFERENCEABLE) ||
|
||||
className.equals(ContentModel.ASPECT_VERSIONABLE));
|
||||
return !getImporter().isExcludedClass(className);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
Reference in New Issue
Block a user