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:
@@ -67,6 +67,14 @@ public interface Importer
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
@@ -31,6 +31,7 @@ import java.util.Set;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
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.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
@@ -543,42 +544,49 @@ public class ImporterComponent
|
||||
ImportParent parentContext = context.getParentContext();
|
||||
NodeRef parentRef = parentContext.getParentRef();
|
||||
|
||||
// determine the child node reference
|
||||
// determine the node reference to link to
|
||||
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
|
||||
if (!parentRef.equals(getRootRef()))
|
||||
{
|
||||
// determine child assoc type
|
||||
QName assocType = getAssocType(context);
|
||||
|
||||
// determine child name
|
||||
QName childQName = getChildName(context);
|
||||
if (childQName == null)
|
||||
AssociationDefinition assocDef = dictionaryService.getAssociation(assocType);
|
||||
if (assocDef.isChild())
|
||||
{
|
||||
String name = (String)nodeService.getProperty(childRef, ContentModel.PROP_NAME);
|
||||
if (name == null || name.length() == 0)
|
||||
// determine child name
|
||||
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
|
||||
nodeService.addChild(parentRef, childRef, assocType, childQName);
|
||||
reportNodeLinked(childRef, parentRef, assocType, childQName);
|
||||
// create the secondary link
|
||||
nodeService.addChild(parentRef, referencedRef, 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
|
||||
updateStrategy.importNode(context);
|
||||
|
||||
return childRef;
|
||||
return referencedRef;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -621,6 +629,19 @@ public class ImporterComponent
|
||||
behaviourFilter.enableBehaviours(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)
|
||||
* @see org.alfresco.repo.importer.Importer#end()
|
||||
@@ -800,7 +821,7 @@ public class ImporterComponent
|
||||
|
||||
return closestAssocType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For the given import node, return the behaviours to disable during import
|
||||
*
|
||||
@@ -1347,7 +1368,7 @@ public class ImporterComponent
|
||||
// do the update
|
||||
Map<QName, Serializable> existingProperties = nodeService.getProperties(existingNodeRef);
|
||||
Map<QName, Serializable> updateProperties = bindProperties(node);
|
||||
if (updateProperties != null)
|
||||
if (updateProperties != null && updateProperties.size() > 0)
|
||||
{
|
||||
existingProperties.putAll(updateProperties);
|
||||
nodeService.setProperties(existingNodeRef, existingProperties);
|
||||
@@ -1382,6 +1403,7 @@ public class ImporterComponent
|
||||
return createNewStrategy.importNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -23,7 +23,7 @@ import java.util.Set;
|
||||
import org.alfresco.repo.importer.ImportParent;
|
||||
import org.alfresco.repo.importer.Importer;
|
||||
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.TypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -80,14 +80,18 @@ public class ParentContext extends ElementContext
|
||||
* @param parent
|
||||
* @param childDef
|
||||
*/
|
||||
public ParentContext(QName elementName, NodeContext parent, ChildAssociationDefinition childDef)
|
||||
public ParentContext(QName elementName, NodeContext parent, AssociationDefinition assocDef)
|
||||
{
|
||||
this(elementName, parent);
|
||||
|
||||
TypeDefinition typeDef = parent.getTypeDefinition();
|
||||
if (typeDef != null)
|
||||
{
|
||||
//
|
||||
// Ensure association type is valid for node parent
|
||||
//
|
||||
|
||||
// Build complete Type Definition
|
||||
Set<QName> allAspects = new HashSet<QName>();
|
||||
for (AspectDefinition typeAspect : parent.getTypeDefinition().getDefaultAspects())
|
||||
{
|
||||
@@ -95,15 +99,17 @@ public class ParentContext extends ElementContext
|
||||
}
|
||||
allAspects.addAll(parent.getNodeAspects());
|
||||
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();
|
||||
assocType = childDef.getName();
|
||||
assocType = assocDef.getName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@@ -26,7 +26,6 @@ import org.alfresco.repo.importer.Importer;
|
||||
import org.alfresco.repo.importer.Parser;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
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.PropertyDefinition;
|
||||
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_ID_ATTR = "id";
|
||||
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_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");
|
||||
@@ -262,15 +262,11 @@ public class ViewParser implements Parser
|
||||
processProperty(xpp, ((PropertyDefinition)def).getName(), parserContext);
|
||||
return;
|
||||
}
|
||||
else if (def instanceof ChildAssociationDefinition)
|
||||
else if (def instanceof AssociationDefinition)
|
||||
{
|
||||
processStartChildAssoc(xpp, (ChildAssociationDefinition)def, parserContext);
|
||||
processStartAssoc(xpp, (AssociationDefinition)def, parserContext);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: general association
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
// TODO: Handle general associations...
|
||||
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);
|
||||
processStartAssoc(xpp, (AssociationDefinition)def, parserContext);
|
||||
}
|
||||
else if (itemName.equals(VIEW_ACL))
|
||||
{
|
||||
@@ -414,10 +405,18 @@ public class ViewParser implements Parser
|
||||
throws XmlPullParserException, IOException
|
||||
{
|
||||
ParentContext parent = (ParentContext)parserContext.elementStack.peek();
|
||||
NodeContext node = new NodeContext(refName, parent, null);
|
||||
node.setReference(true);
|
||||
|
||||
// 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 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)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
uuid = nodeRef.getId();
|
||||
node.setUUID(nodeRef.getId());
|
||||
}
|
||||
|
||||
// Create reference
|
||||
NodeContext node = new NodeContext(refName, parent, null);
|
||||
node.setReference(true);
|
||||
if (uuid != null)
|
||||
else if (pathRef != null && pathRef.length() > 0)
|
||||
{
|
||||
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
|
||||
@@ -705,22 +705,22 @@ public class ViewParser implements Parser
|
||||
}
|
||||
|
||||
/**
|
||||
* Process start of child association definition
|
||||
* Process start of association definition
|
||||
*
|
||||
* @param xpp
|
||||
* @param childAssocDef
|
||||
* @param AssocDef
|
||||
* @param contextStack
|
||||
* @throws XmlPullParserException
|
||||
* @throws IOException
|
||||
*/
|
||||
private void processStartChildAssoc(XmlPullParser xpp, ChildAssociationDefinition childAssocDef, ParserContext parserContext)
|
||||
private void processStartAssoc(XmlPullParser xpp, AssociationDefinition assocDef, ParserContext parserContext)
|
||||
throws XmlPullParserException, IOException
|
||||
{
|
||||
NodeContext node = peekNodeContext(parserContext.elementStack);
|
||||
importNode(parserContext, node);
|
||||
|
||||
// Construct Child Association Context
|
||||
ParentContext parent = new ParentContext(childAssocDef.getName(), node, childAssocDef);
|
||||
ParentContext parent = new ParentContext(assocDef.getName(), node, assocDef);
|
||||
parserContext.elementStack.push(parent);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
@@ -750,7 +750,7 @@ public class ViewParser implements Parser
|
||||
}
|
||||
else if (element instanceof ParentContext)
|
||||
{
|
||||
processEndChildAssoc(parserContext, (ParentContext)element);
|
||||
processEndAssoc(parserContext, (ParentContext)element);
|
||||
}
|
||||
else if (element instanceof MetaDataContext)
|
||||
{
|
||||
@@ -776,7 +776,7 @@ public class ViewParser implements Parser
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
private void processEndChildAssoc(ParserContext parserContext, ParentContext parent)
|
||||
private void processEndAssoc(ParserContext parserContext, ParentContext parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user