mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
AR-380 - Export/Import of Forums/Discussions failed.
AR-395 - Provide abstract bean definition for DictionaryBootstrap Fix build issue; JCR Import failed due to recent extension config changes Fix issue in ISO9075 encoder; failed to encode colon properly meaning that Discussion Posts (with have colon seperated dates in their name) were not importing/exporting. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2299 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -418,8 +418,11 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="dictionaryBootstrap" class="org.alfresco.repo.dictionary.DictionaryBootstrap" init-method="bootstrap">
|
<bean id="dictionaryModelBootstrap" class="org.alfresco.repo.dictionary.DictionaryBootstrap" init-method="bootstrap" abstract="true">
|
||||||
<property name="dictionaryDAO"><ref local="dictionaryDAO"/></property>
|
<property name="dictionaryDAO"><ref local="dictionaryDAO"/></property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="dictionaryBootstrap" parent="dictionaryModelBootstrap">
|
||||||
<property name="models">
|
<property name="models">
|
||||||
<list>
|
<list>
|
||||||
<value>alfresco/model/dictionaryModel.xml</value>
|
<value>alfresco/model/dictionaryModel.xml</value>
|
||||||
|
@@ -310,6 +310,28 @@ import org.alfresco.service.namespace.QName;
|
|||||||
exporter.endAssocs(nodeRef);
|
exporter.endAssocs(nodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.view.Exporter#startReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||||
|
*/
|
||||||
|
public void startReference(NodeRef nodeRef, QName childName)
|
||||||
|
{
|
||||||
|
for (Exporter exporter : exporters)
|
||||||
|
{
|
||||||
|
exporter.startReference(nodeRef, childName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.view.Exporter#endReference(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
public void endReference(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
for (Exporter exporter : exporters)
|
||||||
|
{
|
||||||
|
exporter.endReference(nodeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
|
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
|
||||||
|
@@ -23,25 +23,27 @@ import java.io.Serializable;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
|
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.cmr.security.AccessPermission;
|
import org.alfresco.service.cmr.security.AccessPermission;
|
||||||
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
import org.alfresco.service.cmr.security.AccessStatus;
|
|
||||||
import org.alfresco.service.cmr.view.ExportPackageHandler;
|
import org.alfresco.service.cmr.view.ExportPackageHandler;
|
||||||
import org.alfresco.service.cmr.view.Exporter;
|
import org.alfresco.service.cmr.view.Exporter;
|
||||||
import org.alfresco.service.cmr.view.ExporterContext;
|
import org.alfresco.service.cmr.view.ExporterContext;
|
||||||
@@ -53,12 +55,12 @@ import org.alfresco.service.cmr.view.Location;
|
|||||||
import org.alfresco.service.descriptor.DescriptorService;
|
import org.alfresco.service.descriptor.DescriptorService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.dom4j.io.OutputFormat;
|
import org.dom4j.io.OutputFormat;
|
||||||
import org.dom4j.io.XMLWriter;
|
import org.dom4j.io.XMLWriter;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of the Exporter Service.
|
* Default implementation of the Exporter Service.
|
||||||
*
|
*
|
||||||
@@ -229,23 +231,32 @@ public class ExporterComponent
|
|||||||
*/
|
*/
|
||||||
private class DefaultCrawler implements ExporterCrawler
|
private class DefaultCrawler implements ExporterCrawler
|
||||||
{
|
{
|
||||||
// Flush threshold
|
private ExporterContext context;
|
||||||
private int flushThreshold = 500;
|
private Map<NodeRef, NodeRef> nodesWithSecondaryLinks = new HashMap<NodeRef, NodeRef>();
|
||||||
private int flushCount = 0;
|
private Map<NodeRef, NodeRef> nodesWithAssociations = new HashMap<NodeRef, NodeRef>();
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.view.ExporterCrawler#export(org.alfresco.service.cmr.view.Exporter)
|
* @see org.alfresco.service.cmr.view.ExporterCrawler#export(org.alfresco.service.cmr.view.Exporter)
|
||||||
*/
|
*/
|
||||||
public void export(ExporterCrawlerParameters parameters, Exporter exporter)
|
public void export(ExporterCrawlerParameters parameters, Exporter exporter)
|
||||||
{
|
{
|
||||||
ExporterContext context = new ExporterContextImpl(parameters);
|
// Initialise Crawler
|
||||||
|
nodesWithSecondaryLinks.clear();
|
||||||
|
nodesWithAssociations.clear();
|
||||||
|
context = new ExporterContextImpl(parameters);
|
||||||
exporter.start(context);
|
exporter.start(context);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Export Nodes
|
||||||
|
//
|
||||||
|
|
||||||
// determine if root repository node
|
// determine if root repository node
|
||||||
NodeRef nodeRef = context.getExportOf();
|
NodeRef nodeRef = context.getExportOf();
|
||||||
boolean rootNode = nodeService.getRootNode(nodeRef.getStoreRef()).equals(nodeRef);
|
boolean rootNode = nodeService.getRootNode(nodeRef.getStoreRef()).equals(nodeRef);
|
||||||
if (parameters.isCrawlSelf() && !rootNode)
|
if (parameters.isCrawlSelf() && !rootNode)
|
||||||
{
|
{
|
||||||
|
// export root node of specified export location
|
||||||
walkStartNamespaces(parameters, exporter);
|
walkStartNamespaces(parameters, exporter);
|
||||||
walkNode(nodeRef, parameters, exporter);
|
walkNode(nodeRef, parameters, exporter);
|
||||||
walkEndNamespaces(parameters, exporter);
|
walkEndNamespaces(parameters, exporter);
|
||||||
@@ -261,6 +272,28 @@ public class ExporterComponent
|
|||||||
walkEndNamespaces(parameters, exporter);
|
walkEndNamespaces(parameters, exporter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Export Secondary Links between Nodes
|
||||||
|
//
|
||||||
|
|
||||||
|
for (NodeRef nodeWithAssociations : nodesWithSecondaryLinks.keySet())
|
||||||
|
{
|
||||||
|
walkStartNamespaces(parameters, exporter);
|
||||||
|
walkNodeSecondaryLinks(nodeWithAssociations, parameters, exporter);
|
||||||
|
walkEndNamespaces(parameters, exporter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Export Associations between Nodes
|
||||||
|
//
|
||||||
|
|
||||||
|
for (NodeRef nodeWithAssociations : nodesWithAssociations.keySet())
|
||||||
|
{
|
||||||
|
walkStartNamespaces(parameters, exporter);
|
||||||
|
walkNodeAssociations(nodeWithAssociations, parameters, exporter);
|
||||||
|
walkEndNamespaces(parameters, exporter);
|
||||||
|
}
|
||||||
|
|
||||||
exporter.end();
|
exporter.end();
|
||||||
}
|
}
|
||||||
@@ -310,14 +343,6 @@ public class ExporterComponent
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we need to flush?
|
|
||||||
flushCount++;
|
|
||||||
if (flushCount > flushThreshold)
|
|
||||||
{
|
|
||||||
AlfrescoTransactionSupport.flush();
|
|
||||||
flushCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
exporter.startNode(nodeRef);
|
exporter.startNode(nodeRef);
|
||||||
|
|
||||||
// Export node aspects
|
// Export node aspects
|
||||||
@@ -451,6 +476,11 @@ public class ExporterComponent
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (childAssoc.isPrimary() == false)
|
||||||
|
{
|
||||||
|
nodesWithSecondaryLinks.put(nodeRef, nodeRef);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (i == 0 || childAssocs.get(i - 1).getTypeQName().equals(childAssocType) == false)
|
if (i == 0 || childAssocs.get(i - 1).getTypeQName().equals(childAssocType) == false)
|
||||||
{
|
{
|
||||||
exporter.startAssoc(nodeRef, childAssocType);
|
exporter.startAssoc(nodeRef, childAssocType);
|
||||||
@@ -467,12 +497,114 @@ public class ExporterComponent
|
|||||||
exporter.endAssocs(nodeRef);
|
exporter.endAssocs(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Export node associations
|
// Export node associations
|
||||||
|
if (parameters.isCrawlAssociations())
|
||||||
|
{
|
||||||
|
List<AssociationRef> associations = nodeService.getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL);
|
||||||
|
if (associations.size() > 0)
|
||||||
|
{
|
||||||
|
nodesWithAssociations.put(nodeRef, nodeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Signal end of node
|
// Signal end of node
|
||||||
exporter.endNode(nodeRef);
|
exporter.endNode(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export Secondary Links
|
||||||
|
*
|
||||||
|
* @param nodeRef
|
||||||
|
* @param parameters
|
||||||
|
* @param exporter
|
||||||
|
*/
|
||||||
|
private void walkNodeSecondaryLinks(NodeRef nodeRef, ExporterCrawlerParameters parameters, Exporter exporter)
|
||||||
|
{
|
||||||
|
exporter.startReference(nodeRef, null);
|
||||||
|
exporter.startAssocs(nodeRef);
|
||||||
|
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef);
|
||||||
|
for (int i = 0; i < childAssocs.size(); i++)
|
||||||
|
{
|
||||||
|
ChildAssociationRef childAssoc = childAssocs.get(i);
|
||||||
|
|
||||||
|
// determine if child association should be exported
|
||||||
|
QName childAssocType = childAssoc.getTypeQName();
|
||||||
|
if (isExcludedURI(parameters.getExcludeNamespaceURIs(), childAssocType.getNamespaceURI()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (childAssoc.isPrimary())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isWithinExport(childAssoc.getChildRef(), parameters))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// export the association
|
||||||
|
if (i == 0 || childAssocs.get(i - 1).getTypeQName().equals(childAssocType) == false)
|
||||||
|
{
|
||||||
|
exporter.startAssoc(nodeRef, childAssocType);
|
||||||
|
}
|
||||||
|
QName childName = childAssoc.getQName();
|
||||||
|
if (!isExcludedURI(parameters.getExcludeNamespaceURIs(), childName.getNamespaceURI()))
|
||||||
|
{
|
||||||
|
exporter.startReference(childAssoc.getChildRef(), childName);
|
||||||
|
exporter.endReference(childAssoc.getChildRef());
|
||||||
|
}
|
||||||
|
if (i == childAssocs.size() - 1 || childAssocs.get(i + 1).getTypeQName().equals(childAssocType) == false)
|
||||||
|
{
|
||||||
|
exporter.endAssoc(nodeRef, childAssocType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exporter.endAssocs(nodeRef);
|
||||||
|
exporter.endReference(nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export Node Associations
|
||||||
|
*
|
||||||
|
* @param nodeRef
|
||||||
|
* @param parameters
|
||||||
|
* @param exporter
|
||||||
|
*/
|
||||||
|
private void walkNodeAssociations(NodeRef nodeRef, ExporterCrawlerParameters parameters, Exporter exporter)
|
||||||
|
{
|
||||||
|
exporter.startReference(nodeRef, null);
|
||||||
|
exporter.startAssocs(nodeRef);
|
||||||
|
List<AssociationRef> assocs = nodeService.getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL);
|
||||||
|
for (int i = 0; i < assocs.size(); i++)
|
||||||
|
{
|
||||||
|
AssociationRef assoc = assocs.get(i);
|
||||||
|
|
||||||
|
// determine if association should be exported
|
||||||
|
QName assocType = assoc.getTypeQName();
|
||||||
|
if (isExcludedURI(parameters.getExcludeNamespaceURIs(), assocType.getNamespaceURI()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isWithinExport(assoc.getTargetRef(), parameters))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// export the association
|
||||||
|
if (i == 0 || assocs.get(i - 1).getTypeQName().equals(assocType) == false)
|
||||||
|
{
|
||||||
|
exporter.startAssoc(nodeRef, assocType);
|
||||||
|
}
|
||||||
|
exporter.startReference(assoc.getTargetRef(), null);
|
||||||
|
exporter.endReference(assoc.getTargetRef());
|
||||||
|
if (i == assocs.size() - 1 || assocs.get(i + 1).getTypeQName().equals(assocType) == false)
|
||||||
|
{
|
||||||
|
exporter.endAssoc(nodeRef, assocType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exporter.endAssocs(nodeRef);
|
||||||
|
exporter.endReference(nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the specified URI an excluded URI?
|
* Is the specified URI an excluded URI?
|
||||||
*
|
*
|
||||||
@@ -491,6 +623,40 @@ public class ExporterComponent
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if specified Node Reference is within the set of nodes to be exported
|
||||||
|
*
|
||||||
|
* @param nodeRef node reference to check
|
||||||
|
* @return true => node reference is within export set
|
||||||
|
*/
|
||||||
|
private boolean isWithinExport(NodeRef nodeRef, ExporterCrawlerParameters parameters)
|
||||||
|
{
|
||||||
|
boolean isWithin = false;
|
||||||
|
|
||||||
|
// Current strategy is to determine if node is a child of the root exported node
|
||||||
|
NodeRef exportRoot = context.getExportOf();
|
||||||
|
if (nodeRef.equals(exportRoot) && parameters.isCrawlSelf() == true)
|
||||||
|
{
|
||||||
|
// node to export is the root export node (and root is to be exported)
|
||||||
|
isWithin = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// locate export root in primary parent path of node
|
||||||
|
Path nodePath = nodeService.getPath(nodeRef);
|
||||||
|
for (int i = nodePath.size() -1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
Path.ChildAssocElement pathElement = (Path.ChildAssocElement)nodePath.get(i);
|
||||||
|
if (pathElement.getRef().getChildRef().equals(exportRoot))
|
||||||
|
{
|
||||||
|
isWithin = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isWithin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -500,6 +666,7 @@ public class ExporterComponent
|
|||||||
private class ExporterContextImpl implements ExporterContext
|
private class ExporterContextImpl implements ExporterContext
|
||||||
{
|
{
|
||||||
private NodeRef exportOf;
|
private NodeRef exportOf;
|
||||||
|
private NodeRef parent;
|
||||||
private String exportedBy;
|
private String exportedBy;
|
||||||
private Date exportedDate;
|
private Date exportedDate;
|
||||||
private String exporterVersion;
|
private String exporterVersion;
|
||||||
@@ -521,6 +688,9 @@ public class ExporterComponent
|
|||||||
// get export of
|
// get export of
|
||||||
exportOf = getNodeRef(parameters.getExportFrom());
|
exportOf = getNodeRef(parameters.getExportFrom());
|
||||||
|
|
||||||
|
// get export parent
|
||||||
|
parent = getParent(exportOf, parameters.isCrawlSelf());
|
||||||
|
|
||||||
// get exporter version
|
// get exporter version
|
||||||
exporterVersion = descriptorService.getServerDescriptor().getVersion();
|
exporterVersion = descriptorService.getServerDescriptor().getVersion();
|
||||||
}
|
}
|
||||||
@@ -557,6 +727,15 @@ public class ExporterComponent
|
|||||||
return exportOf;
|
return exportOf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.view.ExporterContext#getExportParent()
|
||||||
|
*/
|
||||||
|
public NodeRef getExportParent()
|
||||||
|
{
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Node Ref from the specified Location
|
* Get the Node Ref from the specified Location
|
||||||
*
|
*
|
||||||
@@ -567,7 +746,7 @@ public class ExporterComponent
|
|||||||
{
|
{
|
||||||
ParameterCheck.mandatory("Location", location);
|
ParameterCheck.mandatory("Location", location);
|
||||||
|
|
||||||
// Establish node to import within
|
// Establish node to export from
|
||||||
NodeRef nodeRef = (location == null) ? null : location.getNodeRef();
|
NodeRef nodeRef = (location == null) ? null : location.getNodeRef();
|
||||||
if (nodeRef == null)
|
if (nodeRef == null)
|
||||||
{
|
{
|
||||||
@@ -596,7 +775,39 @@ public class ExporterComponent
|
|||||||
|
|
||||||
return nodeRef;
|
return nodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the parent node of the items to be exported
|
||||||
|
*
|
||||||
|
* @param exportOf
|
||||||
|
* @param exportSelf
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private NodeRef getParent(NodeRef exportOf, boolean exportSelf)
|
||||||
|
{
|
||||||
|
NodeRef parent = null;
|
||||||
|
|
||||||
|
if (exportSelf)
|
||||||
|
{
|
||||||
|
NodeRef rootNode = nodeService.getRootNode(exportOf.getStoreRef());
|
||||||
|
if (rootNode.equals(exportOf))
|
||||||
|
{
|
||||||
|
parent = exportOf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChildAssociationRef parentRef = nodeService.getPrimaryParent(exportOf);
|
||||||
|
parent = parentRef.getParentRef();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parent = exportOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -231,6 +231,16 @@ public class ExporterComponentTest extends BaseSpringTest
|
|||||||
// System.out.println("TestProgress: endACL: " + nodeRef);
|
// System.out.println("TestProgress: endACL: " + nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startReference(NodeRef nodeRef, QName childName)
|
||||||
|
{
|
||||||
|
// System.out.println("TestProgress: startReference: " + nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endReference(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
// System.out.println("TestProgress: endReference: " + nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -243,7 +243,24 @@ import org.alfresco.util.ParameterCheck;
|
|||||||
{
|
{
|
||||||
exporter.endAssocs(nodeRef);
|
exporter.endAssocs(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.view.Exporter#startReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||||
|
*/
|
||||||
|
public void startReference(NodeRef nodeRef, QName childName)
|
||||||
|
{
|
||||||
|
exporter.startReference(nodeRef, childName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.view.Exporter#endReference(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
public void endReference(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
exporter.endReference(nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
|
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@@ -69,6 +69,8 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
private static final String AUTHORITY_LOCALNAME = "authority";
|
private static final String AUTHORITY_LOCALNAME = "authority";
|
||||||
private static final String PERMISSION_LOCALNAME = "permission";
|
private static final String PERMISSION_LOCALNAME = "permission";
|
||||||
private static final String INHERITPERMISSIONS_LOCALNAME = "inherit";
|
private static final String INHERITPERMISSIONS_LOCALNAME = "inherit";
|
||||||
|
private static final String REFERENCE_LOCALNAME = "reference";
|
||||||
|
private static final String PATHREF_LOCALNAME = "pathref";
|
||||||
private static QName VIEW_QNAME;
|
private static QName VIEW_QNAME;
|
||||||
private static QName VALUES_QNAME;
|
private static QName VALUES_QNAME;
|
||||||
private static QName VALUE_QNAME;
|
private static QName VALUE_QNAME;
|
||||||
@@ -89,6 +91,8 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
private static QName AUTHORITY_QNAME;
|
private static QName AUTHORITY_QNAME;
|
||||||
private static QName PERMISSION_QNAME;
|
private static QName PERMISSION_QNAME;
|
||||||
private static QName INHERITPERMISSIONS_QNAME;
|
private static QName INHERITPERMISSIONS_QNAME;
|
||||||
|
private static QName REFERENCE_QNAME;
|
||||||
|
private static QName PATHREF_QNAME;
|
||||||
private static final AttributesImpl EMPTY_ATTRIBUTES = new AttributesImpl();
|
private static final AttributesImpl EMPTY_ATTRIBUTES = new AttributesImpl();
|
||||||
|
|
||||||
// Service dependencies
|
// Service dependencies
|
||||||
@@ -99,7 +103,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
|
|
||||||
// View context
|
// View context
|
||||||
private ContentHandler contentHandler;
|
private ContentHandler contentHandler;
|
||||||
private Path exportNodePath;
|
private ExporterContext context;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,6 +142,8 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
AUTHORITY_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, AUTHORITY_LOCALNAME, namespaceService);
|
AUTHORITY_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, AUTHORITY_LOCALNAME, namespaceService);
|
||||||
PERMISSION_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PERMISSION_LOCALNAME, namespaceService);
|
PERMISSION_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PERMISSION_LOCALNAME, namespaceService);
|
||||||
INHERITPERMISSIONS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, INHERITPERMISSIONS_LOCALNAME, namespaceService);
|
INHERITPERMISSIONS_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, INHERITPERMISSIONS_LOCALNAME, namespaceService);
|
||||||
|
REFERENCE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, REFERENCE_LOCALNAME, namespaceService);
|
||||||
|
PATHREF_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_PREFIX, PATHREF_LOCALNAME, namespaceService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -148,7 +154,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
exportNodePath = nodeService.getPath(context.getExportOf());
|
this.context = context;
|
||||||
contentHandler.startDocument();
|
contentHandler.startDocument();
|
||||||
contentHandler.startPrefixMapping(NamespaceService.REPOSITORY_VIEW_PREFIX, NamespaceService.REPOSITORY_VIEW_1_0_URI);
|
contentHandler.startPrefixMapping(NamespaceService.REPOSITORY_VIEW_PREFIX, NamespaceService.REPOSITORY_VIEW_1_0_URI);
|
||||||
contentHandler.startElement(NamespaceService.REPOSITORY_VIEW_PREFIX, VIEW_LOCALNAME, VIEW_QNAME.toPrefixString(), EMPTY_ATTRIBUTES);
|
contentHandler.startElement(NamespaceService.REPOSITORY_VIEW_PREFIX, VIEW_LOCALNAME, VIEW_QNAME.toPrefixString(), EMPTY_ATTRIBUTES);
|
||||||
@@ -176,7 +182,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
|
|
||||||
// export of
|
// export of
|
||||||
contentHandler.startElement(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTOF_LOCALNAME, EXPORTOF_QNAME.toPrefixString(), EMPTY_ATTRIBUTES);
|
contentHandler.startElement(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTOF_LOCALNAME, EXPORTOF_QNAME.toPrefixString(), EMPTY_ATTRIBUTES);
|
||||||
String path = exportNodePath.toPrefixString(namespaceService);
|
String path = nodeService.getPath(context.getExportOf()).toPrefixString(namespaceService);
|
||||||
contentHandler.characters(path.toCharArray(), 0, path.length());
|
contentHandler.characters(path.toCharArray(), 0, path.length());
|
||||||
contentHandler.endElement(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTOF_LOCALNAME, EXPORTOF_QNAME.toPrefixString());
|
contentHandler.endElement(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTOF_LOCALNAME, EXPORTOF_QNAME.toPrefixString());
|
||||||
|
|
||||||
@@ -474,7 +480,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
// convert node references to paths
|
// convert node references to paths
|
||||||
if (value instanceof NodeRef)
|
if (value instanceof NodeRef)
|
||||||
{
|
{
|
||||||
Path nodeRefPath = createRelativePath(nodeRef, (NodeRef)value);
|
Path nodeRefPath = createRelativePath(context.getExportOf(), nodeRef, (NodeRef)value);
|
||||||
value = (nodeRefPath == null) ? null : nodeRefPath.toPrefixString(namespaceService);
|
value = (nodeRefPath == null) ? null : nodeRefPath.toPrefixString(namespaceService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +559,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
// convert node references to paths
|
// convert node references to paths
|
||||||
if (value instanceof NodeRef)
|
if (value instanceof NodeRef)
|
||||||
{
|
{
|
||||||
value = createRelativePath(nodeRef, (NodeRef)value).toPrefixString(namespaceService);
|
value = createRelativePath(context.getExportOf(), nodeRef, (NodeRef)value).toPrefixString(namespaceService);
|
||||||
}
|
}
|
||||||
|
|
||||||
// output value
|
// output value
|
||||||
@@ -643,6 +649,44 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
throw new ExporterException("Failed to process end associations", e);
|
throw new ExporterException("Failed to process end associations", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.view.Exporter#startReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||||
|
*/
|
||||||
|
public void startReference(NodeRef nodeRef, QName childName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Path path = createRelativePath(context.getExportParent(), context.getExportParent(), nodeRef);
|
||||||
|
AttributesImpl attrs = new AttributesImpl();
|
||||||
|
attrs.addAttribute(NamespaceService.REPOSITORY_VIEW_1_0_URI, PATHREF_LOCALNAME, PATHREF_QNAME.toPrefixString(), null, path.toPrefixString(namespaceService));
|
||||||
|
if (childName != null)
|
||||||
|
{
|
||||||
|
attrs.addAttribute(NamespaceService.REPOSITORY_VIEW_1_0_URI, CHILDNAME_LOCALNAME, CHILDNAME_QNAME.toPrefixString(), null, childName.toPrefixString(namespaceService));
|
||||||
|
}
|
||||||
|
contentHandler.startElement(REFERENCE_QNAME.getNamespaceURI(), REFERENCE_LOCALNAME, toPrefixString(REFERENCE_QNAME), attrs);
|
||||||
|
}
|
||||||
|
catch (SAXException e)
|
||||||
|
{
|
||||||
|
throw new ExporterException("Failed to process start reference", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.view.Exporter#endReference(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
public void endReference(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
contentHandler.endElement(REFERENCE_QNAME.getNamespaceURI(), REFERENCE_LOCALNAME, toPrefixString(REFERENCE_QNAME));
|
||||||
|
}
|
||||||
|
catch (SAXException e)
|
||||||
|
{
|
||||||
|
throw new ExporterException("Failed to process end reference", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
|
* @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
|
||||||
@@ -685,7 +729,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
* @param toRef to reference
|
* @param toRef to reference
|
||||||
* @return path
|
* @return path
|
||||||
*/
|
*/
|
||||||
private Path createRelativePath(NodeRef fromRef, NodeRef toRef)
|
private Path createRelativePath(NodeRef rootRef, NodeRef fromRef, NodeRef toRef)
|
||||||
{
|
{
|
||||||
// Check that item exists first
|
// Check that item exists first
|
||||||
if (!nodeService.exists(toRef))
|
if (!nodeService.exists(toRef))
|
||||||
@@ -694,6 +738,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Path rootPath = nodeService.getPath(rootRef);
|
||||||
Path fromPath = nodeService.getPath(fromRef);
|
Path fromPath = nodeService.getPath(fromRef);
|
||||||
Path toPath = nodeService.getPath(toRef);
|
Path toPath = nodeService.getPath(toRef);
|
||||||
Path relativePath = null;
|
Path relativePath = null;
|
||||||
@@ -720,19 +765,19 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
{
|
{
|
||||||
// Determine if from node is relative to export tree
|
// Determine if from node is relative to export tree
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < exportNodePath.size() && i < fromPath.size() && exportNodePath.get(i).equals(fromPath.get(i)))
|
while (i < rootPath.size() && i < fromPath.size() && rootPath.get(i).equals(fromPath.get(i)))
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (i == exportNodePath.size())
|
if (i == rootPath.size())
|
||||||
{
|
{
|
||||||
// Determine if to node is relative to export tree
|
// Determine if to node is relative to export tree
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < exportNodePath.size() && i < toPath.size() && exportNodePath.get(i).equals(toPath.get(i)))
|
while (i < rootPath.size() && i < toPath.size() && rootPath.get(i).equals(toPath.get(i)))
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (i == exportNodePath.size())
|
if (i == rootPath.size())
|
||||||
{
|
{
|
||||||
// build relative path between from and to
|
// build relative path between from and to
|
||||||
relativePath = new Path();
|
relativePath = new Path();
|
||||||
@@ -756,11 +801,11 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
}
|
}
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
{
|
{
|
||||||
String msg = "Failed to determine relative path: export path=" + exportNodePath + "; from path=" + fromPath + "; to path=" + toPath;
|
String msg = "Failed to determine relative path: root path=" + rootPath + "; from path=" + fromPath + "; to path=" + toPath;
|
||||||
throw new ExporterException(msg, e);
|
throw new ExporterException(msg, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return relativePath;
|
return relativePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -67,6 +67,14 @@ public interface Importer
|
|||||||
*/
|
*/
|
||||||
public NodeRef importNode(ImportNode node);
|
public NodeRef importNode(ImportNode node);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve path within context of root reference
|
||||||
|
*
|
||||||
|
* @param path the path to resolve
|
||||||
|
* @return node reference
|
||||||
|
*/
|
||||||
|
public NodeRef resolvePath(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal completion of node import
|
* Signal completion of node import
|
||||||
*
|
*
|
||||||
|
@@ -31,6 +31,7 @@ import java.util.Set;
|
|||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.policy.BehaviourFilter;
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
@@ -543,42 +544,49 @@ public class ImporterComponent
|
|||||||
ImportParent parentContext = context.getParentContext();
|
ImportParent parentContext = context.getParentContext();
|
||||||
NodeRef parentRef = parentContext.getParentRef();
|
NodeRef parentRef = parentContext.getParentRef();
|
||||||
|
|
||||||
// determine the child node reference
|
// determine the node reference to link to
|
||||||
String uuid = context.getUUID();
|
String uuid = context.getUUID();
|
||||||
if (uuid == null)
|
if (uuid == null || uuid.length() == 0)
|
||||||
{
|
{
|
||||||
throw new ImporterException("Node reference does not resolve to a node");
|
throw new ImporterException("Node reference does not specify a reference to follow.");
|
||||||
}
|
}
|
||||||
NodeRef childRef = new NodeRef(parentRef.getStoreRef(), uuid);
|
NodeRef referencedRef = new NodeRef(rootRef.getStoreRef(), uuid);
|
||||||
|
|
||||||
// Note: do not link references that are defined in the root of the import
|
// Note: do not link references that are defined in the root of the import
|
||||||
if (!parentRef.equals(getRootRef()))
|
if (!parentRef.equals(getRootRef()))
|
||||||
{
|
{
|
||||||
// determine child assoc type
|
// determine child assoc type
|
||||||
QName assocType = getAssocType(context);
|
QName assocType = getAssocType(context);
|
||||||
|
AssociationDefinition assocDef = dictionaryService.getAssociation(assocType);
|
||||||
// determine child name
|
if (assocDef.isChild())
|
||||||
QName childQName = getChildName(context);
|
|
||||||
if (childQName == null)
|
|
||||||
{
|
{
|
||||||
String name = (String)nodeService.getProperty(childRef, ContentModel.PROP_NAME);
|
// determine child name
|
||||||
if (name == null || name.length() == 0)
|
QName childQName = getChildName(context);
|
||||||
|
if (childQName == null)
|
||||||
{
|
{
|
||||||
throw new ImporterException("Cannot determine node reference child name");
|
String name = (String)nodeService.getProperty(referencedRef, ContentModel.PROP_NAME);
|
||||||
|
if (name == null || name.length() == 0)
|
||||||
|
{
|
||||||
|
throw new ImporterException("Cannot determine node reference child name");
|
||||||
|
}
|
||||||
|
String localName = QName.createValidLocalName(name);
|
||||||
|
childQName = QName.createQName(assocType.getNamespaceURI(), localName);
|
||||||
}
|
}
|
||||||
String localName = QName.createValidLocalName(name);
|
|
||||||
childQName = QName.createQName(assocType.getNamespaceURI(), localName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the link
|
// create the secondary link
|
||||||
nodeService.addChild(parentRef, childRef, assocType, childQName);
|
nodeService.addChild(parentRef, referencedRef, assocType, childQName);
|
||||||
reportNodeLinked(childRef, parentRef, assocType, childQName);
|
reportNodeLinked(referencedRef, parentRef, assocType, childQName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nodeService.createAssociation(parentRef, referencedRef, assocType);
|
||||||
|
reportNodeLinked(parentRef, referencedRef, assocType, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// second, perform any specified udpates to the node
|
// second, perform any specified udpates to the node
|
||||||
updateStrategy.importNode(context);
|
updateStrategy.importNode(context);
|
||||||
|
return referencedRef;
|
||||||
return childRef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -621,6 +629,19 @@ public class ImporterComponent
|
|||||||
behaviourFilter.enableBehaviours(nodeRef);
|
behaviourFilter.enableBehaviours(nodeRef);
|
||||||
ruleService.enableRules(nodeRef);
|
ruleService.enableRules(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.importer.Importer#resolvePath(java.lang.String)
|
||||||
|
*/
|
||||||
|
public NodeRef resolvePath(String path)
|
||||||
|
{
|
||||||
|
NodeRef referencedRef = null;
|
||||||
|
if (path != null && path.length() > 0)
|
||||||
|
{
|
||||||
|
referencedRef = resolveImportedNodeRef(rootRef, path);
|
||||||
|
}
|
||||||
|
return referencedRef;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.importer.Importer#end()
|
* @see org.alfresco.repo.importer.Importer#end()
|
||||||
@@ -800,7 +821,7 @@ public class ImporterComponent
|
|||||||
|
|
||||||
return closestAssocType;
|
return closestAssocType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For the given import node, return the behaviours to disable during import
|
* For the given import node, return the behaviours to disable during import
|
||||||
*
|
*
|
||||||
@@ -1347,7 +1368,7 @@ public class ImporterComponent
|
|||||||
// do the update
|
// do the update
|
||||||
Map<QName, Serializable> existingProperties = nodeService.getProperties(existingNodeRef);
|
Map<QName, Serializable> existingProperties = nodeService.getProperties(existingNodeRef);
|
||||||
Map<QName, Serializable> updateProperties = bindProperties(node);
|
Map<QName, Serializable> updateProperties = bindProperties(node);
|
||||||
if (updateProperties != null)
|
if (updateProperties != null && updateProperties.size() > 0)
|
||||||
{
|
{
|
||||||
existingProperties.putAll(updateProperties);
|
existingProperties.putAll(updateProperties);
|
||||||
nodeService.setProperties(existingNodeRef, existingProperties);
|
nodeService.setProperties(existingNodeRef, existingProperties);
|
||||||
@@ -1382,6 +1403,7 @@ public class ImporterComponent
|
|||||||
return createNewStrategy.importNode(node);
|
return createNewStrategy.importNode(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,7 +23,7 @@ import java.util.Set;
|
|||||||
import org.alfresco.repo.importer.ImportParent;
|
import org.alfresco.repo.importer.ImportParent;
|
||||||
import org.alfresco.repo.importer.Importer;
|
import org.alfresco.repo.importer.Importer;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -80,14 +80,18 @@ public class ParentContext extends ElementContext
|
|||||||
* @param parent
|
* @param parent
|
||||||
* @param childDef
|
* @param childDef
|
||||||
*/
|
*/
|
||||||
public ParentContext(QName elementName, NodeContext parent, ChildAssociationDefinition childDef)
|
public ParentContext(QName elementName, NodeContext parent, AssociationDefinition assocDef)
|
||||||
{
|
{
|
||||||
this(elementName, parent);
|
this(elementName, parent);
|
||||||
|
|
||||||
TypeDefinition typeDef = parent.getTypeDefinition();
|
TypeDefinition typeDef = parent.getTypeDefinition();
|
||||||
if (typeDef != null)
|
if (typeDef != null)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
// Ensure association type is valid for node parent
|
// Ensure association type is valid for node parent
|
||||||
|
//
|
||||||
|
|
||||||
|
// Build complete Type Definition
|
||||||
Set<QName> allAspects = new HashSet<QName>();
|
Set<QName> allAspects = new HashSet<QName>();
|
||||||
for (AspectDefinition typeAspect : parent.getTypeDefinition().getDefaultAspects())
|
for (AspectDefinition typeAspect : parent.getTypeDefinition().getDefaultAspects())
|
||||||
{
|
{
|
||||||
@@ -95,15 +99,17 @@ public class ParentContext extends ElementContext
|
|||||||
}
|
}
|
||||||
allAspects.addAll(parent.getNodeAspects());
|
allAspects.addAll(parent.getNodeAspects());
|
||||||
TypeDefinition anonymousType = getDictionaryService().getAnonymousType(parent.getTypeDefinition().getName(), allAspects);
|
TypeDefinition anonymousType = getDictionaryService().getAnonymousType(parent.getTypeDefinition().getName(), allAspects);
|
||||||
Map<QName, ChildAssociationDefinition> nodeAssociations = anonymousType.getChildAssociations();
|
|
||||||
if (nodeAssociations.containsKey(childDef.getName()) == false)
|
// Determine if Association is valid for Type Definition
|
||||||
|
Map<QName, AssociationDefinition> nodeAssociations = anonymousType.getAssociations();
|
||||||
|
if (nodeAssociations.containsKey(assocDef.getName()) == false)
|
||||||
{
|
{
|
||||||
throw new ImporterException("Association " + childDef.getName() + " is not valid for node " + parent.getTypeDefinition().getName());
|
throw new ImporterException("Association " + assocDef.getName() + " is not valid for node " + parent.getTypeDefinition().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parentRef = parent.getNodeRef();
|
parentRef = parent.getNodeRef();
|
||||||
assocType = childDef.getName();
|
assocType = assocDef.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@@ -26,7 +26,6 @@ import org.alfresco.repo.importer.Importer;
|
|||||||
import org.alfresco.repo.importer.Parser;
|
import org.alfresco.repo.importer.Parser;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
@@ -60,6 +59,7 @@ public class ViewParser implements Parser
|
|||||||
private static final String VIEW_ACCESS_STATUS_ATTR = "access";
|
private static final String VIEW_ACCESS_STATUS_ATTR = "access";
|
||||||
private static final String VIEW_ID_ATTR = "id";
|
private static final String VIEW_ID_ATTR = "id";
|
||||||
private static final String VIEW_IDREF_ATTR = "idref";
|
private static final String VIEW_IDREF_ATTR = "idref";
|
||||||
|
private static final String VIEW_PATHREF_ATTR = "pathref";
|
||||||
private static final QName VIEW_METADATA = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "metadata");
|
private static final QName VIEW_METADATA = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "metadata");
|
||||||
private static final QName VIEW_VALUE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "value");
|
private static final QName VIEW_VALUE_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "value");
|
||||||
private static final QName VIEW_VALUES_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "values");
|
private static final QName VIEW_VALUES_QNAME = QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "values");
|
||||||
@@ -262,15 +262,11 @@ public class ViewParser implements Parser
|
|||||||
processProperty(xpp, ((PropertyDefinition)def).getName(), parserContext);
|
processProperty(xpp, ((PropertyDefinition)def).getName(), parserContext);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (def instanceof ChildAssociationDefinition)
|
else if (def instanceof AssociationDefinition)
|
||||||
{
|
{
|
||||||
processStartChildAssoc(xpp, (ChildAssociationDefinition)def, parserContext);
|
processStartAssoc(xpp, (AssociationDefinition)def, parserContext);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: general association
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (element instanceof NodeItemContext)
|
else if (element instanceof NodeItemContext)
|
||||||
{
|
{
|
||||||
@@ -298,12 +294,7 @@ public class ViewParser implements Parser
|
|||||||
{
|
{
|
||||||
throw new ImporterException("Association name " + defName + " is not valid; cannot find in Repository dictionary");
|
throw new ImporterException("Association name " + defName + " is not valid; cannot find in Repository dictionary");
|
||||||
}
|
}
|
||||||
// TODO: Handle general associations...
|
processStartAssoc(xpp, (AssociationDefinition)def, parserContext);
|
||||||
if (!(def instanceof ChildAssociationDefinition))
|
|
||||||
{
|
|
||||||
throw new ImporterException("Unsupported operation: The association " + defName + " cannot be imported - only child associations are supported at this time");
|
|
||||||
}
|
|
||||||
processStartChildAssoc(xpp, (ChildAssociationDefinition)def, parserContext);
|
|
||||||
}
|
}
|
||||||
else if (itemName.equals(VIEW_ACL))
|
else if (itemName.equals(VIEW_ACL))
|
||||||
{
|
{
|
||||||
@@ -414,10 +405,18 @@ public class ViewParser implements Parser
|
|||||||
throws XmlPullParserException, IOException
|
throws XmlPullParserException, IOException
|
||||||
{
|
{
|
||||||
ParentContext parent = (ParentContext)parserContext.elementStack.peek();
|
ParentContext parent = (ParentContext)parserContext.elementStack.peek();
|
||||||
|
NodeContext node = new NodeContext(refName, parent, null);
|
||||||
|
node.setReference(true);
|
||||||
|
|
||||||
// Extract Import scoped reference Id if explicitly defined
|
// Extract Import scoped reference Id if explicitly defined
|
||||||
String uuid = null;
|
|
||||||
String idRef = xpp.getAttributeValue(NamespaceService.REPOSITORY_VIEW_1_0_URI, VIEW_IDREF_ATTR);
|
String idRef = xpp.getAttributeValue(NamespaceService.REPOSITORY_VIEW_1_0_URI, VIEW_IDREF_ATTR);
|
||||||
|
String pathRef = xpp.getAttributeValue(NamespaceService.REPOSITORY_VIEW_1_0_URI, VIEW_PATHREF_ATTR);
|
||||||
|
|
||||||
|
if ((idRef != null && idRef.length() > 0) && (pathRef != null && pathRef.length() > 0))
|
||||||
|
{
|
||||||
|
// Do not support both IDREF and PATHREF
|
||||||
|
throw new ImporterException("Only one of " + VIEW_IDREF_ATTR + " or " + VIEW_PATHREF_ATTR + " can be specified.");
|
||||||
|
}
|
||||||
if (idRef != null && idRef.length() > 0)
|
if (idRef != null && idRef.length() > 0)
|
||||||
{
|
{
|
||||||
// retrieve uuid from previously imported node
|
// retrieve uuid from previously imported node
|
||||||
@@ -426,15 +425,16 @@ public class ViewParser implements Parser
|
|||||||
{
|
{
|
||||||
throw new ImporterException("Cannot find node referenced by id " + idRef);
|
throw new ImporterException("Cannot find node referenced by id " + idRef);
|
||||||
}
|
}
|
||||||
uuid = nodeRef.getId();
|
node.setUUID(nodeRef.getId());
|
||||||
}
|
}
|
||||||
|
else if (pathRef != null && pathRef.length() > 0)
|
||||||
// Create reference
|
|
||||||
NodeContext node = new NodeContext(refName, parent, null);
|
|
||||||
node.setReference(true);
|
|
||||||
if (uuid != null)
|
|
||||||
{
|
{
|
||||||
node.setUUID(uuid);
|
NodeRef referencedRef = parserContext.importer.resolvePath(pathRef);
|
||||||
|
if (referencedRef == null)
|
||||||
|
{
|
||||||
|
throw new ImporterException("Cannot find node referenced by path " + pathRef);
|
||||||
|
}
|
||||||
|
node.setUUID(referencedRef.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract child name if explicitly defined
|
// Extract child name if explicitly defined
|
||||||
@@ -705,22 +705,22 @@ public class ViewParser implements Parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process start of child association definition
|
* Process start of association definition
|
||||||
*
|
*
|
||||||
* @param xpp
|
* @param xpp
|
||||||
* @param childAssocDef
|
* @param AssocDef
|
||||||
* @param contextStack
|
* @param contextStack
|
||||||
* @throws XmlPullParserException
|
* @throws XmlPullParserException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void processStartChildAssoc(XmlPullParser xpp, ChildAssociationDefinition childAssocDef, ParserContext parserContext)
|
private void processStartAssoc(XmlPullParser xpp, AssociationDefinition assocDef, ParserContext parserContext)
|
||||||
throws XmlPullParserException, IOException
|
throws XmlPullParserException, IOException
|
||||||
{
|
{
|
||||||
NodeContext node = peekNodeContext(parserContext.elementStack);
|
NodeContext node = peekNodeContext(parserContext.elementStack);
|
||||||
importNode(parserContext, node);
|
importNode(parserContext, node);
|
||||||
|
|
||||||
// Construct Child Association Context
|
// Construct Child Association Context
|
||||||
ParentContext parent = new ParentContext(childAssocDef.getName(), node, childAssocDef);
|
ParentContext parent = new ParentContext(assocDef.getName(), node, assocDef);
|
||||||
parserContext.elementStack.push(parent);
|
parserContext.elementStack.push(parent);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
@@ -750,7 +750,7 @@ public class ViewParser implements Parser
|
|||||||
}
|
}
|
||||||
else if (element instanceof ParentContext)
|
else if (element instanceof ParentContext)
|
||||||
{
|
{
|
||||||
processEndChildAssoc(parserContext, (ParentContext)element);
|
processEndAssoc(parserContext, (ParentContext)element);
|
||||||
}
|
}
|
||||||
else if (element instanceof MetaDataContext)
|
else if (element instanceof MetaDataContext)
|
||||||
{
|
{
|
||||||
@@ -776,7 +776,7 @@ public class ViewParser implements Parser
|
|||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
private void processEndChildAssoc(ParserContext parserContext, ParentContext parent)
|
private void processEndAssoc(ParserContext parserContext, ParentContext parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,6 +67,20 @@ public interface Exporter
|
|||||||
*/
|
*/
|
||||||
public void endNode(NodeRef nodeRef);
|
public void endNode(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start export of node reference
|
||||||
|
*
|
||||||
|
* @param nodeRef the node reference
|
||||||
|
*/
|
||||||
|
public void startReference(NodeRef nodeRef, QName childName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End export of node reference
|
||||||
|
*
|
||||||
|
* @param nodeRef the node reference
|
||||||
|
*/
|
||||||
|
public void endReference(NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start export of aspects
|
* Start export of aspects
|
||||||
*
|
*
|
||||||
@@ -97,15 +111,28 @@ public interface Exporter
|
|||||||
*/
|
*/
|
||||||
public void endAspects(NodeRef nodeRef);
|
public void endAspects(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start export of ACL
|
||||||
|
*
|
||||||
|
* @param nodeRef for node reference
|
||||||
|
*/
|
||||||
public void startACL(NodeRef nodeRef);
|
public void startACL(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export permission
|
||||||
|
*
|
||||||
|
* @param nodeRef for node reference
|
||||||
|
* @param permission the permission
|
||||||
|
*/
|
||||||
public void permission(NodeRef nodeRef, AccessPermission permission);
|
public void permission(NodeRef nodeRef, AccessPermission permission);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End export of ACL
|
||||||
|
*
|
||||||
|
* @param nodeRef for node reference
|
||||||
|
*/
|
||||||
public void endACL(NodeRef nodeRef);
|
public void endACL(NodeRef nodeRef);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start export of properties
|
* Start export of properties
|
||||||
*
|
*
|
||||||
|
@@ -15,4 +15,6 @@ public interface ExporterContext
|
|||||||
|
|
||||||
public NodeRef getExportOf();
|
public NodeRef getExportOf();
|
||||||
|
|
||||||
|
public NodeRef getExportParent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@ public class ExporterCrawlerParameters
|
|||||||
private Location exportFrom = null;
|
private Location exportFrom = null;
|
||||||
private boolean crawlSelf = false;
|
private boolean crawlSelf = false;
|
||||||
private boolean crawlChildNodes = true;
|
private boolean crawlChildNodes = true;
|
||||||
|
private boolean crawlAssociations = true;
|
||||||
private boolean crawlContent = true;
|
private boolean crawlContent = true;
|
||||||
private boolean crawlNullProperties = true;
|
private boolean crawlNullProperties = true;
|
||||||
private String[] excludeNamespaceURIs = new String[] { NamespaceService.REPOSITORY_VIEW_1_0_URI };
|
private String[] excludeNamespaceURIs = new String[] { NamespaceService.REPOSITORY_VIEW_1_0_URI };
|
||||||
@@ -57,6 +58,26 @@ public class ExporterCrawlerParameters
|
|||||||
this.crawlChildNodes = crawlChildNodes;
|
this.crawlChildNodes = crawlChildNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crawl and export associations
|
||||||
|
*
|
||||||
|
* @return true => crawl associations
|
||||||
|
*/
|
||||||
|
public boolean isCrawlAssociations()
|
||||||
|
{
|
||||||
|
return crawlAssociations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether to crawl associations
|
||||||
|
*
|
||||||
|
* @param crawlAssociations
|
||||||
|
*/
|
||||||
|
public void setCrawlAssociations(boolean crawlAssociations)
|
||||||
|
{
|
||||||
|
this.crawlAssociations = crawlAssociations;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crawl and export content properties
|
* Crawl and export content properties
|
||||||
*
|
*
|
||||||
|
@@ -615,6 +615,22 @@ public final class Export extends Tool
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.view.Exporter#startReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||||
|
*/
|
||||||
|
public void startReference(NodeRef nodeRef, QName childName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.view.Exporter#endReference(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
public void endReference(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -64,7 +64,7 @@ public class ISO9075
|
|||||||
{
|
{
|
||||||
return toEncode;
|
return toEncode;
|
||||||
}
|
}
|
||||||
else if (XMLChar.isValidName(toEncode) && (toEncode.indexOf("_x") == -1))
|
else if (XMLChar.isValidName(toEncode) && (toEncode.indexOf("_x") == -1) && (toEncode.indexOf(':') == -1))
|
||||||
{
|
{
|
||||||
return toEncode;
|
return toEncode;
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ public class ISO9075Test extends TestCase
|
|||||||
"_x0020__x0060__x00ac__x00a6__x0021__x0022__x00a3__x0024__x0025__x005e__x0026__x002a__x0028__x0029_-__x003d__x002b__x0009__x000a__x005c__x0000__x005b__x005d__x007b__x007d__x003b__x0027__x0023__x003a__x0040__x007e__x002c_._x002f__x003c__x003e__x003f__x005c__x007c_",
|
"_x0020__x0060__x00ac__x00a6__x0021__x0022__x00a3__x0024__x0025__x005e__x0026__x002a__x0028__x0029_-__x003d__x002b__x0009__x000a__x005c__x0000__x005b__x005d__x007b__x007d__x003b__x0027__x0023__x003a__x0040__x007e__x002c_._x002f__x003c__x003e__x003f__x005c__x007c_",
|
||||||
ISO9075.encode(" `<60><>!\"<EFBFBD>$%^&*()-_=+\t\n\\\u0000[]{};'#:@~,./<>?\\|"));
|
ISO9075.encode(" `<60><>!\"<EFBFBD>$%^&*()-_=+\t\n\\\u0000[]{};'#:@~,./<>?\\|"));
|
||||||
assertEquals("\u0123_x4567_\u8900_xabcd__xefff__xT65A_", ISO9075.encode("\u0123\u4567\u8900\uabcd\uefff_xT65A_"));
|
assertEquals("\u0123_x4567_\u8900_xabcd__xefff__xT65A_", ISO9075.encode("\u0123\u4567\u8900\uabcd\uefff_xT65A_"));
|
||||||
|
assertEquals("_x003a_", ISO9075.encode(":"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeEncoding()
|
public void testDeEncoding()
|
||||||
|
@@ -62,6 +62,32 @@ public class NodeStoreInspector
|
|||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the contents of a node
|
||||||
|
*
|
||||||
|
* @param nodeService
|
||||||
|
* @param nodeRef
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String dumpNode(NodeService nodeService, NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
if (nodeService.exists(nodeRef) == true)
|
||||||
|
{
|
||||||
|
builder.append(outputNode(0, nodeService, nodeRef));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.
|
||||||
|
append("The node ").
|
||||||
|
append(nodeRef.toString()).
|
||||||
|
append(" does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output the node
|
* Output the node
|
||||||
|
Reference in New Issue
Block a user