From 0e936193581c7f86b1609610a5ec88bdb8608afb Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Wed, 4 Feb 2015 07:43:17 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud) 95987: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud) 94457: Merged DEV (5.0.1) to 5.0.N (5.0.1) 94445: MNT-12995: Items are not accessible using the urls received via IMAP Added a patch which replaces the IMAP template's content. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@96016 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/patch/patch-services-context.xml | 18 +++++++ config/alfresco/version.properties | 2 +- .../org/alfresco/repo/importer/Importer.java | 6 +++ .../repo/importer/ImporterComponent.java | 53 ++++++++++++++----- 4 files changed, 64 insertions(+), 15 deletions(-) diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 330300d4ca..f6aeb185a0 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -1119,4 +1119,22 @@ + + patch.imapSpacesTemplates3 + patch.imapSpacesLocaleTemplates2.description + 0 + 9001 + 9002 + + + + + + /${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.imapConfig.childname}/${spaces.imap_templates.childname} + alfresco/bootstrap/imapSpacesTemplates.xml + alfresco/messages/bootstrap-spaces + UPDATE_EXISTING + + + diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties index b1ae0d1b6f..bd636c57e6 100644 --- a/config/alfresco/version.properties +++ b/config/alfresco/version.properties @@ -23,4 +23,4 @@ version.build=r@scm-revision@-b@build-number@ # Schema number -version.schema=9001 +version.schema=9002 diff --git a/source/java/org/alfresco/repo/importer/Importer.java b/source/java/org/alfresco/repo/importer/Importer.java index 854a18f03e..f6b7cf734d 100644 --- a/source/java/org/alfresco/repo/importer/Importer.java +++ b/source/java/org/alfresco/repo/importer/Importer.java @@ -21,6 +21,7 @@ package org.alfresco.repo.importer; import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.view.Location; import org.alfresco.service.namespace.QName; /** @@ -41,6 +42,11 @@ public interface Importer */ public QName getRootAssocType(); + /** + * @return the location to import under + */ + public Location getLocation(); + /** * Signal start of import */ diff --git a/source/java/org/alfresco/repo/importer/ImporterComponent.java b/source/java/org/alfresco/repo/importer/ImporterComponent.java index f0e0743b2c..82dc73237b 100644 --- a/source/java/org/alfresco/repo/importer/ImporterComponent.java +++ b/source/java/org/alfresco/repo/importer/ImporterComponent.java @@ -258,7 +258,7 @@ public class ImporterComponent implements ImporterService public void importView(Reader viewReader, Location location, ImporterBinding binding, ImporterProgress progress) { NodeRef nodeRef = getNodeRef(location, binding); - parserImport(nodeRef, location.getChildAssocType(), viewReader, new DefaultStreamHandler(), binding, progress); + parserImport(nodeRef, location, viewReader, new DefaultStreamHandler(), binding, progress); } /* (non-Javadoc) @@ -269,7 +269,7 @@ public class ImporterComponent implements ImporterService importHandler.startImport(); Reader dataFileReader = importHandler.getDataStream(); NodeRef nodeRef = getNodeRef(location, binding); - parserImport(nodeRef, location.getChildAssocType(), dataFileReader, importHandler, binding, progress); + parserImport(nodeRef, location, dataFileReader, importHandler, binding, progress); importHandler.endImport(); } @@ -404,19 +404,19 @@ public class ImporterComponent implements ImporterService * Perform Import via Parser * * @param nodeRef node reference to import under - * @param childAssocType the child association type to import under + * @param location the location to import under * @param inputStream the input stream to import from * @param streamHandler the content property import stream handler * @param binding import configuration * @param progress import progress */ - public void parserImport(NodeRef nodeRef, QName childAssocType, Reader viewReader, ImportPackageHandler streamHandler, ImporterBinding binding, ImporterProgress progress) + public void parserImport(NodeRef nodeRef, Location location, Reader viewReader, ImportPackageHandler streamHandler, ImporterBinding binding, ImporterProgress progress) { ParameterCheck.mandatory("Node Reference", nodeRef); ParameterCheck.mandatory("View Reader", viewReader); ParameterCheck.mandatory("Stream Handler", streamHandler); - Importer nodeImporter = new NodeImporter(nodeRef, childAssocType, binding, streamHandler, progress); + Importer nodeImporter = new NodeImporter(nodeRef, location, binding, streamHandler, progress); try { nodeImporter.start(); @@ -434,19 +434,19 @@ public class ImporterComponent implements ImporterService * Perform import via Content Handler * * @param nodeRef node reference to import under - * @param childAssocType the child association type to import under + * @param location the location to import under * @param handler the import content handler * @param binding import configuration * @param progress import progress * @return content handler to interact with */ - public ContentHandler handlerImport(NodeRef nodeRef, QName childAssocType, ImportContentHandler handler, ImporterBinding binding, ImporterProgress progress) + public ContentHandler handlerImport(NodeRef nodeRef, Location location, ImportContentHandler handler, ImporterBinding binding, ImporterProgress progress) { ParameterCheck.mandatory("Node Reference", nodeRef); DefaultContentHandler defaultHandler = new DefaultContentHandler(handler); ImportPackageHandler streamHandler = new ContentHandlerStreamHandler(defaultHandler); - Importer nodeImporter = new NodeImporter(nodeRef, childAssocType, binding, streamHandler, progress); + Importer nodeImporter = new NodeImporter(nodeRef, location, binding, streamHandler, progress); defaultHandler.setImporter(nodeImporter); return defaultHandler; } @@ -474,6 +474,7 @@ public class ImporterComponent implements ImporterService { private NodeRef rootRef; private QName rootAssocType; + private Location location; private ImporterBinding binding; private ImporterProgress progress; private ImportPackageHandler streamHandler; @@ -488,14 +489,15 @@ public class ImporterComponent implements ImporterService * Construct * * @param rootRef - * @param rootAssocType + * @param location * @param binding * @param progress */ - private NodeImporter(NodeRef rootRef, QName rootAssocType, ImporterBinding binding, ImportPackageHandler streamHandler, ImporterProgress progress) + private NodeImporter(NodeRef rootRef, Location location, ImporterBinding binding, ImportPackageHandler streamHandler, ImporterProgress progress) { this.rootRef = rootRef; - this.rootAssocType = rootAssocType; + this.rootAssocType = location.getChildAssocType(); + this.location = location; this.binding = binding; this.progress = progress; this.streamHandler = streamHandler; @@ -570,7 +572,13 @@ public class ImporterComponent implements ImporterService { return rootAssocType; } - + + @Override + public Location getLocation() + { + return location; + } + /* (non-Javadoc) * @see org.alfresco.repo.importer.Importer#start() */ @@ -1597,9 +1605,26 @@ public class ImporterComponent implements ImporterService // replace existing node, if node to import has a UUID and an existing node of the same // uuid already exists String uuid = node.getUUID(); - if (uuid != null && uuid.length() > 0) + NodeRef existingNodeRef = null; + if (uuid == null) { - NodeRef existingNodeRef = new NodeRef(rootRef.getStoreRef(), uuid); + NodeRef parentNodeRef = node.getParentContext().getParentRef(); + + // Resolve to path within node, if one specified + String path = location.getPath() + "/" + QName.createQName(node.getTypeDefinition().getName().getNamespaceURI(), node.getChildName()).toPrefixString(); + // Search the node by name + List nodeRefs = searchService.selectNodes(parentNodeRef, path, null, namespaceService, false); + if (!nodeRefs.isEmpty()) + { + existingNodeRef = nodeRefs.get(0); + } + } + if (uuid != null && uuid.length() > 0 || existingNodeRef != null) + { + if (existingNodeRef == null) + { + existingNodeRef = new NodeRef(rootRef.getStoreRef(), uuid); + } if (nodeService.exists(existingNodeRef)) { // do the update