manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rh...@apache.org
Subject svn commit: r1828167 - in /manifoldcf/trunk/connectors/nuxeo: ./ connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/ connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/ connector/src/main/java/org/apache/man...
Date Mon, 02 Apr 2018 13:08:39 GMT
Author: rharo
Date: Mon Apr  2 13:08:39 2018
New Revision: 1828167

URL: http://svn.apache.org/viewvc?rev=1828167&view=rev
Log:
Nuxeo Connector: Updating Nuxeo Java Client, Fixing Tests and Minor Refactoring

Modified:
    manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java
    manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java
    manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoRepositoryConnector.java
    manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/DocumentManifold.java
    manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityTest.java
    manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConnectorTest.java
    manifoldcf/trunk/connectors/nuxeo/pom.xml

Modified: manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java?rev=1828167&r1=1828166&r2=1828167&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java
(original)
+++ manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java
Mon Apr  2 13:08:39 2018
@@ -33,9 +33,9 @@ import org.apache.manifoldcf.core.interf
 import org.apache.manifoldcf.core.interfaces.IThreadContext;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
 import org.apache.manifoldcf.crawler.connectors.nuxeo.NuxeoConfiguration;
-import org.nuxeo.client.api.NuxeoClient;
-import org.nuxeo.client.api.objects.user.User;
-import org.nuxeo.client.internals.spi.NuxeoClientException;
+import org.nuxeo.client.NuxeoClient;
+import org.nuxeo.client.objects.user.User;
+import org.nuxeo.client.spi.NuxeoClientException;
 
 /**
  *
@@ -76,10 +76,10 @@ public class NuxeoAuthorityConnector ext
   protected String username = null;
   protected String password = null;
 
-  protected NuxeoClient nuxeoClient = null;
+  private NuxeoClient nuxeoClient = null;
 
-  protected long lastSessionFetch = -1L;
-  protected static final long timeToRelease = 300000L;
+  private long lastSessionFetch = -1L;
+  private static final long timeToRelease = 300000L;
 
   // Constructor
   public NuxeoAuthorityConnector() {
@@ -123,10 +123,9 @@ public class NuxeoAuthorityConnector ext
    */
   @Override
   public String check() throws ManifoldCFException {
-    shutdownNuxeoClient();
-    initNuxeoClient();
+    //shutdownNuxeoClient();
     try {
-      nuxeoClient.repository().getDocumentRoot();
+      initNuxeoClient();
     } catch (NuxeoClientException ex) {
       return "Connection failed: "+ex.getMessage();
     }
@@ -152,7 +151,8 @@ public class NuxeoAuthorityConnector ext
       }
 
       String url = getUrl();
-      nuxeoClient = new NuxeoClient(url, username, password);
+      nuxeoClient = new NuxeoClient.Builder()
+              .url(url).authentication(username, password).connect();
 
     }
 
@@ -163,7 +163,7 @@ public class NuxeoAuthorityConnector ext
    */
   private void shutdownNuxeoClient() {
     if (nuxeoClient != null) {
-      nuxeoClient.shutdown();
+      nuxeoClient.disconnect();
       nuxeoClient = null;
       lastSessionFetch = -1L;
     }
@@ -193,7 +193,7 @@ public class NuxeoAuthorityConnector ext
       try {
         portInt = Integer.parseInt(port);
       } catch (NumberFormatException formatException) {
-        throw new ManifoldCFException("Bad number: " + formatException.getMessage(), formatException);
+        throw new ManifoldCFException("Port Format Error: " + formatException.getMessage(),
formatException);
       }
     } else {
       if (protocol.toLowerCase(Locale.ROOT).equals("http")) {
@@ -203,9 +203,7 @@ public class NuxeoAuthorityConnector ext
       }
     }
 
