You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2016/11/23 07:28:32 UTC
svn commit: r1770925 [3/3] - in
/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src:
main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/
main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/
main/java/org/apache/manifoldc...
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/exception/NuxeoException.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/exception/NuxeoException.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/exception/NuxeoException.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/exception/NuxeoException.java Wed Nov 23 07:28:32 2016
@@ -1,17 +1,35 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
+/**
+* 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.nuxeo.exception;
public class NuxeoException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = -7504820888917970500L;
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7504820888917970500L;
- public NuxeoException(String message) {
- super(message);
- }
+ public NuxeoException(String message) {
+ super(message);
+ }
- public NuxeoException(String message, Throwable throwable) {
- super(message, throwable);
- }
+ public NuxeoException(String message, Throwable throwable) {
+ super(message, throwable);
+ }
}
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Ace.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Ace.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Ace.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Ace.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.model;
/**
@@ -9,45 +24,45 @@ package org.apache.manifoldcf.crawler.co
*/
public class Ace {
- protected String name;
- protected boolean granted;
- protected String status;
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
- /**
- * @return the granted
- */
- public boolean isGranted() {
- return granted;
- }
- /**
- * @param granted the granted to set
- */
- public void setGranted(boolean granted) {
- this.granted = granted;
- }
- /**
- * @return the status
- */
- public String getStatus() {
- return status;
- }
- /**
- * @param status the status to set
- */
- public void setStatus(String status) {
- this.status = status;
- }
-
-
+ protected String name;
+ protected boolean granted;
+ protected String status;
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return the granted
+ */
+ public boolean isGranted() {
+ return granted;
+ }
+ /**
+ * @param granted the granted to set
+ */
+ public void setGranted(boolean granted) {
+ this.granted = granted;
+ }
+ /**
+ * @return the status
+ */
+ public String getStatus() {
+ return status;
+ }
+ /**
+ * @param status the status to set
+ */
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+
}
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Acl.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Acl.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Acl.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Acl.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.model;
import java.util.ArrayList;
@@ -17,73 +32,73 @@ import org.json.JSONObject;
*/
public class Acl extends Document {
- public static final String KEY_ACL = "acl";
- public static final String KEY_ACE = "ace";
+ public static final String KEY_ACL = "acl";
+ public static final String KEY_ACE = "ace";
- public static final String KEY_NAME = "username";
- public static final String KEY_GRANTED = "granted";
- public static final String KEY_STATUS = "status";
-
- protected List<Ace> aces = new ArrayList<Ace>();;
-
- public List<Ace> getAces() {
- return aces;
- }
-
- public static NuxeoResourceBuilder<? extends Acl> builder() {
- return new AclBuilder();
- }
-
- public static class AclBuilder implements NuxeoResourceBuilder<Acl> {
-
- public Acl fromJson(JSONObject jsonDocument) {
- return fromJson(jsonDocument, new Acl());
- }
-
- public Acl fromJson(JSONObject jsonDocument, Acl acl) {
-
- try {
-
- JSONArray aclArray = jsonDocument.getJSONArray(KEY_ACL);
-
- for (int i = 0; i < aclArray.length(); i++) {
- JSONObject aclObj = aclArray.getJSONObject(i);
- JSONArray aceArray = aclObj.getJSONArray(KEY_ACE);
-
- for (int j = 0; j < aceArray.length(); j++) {
- Ace ace = new Ace();
- JSONObject aceObj = aceArray.getJSONObject(j);
-
- ace.setName(aceObj.getString(KEY_NAME));
- ace.setGranted(aceObj.getBoolean(KEY_GRANTED));
- ace.setStatus(aceObj.getString(KEY_STATUS));
-
- acl.aces.add(ace);
- }
-
-
- }
-
- return acl;
-
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- return new Acl();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.manifoldcf.crawler.connectors.nuxeo.model.builder.
- * NuxeoResourceBuilder#getType()
- */
- @Override
- public Class<Acl> getType() {
- return Acl.class;
- }
+ public static final String KEY_NAME = "username";
+ public static final String KEY_GRANTED = "granted";
+ public static final String KEY_STATUS = "status";
+
+ protected List<Ace> aces = new ArrayList<Ace>();;
+
+ public List<Ace> getAces() {
+ return aces;
+ }
+
+ public static NuxeoResourceBuilder<? extends Acl> builder() {
+ return new AclBuilder();
+ }
+
+ public static class AclBuilder implements NuxeoResourceBuilder<Acl> {
+
+ public Acl fromJson(JSONObject jsonDocument) {
+ return fromJson(jsonDocument, new Acl());
+ }
+
+ public Acl fromJson(JSONObject jsonDocument, Acl acl) {
+
+ try {
+
+ JSONArray aclArray = jsonDocument.getJSONArray(KEY_ACL);
+
+ for (int i = 0; i < aclArray.length(); i++) {
+ JSONObject aclObj = aclArray.getJSONObject(i);
+ JSONArray aceArray = aclObj.getJSONArray(KEY_ACE);
+
+ for (int j = 0; j < aceArray.length(); j++) {
+ Ace ace = new Ace();
+ JSONObject aceObj = aceArray.getJSONObject(j);
+
+ ace.setName(aceObj.getString(KEY_NAME));
+ ace.setGranted(aceObj.getBoolean(KEY_GRANTED));
+ ace.setStatus(aceObj.getString(KEY_STATUS));
+
+ acl.aces.add(ace);
+ }
+
+
+ }
+
+ return acl;
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ return new Acl();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.manifoldcf.crawler.connectors.nuxeo.model.builder.
+ * NuxeoResourceBuilder#getType()
+ */
+ @Override
+ public Class<Acl> getType() {
+ return Acl.class;
+ }
- }
+ }
}
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Attachment.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Attachment.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Attachment.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Attachment.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.model;
/**
@@ -9,31 +24,31 @@ package org.apache.manifoldcf.crawler.co
*/
public class Attachment{
- public static final String ATT_KEY_FILE = "file";
- public static final String ATT_KEY_NAME = "name";
- public static final String ATT_KEY_MIME_TYPE = "mime-type";
- public static final String ATT_KEY_URL = "data";
- public static final String ATT_KEY_LENGTH = "length";
-
- protected String name;
- protected String mime_type;
- protected String url;
- protected long length;
-
- public String getName() {
- return name;
- }
-
- public String getMime_type() {
- return mime_type;
- }
-
- public String getUrl() {
- return url;
- }
-
- public long getLength() {
- return length;
- }
+ public static final String ATT_KEY_FILE = "file";
+ public static final String ATT_KEY_NAME = "name";
+ public static final String ATT_KEY_MIME_TYPE = "mime-type";
+ public static final String ATT_KEY_URL = "data";
+ public static final String ATT_KEY_LENGTH = "length";
+
+ protected String name;
+ protected String mime_type;
+ protected String url;
+ protected long length;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getMime_type() {
+ return mime_type;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public long getLength() {
+ return length;
+ }
}
\ No newline at end of file
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Document.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Document.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Document.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Document.java Wed Nov 23 07:28:32 2016
@@ -1,3 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
+/**
+* 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.nuxeo.model;
import java.io.ByteArrayInputStream;
@@ -18,396 +36,396 @@ import com.google.common.collect.Maps;
public class Document extends NuxeoResource {
- public static final String DELETED = "deleted";
- // KEYS
- protected static final String KEY_UID = "uid";
- protected static final String KEY_TITLE = "title";
- protected static final String KEY_LAST_MODIFIED = "lastModified";
- protected static final String KEY_STATE = "state";
- protected static final String KEY_TYPE = "type";
- protected static final String KEY_PATH = "path";
- protected static final String KEY_MEDIATYPE = "mediaType";
- protected static final String KEY_IS_CHECKED_OUT = "isCheckedOut";
- protected static final String KEY_PARENT_REF = "parentRef";
- protected static final String KEY_REPOSITORY = "repository";
- protected static final String KEY_ATTACHMENTS = "atachments";
-
- protected static final String KEY_PROPERTIES = "properties";
-
- protected static final String DC_PREFFIX = "dc:";
- protected static final String KEY_DC_DESCRIPTION = "description";
- protected static final String KEY_DC_LANGUAGE = "language";
- protected static final String KEY_DC_COVERAGE = "coverage";
- protected static final String KEY_DC_VALID = "valid";
- protected static final String KEY_DC_CREATOR = "creator";
- protected static final String KEY_DC_CREATED = "created";
- protected static final String KEY_DC_LAST_CONTRIBUTOR = "dc:lastContributor";
- protected static final String KEY_DC_RIGHTS = "rights";
- protected static final String KEY_DC_EXPIRED = "expired";
- protected static final String KEY_DC_ISSUED = "issued";
- protected static final String KEY_DC_NATURE = "nature";
- protected static final String KEY_DC_SUBJECTS = "subjects";
- protected static final String KEY_DC_CONTRIBUTORS = "contributors";
- protected static final String KEY_DC_SOURCE = "source";
- protected static final String KEY_DC_PUBLISHER = "publisher";
-
- protected static final String NOTE_PREFFIX = "note:";
- protected static final String NOTE_SAVE_PREFFIX = "note__";
- protected static final String KEY_NOTE_NOTE = "note";
- protected static final String KEY_NOTE_MYMETYPE = "mime_type";
-
- protected static final String ATT_PREFFIX = "files:";
- protected static final String ATT_MAIN_PREFFIX = "file:";
- protected static final String ATT_CONTENT = "content";
- protected static final String ATT_FILES = "files";
-
- protected static final String DOCUMENT_SIZE = "size";
-
- // Attributes
- protected String uid;
- protected String title;
- protected Date lastModified;
- protected String state;
- protected String mediatype = "text/html; charset=utf-8";
- protected long length;
- protected String content;
- protected String path;
- protected String type;
- protected Boolean isCheckedOut;
- protected String parentRef;
- protected String repository;
-
- protected String description;
- protected String language;
- protected String coverage;
- protected String valid;
- protected String creator;
- protected String created;
- protected String lastContributor;
- protected String rights;
- protected String expired;
- protected String issued;
- protected String nature;
- protected List<String> subjects = new ArrayList<>();
- protected List<String> contributors = new ArrayList<>();
- protected String source;
- protected String publisher;
-
- protected String note;
- protected String noteMimeType;
-
- protected List<Attachment> attachments = new ArrayList<>();
-
- @SuppressWarnings("unused")
- private JSONObject delegated;
-
- public Document() {
-
- }
-
- // Getters
- public String getUid() {
- return uid;
- }
-
- public String getTitle() {
- return title;
- }
-
- public Date getLastModified() {
- return lastModified;
- }
-
- public String getState() {
- return state;
- }
-
- public String getPath() {
- return path;
- }
-
- public String getType() {
- return type;
- }
-
- public String getMediatype() {
- return this.mediatype;
- }
-
- public Boolean getIsCheckedOut() {
- return isCheckedOut;
- }
-
- public String getParentRef() {
- return parentRef;
- }
-
- public String getRepository() {
- return repository;
- }
-
- public long getLenght() {
- return this.length;
- }
-
- public String getContent() {
- return content;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public String getCoverage() {
- return coverage;
- }
-
- public String getValid() {
- return valid;
- }
-
- public String getCreator() {
- return creator;
- }
-
- public String getCreated() {
- return created;
- }
-
- public String getLastContributor() {
- return lastContributor;
- }
-
- public String getRights() {
- return rights;
- }
-
- public String getExpired() {
- return expired;
- }
-
- public String getIssued() {
- return issued;
- }
-
- public String getNature() {
- return nature;
- }
-
- public List<String> getSubjects() {
- return subjects;
- }
-
- public List<String> getContributors() {
- return contributors;
- }
-
- public String getSource() {
- return source;
- }
-
- public String getPublisher() {
- return publisher;
- }
-
- public String getNote() {
- return note;
- }
-
- public String getNoteMimeType() {
- return noteMimeType;
- }
-
- public List<Attachment> getAttachments() {
- return attachments;
- }
-
- public boolean hasContent() {
- return this.length > 0 && this.content != null;
- }
-
- public InputStream getContentStream() {
- String contentStream = content != null ? content : "";
- return new ByteArrayInputStream(contentStream.getBytes(StandardCharsets.UTF_8));
- }
-
- public Map<String, Object> getMetadataAsMap() {
- Map<String, Object> docMetadata = Maps.newHashMap();
-
- docMetadata.put(KEY_UID, this.uid);
- docMetadata.put(KEY_TITLE, this.title);
- if (this.lastModified != null)
- docMetadata.put(KEY_LAST_MODIFIED, DateParser.formatISO8601Date(this.lastModified));
- docMetadata.put(KEY_STATE, this.state);
- docMetadata.put(KEY_MEDIATYPE, this.mediatype);
- docMetadata.put(KEY_TYPE, this.type);
- docMetadata.put(KEY_PATH, this.path);
- if (this.isCheckedOut != null)
- docMetadata.put(KEY_IS_CHECKED_OUT, this.isCheckedOut.toString());
- docMetadata.put(KEY_REPOSITORY, this.repository);
- docMetadata.put(KEY_PARENT_REF, this.parentRef);
-
- addIfNotEmpty(docMetadata, KEY_DC_DESCRIPTION, this.description);
- addIfNotEmpty(docMetadata, KEY_DC_LANGUAGE, this.language);
- addIfNotEmpty(docMetadata, KEY_DC_COVERAGE, this.coverage);
- addIfNotEmpty(docMetadata, KEY_DC_VALID, this.valid);
- addIfNotEmpty(docMetadata, KEY_DC_CREATOR, this.creator);
- addIfNotEmpty(docMetadata, KEY_DC_LAST_CONTRIBUTOR, this.lastContributor);
- addIfNotEmpty(docMetadata, KEY_DC_RIGHTS, this.rights);
- addIfNotEmpty(docMetadata, KEY_DC_EXPIRED, this.expired);
- addIfNotEmpty(docMetadata, KEY_DC_CREATED, this.created);
- addIfNotEmpty(docMetadata, KEY_DC_ISSUED, this.issued);
- addIfNotEmpty(docMetadata, KEY_DC_NATURE, this.nature);
- addIfNotEmpty(docMetadata, KEY_DC_SOURCE, this.source);
- addIfNotEmpty(docMetadata, KEY_DC_PUBLISHER, this.publisher);
- addIfNotEmpty(docMetadata, KEY_DC_SUBJECTS, this.subjects);
- addIfNotEmpty(docMetadata, KEY_DC_CONTRIBUTORS, this.contributors);
- addIfNotEmpty(docMetadata, NOTE_SAVE_PREFFIX + KEY_NOTE_NOTE, this.note);
- addIfNotEmpty(docMetadata, NOTE_SAVE_PREFFIX + KEY_NOTE_MYMETYPE, this.noteMimeType);
-
- return docMetadata;
- }
-
- public 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);
- }
- }
-
- public static NuxeoResourceBuilder<? extends Document> builder() {
- return new DocumentBuilder();
- }
-
- public static class DocumentBuilder implements NuxeoResourceBuilder<Document> {
-
- public Document fromJson(JSONObject jsonDocument) {
- return fromJson(jsonDocument, new Document());
- }
-
- public Document fromJson(JSONObject jsonDocument, Document document) {
-
- try {
- String uid = jsonDocument.getString(KEY_UID);
- String title = jsonDocument.getString(KEY_TITLE);
- Date lastModified = DateParser.parseISO8601Date(jsonDocument.optString(KEY_LAST_MODIFIED, ""));
- String state = jsonDocument.optString(KEY_STATE, "");
- String path = jsonDocument.optString(KEY_PATH, "");
- String type = jsonDocument.optString(KEY_TYPE, "");
- Boolean isCheckedOut = jsonDocument.optBoolean(KEY_IS_CHECKED_OUT);
- String repository = jsonDocument.optString(KEY_REPOSITORY, "");
- String parentRef = jsonDocument.optString(KEY_PARENT_REF, "");
-
- document.uid = uid;
- document.title = title;
- document.lastModified = lastModified;
- document.state = state;
- document.path = path;
- document.type = type;
- document.isCheckedOut = isCheckedOut;
- document.repository = repository;
- document.parentRef = parentRef;
-
- document.length = (document.content != null) ? document.content.getBytes().length : 0;
-
- JSONObject properties = (JSONObject) jsonDocument.opt(KEY_PROPERTIES);
-
- if (properties != null) {
-
- document.description = properties.optString(DC_PREFFIX + KEY_DC_DESCRIPTION);
- document.language = properties.optString(DC_PREFFIX + KEY_DC_LANGUAGE);
- document.coverage = properties.optString(DC_PREFFIX + KEY_DC_COVERAGE);
- document.valid = properties.optString(DC_PREFFIX + KEY_DC_VALID);
- document.creator = properties.optString(DC_PREFFIX + KEY_DC_CREATOR);
- document.lastContributor = properties.optString(DC_PREFFIX + KEY_DC_LAST_CONTRIBUTOR);
- document.rights = properties.optString(DC_PREFFIX + KEY_DC_RIGHTS);
- document.expired = properties.optString(DC_PREFFIX + KEY_DC_EXPIRED);
- document.created = properties.optString(DC_PREFFIX + KEY_DC_CREATED);
- document.issued = properties.optString(DC_PREFFIX + KEY_DC_ISSUED);
- document.nature = properties.optString(DC_PREFFIX + KEY_DC_NATURE);
- document.source = properties.optString(DC_PREFFIX + KEY_DC_SOURCE);
- document.publisher = properties.optString(DC_PREFFIX + KEY_DC_PUBLISHER);
-
- JSONArray subjectsArray = properties.optJSONArray(DC_PREFFIX + KEY_DC_SUBJECTS);
-
- if (subjectsArray != null)
- for (int i = 0; i < subjectsArray.length(); i++) {
- if (subjectsArray.optString(i) != null)
- document.subjects.add(subjectsArray.getString(i));
- }
-
- JSONArray contributorsArray = properties.optJSONArray(DC_PREFFIX + KEY_DC_CONTRIBUTORS);
-
- if (contributorsArray != null)
- for (int i = 0; i < contributorsArray.length(); i++) {
- if (contributorsArray.optString(i) != null)
- document.contributors.add(contributorsArray.getString(i));
- }
-
- if (document.type.equalsIgnoreCase(DocumentType.NOTE.value())) {
- document.note = properties.optString(NOTE_PREFFIX + KEY_NOTE_NOTE);
- document.noteMimeType = properties.optString(NOTE_PREFFIX + KEY_NOTE_MYMETYPE);
- }
-
- JSONObject mainFile = properties.optJSONObject(ATT_MAIN_PREFFIX + ATT_CONTENT);
-
- if (mainFile != null) {
- Attachment att = new Attachment();
-
- att.name = mainFile.optString(Attachment.ATT_KEY_NAME);
- att.mime_type = mainFile.optString(Attachment.ATT_KEY_MIME_TYPE);
- att.url = mainFile.optString(Attachment.ATT_KEY_URL);
- att.length = mainFile.optLong(Attachment.ATT_KEY_LENGTH);
-
- document.attachments.add(att);
- }
-
- JSONArray files = properties.optJSONArray(ATT_PREFFIX + ATT_FILES);
-
- if (files != null)
- for (int i = 0; i < files.length(); i++) {
- if (files.optJSONObject(i) != null) {
- Attachment att = new Attachment();
-
- JSONObject fileObj = files.optJSONObject(i);
- JSONObject file = fileObj.getJSONObject(Attachment.ATT_KEY_FILE);
-
- att.name = file.optString(Attachment.ATT_KEY_NAME);
- att.mime_type = file.optString(Attachment.ATT_KEY_MIME_TYPE);
- att.url = file.optString(Attachment.ATT_KEY_URL);
- att.length = file.optLong(Attachment.ATT_KEY_LENGTH);
-
- document.attachments.add(att);
- }
-
- }
- }
-
- document.delegated = jsonDocument;
-
- return document;
-
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- return new Document();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.manifoldcf.crawler.connectors.nuxeo.model.builder.
- * NuxeoResourceBuilder#getType()
- */
- @Override
- public Class<Document> getType() {
- return Document.class;
- }
+ public static final String DELETED = "deleted";
+ // KEYS
+ protected static final String KEY_UID = "uid";
+ protected static final String KEY_TITLE = "title";
+ protected static final String KEY_LAST_MODIFIED = "lastModified";
+ protected static final String KEY_STATE = "state";
+ protected static final String KEY_TYPE = "type";
+ protected static final String KEY_PATH = "path";
+ protected static final String KEY_MEDIATYPE = "mediaType";
+ protected static final String KEY_IS_CHECKED_OUT = "isCheckedOut";
+ protected static final String KEY_PARENT_REF = "parentRef";
+ protected static final String KEY_REPOSITORY = "repository";
+ protected static final String KEY_ATTACHMENTS = "atachments";
+
+ protected static final String KEY_PROPERTIES = "properties";
+
+ protected static final String DC_PREFFIX = "dc:";
+ protected static final String KEY_DC_DESCRIPTION = "description";
+ protected static final String KEY_DC_LANGUAGE = "language";
+ protected static final String KEY_DC_COVERAGE = "coverage";
+ protected static final String KEY_DC_VALID = "valid";
+ protected static final String KEY_DC_CREATOR = "creator";
+ protected static final String KEY_DC_CREATED = "created";
+ protected static final String KEY_DC_LAST_CONTRIBUTOR = "dc:lastContributor";
+ protected static final String KEY_DC_RIGHTS = "rights";
+ protected static final String KEY_DC_EXPIRED = "expired";
+ protected static final String KEY_DC_ISSUED = "issued";
+ protected static final String KEY_DC_NATURE = "nature";
+ protected static final String KEY_DC_SUBJECTS = "subjects";
+ protected static final String KEY_DC_CONTRIBUTORS = "contributors";
+ protected static final String KEY_DC_SOURCE = "source";
+ protected static final String KEY_DC_PUBLISHER = "publisher";
+
+ protected static final String NOTE_PREFFIX = "note:";
+ protected static final String NOTE_SAVE_PREFFIX = "note__";
+ protected static final String KEY_NOTE_NOTE = "note";
+ protected static final String KEY_NOTE_MYMETYPE = "mime_type";
+
+ protected static final String ATT_PREFFIX = "files:";
+ protected static final String ATT_MAIN_PREFFIX = "file:";
+ protected static final String ATT_CONTENT = "content";
+ protected static final String ATT_FILES = "files";
+
+ protected static final String DOCUMENT_SIZE = "size";
+
+ // Attributes
+ protected String uid;
+ protected String title;
+ protected Date lastModified;
+ protected String state;
+ protected String mediatype = "text/html; charset=utf-8";
+ protected long length;
+ protected String content;
+ protected String path;
+ protected String type;
+ protected Boolean isCheckedOut;
+ protected String parentRef;
+ protected String repository;
+
+ protected String description;
+ protected String language;
+ protected String coverage;
+ protected String valid;
+ protected String creator;
+ protected String created;
+ protected String lastContributor;
+ protected String rights;
+ protected String expired;
+ protected String issued;
+ protected String nature;
+ protected List<String> subjects = new ArrayList<>();
+ protected List<String> contributors = new ArrayList<>();
+ protected String source;
+ protected String publisher;
+
+ protected String note;
+ protected String noteMimeType;
+
+ protected List<Attachment> attachments = new ArrayList<>();
+
+ @SuppressWarnings("unused")
+ private JSONObject delegated;
+
+ public Document() {
+
+ }
+
+ // Getters
+ public String getUid() {
+ return uid;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public Date getLastModified() {
+ return lastModified;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getMediatype() {
+ return this.mediatype;
+ }
+
+ public Boolean getIsCheckedOut() {
+ return isCheckedOut;
+ }
+
+ public String getParentRef() {
+ return parentRef;
+ }
+
+ public String getRepository() {
+ return repository;
+ }
+
+ public long getLenght() {
+ return this.length;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public String getCoverage() {
+ return coverage;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public String getCreator() {
+ return creator;
+ }
+
+ public String getCreated() {
+ return created;
+ }
+
+ public String getLastContributor() {
+ return lastContributor;
+ }
+
+ public String getRights() {
+ return rights;
+ }
+
+ public String getExpired() {
+ return expired;
+ }
+
+ public String getIssued() {
+ return issued;
+ }
+
+ public String getNature() {
+ return nature;
+ }
+
+ public List<String> getSubjects() {
+ return subjects;
+ }
+
+ public List<String> getContributors() {
+ return contributors;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public String getPublisher() {
+ return publisher;
+ }
+
+ public String getNote() {
+ return note;
+ }
+
+ public String getNoteMimeType() {
+ return noteMimeType;
+ }
+
+ public List<Attachment> getAttachments() {
+ return attachments;
+ }
+
+ public boolean hasContent() {
+ return this.length > 0 && this.content != null;
+ }
+
+ public InputStream getContentStream() {
+ String contentStream = content != null ? content : "";
+ return new ByteArrayInputStream(contentStream.getBytes(StandardCharsets.UTF_8));
+ }
+
+ public Map<String, Object> getMetadataAsMap() {
+ Map<String, Object> docMetadata = Maps.newHashMap();
+
+ docMetadata.put(KEY_UID, this.uid);
+ docMetadata.put(KEY_TITLE, this.title);
+ if (this.lastModified != null)
+ docMetadata.put(KEY_LAST_MODIFIED, DateParser.formatISO8601Date(this.lastModified));
+ docMetadata.put(KEY_STATE, this.state);
+ docMetadata.put(KEY_MEDIATYPE, this.mediatype);
+ docMetadata.put(KEY_TYPE, this.type);
+ docMetadata.put(KEY_PATH, this.path);
+ if (this.isCheckedOut != null)
+ docMetadata.put(KEY_IS_CHECKED_OUT, this.isCheckedOut.toString());
+ docMetadata.put(KEY_REPOSITORY, this.repository);
+ docMetadata.put(KEY_PARENT_REF, this.parentRef);
+
+ addIfNotEmpty(docMetadata, KEY_DC_DESCRIPTION, this.description);
+ addIfNotEmpty(docMetadata, KEY_DC_LANGUAGE, this.language);
+ addIfNotEmpty(docMetadata, KEY_DC_COVERAGE, this.coverage);
+ addIfNotEmpty(docMetadata, KEY_DC_VALID, this.valid);
+ addIfNotEmpty(docMetadata, KEY_DC_CREATOR, this.creator);
+ addIfNotEmpty(docMetadata, KEY_DC_LAST_CONTRIBUTOR, this.lastContributor);
+ addIfNotEmpty(docMetadata, KEY_DC_RIGHTS, this.rights);
+ addIfNotEmpty(docMetadata, KEY_DC_EXPIRED, this.expired);
+ addIfNotEmpty(docMetadata, KEY_DC_CREATED, this.created);
+ addIfNotEmpty(docMetadata, KEY_DC_ISSUED, this.issued);
+ addIfNotEmpty(docMetadata, KEY_DC_NATURE, this.nature);
+ addIfNotEmpty(docMetadata, KEY_DC_SOURCE, this.source);
+ addIfNotEmpty(docMetadata, KEY_DC_PUBLISHER, this.publisher);
+ addIfNotEmpty(docMetadata, KEY_DC_SUBJECTS, this.subjects);
+ addIfNotEmpty(docMetadata, KEY_DC_CONTRIBUTORS, this.contributors);
+ addIfNotEmpty(docMetadata, NOTE_SAVE_PREFFIX + KEY_NOTE_NOTE, this.note);
+ addIfNotEmpty(docMetadata, NOTE_SAVE_PREFFIX + KEY_NOTE_MYMETYPE, this.noteMimeType);
+
+ return docMetadata;
+ }
+
+ public 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);
+ }
+ }
+
+ public static NuxeoResourceBuilder<? extends Document> builder() {
+ return new DocumentBuilder();
+ }
+
+ public static class DocumentBuilder implements NuxeoResourceBuilder<Document> {
+
+ public Document fromJson(JSONObject jsonDocument) {
+ return fromJson(jsonDocument, new Document());
+ }
+
+ public Document fromJson(JSONObject jsonDocument, Document document) {
+
+ try {
+ String uid = jsonDocument.getString(KEY_UID);
+ String title = jsonDocument.getString(KEY_TITLE);
+ Date lastModified = DateParser.parseISO8601Date(jsonDocument.optString(KEY_LAST_MODIFIED, ""));
+ String state = jsonDocument.optString(KEY_STATE, "");
+ String path = jsonDocument.optString(KEY_PATH, "");
+ String type = jsonDocument.optString(KEY_TYPE, "");
+ Boolean isCheckedOut = jsonDocument.optBoolean(KEY_IS_CHECKED_OUT);
+ String repository = jsonDocument.optString(KEY_REPOSITORY, "");
+ String parentRef = jsonDocument.optString(KEY_PARENT_REF, "");
+
+ document.uid = uid;
+ document.title = title;
+ document.lastModified = lastModified;
+ document.state = state;
+ document.path = path;
+ document.type = type;
+ document.isCheckedOut = isCheckedOut;
+ document.repository = repository;
+ document.parentRef = parentRef;
+
+ document.length = (document.content != null) ? document.content.getBytes().length : 0;
+
+ JSONObject properties = (JSONObject) jsonDocument.opt(KEY_PROPERTIES);
+
+ if (properties != null) {
+
+ document.description = properties.optString(DC_PREFFIX + KEY_DC_DESCRIPTION);
+ document.language = properties.optString(DC_PREFFIX + KEY_DC_LANGUAGE);
+ document.coverage = properties.optString(DC_PREFFIX + KEY_DC_COVERAGE);
+ document.valid = properties.optString(DC_PREFFIX + KEY_DC_VALID);
+ document.creator = properties.optString(DC_PREFFIX + KEY_DC_CREATOR);
+ document.lastContributor = properties.optString(DC_PREFFIX + KEY_DC_LAST_CONTRIBUTOR);
+ document.rights = properties.optString(DC_PREFFIX + KEY_DC_RIGHTS);
+ document.expired = properties.optString(DC_PREFFIX + KEY_DC_EXPIRED);
+ document.created = properties.optString(DC_PREFFIX + KEY_DC_CREATED);
+ document.issued = properties.optString(DC_PREFFIX + KEY_DC_ISSUED);
+ document.nature = properties.optString(DC_PREFFIX + KEY_DC_NATURE);
+ document.source = properties.optString(DC_PREFFIX + KEY_DC_SOURCE);
+ document.publisher = properties.optString(DC_PREFFIX + KEY_DC_PUBLISHER);
+
+ JSONArray subjectsArray = properties.optJSONArray(DC_PREFFIX + KEY_DC_SUBJECTS);
+
+ if (subjectsArray != null)
+ for (int i = 0; i < subjectsArray.length(); i++) {
+ if (subjectsArray.optString(i) != null)
+ document.subjects.add(subjectsArray.getString(i));
+ }
+
+ JSONArray contributorsArray = properties.optJSONArray(DC_PREFFIX + KEY_DC_CONTRIBUTORS);
+
+ if (contributorsArray != null)
+ for (int i = 0; i < contributorsArray.length(); i++) {
+ if (contributorsArray.optString(i) != null)
+ document.contributors.add(contributorsArray.getString(i));
+ }
+
+ if (document.type.equalsIgnoreCase(DocumentType.NOTE.value())) {
+ document.note = properties.optString(NOTE_PREFFIX + KEY_NOTE_NOTE);
+ document.noteMimeType = properties.optString(NOTE_PREFFIX + KEY_NOTE_MYMETYPE);
+ }
+
+ JSONObject mainFile = properties.optJSONObject(ATT_MAIN_PREFFIX + ATT_CONTENT);
+
+ if (mainFile != null) {
+ Attachment att = new Attachment();
+
+ att.name = mainFile.optString(Attachment.ATT_KEY_NAME);
+ att.mime_type = mainFile.optString(Attachment.ATT_KEY_MIME_TYPE);
+ att.url = mainFile.optString(Attachment.ATT_KEY_URL);
+ att.length = mainFile.optLong(Attachment.ATT_KEY_LENGTH);
+
+ document.attachments.add(att);
+ }
+
+ JSONArray files = properties.optJSONArray(ATT_PREFFIX + ATT_FILES);
+
+ if (files != null)
+ for (int i = 0; i < files.length(); i++) {
+ if (files.optJSONObject(i) != null) {
+ Attachment att = new Attachment();
+
+ JSONObject fileObj = files.optJSONObject(i);
+ JSONObject file = fileObj.getJSONObject(Attachment.ATT_KEY_FILE);
+
+ att.name = file.optString(Attachment.ATT_KEY_NAME);
+ att.mime_type = file.optString(Attachment.ATT_KEY_MIME_TYPE);
+ att.url = file.optString(Attachment.ATT_KEY_URL);
+ att.length = file.optLong(Attachment.ATT_KEY_LENGTH);
+
+ document.attachments.add(att);
+ }
+
+ }
+ }
+
+ document.delegated = jsonDocument;
+
+ return document;
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ return new Document();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.manifoldcf.crawler.connectors.nuxeo.model.builder.
+ * NuxeoResourceBuilder#getType()
+ */
+ @Override
+ public Class<Document> getType() {
+ return Document.class;
+ }
- }
+ }
}
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/DocumentType.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/DocumentType.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/DocumentType.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/DocumentType.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.model;
/**
@@ -9,15 +24,15 @@ package org.apache.manifoldcf.crawler.co
*/
public enum DocumentType {
- NOTE("note"),FILE("file");
-
- private String value;
-
- DocumentType(String value){
- this.value = value;
- }
-
- public String value(){
- return value;
- }
+ NOTE("note"),FILE("file");
+
+ private String value;
+
+ DocumentType(String value){
+ this.value = value;
+ }
+
+ public String value(){
+ return value;
+ }
}
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/MutableAcl.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/MutableAcl.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/MutableAcl.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/MutableAcl.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.model;
/**
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/MutableDocument.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/MutableDocument.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/MutableDocument.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/MutableDocument.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.model;
import java.util.Date;
@@ -11,22 +26,22 @@ import java.util.Date;
*/
public class MutableDocument extends Document{
- public MutableDocument(){
-
- }
-
- //Setters
- public void setUid(String uid){
- this.uid = uid;
- }
-
- public void setTitle(String title){
- this.title = title;
- }
-
- public void setLastModified(Date lastModified){
- this.lastModified = lastModified;
- }
+ public MutableDocument(){
+
+ }
+
+ //Setters
+ public void setUid(String uid){
+ this.uid = uid;
+ }
+
+ public void setTitle(String title){
+ this.title = title;
+ }
+
+ public void setLastModified(Date lastModified){
+ this.lastModified = lastModified;
+ }
}
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/NuxeoResource.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/NuxeoResource.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/NuxeoResource.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/NuxeoResource.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.model;
/**
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/NuxeoResponse.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/NuxeoResponse.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/NuxeoResponse.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/NuxeoResponse.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.model;
import java.util.ArrayList;
@@ -17,76 +32,76 @@ import org.json.JSONObject;
*/
public class NuxeoResponse<T extends NuxeoResource> {
- private List<T> results;
- private int start;
- private int limit;
- private Boolean isLast;
-
- public NuxeoResponse(List<T> resuts, int start, int limit, Boolean isLast) {
- this.results = resuts;
- this.start = start;
- this.limit = limit;
- this.isLast = isLast;
- }
-
- /**
- * @return the results
- */
- public List<T> getResults() {
- return results;
- }
-
- /**
- * @return the start
- */
- public int getStart() {
- return start;
- }
-
- /**
- * @return the limit
- */
- public int getLimit() {
- return limit;
- }
-
- /**
- * @return the isLast
- */
- public Boolean isLast() {
- return isLast;
- }
-
- public static <T extends NuxeoResource> NuxeoResponse<T> fromJson(JSONObject response,
- NuxeoResourceBuilder<T> builder) {
- List<T> resources = new ArrayList<T>();
-
- try{
- JSONArray jsonArray = response.getJSONArray("entries");
-
- for(int i=0,size=jsonArray.length();i< size;i++){
- JSONObject jsonDocument = jsonArray.getJSONObject(i);
- T resource= (T) builder.fromJson(jsonDocument);
- resources.add(resource);
- }
- int limit = response.getInt("pageSize");
- int start = response.getInt("currentPageIndex");
- String isNextPage = response.getString("isNextPageAvailable");
- Boolean isLast = false;
-
- if(isNextPage.equalsIgnoreCase("false")){
- isLast = true;
- }
-
-
-
- return new NuxeoResponse<>(resources, start, limit, isLast);
-
- }catch(JSONException e){
- e.printStackTrace();
- }
-
- return new NuxeoResponse<T>(new ArrayList<T>(), 0, 0, false);
- }
+ private List<T> results;
+ private int start;
+ private int limit;
+ private Boolean isLast;
+
+ public NuxeoResponse(List<T> resuts, int start, int limit, Boolean isLast) {
+ this.results = resuts;
+ this.start = start;
+ this.limit = limit;
+ this.isLast = isLast;
+ }
+
+ /**
+ * @return the results
+ */
+ public List<T> getResults() {
+ return results;
+ }
+
+ /**
+ * @return the start
+ */
+ public int getStart() {
+ return start;
+ }
+
+ /**
+ * @return the limit
+ */
+ public int getLimit() {
+ return limit;
+ }
+
+ /**
+ * @return the isLast
+ */
+ public Boolean isLast() {
+ return isLast;
+ }
+
+ public static <T extends NuxeoResource> NuxeoResponse<T> fromJson(JSONObject response,
+ NuxeoResourceBuilder<T> builder) {
+ List<T> resources = new ArrayList<T>();
+
+ try{
+ JSONArray jsonArray = response.getJSONArray("entries");
+
+ for(int i=0,size=jsonArray.length();i< size;i++){
+ JSONObject jsonDocument = jsonArray.getJSONObject(i);
+ T resource= (T) builder.fromJson(jsonDocument);
+ resources.add(resource);
+ }
+ int limit = response.getInt("pageSize");
+ int start = response.getInt("currentPageIndex");
+ String isNextPage = response.getString("isNextPageAvailable");
+ Boolean isLast = false;
+
+ if(isNextPage.equalsIgnoreCase("false")){
+ isLast = true;
+ }
+
+
+
+ return new NuxeoResponse<>(resources, start, limit, isLast);
+
+ }catch(JSONException e){
+ e.printStackTrace();
+ }
+
+ return new NuxeoResponse<T>(new ArrayList<T>(), 0, 0, false);
+ }
}
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/builder/NuxeoResourceBuilder.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/builder/NuxeoResourceBuilder.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/builder/NuxeoResourceBuilder.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/builder/NuxeoResourceBuilder.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.model.builder;
import org.apache.manifoldcf.crawler.connectors.nuxeo.model.NuxeoResource;
@@ -11,11 +26,11 @@ import org.json.JSONObject;
*
*/
public interface NuxeoResourceBuilder <T extends NuxeoResource> {
-
- T fromJson(JSONObject jsonDocument);
-
- T fromJson(JSONObject jsonDocument, T document);
-
- Class<T> getType();
+
+ T fromJson(JSONObject jsonDocument);
+
+ T fromJson(JSONObject jsonDocument, T document);
+
+ Class<T> getType();
}
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/nuxeo/tests/NuxeoAuthorityTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/nuxeo/tests/NuxeoAuthorityTest.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/nuxeo/tests/NuxeoAuthorityTest.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/nuxeo/tests/NuxeoAuthorityTest.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.authorities.nuxeo.tests;
import org.apache.manifoldcf.authorities.authorities.nuxeo.NuxeoAuthorityConnector;
@@ -29,44 +44,44 @@ import org.mockito.runners.MockitoJUnitR
@RunWith(MockitoJUnitRunner.class)
public class NuxeoAuthorityTest {
- @Mock
- private NuxeoClient client;
+ @Mock
+ private NuxeoClient client;
- private NuxeoAuthorityConnector authorityConnector;
+ private NuxeoAuthorityConnector authorityConnector;
- @Before
- public void setup() throws Exception {
- authorityConnector = new NuxeoAuthorityConnector();
- authorityConnector.setNuxeoClient(client);
- }
-
- @Test
- public void check() throws Exception {
- when(client.checkAuth()).thenReturn(true);
- assertEquals(authorityConnector.check(), "Connection working");
- }
-
- @Test
- public void checkUserNotFound() throws Exception {
- when(client.getUserAuthorities(anyString())).thenReturn(new ArrayList<String>());
- AuthorizationResponse response = authorityConnector.getAuthorizationResponse(anyString());
- String[] tokens = response.getAccessTokens();
-
- assertEquals(tokens.length, 1);
- assertEquals(tokens[0], IAuthorityConnector.GLOBAL_DENY_TOKEN);
- assertEquals(response.getResponseStatus(), AuthorizationResponse.RESPONSE_USERNOTFOUND);
- }
-
- @Test
- public void checkuserFound() throws Exception {
- List<String> tokensList = new ArrayList<String>();
- tokensList.add("token");
- when(client.getUserAuthorities(anyString())).thenReturn(tokensList);
- AuthorizationResponse response = authorityConnector.getAuthorizationResponse(anyString());
-
- String[] tokens = response.getAccessTokens();
- assertEquals(tokens.length, 1);
- assertEquals(tokens[0], tokensList.get(0));
- assertEquals(response.getResponseStatus(), AuthorizationResponse.RESPONSE_OK);
- }
+ @Before
+ public void setup() throws Exception {
+ authorityConnector = new NuxeoAuthorityConnector();
+ authorityConnector.setNuxeoClient(client);
+ }
+
+ @Test
+ public void check() throws Exception {
+ when(client.checkAuth()).thenReturn(true);
+ assertEquals(authorityConnector.check(), "Connection working");
+ }
+
+ @Test
+ public void checkUserNotFound() throws Exception {
+ when(client.getUserAuthorities(anyString())).thenReturn(new ArrayList<String>());
+ AuthorizationResponse response = authorityConnector.getAuthorizationResponse(anyString());
+ String[] tokens = response.getAccessTokens();
+
+ assertEquals(tokens.length, 1);
+ assertEquals(tokens[0], IAuthorityConnector.GLOBAL_DENY_TOKEN);
+ assertEquals(response.getResponseStatus(), AuthorizationResponse.RESPONSE_USERNOTFOUND);
+ }
+
+ @Test
+ public void checkuserFound() throws Exception {
+ List<String> tokensList = new ArrayList<String>();
+ tokensList.add("token");
+ when(client.getUserAuthorities(anyString())).thenReturn(tokensList);
+ AuthorizationResponse response = authorityConnector.getAuthorizationResponse(anyString());
+
+ String[] tokens = response.getAccessTokens();
+ assertEquals(tokens.length, 1);
+ assertEquals(tokens[0], tokensList.get(0));
+ assertEquals(response.getResponseStatus(), AuthorizationResponse.RESPONSE_OK);
+ }
}
Copied: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/AbstractTestBase.java (from r1770899, manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/AbstractTest.java)
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/AbstractTestBase.java?p2=manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/AbstractTestBase.java&p1=manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/AbstractTest.java&r1=1770899&r2=1770925&rev=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/AbstractTest.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/AbstractTestBase.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.tests;
import org.apache.manifoldcf.crawler.connectors.nuxeo.NuxeoRepositoryConnector;
@@ -13,22 +28,22 @@ import org.mockito.Mock;
* @author David Arroyo Escobar <ar...@gmail.com>
*
*/
-public abstract class AbstractTest {
+public abstract class AbstractTestBase {
- @Mock
- public NuxeoClient client;
+ @Mock
+ public NuxeoClient client;
- public NuxeoRepositoryConnector repositoryConnector;
+ public NuxeoRepositoryConnector repositoryConnector;
- @Before
- public void setup() throws Exception {
- repositoryConnector = new NuxeoRepositoryConnector();
- repositoryConnector.setNuxeoClient(client);
- }
+ @Before
+ public void setup() throws Exception {
+ repositoryConnector = new NuxeoRepositoryConnector();
+ repositoryConnector.setNuxeoClient(client);
+ }
- @After
- public void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
- }
+ }
}
Modified: manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/NuxeoConnectorTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/NuxeoConnectorTest.java?rev=1770925&r1=1770924&r2=1770925&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/NuxeoConnectorTest.java (original)
+++ manifoldcf/branches/CONNECTORS-1290/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/NuxeoConnectorTest.java Wed Nov 23 07:28:32 2016
@@ -1,6 +1,21 @@
+/* $Id: DefaultAuthenticator.java 1688076 2015-06-28 23:04:30Z kwright $ */
+
/**
- *
- */
+* 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.nuxeo.tests;
import static org.junit.Assert.assertEquals;
@@ -42,157 +57,157 @@ import org.mockito.runners.MockitoJUnitR
*
*/
@RunWith(MockitoJUnitRunner.class)
-public class NuxeoConnectorTest extends AbstractTest {
+public class NuxeoConnectorTest extends AbstractTestBase {
- @Override
- public void setup() throws Exception {
- super.setup();
-
- when(client.getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(), anyInt(),
- anyObject())).thenReturn(new NuxeoResponse<Document>(Collections.<Document> emptyList(), 0, 0, true));
- };
-
- @Test
- public void checkMockInjection() throws Exception {
- when(client.check()).thenReturn(true);
- assertEquals(repositoryConnector.check(), "Connection working");
- }
-
- @Test
- public void mockSeeding() throws Exception {
- SeedingActivity activities = mock(SeedingActivity.class);
- Specification spec = new Specification();
- List<Document> documents = new ArrayList<Document>();
- Document document = mock(Document.class);
- long seedTime = 0;
-
- documents.add(document);
- documents.add(document);
-
- when(client.getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(), anyInt(),
- anyObject())).thenReturn(new NuxeoResponse<Document>(documents, 0, 0, true))
- .thenReturn(new NuxeoResponse<Document>(Collections.<Document> emptyList(), 0, 0, true));
-
- repositoryConnector.addSeedDocuments(activities, spec, "", seedTime,
- BaseRepositoryConnector.JOBMODE_CONTINUOUS);
-
- verify(activities, times(2)).addSeedDocument(anyString());
- verify(client, times(1)).getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(),
- anyInt(), anyObject());
-
- }
-
- @Test
- public void mockEmptySeeding() throws Exception {
- SeedingActivity activities = mock(SeedingActivity.class);
- Specification spec = new Specification();
- long seedTime = 0;
-
- when(client.getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(), anyInt(),
- anyObject())).thenReturn(new NuxeoResponse<Document>(Collections.<Document> emptyList(), 0, 0, true));
-
- repositoryConnector.addSeedDocuments(activities, spec, "", seedTime,
- BaseRepositoryConnector.JOBMODE_CONTINUOUS);
-
- verify(activities, times(0)).addSeedDocument(anyString());
- verify(client, times(1)).getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(),
- anyInt(), anyObject());
-
- }
-
- @Test
- public void mockDeleteDocument() throws Exception {
- Document doc = mock(Document.class);
- String uid = "297529bf-191a-4c87-8259-28b692394229";
- Specification spec = new Specification();
- IProcessActivity activities = mock(IProcessActivity.class);
- IExistingVersions statuses = mock(IExistingVersions.class);
-
- when(doc.getState()).thenReturn("deleted");
- when(client.getDocument(uid)).thenReturn(doc);
-
- repositoryConnector.processDocuments(new String[] { uid }, statuses, spec, activities,
- BaseRepositoryConnector.JOBMODE_CONTINUOUS, true);
-
- verify(client, times(1)).getDocument(anyString());
- verify(activities, times(1)).deleteDocument(uid);
- }
-
- @Test
- public void mockSimpleIngestion() throws Exception {
-
- Document doc = mock(Document.class);
- Date date = new Date();
- DateFormat df = DateFormat.getDateTimeInstance();
- 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>();
- IProcessActivity activities = mock(IProcessActivity.class);
- IExistingVersions statuses = mock(IExistingVersions.class);
- Specification spec = new Specification();
- String mediaType = "text/html; charset=utf-8";
-
- metadata.put("key", "value");
- id = df.format(date);
-
- when(doc.getLenght()).thenReturn(size);
- when(doc.getLastModified()).thenReturn(date);
- when(doc.getMediatype()).thenReturn(mediaType);
- when(doc.getMetadataAsMap()).thenReturn(metadata);
- when(doc.getUid()).thenReturn(uri);
-
- when(activities.checkDocumentNeedsReindexing(anyString(), anyString())).thenReturn(true);
-
- when(statuses.getIndexedVersionString(id)).thenReturn(null);
-
- when(client.getDocument(anyString())).thenReturn(doc);
-
- when(client.getPathDocument(anyString())).thenReturn(uri);
-
- repositoryConnector.processDocuments(new String[] { id }, statuses, spec, activities,
- BaseRepositoryConnector.JOBMODE_CONTINUOUS, true);
- ArgumentCaptor<RepositoryDocument> ac = ArgumentCaptor.forClass(RepositoryDocument.class);
-
- verify(client, times(1)).getDocument(id);
- verify(activities, times(1)).ingestDocumentWithException(eq(id), eq(df.format(date)), eq(uri), ac.capture());
- verify(activities, times(1)).recordActivity(anyLong(), eq("read document"), eq(size), eq(id), eq("OK"),
- anyString(), Mockito.isNull(String[].class));
-
- RepositoryDocument rd = ac.getValue();
- Long rdSize = rd.getBinaryLength();
-
- String[] keyValue = rd.getFieldAsStrings("key");
- assertEquals(size, rdSize);
-
- assertEquals(keyValue.length, 1);
- assertEquals(keyValue[0], "value");
- }
-
- @Test
- public void mockNotNeedReindexing() throws Exception {
- Document doc = mock(Document.class);
- Date date = new Date();
- DateFormat df = DateFormat.getDateTimeInstance();
- String version = df.format(date);
- String uid = "297529bf-191a-4c87-8259-28b692394229";
-
- IProcessActivity activities = mock(IProcessActivity.class);
- IExistingVersions statuses = mock(IExistingVersions.class);
- Specification spec = new Specification();
-
- when(doc.getLastModified()).thenReturn(df.parse(version));
- when(statuses.getIndexedVersionString(uid)).thenReturn(version);
- when(client.getDocument(anyString())).thenReturn(doc);
-
- repositoryConnector.processDocuments(new String[] { uid }, statuses, spec, activities,
- BaseRepositoryConnector.JOBMODE_CONTINUOUS, true);
- ArgumentCaptor<RepositoryDocument> ac = ArgumentCaptor.forClass(RepositoryDocument.class);
-
- verify(client, times(1)).getDocument(uid);
- verify(activities, times(1)).checkDocumentNeedsReindexing(uid, version);
- verify(activities, times(0)).ingestDocumentWithException(anyString(), anyString(), anyString(), ac.capture());
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+
+ when(client.getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(), anyInt(),
+ anyObject())).thenReturn(new NuxeoResponse<Document>(Collections.<Document> emptyList(), 0, 0, true));
+ };
+
+ @Test
+ public void checkMockInjection() throws Exception {
+ when(client.check()).thenReturn(true);
+ assertEquals(repositoryConnector.check(), "Connection working");
+ }
+
+ @Test
+ public void mockSeeding() throws Exception {
+ SeedingActivity activities = mock(SeedingActivity.class);
+ Specification spec = new Specification();
+ List<Document> documents = new ArrayList<Document>();
+ Document document = mock(Document.class);
+ long seedTime = 0;
+
+ documents.add(document);
+ documents.add(document);
+
+ when(client.getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(), anyInt(),
+ anyObject())).thenReturn(new NuxeoResponse<Document>(documents, 0, 0, true))
+ .thenReturn(new NuxeoResponse<Document>(Collections.<Document> emptyList(), 0, 0, true));
+
+ repositoryConnector.addSeedDocuments(activities, spec, "", seedTime,
+ BaseRepositoryConnector.JOBMODE_CONTINUOUS);
+
+ verify(activities, times(2)).addSeedDocument(anyString());
+ verify(client, times(1)).getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(),
+ anyInt(), anyObject());
+
+ }
+
+ @Test
+ public void mockEmptySeeding() throws Exception {
+ SeedingActivity activities = mock(SeedingActivity.class);
+ Specification spec = new Specification();
+ long seedTime = 0;
+
+ when(client.getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(), anyInt(),
+ anyObject())).thenReturn(new NuxeoResponse<Document>(Collections.<Document> emptyList(), 0, 0, true));
+
+ repositoryConnector.addSeedDocuments(activities, spec, "", seedTime,
+ BaseRepositoryConnector.JOBMODE_CONTINUOUS);
+
+ verify(activities, times(0)).addSeedDocument(anyString());
+ verify(client, times(1)).getDocuments(anyListOf(String.class), anyListOf(String.class), anyString(), anyInt(),
+ anyInt(), anyObject());
+
+ }
+
+ @Test
+ public void mockDeleteDocument() throws Exception {
+ Document doc = mock(Document.class);
+ String uid = "297529bf-191a-4c87-8259-28b692394229";
+ Specification spec = new Specification();
+ IProcessActivity activities = mock(IProcessActivity.class);
+ IExistingVersions statuses = mock(IExistingVersions.class);
+
+ when(doc.getState()).thenReturn("deleted");
+ when(client.getDocument(uid)).thenReturn(doc);
+
+ repositoryConnector.processDocuments(new String[] { uid }, statuses, spec, activities,
+ BaseRepositoryConnector.JOBMODE_CONTINUOUS, true);
+
+ verify(client, times(1)).getDocument(anyString());
+ verify(activities, times(1)).deleteDocument(uid);
+ }
+
+ @Test
+ public void mockSimpleIngestion() throws Exception {
+
+ Document doc = mock(Document.class);
+ Date date = new Date();
+ DateFormat df = DateFormat.getDateTimeInstance();
+ 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>();
+ IProcessActivity activities = mock(IProcessActivity.class);
+ IExistingVersions statuses = mock(IExistingVersions.class);
+ Specification spec = new Specification();
+ String mediaType = "text/html; charset=utf-8";
+
+ metadata.put("key", "value");
+ id = df.format(date);
+
+ when(doc.getLenght()).thenReturn(size);
+ when(doc.getLastModified()).thenReturn(date);
+ when(doc.getMediatype()).thenReturn(mediaType);
+ when(doc.getMetadataAsMap()).thenReturn(metadata);
+ when(doc.getUid()).thenReturn(uri);
+
+ when(activities.checkDocumentNeedsReindexing(anyString(), anyString())).thenReturn(true);
+
+ when(statuses.getIndexedVersionString(id)).thenReturn(null);
+
+ when(client.getDocument(anyString())).thenReturn(doc);
+
+ when(client.getPathDocument(anyString())).thenReturn(uri);
+
+ repositoryConnector.processDocuments(new String[] { id }, statuses, spec, activities,
+ BaseRepositoryConnector.JOBMODE_CONTINUOUS, true);
+ ArgumentCaptor<RepositoryDocument> ac = ArgumentCaptor.forClass(RepositoryDocument.class);
+
+ verify(client, times(1)).getDocument(id);
+ verify(activities, times(1)).ingestDocumentWithException(eq(id), eq(df.format(date)), eq(uri), ac.capture());
+ verify(activities, times(1)).recordActivity(anyLong(), eq("read document"), eq(size), eq(id), eq("OK"),
+ anyString(), Mockito.isNull(String[].class));
+
+ RepositoryDocument rd = ac.getValue();
+ Long rdSize = rd.getBinaryLength();
+
+ String[] keyValue = rd.getFieldAsStrings("key");
+ assertEquals(size, rdSize);
+
+ assertEquals(keyValue.length, 1);
+ assertEquals(keyValue[0], "value");
+ }
+
+ @Test
+ public void mockNotNeedReindexing() throws Exception {
+ Document doc = mock(Document.class);
+ Date date = new Date();
+ DateFormat df = DateFormat.getDateTimeInstance();
+ String version = df.format(date);
+ String uid = "297529bf-191a-4c87-8259-28b692394229";
+
+ IProcessActivity activities = mock(IProcessActivity.class);
+ IExistingVersions statuses = mock(IExistingVersions.class);
+ Specification spec = new Specification();
+
+ when(doc.getLastModified()).thenReturn(df.parse(version));
+ when(statuses.getIndexedVersionString(uid)).thenReturn(version);
+ when(client.getDocument(anyString())).thenReturn(doc);
+
+ repositoryConnector.processDocuments(new String[] { uid }, statuses, spec, activities,
+ BaseRepositoryConnector.JOBMODE_CONTINUOUS, true);
+ ArgumentCaptor<RepositoryDocument> ac = ArgumentCaptor.forClass(RepositoryDocument.class);
+
+ verify(client, times(1)).getDocument(uid);
+ verify(activities, times(1)).checkDocumentNeedsReindexing(uid, version);
+ verify(activities, times(0)).ingestDocumentWithException(anyString(), anyString(), anyString(), ac.capture());
- }
+ }
}