mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV/MOB453 to HEAD
14474: MOB-453 Export multiple root nodes into a single export package (for RM) ___________________________________________________________________ Modified: svn:mergeinfo Merged /alfresco/BRANCHES/DEV/MOB453:r14474 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14496 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -270,50 +270,52 @@ public class ExporterComponent
|
||||
// Export Nodes
|
||||
//
|
||||
|
||||
// determine if root repository node
|
||||
NodeRef nodeRef = context.getExportOf();
|
||||
if (parameters.isCrawlSelf())
|
||||
while (context.canRetrieve())
|
||||
{
|
||||
// export root node of specified export location
|
||||
walkStartNamespaces(parameters, exporter);
|
||||
boolean rootNode = nodeService.getRootNode(nodeRef.getStoreRef()).equals(nodeRef);
|
||||
walkNode(nodeRef, parameters, exporter, rootNode);
|
||||
walkEndNamespaces(parameters, exporter);
|
||||
}
|
||||
else if (parameters.isCrawlChildNodes())
|
||||
{
|
||||
// export child nodes only
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef);
|
||||
for (ChildAssociationRef childAssoc : childAssocs)
|
||||
// determine if root repository node
|
||||
NodeRef nodeRef = context.getExportOf();
|
||||
if (parameters.isCrawlSelf())
|
||||
{
|
||||
// export root node of specified export location
|
||||
walkStartNamespaces(parameters, exporter);
|
||||
walkNode(childAssoc.getChildRef(), parameters, exporter, false);
|
||||
boolean rootNode = nodeService.getRootNode(nodeRef.getStoreRef()).equals(nodeRef);
|
||||
walkNode(nodeRef, parameters, exporter, rootNode);
|
||||
walkEndNamespaces(parameters, exporter);
|
||||
}
|
||||
}
|
||||
else if (parameters.isCrawlChildNodes())
|
||||
{
|
||||
// export child nodes only
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef);
|
||||
for (ChildAssociationRef childAssoc : childAssocs)
|
||||
{
|
||||
walkStartNamespaces(parameters, exporter);
|
||||
walkNode(childAssoc.getChildRef(), parameters, exporter, false);
|
||||
walkEndNamespaces(parameters, exporter);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Export Secondary Links between Nodes
|
||||
//
|
||||
|
||||
for (NodeRef nodeWithAssociations : nodesWithSecondaryLinks.keySet())
|
||||
{
|
||||
walkStartNamespaces(parameters, exporter);
|
||||
walkNodeSecondaryLinks(nodeWithAssociations, 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
|
||||
//
|
||||
//
|
||||
// Export Associations between Nodes
|
||||
//
|
||||
for (NodeRef nodeWithAssociations : nodesWithAssociations.keySet())
|
||||
{
|
||||
walkStartNamespaces(parameters, exporter);
|
||||
walkNodeAssociations(nodeWithAssociations, parameters, exporter);
|
||||
walkEndNamespaces(parameters, exporter);
|
||||
}
|
||||
|
||||
for (NodeRef nodeWithAssociations : nodesWithAssociations.keySet())
|
||||
{
|
||||
walkStartNamespaces(parameters, exporter);
|
||||
walkNodeAssociations(nodeWithAssociations, parameters, exporter);
|
||||
walkEndNamespaces(parameters, exporter);
|
||||
context.setNextValue();
|
||||
}
|
||||
|
||||
exporter.end();
|
||||
}
|
||||
|
||||
@@ -807,27 +809,28 @@ public class ExporterComponent
|
||||
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)
|
||||
for (NodeRef exportRoot : context.getExportList())
|
||||
{
|
||||
// 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--)
|
||||
if (nodeRef.equals(exportRoot) && parameters.isCrawlSelf() == true)
|
||||
{
|
||||
Path.ChildAssocElement pathElement = (Path.ChildAssocElement)nodePath.get(i);
|
||||
if (pathElement.getRef().getChildRef().equals(exportRoot))
|
||||
// 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--)
|
||||
{
|
||||
isWithin = true;
|
||||
break;
|
||||
Path.ChildAssocElement pathElement = (Path.ChildAssocElement)nodePath.get(i);
|
||||
if (pathElement.getRef().getChildRef().equals(exportRoot))
|
||||
{
|
||||
isWithin = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isWithin;
|
||||
}
|
||||
}
|
||||
@@ -838,12 +841,14 @@ public class ExporterComponent
|
||||
*/
|
||||
private class ExporterContextImpl implements ExporterContext
|
||||
{
|
||||
private NodeRef exportOf;
|
||||
private NodeRef parent;
|
||||
private NodeRef[] exportList;
|
||||
private NodeRef[] parentList;
|
||||
private String exportedBy;
|
||||
private Date exportedDate;
|
||||
private String exporterVersion;
|
||||
|
||||
private int index;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
@@ -851,23 +856,49 @@ public class ExporterComponent
|
||||
*/
|
||||
public ExporterContextImpl(ExporterCrawlerParameters parameters)
|
||||
{
|
||||
index = 0;
|
||||
|
||||
// get current user performing export
|
||||
String currentUserName = authenticationService.getCurrentUserName();
|
||||
exportedBy = (currentUserName == null) ? "unknown" : currentUserName;
|
||||
|
||||
// get current date
|
||||
exportedDate = new Date(System.currentTimeMillis());
|
||||
|
||||
// get export of
|
||||
exportOf = getNodeRef(parameters.getExportFrom());
|
||||
|
||||
// get export parent
|
||||
parent = getParent(exportOf, parameters.isCrawlSelf());
|
||||
|
||||
// get list of exported nodes
|
||||
exportList = (parameters.getExportFrom() == null) ? null : parameters.getExportFrom().getNodeRefs();
|
||||
if (exportList == null)
|
||||
{
|
||||
// multi-node export
|
||||
exportList = new NodeRef[1];
|
||||
NodeRef exportOf = getNodeRef(parameters.getExportFrom());
|
||||
exportList[0] = exportOf;
|
||||
}
|
||||
parentList = new NodeRef[exportList.length];
|
||||
for (int i = 0; i < exportList.length; i++)
|
||||
{
|
||||
parentList[i] = getParent(exportList[i], parameters.isCrawlSelf());
|
||||
}
|
||||
|
||||
// get exporter version
|
||||
exporterVersion = descriptorService.getServerDescriptor().getVersion();
|
||||
}
|
||||
|
||||
public boolean canRetrieve()
|
||||
{
|
||||
return index < exportList.length;
|
||||
}
|
||||
|
||||
public int setNextValue()
|
||||
{
|
||||
return ++index;
|
||||
}
|
||||
|
||||
public void resetContext()
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ExporterContext#getExportedBy()
|
||||
*/
|
||||
@@ -897,7 +928,11 @@ public class ExporterComponent
|
||||
*/
|
||||
public NodeRef getExportOf()
|
||||
{
|
||||
return exportOf;
|
||||
if (canRetrieve())
|
||||
{
|
||||
return exportList[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -906,9 +941,32 @@ public class ExporterComponent
|
||||
*/
|
||||
public NodeRef getExportParent()
|
||||
{
|
||||
return parent;
|
||||
if (canRetrieve())
|
||||
{
|
||||
return parentList[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ExporterContext#getExportList()
|
||||
*/
|
||||
public NodeRef[] getExportList()
|
||||
{
|
||||
return exportList;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ExporterContext#getExportParentList()
|
||||
*/
|
||||
public NodeRef[] getExportParentList()
|
||||
{
|
||||
return parentList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Node Ref from the specified Location
|
||||
*
|
||||
|
@@ -45,6 +45,7 @@ import org.alfresco.service.cmr.view.ExporterException;
|
||||
import org.alfresco.service.cmr.view.ReferenceType;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
@@ -212,10 +213,19 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
// export of
|
||||
contentHandler.startElement(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTOF_LOCALNAME, EXPORTOF_QNAME.toPrefixString(), EMPTY_ATTRIBUTES);
|
||||
String path = nodeService.getPath(context.getExportOf()).toPrefixString(namespaceService);
|
||||
contentHandler.characters(path.toCharArray(), 0, path.length());
|
||||
NodeRef[] exportList = context.getExportList();
|
||||
int comma = 1;
|
||||
for(int i=0;i < exportList.length; i++)
|
||||
{
|
||||
NodeRef nodeRef = exportList[i];
|
||||
String path = nodeService.getPath(nodeRef).toPrefixString(namespaceService);
|
||||
if (i == exportList.length - 1)
|
||||
{
|
||||
comma = 0;
|
||||
}
|
||||
contentHandler.characters(ArrayUtils.addAll(path.toCharArray(), ",".toCharArray()), 0, path.length() + comma);
|
||||
}
|
||||
contentHandler.endElement(NamespaceService.REPOSITORY_VIEW_PREFIX, EXPORTOF_LOCALNAME, EXPORTOF_QNAME.toPrefixString());
|
||||
|
||||
contentHandler.endElement(NamespaceService.REPOSITORY_VIEW_PREFIX, METADATA_LOCALNAME, METADATA_QNAME.toPrefixString());
|
||||
}
|
||||
catch (SAXException e)
|
||||
@@ -545,7 +555,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
NodeRef valueNodeRef = (NodeRef)value;
|
||||
if (nodeRef.getStoreRef().equals(valueNodeRef.getStoreRef()))
|
||||
{
|
||||
Path nodeRefPath = createPath(context.getExportOf(), nodeRef, valueNodeRef);
|
||||
Path nodeRefPath = createPath(context.getExportParent(), nodeRef, valueNodeRef);
|
||||
value = (nodeRefPath == null) ? null : nodeRefPath.toPrefixString(namespaceService);
|
||||
}
|
||||
}
|
||||
@@ -569,12 +579,11 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
String strValue = (String)DefaultTypeConverter.INSTANCE.convert(String.class, value);
|
||||
if (strValue != null)
|
||||
{
|
||||
for (int i = 0; i < strValue.length(); i++)
|
||||
{
|
||||
char[] temp = new char[]{strValue.charAt(i)};
|
||||
contentHandler.characters(temp, 0, 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < strValue.length(); i++)
|
||||
{
|
||||
char[] temp = new char[]{strValue.charAt(i)};
|
||||
contentHandler.characters(temp, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// output value wrapper if property data type is any
|
||||
@@ -802,26 +811,33 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||
if (i == rootPath.size())
|
||||
{
|
||||
// Determine if to node is relative to export tree
|
||||
i = 0;
|
||||
while (i < rootPath.size() && i < toPath.size() && rootPath.get(i).equals(toPath.get(i)))
|
||||
for (NodeRef nodeRef : context.getExportParentList())
|
||||
{
|
||||
i++;
|
||||
}
|
||||
if (i == rootPath.size())
|
||||
{
|
||||
// build relative path between from and to
|
||||
relativePath = new Path();
|
||||
for (int p = 0; p < fromPath.size() - i; p++)
|
||||
int j = 0;
|
||||
Path tryPath = createIndexedPath(nodeRef, nodeService.getPath(nodeRef));
|
||||
while (j < tryPath.size() && j < toPath.size() && tryPath.get(j).equals(toPath.get(j)))
|
||||
{
|
||||
relativePath.append(new Path.ParentElement());
|
||||
j++;
|
||||
}
|
||||
if (i < toPath.size())
|
||||
if (j == tryPath.size())
|
||||
{
|
||||
relativePath.append(toPath.subPath(i, toPath.size() -1));
|
||||
// build relative path between from and to
|
||||
relativePath = new Path();
|
||||
for (int p = 0; p < fromPath.size() - i; p++)
|
||||
{
|
||||
relativePath.append(new Path.ParentElement());
|
||||
}
|
||||
if (j < toPath.size())
|
||||
{
|
||||
relativePath.append(toPath.subPath(j, toPath.size() - 1));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (relativePath == null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user