-    String url = protocol + "://" + host + ":" + portInt + "/" + path;
-
-    return url;
+    return protocol + "://" + host + ":" + portInt + "/" + path;
   }
 
   /**
@@ -352,7 +350,7 @@ public class NuxeoAuthorityConnector ext
 
     List<String> authorities = null;
 
-    User user = nuxeoClient.getUserManager().fetchUser(username);
+    User user = nuxeoClient.userManager().fetchUser(username);
     if (user != null) {
       authorities = user.getGroups();
       authorities.add(user.getUserName());

Modified: manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java?rev=1828167&r1=1828166&r2=1828167&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java
(original)
+++ manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java
Mon Apr  2 13:08:39 2018
@@ -28,35 +28,35 @@ package org.apache.manifoldcf.crawler.co
  */
 public class NuxeoConfiguration {
 
-  public static interface Server {
+  public interface Server {
 
-    public static final String USERNAME = "username";
-    public static final String PASSWORD = "password";
-    public static final String PROTOCOL = "protocol";
-    public static final String HOST = "host";
-    public static final String PORT = "port";
-    public static final String PATH = "path";
-
-    public static final String PROTOCOL_DEFAULT_VALUE = "http";
-    public static final String HOST_DEFAULT_VALUE = "";
-    public static final String PORT_DEFAULT_VALUE = "8080";
-    public static final String PATH_DEFAULT_VALUE = "/nuxeo";
-    public static final String USERNAME_DEFAULT_VALUE = "";
-    public static final String PASSWORD_DEFAULT_VALUE = "";
+    String USERNAME = "username";
+    String PASSWORD = "password";
+    String PROTOCOL = "protocol";
+    String HOST = "host";
+    String PORT = "port";
+    String PATH = "path";
+
+    String PROTOCOL_DEFAULT_VALUE = "http";
+    String HOST_DEFAULT_VALUE = "";
+    String PORT_DEFAULT_VALUE = "8080";
+    String PATH_DEFAULT_VALUE = "/nuxeo";
+    String USERNAME_DEFAULT_VALUE = "";
+    String PASSWORD_DEFAULT_VALUE = "";
 
   }
 
-  public static interface Specification {
+  public interface Specification {
 
-    public static final String DOMAINS = "domains";
-    public static final String DOMAIN = "domain";
-    public static final String DOMAIN_KEY = "key";
-    public static final String DOCUMENTS = "documents";
-    public static final String PROCESS_TAGS = "process_tags";
-    public static final String PROCESS_ATTACHMENTS = "process_attachments";
-    public static final String DOCUMENTS_TYPE = "documentsType";
-    public static final String DOCUMENT_TYPE = "documentType";
-    public static final String DOCUMENT_TYPE_KEY = "key";
+    String DOMAINS = "domains";
+    String DOMAIN = "domain";
+    String DOMAIN_KEY = "key";
+    String DOCUMENTS = "documents";
+    String PROCESS_TAGS = "process_tags";
+    String PROCESS_ATTACHMENTS = "process_attachments";
+    String DOCUMENTS_TYPE = "documentsType";
+    String DOCUMENT_TYPE = "documentType";
+    String DOCUMENT_TYPE_KEY = "key";
 
   }
 }

Modified: manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoRepositoryConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoRepositoryConnector.java?rev=1828167&r1=1828166&r2=1828167&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoRepositoryConnector.java
(original)
+++ manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoRepositoryConnector.java
Mon Apr  2 13:08:39 2018
@@ -47,10 +47,10 @@ import org.apache.manifoldcf.crawler.int
 import org.apache.manifoldcf.crawler.interfaces.IProcessActivity;
 import org.apache.manifoldcf.crawler.interfaces.IRepositoryConnector;
 import org.apache.manifoldcf.crawler.interfaces.ISeedingActivity;
-import org.nuxeo.client.api.NuxeoClient;
-import org.nuxeo.client.api.objects.Document;
-import org.nuxeo.client.api.objects.Documents;
-import org.nuxeo.client.internals.spi.NuxeoClientException;
+import org.nuxeo.client.NuxeoClient;
+import org.nuxeo.client.objects.Document;
+import org.nuxeo.client.objects.Documents;
+import org.nuxeo.client.spi.NuxeoClientException;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -69,7 +69,7 @@ public class NuxeoRepositoryConnector ex
 
   private static final String URI_DOCUMENT = "SELECT * FROM Document";
 
-  protected final static String ACTIVITY_READ = "read document";
+  private final static String ACTIVITY_READ = "read document";
 
   // Configuration tabs
   private static final String NUXEO_SERVER_TAB_PROPERTY = "NuxeoRepositoryConnector.Server";
@@ -138,7 +138,7 @@ public class NuxeoRepositoryConnector ex
   protected String username = null;
   protected String password = null;
 
-  protected NuxeoClient nuxeoClient = null;
+  private NuxeoClient nuxeoClient = null;
 
   // Constructor
   public NuxeoRepositoryConnector() {
@@ -299,10 +299,9 @@ public class NuxeoRepositoryConnector ex
   // Check the connection
   @Override
   public String check() throws ManifoldCFException {
-    shutdownNuxeoClient();
-    initNuxeoClient();
+    //shutdownNuxeoClient();
     try {
-      nuxeoClient.repository().getDocumentRoot();
+      initNuxeoClient();
     } catch (NuxeoClientException ex) {
       return "Connection failed: "+ex.getMessage();
     }
@@ -328,12 +327,12 @@ public class NuxeoRepositoryConnector ex
       }
 
       String url = getUrl();
-      nuxeoClient = new NuxeoClient(url, username, password);
+      nuxeoClient = new NuxeoClient.Builder()
+              .url(url).authentication(username, password).connect();
 
       lastSessionFetch = System.currentTimeMillis();
 
     }
-
   }
 
   /**
@@ -341,7 +340,7 @@ public class NuxeoRepositoryConnector ex
    */
   private void shutdownNuxeoClient() {
     if (nuxeoClient != null) {
-      nuxeoClient.shutdown();
+      nuxeoClient.disconnect();
       nuxeoClient = null;
       lastSessionFetch = -1L;
     }
@@ -354,6 +353,9 @@ public class NuxeoRepositoryConnector ex
    */
   String getUrl() throws ManifoldCFException {
     int portInt;
+    if (protocol == null || host == null || path == null){
+        throw new ManifoldCFException("Nuxeo Endpoint Bad Configured");
+    }
     if (port != null && port.length() > 0) {
       try {
         portInt = Integer.parseInt(port);
@@ -416,7 +418,7 @@ public class NuxeoRepositoryConnector ex
         }
 
         lastStart++;
-        isLast = docs.getIsNextPageAvailable();
+        isLast = docs.isNextPageAvailable();
 
       } while (isLast);
 
@@ -438,16 +440,6 @@ public class NuxeoRepositoryConnector ex
     }
   }
   
-  /**
-   * 
-   * @param nuxeoClient
-   * @param date
-   * @param domains
-   * @param documentsType
-   * @param limit
-   * @param start
-   * @return Documents
-   */
   Documents getDocsByDate(NuxeoClient nuxeoClient, String date, List<String> domains,
       List<String> documentsType, int limit, int start) {
 
@@ -531,15 +523,6 @@ public class NuxeoRepositoryConnector ex
     }
   }
 
