incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From piergior...@apache.org
Subject svn commit: r1295045 - in /incubator/lcf/trunk: ./ connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/ tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/
Date Wed, 29 Feb 2012 09:52:40 GMT
Author: piergiorgio
Date: Wed Feb 29 09:52:40 2012
New Revision: 1295045

URL: http://svn.apache.org/viewvc?rev=1295045&view=rev
Log:
added an utility class for CMIS Connector that creates documentURI using an internal method
of the OpenCMIS API (CONNECTORS-417)

Added:
    incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnectorUtils.java
  (with props)
Modified:
    incubator/lcf/trunk/CHANGES.txt
    incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisAuthorityConnector.java
    incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisConfig.java
    incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
    incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/APISanityIT.java
    incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/BaseUIDerby.java
    incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/NavigationDerbyUI.java

Modified: incubator/lcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/CHANGES.txt?rev=1295045&r1=1295044&r2=1295045&view=diff
==============================================================================
--- incubator/lcf/trunk/CHANGES.txt (original)
+++ incubator/lcf/trunk/CHANGES.txt Wed Feb 29 09:52:40 2012
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 0.5-dev =====================
 
+CONNECTORS-417: CMIS Connector creates documentURI with wrong value when version is null.

+Now the documentURI to get the content stream is retrieved from the CMIS server using an
internal method of the OpenCMIS API.
+(Piergiorgio Lucidi)
+
 CONNECTORS-416: Fix web connector authentication tab.
 (Karl Wright)
 

Modified: incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisAuthorityConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisAuthorityConnector.java?rev=1295045&r1=1295044&r2=1295045&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisAuthorityConnector.java
(original)
+++ incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisAuthorityConnector.java
Wed Feb 29 09:52:40 2012
@@ -1,3 +1,5 @@
+/* $Id$ */
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements. See the NOTICE file distributed with

Modified: incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisConfig.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisConfig.java?rev=1295045&r1=1295044&r2=1295045&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisConfig.java
(original)
+++ incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisConfig.java
Wed Feb 29 09:52:40 2012
@@ -1,3 +1,5 @@
+/* $Id$ */
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements. See the NOTICE file distributed with

Modified: incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java?rev=1295045&r1=1295044&r2=1295045&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
(original)
+++ incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
Wed Feb 29 09:52:40 2012
@@ -1,3 +1,5 @@
+/* $Id$ */
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements. See the NOTICE file distributed with
@@ -16,12 +18,9 @@
  */
 package org.apache.manifoldcf.crawler.connectors.cmis;
 
-import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.InterruptedIOException;
-import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.rmi.NotBoundException;
@@ -31,8 +30,8 @@ import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Locale;
+import java.util.Map;
 
 import org.apache.chemistry.opencmis.client.api.CmisObject;
 import org.apache.chemistry.opencmis.client.api.Document;
@@ -50,7 +49,6 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
 import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
@@ -1156,9 +1154,15 @@ public class CmisRepositoryConnector ext
           }
           
           //ingestion
+          
+          //version label
           String version = document.getVersionLabel();
-          String endpoint = protocol+"://"+server+":"+port+path;
-          String documentURI = endpoint+"/"+id+"/"+version;
+          if(StringUtils.isEmpty(version))
+            version = StringUtils.EMPTY;
+          
+          //documentURI
+          String documentURI = CmisRepositoryConnectorUtils.getDocumentURL(document, session);
+          
           activities.ingestDocument(id, version, documentURI, rd);
 
         } finally {

Added: incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnectorUtils.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnectorUtils.java?rev=1295045&view=auto
==============================================================================
--- incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnectorUtils.java
(added)
+++ incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnectorUtils.java
Wed Feb 29 09:52:40 2012
@@ -0,0 +1,56 @@
+/* $Id$ */
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.manifoldcf.crawler.connectors.cmis;
+
+import java.lang.reflect.Method;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService;
+import org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomPubParser;
+import org.apache.manifoldcf.crawler.system.Logging;
+
+/**
+ * 
+ * @author Piergiorgio Lucidi
+ *
+ */
+public class CmisRepositoryConnectorUtils {
+
+  private static final String LOAD_LINK_METHOD_NAME = "loadLink";
+  
+  public static final String getDocumentURL(final Document document, final Session session)
{
+    String link = null;
+    try {
+        Method loadLink = AbstractAtomPubService.class.getDeclaredMethod(LOAD_LINK_METHOD_NAME,

+            new Class[] { String.class, String.class, String.class, String.class });
+        
+        loadLink.setAccessible(true);
+        
+        link = (String) loadLink.invoke(session.getBinding().getObjectService(), session.getRepositoryInfo().getId(),
+            document.getId(), AtomPubParser.LINK_REL_CONTENT, null);
+    } catch (Exception e) {
+      Logging.connectors.error(
+          "CMIS: Error during getting the content stream url: "
+              + e.getMessage(), e);
+    }
+    return link;
+  }
+  
+}
\ No newline at end of file

Propchange: incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnectorUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnectorUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnectorUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/APISanityIT.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/APISanityIT.java?rev=1295045&r1=1295044&r2=1295045&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/APISanityIT.java
(original)
+++ incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/APISanityIT.java
Wed Feb 29 09:52:40 2012
@@ -1,5 +1,4 @@
-package org.apache.manifoldcf.cmis_tests;
-/* $Id$ */
+/* $Id: APISanityIT.java 1234472 2012-01-22 09:59:32Z kwright $ */
 
 /**
 * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,7 +16,7 @@ package org.apache.manifoldcf.cmis_tests
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-
+package org.apache.manifoldcf.cmis_tests;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;

Modified: incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/BaseUIDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/BaseUIDerby.java?rev=1295045&r1=1295044&r2=1295045&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/BaseUIDerby.java
(original)
+++ incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/BaseUIDerby.java
Wed Feb 29 09:52:40 2012
@@ -18,15 +18,6 @@
 */
 package org.apache.manifoldcf.cmis_tests;
 
-import org.apache.manifoldcf.core.interfaces.*;
-import org.apache.manifoldcf.agents.interfaces.*;
-import org.apache.manifoldcf.crawler.interfaces.*;
-import org.apache.manifoldcf.crawler.system.ManifoldCF;
-
-import java.io.*;
-import java.util.*;
-import org.junit.*;
-
 /** Tests that run the "agents daemon" should be derived from this */
 public class BaseUIDerby extends org.apache.manifoldcf.crawler.tests.ConnectorBaseUIDerby
 {

Modified: incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/NavigationDerbyUI.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/NavigationDerbyUI.java?rev=1295045&r1=1295044&r2=1295045&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/NavigationDerbyUI.java
(original)
+++ incubator/lcf/trunk/tests/cmis/src/test/java/org/apache/manifoldcf/cmis_tests/NavigationDerbyUI.java
Wed Feb 29 09:52:40 2012
@@ -18,16 +18,10 @@
 */
 package org.apache.manifoldcf.cmis_tests;
 
-import org.apache.manifoldcf.core.interfaces.*;
-import org.apache.manifoldcf.agents.interfaces.*;
-import org.apache.manifoldcf.crawler.interfaces.*;
-import org.apache.manifoldcf.crawler.system.ManifoldCF;
-
-import java.io.*;
-import java.util.*;
-import org.junit.*;
+import java.util.Locale;
 
 import org.apache.manifoldcf.core.tests.HTMLTester;
+import org.junit.Test;
 
 /** Basic UI navigation tests */
 public class NavigationDerbyUI extends BaseUIDerby



Mime
View raw message