manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From piergior...@apache.org
Subject svn commit: r1828855 - /manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java
Date Tue, 10 Apr 2018 19:33:33 GMT
Author: piergiorgio
Date: Tue Apr 10 19:33:33 2018
New Revision: 1828855

URL: http://svn.apache.org/viewvc?rev=1828855&view=rev
Log:
added some bugfixes to solve issues on a real CMIS server (Alfresco 5.2.2) (CONNECTORS-1356)

Modified:
    manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java

Modified: manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java?rev=1828855&r1=1828854&r2=1828855&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java
(original)
+++ manifoldcf/branches/CONNECTORS-1356-2.7.1/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/agents/output/cmisoutput/CmisOutputConnector.java
Tue Apr 10 19:33:33 2018
@@ -23,8 +23,10 @@ import java.io.InputStream;
 import java.io.InterruptedIOException;
 import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URLEncoder;
+import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.rmi.NotBoundException;
 import java.rmi.RemoteException;
@@ -36,7 +38,6 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
-import org.apache.chemistry.opencmis.client.api.CmisObject;
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.client.api.Folder;
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
@@ -63,6 +64,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.commons.lang.StringUtils;
 import org.apache.http.NameValuePair;
 import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.client.utils.URLEncodedUtils;
 import org.apache.manifoldcf.agents.interfaces.IOutputAddActivity;
 import org.apache.manifoldcf.agents.interfaces.IOutputRemoveActivity;
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
@@ -1063,10 +1065,19 @@ public class CmisOutputConnector extends
 		return folder;
 	}
 	
+	
+	/**
+	 * Encoding process to retrieve the contentPath parameter from the documentURI.
+	 * The contentPath parameter can be passed from any repository connector that is currently
supporting the content migration capability.
+	 * @param documentURI
+	 * @return contentPath
+	 * @throws URISyntaxException
+	 * @throws UnsupportedEncodingException
+	 */
 	private String getContentPath(String documentURI) throws URISyntaxException, UnsupportedEncodingException
{
 		String contentPath = StringUtils.EMPTY;
-		String encodedDocumentURI = URLEncoder.encode(documentURI, StandardCharsets.UTF_8.name());
-		List<NameValuePair> params = new URIBuilder(encodedDocumentURI).getQueryParams();
+		String documentURIWithFixedEncoding = StringUtils.replace(documentURI, " ", "%20");
+		List<NameValuePair> params = URLEncodedUtils.parse(new URI(documentURIWithFixedEncoding),
StandardCharsets.UTF_8);
 		Iterator<NameValuePair> paramsIterator = params.iterator();
 		while (paramsIterator.hasNext()) {
 			NameValuePair param = (NameValuePair) paramsIterator.next();
@@ -1077,17 +1088,19 @@ public class CmisOutputConnector extends
 		return contentPath;
 	}
 	
-	
 	@Override
 	public void removeDocument(String documentURI, String outputDescription, IOutputRemoveActivity
activities)
 	    throws ManifoldCFException, ServiceInterruption {
 		getSession();
 		long startTime = System.currentTimeMillis();
 		String result = StringUtils.EMPTY;
+		boolean isDropZoneFolder = isDropZoneFolder(cmisQuery);
 		
 		//append the prefix for the relative path in the target repo
 		try {
-			if(parentDropZoneFolder != null && StringUtils.isNotEmpty(documentURI)) {
+			if(isDropZoneFolder 
+					&& parentDropZoneFolder != null 
+					&& StringUtils.isNotEmpty(documentURI)) {
 				String parentDropZonePath = parentDropZoneFolder.getPath();
 				
 				String contentPath = getContentPath(documentURI);



Mime
View raw message