-  /**
-   * @param documentId
-   * @param version
-   * @param activities
-   * @param doLog
-   * @param newHashMap
-   * @return
-   */
-
   private ProcessResult processDocument(String documentId, Specification spec, String version,
       IProcessActivity activities, boolean doLog, HashMap<String, String> extraProperties)
       throws ManifoldCFException, ServiceInterruption, IOException {
@@ -549,16 +532,6 @@ public class NuxeoRepositoryConnector ex
     return processDocumentInternal(doc, documentId, spec, version, activities, doLog, extraProperties);
   }
 
-  /**
-   * @param doc
-   * @param documentId
-   * @param version
-   * @param activities
-   * @param doLog
-   * @param extraProperties
-   * @return
-   */
-
   private ProcessResult processDocumentInternal(DocumentManifold doc, String manifoldDocumentIdentifier,
       Specification spec, String version, IProcessActivity activities, boolean doLog,
       HashMap<String, String> extraProperties) throws ManifoldCFException, ServiceInterruption,
IOException {
@@ -618,12 +591,12 @@ public class NuxeoRepositoryConnector ex
     try {
       documentUri = getUrl() + "/nxpath/" + doc.getDocument().getRepositoryName() + doc.getDocument().getPath()
           + "@view_documents";
-    } catch (NuxeoClientException ex) {
+    } catch (NuxeoClientException|ManifoldCFException ex) {
       documentUri = doc.getDocument().getUid();
     }
 
     // Set repository ACLs
-    String[] permissions = doc.getPermissions(nuxeoClient);
+    String[] permissions = doc.getPermissions();
     rd.setSecurityACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT, permissions);
     rd.setSecurityDenyACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT, new String[] { GLOBAL_DENY_TOKEN
});
     rd.setBinary(doc.getContent(), lenght);

Modified: manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/DocumentManifold.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/DocumentManifold.java?rev=1828167&r1=1828166&r2=1828167&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/DocumentManifold.java
(original)
+++ manifoldcf/trunk/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/DocumentManifold.java
Mon Apr  2 13:08:39 2018
@@ -26,13 +26,13 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import org.nuxeo.client.api.NuxeoClient;
-import org.nuxeo.client.api.objects.Document;
-import org.nuxeo.client.api.objects.Documents;
-import org.nuxeo.client.api.objects.Operation;
-import org.nuxeo.client.api.objects.acl.ACE;
-import org.nuxeo.client.api.objects.acl.ACL;
-import org.nuxeo.client.api.objects.blob.Blob;
+import org.nuxeo.client.NuxeoClient;
+import org.nuxeo.client.objects.Document;
+import org.nuxeo.client.objects.Documents;
+import org.nuxeo.client.objects.Operation;
+import org.nuxeo.client.objects.acl.ACE;
+import org.nuxeo.client.objects.acl.ACL;
+import org.nuxeo.client.objects.blob.Blob;
 
 import com.google.common.collect.Maps;
 
@@ -43,16 +43,16 @@ public class DocumentManifold {
   private static final String DEFAULT_MIMETYPE = "text/html; charset=utf-8";
   private static final String[] avoid_properties = { "file:filename", "file:content", "files:files"
};
 
-  public Document document;
-  public InputStream content;
-  protected String mimetype;
+  private Document document;
+  private InputStream content;
+  private String mimetype;
 
   public static final String DELETED = "deleted";
 
-  public static final String DOC_UID = "uid";
-  public static final String DOC_ENTITY_TYPE = "entity-type";
-  public static final String DOC_LAST_MODIFIED = "last-modified";
-  public static final String DOC_STATE = "state";
+  private static final String DOC_UID = "uid";
+  private static final String DOC_ENTITY_TYPE = "entity-type";
+  private static final String DOC_LAST_MODIFIED = "last-modified";
+  private static final String DOC_STATE = "state";
 
   // Constructor
   public DocumentManifold(Document document) {
@@ -82,26 +82,20 @@ public class DocumentManifold {
     return docMetadata;
   }
 
-  public void addIfNotEmpty(Map<String, Object> docMetadata, String key, Object obj)
{
+  private void addIfNotEmpty(Map<String, Object> docMetadata, String key, Object obj)
{
     if (obj != null && ((obj instanceof String && !((String) obj).isEmpty())
|| !(obj instanceof String))) {
       docMetadata.put(key, obj);
     }
   }
 
   private void processDocument() {
-
-    // Content
-    InputStream is = null;
-    String mimetype = null;
     try {
-      is = document.fetchBlob().getStream();
-      this.mimetype = (String) ((LinkedHashMap<?, ?>) this.getDocument().get("file:content")).get("mime-type");
+      this.content = document.fetchBlob().getStream();
+      this.mimetype = (String) ((Map) this.document.getPropertyValue("file:content")).get("mime-type");
     } catch (Exception ex) {
-      is = new ByteArrayInputStream("".getBytes());
-      mimetype = DEFAULT_MIMETYPE;
+      this.content = new ByteArrayInputStream("".getBytes());
+      this.mimetype = DEFAULT_MIMETYPE;
     }
-    this.content = is;
-    this.mimetype = mimetype;
   }
 
   // GETTERS AND SETERS
@@ -127,9 +121,9 @@ public class DocumentManifold {
     return this.content;
   }
 
-  public String[] getPermissions(NuxeoClient nuxeoClient) {
+  public String[] getPermissions() {
 
-    List<String> permissions = new ArrayList<String>();
+    List<String> permissions = new ArrayList<>();
     try {
       for (ACL acl : this.getDocument().fetchPermissions().getAcls()) {
         for (ACE ace : acl.getAces()) {
@@ -146,8 +140,8 @@ public class DocumentManifold {
   }
 
   public List<Attachment> getAttachments(NuxeoClient nuxeoClient) {
-    List<Attachment> attachments = new ArrayList<Attachment>();
-    List<?> arrayList = (List<?>) this.document.get(Attachment.ATT_KEY_FILES);
+    List<Attachment> attachments = new ArrayList<>();
+    List<?> arrayList = this.document.getPropertyValue(Attachment.ATT_KEY_FILES);
 
     for (Object object : arrayList) {
       Attachment attach = new Attachment();
@@ -179,20 +173,18 @@ public class DocumentManifold {
     return attachments;
   }
 
-  public String getAttachPath(String absolutePath) {
+  private String getAttachPath(String absolutePath) {
     String[] splitPath = absolutePath.split("/");
     int size = splitPath.length;
-    String path = String.join("/", splitPath[size - 4], splitPath[size - 3], splitPath[size
- 2]);
-
-    return path;
+    return String.join("/", splitPath[size - 4], splitPath[size - 3], splitPath[size - 2]);
   }
 
   public String[] getTags(NuxeoClient nuxeoClient) {
     try {
-      Operation op = nuxeoClient.automation("Repository.Query").param("query",
+      Operation op = nuxeoClient.operation("Repository.Query").param("query",
           URI_TAGGING + " where relation:source='" + this.document.getUid() + "'");
       Documents tags = op.execute();
-      List<String> ls = new ArrayList<String>();
+      List<String> ls = new ArrayList<>();
 
       for (Document tag : tags.getDocuments()) {
         ls.add(tag.getTitle());

Modified: manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityTest.java?rev=1828167&r1=1828166&r2=1828167&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityTest.java
(original)
+++ manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityTest.java
Mon Apr  2 13:08:39 2018
@@ -16,17 +16,15 @@
 */
 package org.apache.manifoldcf.authorities.authorities.nuxeo;
 
-import org.apache.manifoldcf.authorities.authorities.nuxeo.NuxeoAuthorityConnector;
 import org.apache.manifoldcf.authorities.interfaces.AuthorizationResponse;
 import org.apache.manifoldcf.authorities.interfaces.IAuthorityConnector;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.Ignore;
 import org.junit.runner.RunWith;
 import static org.junit.Assert.assertEquals;
-import org.nuxeo.client.api.NuxeoClient;
-import org.nuxeo.client.api.objects.user.User;
-import org.nuxeo.client.api.objects.user.UserManager;
+import org.nuxeo.client.NuxeoClient;
+import org.nuxeo.client.objects.user.User;
+import org.nuxeo.client.objects.user.UserManager;
 import org.mockito.Mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -48,17 +46,16 @@ public class NuxeoAuthorityTest {
   private NuxeoAuthorityConnector authorityConnector;
 
   @Before
-  public void setup() throws Exception {
+  public void setup() {
     authorityConnector = new NuxeoAuthorityConnector();
     authorityConnector.setNuxeoClient(client);
   }
 
   @Test
-  @Ignore
   public void check() throws Exception {
 
-    when(client.getUserManager()).thenReturn(mock(UserManager.class));
-    when(client.getUserManager().fetchUser(anyString())).thenReturn(mock(User.class));
+    when(client.userManager()).thenReturn(mock(UserManager.class));
+    when(client.userManager().fetchUser(anyString())).thenReturn(mock(User.class));
     
     assertEquals(authorityConnector.check(), "Connection working");
   }
@@ -68,8 +65,8 @@ public class NuxeoAuthorityTest {
     UserManager userManager = mock(UserManager.class);
     User user = mock(User.class);
     
-    when(client.getUserManager()).thenReturn(userManager);
-    when(client.getUserManager().fetchUser("")).thenReturn(user);
+    when(client.userManager()).thenReturn(userManager);
+    when(client.userManager().fetchUser("")).thenReturn(user);
     
     AuthorizationResponse response = authorityConnector.getAuthorizationResponse("NOT_USER_EXIST");
     String[] tokens = response.getAccessTokens();
@@ -81,8 +78,8 @@ public class NuxeoAuthorityTest {
 
   @Test
   public void checkUserFound() throws Exception {
-    when(client.getUserManager()).thenReturn(mock(UserManager.class));
-    when(client.getUserManager().fetchUser(anyString())).thenReturn(mock(User.class));
+    when(client.userManager()).thenReturn(mock(UserManager.class));
+    when(client.userManager().fetchUser(anyString())).thenReturn(mock(User.class));
     
     AuthorizationResponse response = authorityConnector.getAuthorizationResponse("Administrator");
     

Modified: manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConnectorTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConnectorTest.java?rev=1828167&r1=1828166&r2=1828167&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConnectorTest.java
(original)
+++ manifoldcf/trunk/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConnectorTest.java
Mon Apr  2 13:08:39 2018
@@ -29,29 +29,27 @@ import java.text.DateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
+import java.util.List;
 
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
 import org.apache.manifoldcf.core.interfaces.Specification;
 import org.apache.manifoldcf.crawler.connectors.BaseRepositoryConnector;
-import org.apache.manifoldcf.crawler.connectors.nuxeo.NuxeoRepositoryConnector;
 import org.apache.manifoldcf.crawler.connectors.nuxeo.model.DocumentManifold;
 import org.apache.manifoldcf.crawler.interfaces.IExistingVersions;
 import org.apache.manifoldcf.crawler.interfaces.IProcessActivity;
 import org.apache.manifoldcf.crawler.system.SeedingActivity;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.Ignore;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.nuxeo.client.api.NuxeoClient;
-import org.nuxeo.client.api.objects.Document;
-import org.nuxeo.client.api.objects.Documents;
-import org.nuxeo.client.api.objects.Repository;
+import org.nuxeo.client.NuxeoClient;
+import org.nuxeo.client.objects.Document;
+import org.nuxeo.client.objects.Documents;
+import org.nuxeo.client.objects.Repository;
 
 /**
  * @author David Arroyo Escobar <arroyoescobardavid@gmail.com>
@@ -61,25 +59,24 @@ import org.nuxeo.client.api.objects.Repo
 public class NuxeoConnectorTest {
 
   @Mock
-  public NuxeoClient client;
+  private NuxeoClient client;
 
-  public NuxeoRepositoryConnector repositoryConnector;
+  private NuxeoRepositoryConnector repositoryConnector;
 
   @Before
-  public void setup() throws Exception {
+  public void setup(){
 
     repositoryConnector = new NuxeoRepositoryConnector();
     repositoryConnector.setNuxeoClient(client);
-  };
+  }
 
   @Test
-  @Ignore
   public void checkMockInjection() throws Exception {
     Document doc = mock(Document.class);
     Repository repository = mock(Repository.class);
     
     when(client.repository()).thenReturn(repository);
-    when(client.repository().getDocumentRoot()).thenReturn(doc);
+    when(client.repository().fetchDocumentRoot()).thenReturn(doc);
     assertEquals(repositoryConnector.check(), "Connection working");
   }
 
@@ -99,7 +96,7 @@ public class NuxeoConnectorTest {
     when(client.repository()).thenReturn(repository);
     when(client.repository().query(anyString(), anyString(), anyString(), anyString(), anyString(),
         anyString(), anyString())).thenReturn(docs);
-    when(docs.getIsNextPageAvailable()).thenReturn(false);
+    when(docs.isNextPageAvailable()).thenReturn(false);
     when(docs.getDocuments()).thenReturn(documents);
     
     repositoryConnector.addSeedDocuments(activities, spec, "", seedTime,
@@ -122,7 +119,7 @@ public class NuxeoConnectorTest {
     when(client.repository()).thenReturn(repository);
     when(client.repository().query(anyString(), anyString(), anyString(), anyString(), anyString(),
         anyString(), anyString())).thenReturn(docs);
-    when(docs.getIsNextPageAvailable()).thenReturn(false);
+    when(docs.isNextPageAvailable()).thenReturn(false);
     when(docs.getDocuments()).thenReturn(documents);
     
     repositoryConnector.addSeedDocuments(activities, spec, "", seedTime,
@@ -152,7 +149,6 @@ public class NuxeoConnectorTest {
   }
 
   @Test
-  @Ignore
   public void mockSimpleIngestion() throws Exception {
 
     Document doc = mock(Document.class);
@@ -163,7 +159,7 @@ public class NuxeoConnectorTest {
     Long size = 0L;
     String id;
     String uri = "http://localhost:8080/nuxeo/site/api/v1/id/7995ff6d-1eda-41db-b9de-3ea4037fdb81";
-    Map<String, Object> metadata = new HashMap<String, Object>();
+    Map<String, Object> metadata = new HashMap<>();
     IProcessActivity activities = mock(IProcessActivity.class);
     IExistingVersions statuses = mock(IExistingVersions.class);
     Specification spec = new Specification();
@@ -173,7 +169,7 @@ public class NuxeoConnectorTest {
     metadata.put("key", "value");
     id = df.format(date);
 
-    when(doc.get("lenght")).thenReturn(size);
+    when(doc.getPropertyValue("lenght")).thenReturn(size);
     when(doc.getLastModified()).thenReturn(version);
     when(docMa.getMetadata()).thenReturn(metadata);
     when(doc.getUid()).thenReturn(uri);

Modified: manifoldcf/trunk/connectors/nuxeo/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/nuxeo/pom.xml?rev=1828167&r1=1828166&r2=1828167&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/nuxeo/pom.xml (original)
+++ manifoldcf/trunk/connectors/nuxeo/pom.xml Mon Apr  2 13:08:39 2018
@@ -36,6 +36,11 @@
       <name>David Arroyo Escobar</name>
       <email>arroyoescobardavid@gmail.com</email>
     </developer>
+
+    <developer>
+      <name>Rafa Haro</name>
+      <email>rharo@apache.org</email>
+    </developer>
   </developers>
 
   <properties>
@@ -371,9 +376,8 @@
     <dependency>
         <groupId>org.nuxeo.client</groupId>
         <artifactId>nuxeo-java-client</artifactId>
-        <version>2.5</version>
+        <version>3.0.1-SNAPSHOT</version>
       </dependency>
-      <!-- End nuxeo client -->
   </dependencies>
 
 </project>



Mime
View raw message