]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6826: Added boiler plate code for Index sub-resource and added AuthZ check...
authorremillet <remillet@yahoo.com>
Thu, 24 Mar 2016 22:25:26 +0000 (15:25 -0700)
committerremillet <remillet@yahoo.com>
Thu, 24 Mar 2016 22:25:26 +0000 (15:25 -0700)
47 files changed:
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/BatchDocumentModelHandler.java
services/build.xml
services/client/src/main/java/org/collectionspace/services/client/index/IndexClient.java [new file with mode: 0644]
services/client/src/main/java/org/collectionspace/services/client/index/IndexProxy.java [new file with mode: 0644]
services/common/src/main/cspace/config/services/service-config.xml
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml
services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java
services/common/src/main/java/org/collectionspace/services/common/ServiceMessages.java
services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java
services/common/src/main/java/org/collectionspace/services/common/relation/RelationUtils.java
services/common/src/main/java/org/collectionspace/services/common/repository/RepositoryClient.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityUtils.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CSReindexFulltextRoot.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryClientImpl.java [moved from services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java with 98% similarity]
services/common/src/main/java/org/collectionspace/services/nuxeo/util/ReindexFulltextRoot.java [new file with mode: 0644]
services/index/3rdparty/build.xml [new file with mode: 0644]
services/index/3rdparty/nuxeo-platform-cs-index/build.xml [new file with mode: 0644]
services/index/3rdparty/nuxeo-platform-cs-index/pom.xml [new file with mode: 0644]
services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/META-INF/MANIFEST.MF [new file with mode: 0644]
services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/OSGI-INF/core-types-contrib.xml [new file with mode: 0644]
services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/OSGI-INF/deployment-fragment.xml [new file with mode: 0644]
services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/schemas/item_common.xsd [new file with mode: 0644]
services/index/3rdparty/pom.xml [new file with mode: 0644]
services/index/build.xml [new file with mode: 0644]
services/index/client/pom.xml [new file with mode: 0644]
services/index/client/src/test/java/org/collectionspace/services/client/test/IndexServiceTest.java [new file with mode: 0644]
services/index/client/src/test/resources/log4j.properties [new file with mode: 0644]
services/index/jaxb/pom.xml [new file with mode: 0644]
services/index/pom.xml [new file with mode: 0644]
services/index/service/pom.xml [new file with mode: 0644]
services/index/service/src/main/java/org/collectionspace/services/index/IndexResource.java [new file with mode: 0644]
services/index/service/src/main/java/org/collectionspace/services/index/nuxeo/IndexValidatorHandler.java [new file with mode: 0644]
services/index/service/src/test/java/org/collectionspace/services/test/IndexServiceTest.java [new file with mode: 0644]
services/index/service/src/test/resources/log4j.xml [new file with mode: 0644]
services/jaxb/src/main/resources/index_common.xsd [new file with mode: 0644]
services/pom.xml
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java
services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java

index 867c53c1195bb34b9876bd11c453170d1e2a1a03..542d2bcc7e5a9c8e9e35b254b33de8f73b24a25e 100644 (file)
@@ -80,7 +80,7 @@ import org.collectionspace.services.lifecycle.TransitionDef;
 import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentFilter;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.workflow.WorkflowCommon;
 import org.jboss.resteasy.util.HttpResponseCodes;
@@ -336,7 +336,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(item.inAuthority.resource);
         
         // HACK - this really must be moved to the doc handler, not here. No Nuxeo specific stuff here!
-        RepositoryJavaClientImpl client = (RepositoryJavaClientImpl)getRepositoryClient(ctx);
+        RepositoryClientImpl client = (RepositoryClientImpl)getRepositoryClient(ctx);
         String parentcsid = client.findDocCSID(repoSession, ctx, whereClause);
 
         String itemWhereClause = buildWhereForAuthItemByName(item.getShortIdentifier(), parentcsid);
index 4e78078b00bbaea2347a78cd973b79f2f9be44e5..2dad57a22ecf8344fdc64c0683522a48e5069947 100644 (file)
@@ -38,7 +38,7 @@ import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
 import org.collectionspace.services.config.service.ObjectPartType;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.slf4j.Logger;
@@ -203,7 +203,7 @@ public abstract class AuthorityDocumentModelHandler<AuthCommon>
         CoreSessionInterface repoSession = null;
 
         ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
-       RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
+       RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
         try {
                repoSession = nuxeoRepoClient.getRepositorySession(ctx);
             DocumentWrapper<DocumentModel> wrapDoc = nuxeoRepoClient.getDocFromCsid(ctx, repoSession, authCSID);
index 075c15624d515f3973c88cf26396c4ee722b9721..f07dfaa9d8ecce97efc74299a4fd19f47317e833 100644 (file)
@@ -45,7 +45,7 @@ import org.collectionspace.services.config.service.ListResultField;
 import org.collectionspace.services.config.service.ObjectPartType;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.relation.RelationsCommonList;
 import org.collectionspace.services.vocabulary.VocabularyItemJAXBSchema;
@@ -474,7 +474,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
        boolean releaseRepoSession = false;
         
        try {
-               RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
+               RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {
                        repoSession = repoClient.getRepositorySession(ctx);
@@ -605,8 +605,8 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         String filteredTerm;
         StringBuilder filteredTermBuilder = new StringBuilder(term);
         // Term contains no anchor or wildcard characters.
-        if ( (! term.contains(RepositoryJavaClientImpl.USER_SUPPLIED_ANCHOR_CHAR))
-                && (! term.contains(RepositoryJavaClientImpl.USER_SUPPLIED_WILDCARD)) ) {
+        if ( (! term.contains(RepositoryClientImpl.USER_SUPPLIED_ANCHOR_CHAR))
+                && (! term.contains(RepositoryClientImpl.USER_SUPPLIED_WILDCARD)) ) {
             filteredTerm = term;
         } else {
             // Term contains at least one such character.
@@ -614,10 +614,10 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
                 // Filter the starting anchor or wildcard character, if any.
                 String firstChar = filteredTermBuilder.substring(0,1);
                 switch (firstChar) {
-                    case RepositoryJavaClientImpl.USER_SUPPLIED_ANCHOR_CHAR:
+                    case RepositoryClientImpl.USER_SUPPLIED_ANCHOR_CHAR:
                         anchorAtStart = true;
                         break;
-                    case RepositoryJavaClientImpl.USER_SUPPLIED_WILDCARD:
+                    case RepositoryClientImpl.USER_SUPPLIED_WILDCARD:
                         filteredTermBuilder.deleteCharAt(0);
                         break;
                 }
@@ -628,12 +628,12 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
                 int lastPos = filteredTermBuilder.length() - 1;
                 String lastChar = filteredTermBuilder.substring(lastPos);
                 switch (lastChar) {
-                    case RepositoryJavaClientImpl.USER_SUPPLIED_ANCHOR_CHAR:
+                    case RepositoryClientImpl.USER_SUPPLIED_ANCHOR_CHAR:
                         filteredTermBuilder.deleteCharAt(lastPos);
-                        filteredTermBuilder.insert(filteredTermBuilder.length(), RepositoryJavaClientImpl.ENDING_ANCHOR_CHAR);
+                        filteredTermBuilder.insert(filteredTermBuilder.length(), RepositoryClientImpl.ENDING_ANCHOR_CHAR);
                         anchorAtEnd = true;
                         break;
-                    case RepositoryJavaClientImpl.USER_SUPPLIED_WILDCARD:
+                    case RepositoryClientImpl.USER_SUPPLIED_WILDCARD:
                         filteredTermBuilder.deleteCharAt(lastPos);
                         break;
                 }
@@ -642,7 +642,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
                 }
                 filteredTerm = filteredTermBuilder.toString();
                 // Filter all other wildcards, if any.
-                filteredTerm = filteredTerm.replaceAll(RepositoryJavaClientImpl.USER_SUPPLIED_WILDCARD_REGEX, ZERO_OR_MORE_ANY_CHAR_REGEX);
+                filteredTerm = filteredTerm.replaceAll(RepositoryClientImpl.USER_SUPPLIED_WILDCARD_REGEX, ZERO_OR_MORE_ANY_CHAR_REGEX);
                 if (logger.isTraceEnabled()) {
                     logger.trace(String.format("After replacing user wildcards = %s", filteredTerm));
                 }
@@ -835,7 +835,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
     @Override
     public Map<String,String> getJDBCQueryParams() {
         // FIXME: Get all of the following values from appropriate external constants.
-        // At present, these are duplicated in both RepositoryJavaClientImpl
+        // At present, these are duplicated in both RepositoryClientImpl
         // and in AuthorityItemDocumentModelHandler.
         final String TERM_GROUP_LIST_NAME = "TERM_GROUP_LIST_NAME";
         final String TERM_GROUP_TABLE_NAME_PARAM = "TERM_GROUP_TABLE_NAME";
index 9f2aa7ae0b326de1a665b88e0930f586b5633146..1dc994666c061925312bc356fdab8ad04a6eadf0 100644 (file)
@@ -31,7 +31,7 @@ import org.collectionspace.services.BatchJAXBSchema;
 import org.collectionspace.services.jaxb.InvocableJAXBSchema;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.batch.BatchCommon;
 import org.collectionspace.services.batch.BatchInvocable;
@@ -79,7 +79,7 @@ public class BatchDocumentModelHandler extends NuxeoDocumentModelHandler<BatchCo
                        throw new BadRequestException("BatchResource: unknown Invocation Mode: " + invocationMode);
                }
 
-               RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl) this.getRepositoryClient(ctx);
+               RepositoryClientImpl repoClient = (RepositoryClientImpl) this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {
                        repoSession = repoClient.getRepositorySession(ctx);
index e44f38413160182a991e944512a19ccf659b9d4d..069b932e88f79b186050ead3815ae7e440d8f049 100644 (file)
         <ant antfile="authority/build.xml" target="deploy" inheritAll="false"/>
         <ant antfile="blob/build.xml" target="deploy" inheritAll="false"/>
         <ant antfile="workflow/build.xml" target="deploy" inheritAll="false"/>
+        <ant antfile="index/build.xml" target="deploy" inheritAll="false"/>
         <ant antfile="common/build.xml" target="deploy" inheritAll="false"/>
         <ant antfile="account/build.xml" target="deploy" inheritAll="false"/>
         <ant antfile="relation/build.xml" target="deploy" inheritAll="false"/>
         <ant antfile="media/build.xml" target="undeploy" inheritAll="false"/>
         <ant antfile="blob/build.xml" target="undeploy" inheritAll="false"/>
         <ant antfile="workflow/build.xml" target="undeploy" inheritAll="false"/>
+               <ant antfile="index/build.xml" target="undeploy" inheritAll="false"/>
         <ant antfile="authority/build.xml" target="undeploy" inheritAll="false"/>
         <ant antfile="authorization/build.xml" target="undeploy" inheritAll="false"/>
         <ant antfile="authentication/build.xml" target="undeploy" inheritAll="false"/>
         <ant antfile="account/build.xml" target="dist" inheritAll="false"/>
         <ant antfile="blob/build.xml" target="dist" inheritAll="false"/>
         <ant antfile="workflow/build.xml" target="dist" inheritAll="false"/>
+        <ant antfile="index/build.xml" target="dist" inheritAll="false"/>
         <ant antfile="common/build.xml" target="dist" inheritAll="false"/>
         <ant antfile="relation/build.xml" target="dist" inheritAll="false"/>
         <ant antfile="id/build.xml" target="dist" inheritAll="false"/>
diff --git a/services/client/src/main/java/org/collectionspace/services/client/index/IndexClient.java b/services/client/src/main/java/org/collectionspace/services/client/index/IndexClient.java
new file mode 100644 (file)
index 0000000..68f2570
--- /dev/null
@@ -0,0 +1,72 @@
+/**    
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright (c) 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ */
+package org.collectionspace.services.client.index;
+
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.client.AbstractCommonListPoxServiceClientImpl;
+
+/**
+ * IndexClient.java
+ *
+ * $LastChangedRevision: 2108 $
+ * $LastChangedDate: 2010-05-17 18:25:37 -0700 (Mon, 17 May 2010) $
+ *
+ */
+public class IndexClient extends AbstractCommonListPoxServiceClientImpl<IndexProxy> {
+       public static final String SERVICE_NAME = "index";
+       public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;       
+       public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
+       public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
+       public static final String SERVICE_COMMONPART_NAME = SERVICE_NAME + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
+       public static final String SERVICE_AUTHZ_SUFFIX = "/*/" + SERVICE_PATH_COMPONENT + "/";
+       public static final String INDEX_ID_PARAM = "indexid";
+       
+       @Override
+       public String getServiceName() {
+               return SERVICE_NAME;
+       }
+       
+       @Override
+    public String getServicePathComponent() {
+        return SERVICE_PATH_COMPONENT;
+    }
+
+       @Override
+       public Class<IndexProxy> getProxyClass() {
+               // TODO Auto-generated method stub
+               return IndexProxy.class;
+       }
+
+       /*
+        * Proxied service calls
+        */
+       
+       @Override
+       public Response readList() {
+        throw new UnsupportedOperationException();
+       }
+       
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.AbstractServiceClientImpl#delete(java.lang.String)
+     */
+    @Override
+       public Response delete(String csid) {
+        throw new UnsupportedOperationException();
+    }
+       
+}
diff --git a/services/client/src/main/java/org/collectionspace/services/client/index/IndexProxy.java b/services/client/src/main/java/org/collectionspace/services/client/index/IndexProxy.java
new file mode 100644 (file)
index 0000000..64f5261
--- /dev/null
@@ -0,0 +1,16 @@
+package org.collectionspace.services.client.index;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.collectionspace.services.client.CollectionSpaceCommonListPoxProxy;
+
+/**
+ * @version $Revision: 2108 $
+ */
+@Path(IndexClient.SERVICE_PATH + "/")
+@Produces({"application/xml"})
+@Consumes({"application/xml"})
+public interface IndexProxy extends CollectionSpaceCommonListPoxProxy {
+}
index 463a4340e05da3a7317dad92bc05b718b64cba72..7353357fd3c90b4ba455a65a1795290d16f83753 100644 (file)
@@ -29,7 +29,7 @@
         <user>Administrator</user>
         <password>Administrator</password>
         <client-type>java</client-type>
-        <client-class>org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl</client-class>
+        <client-class>org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl</client-class>
         <properties>
             <types:item><types:key>pageSizeDefault</types:key><types:value>40</types:value></types:item> <!-- Use 'pgSz' query param to override this on a per request bassis. -->
             <types:item><types:key>pageSizeMax</types:key><types:value>2500</types:value></types:item> <!-- No list result page size can be greater than this amount -->
index 00f7c864825155ba13290549a5e43805b3ced6c0..f599cafcab6f29561b46b5a83c05ba3043f09b60 100644 (file)
                        </service:object>
                </tenant:serviceBindings>
                <!-- end Workflow service meta-data -->
+               
+               <!-- begin Index service meta-data -->
+               <tenant:serviceBindings id="Index" merge:matcher="id" name="Index" type="utility"
+                       version="1.0">
+                       <service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
+                       <service:documentHandler xmlns:service="http://collectionspace.org/services/config/service">org.collectionspace.services.common.index.service.nuxeo.WorkflowDocumentModelHandler
+                       </service:documentHandler>
+                       <service:validatorHandler xmlns:service="http://collectionspace.org/services/config/service">org.collectionspace.services.index.nuxeo.WorkflowValidatorHandler
+                       </service:validatorHandler>
+                       <service:object xmlns:service="http://collectionspace.org/services/config/service" name="Index"
+                               version="1.0">
+                               <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="index-system"
+                                       updated="" order="0">
+                                       <service:content contentType="application/xml">
+                                               <service:xmlContent namespaceURI="http://collectionspace.org/services/config/system"
+                                                       schemaLocation="http://collectionspace.org/services/config/system http://collectionspace.org/services/config/system/system-response.xsd" />
+                                       </service:content>
+                               </service:part>
+                               <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="index_common"
+                                       updated="" order="1">
+                                       <service:content contentType="application/xml">
+                                               <service:xmlContent namespaceURI="http://collectionspace.org/services/index"
+                                                       schemaLocation="http://collectionspace.org/services/index http://services.collectionspace.org/movement/index_common.xsd" />
+                                       </service:content>
+                               </service:part>
+                       </service:object>
+               </tenant:serviceBindings>
+               <!-- end Index service meta-data -->            
 
                <!-- begin report service meta-data -->
                <tenant:serviceBindings id="Reports" merge:matcher="id" name="Reports" type="utility" version="1.0">
index de4c957d10ec67c1d6e3888e93fdfce8d2e2369d..6856a80cb874c61a87908f9d37eb9147c61dc32a 100644 (file)
@@ -41,6 +41,7 @@ import org.collectionspace.services.common.config.ServiceConfigUtils;
 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
 import org.collectionspace.services.common.context.RemoteServiceContext;
 import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
@@ -55,10 +56,8 @@ import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.util.HttpResponseCodes;
-
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
 
@@ -94,6 +93,65 @@ public abstract class NuxeoBasedResource
         }
     }
     
+    //======================= REINDEX ====================================================
+    @GET
+    @Path("{csid}/index/{indexid}")
+    public Response reindex(
+            @Context Request request,                  
+            @Context UriInfo uriInfo,
+            @PathParam("csid") String csid,
+            @PathParam("indexid") String indexid) {
+               Response result = Response.noContent().build();
+               boolean success = false;
+               
+        ensureCSID(csid, READ);
+        try {
+            RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(uriInfo);
+            DocumentHandler handler = createDocumentHandler(ctx);
+            success = getRepositoryClient(ctx).reindex(handler, csid);
+        } catch (Exception e) {
+            throw bigReThrow(e, ServiceMessages.REINDEX_FAILED, csid);
+        }
+        
+        if (success == false) {
+            Response response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+                    ServiceMessages.REINDEX_FAILED + ServiceMessages.resourceNotReindexedMsg(csid)).type("text/plain").build();
+            throw new CSWebApplicationException(response);
+        }
+               
+               return result;
+    }
+    
+    //======================= REINDEX ====================================================
+    @GET
+    @Path("index/{indexid}")
+    public Response reindex(
+            @Context Request request,
+            @Context UriInfo uriInfo,
+            @PathParam("indexid") String indexid) {
+               Response result = Response.noContent().build();;
+               boolean success = false;
+               String docType = null;
+               
+        try {
+            RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(uriInfo);
+            docType = ctx.getTenantQualifiedDoctype(); // this will used in the error message if an error occurs
+            DocumentHandler handler = createDocumentHandler(ctx);
+            success = getRepositoryClient(ctx).reindex(handler, indexid);
+        } catch (Exception e) {
+            throw bigReThrow(e, ServiceMessages.REINDEX_FAILED);
+        }
+        
+        if (success == false) {
+            Response response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+                    ServiceMessages.REINDEX_FAILED + ServiceMessages.resourceNotReindexedMsg(docType)).type("text/plain").build();
+            throw new CSWebApplicationException(response);
+        }
+               
+               return result;
+    }
+    
+    
     //======================= CREATE ====================================================
     
     @POST
index 2fe4e522e36d72f009502388de83981ed08941ce..001830049ba4c964394880e40ee1e1c54115dc59 100644 (file)
@@ -42,6 +42,7 @@ public class ServiceMessages {
     
     public static final String CREATE_FAILED = "Create request " + FAILED;
     public static final String READ_FAILED = "Read request " + FAILED;
+    public static final String REINDEX_FAILED = "Reindex request " + FAILED;
     public static final String UPDATE_FAILED = "Update request " + FAILED;
     
     public static final String POST_UNSUPPORTED = "POST " + UNSUPPORTED;
@@ -61,7 +62,15 @@ public class ServiceMessages {
     public static final String MISSING_INVALID_CSID = "missing/invalid csid=";
 
     public static String resourceNotFoundMsg(String csid) {
-        return "resource identified by CSID '" + csid + "' was not found.";
+        return String.format("The resource identified by CSID '%s' was not found.", csid);
     }
 
+    public static String resourceNotReindexedMsg(String csid) {
+        return String.format("The resource identified by CSID '%s' could not be reindexed. See the service logs for details.", csid);
+    }
+    
+    public static String resourceTypeNotReindexedMsg(String resourceType) {
+        return String.format("The resource types identified by '%s' could not be reindexed. See the service logs for details.", resourceType);
+    }    
+
 }
index 77c7c52c689a93c7f6254cf4e863f01df7adf92b..2c456ffdd91d01892e5710e74eb54d1097f13e0b 100644 (file)
@@ -83,7 +83,7 @@ import org.collectionspace.services.blob.MeasuredPartGroupList;
 import org.collectionspace.services.jaxb.BlobJAXBSchema;
 import org.collectionspace.services.nuxeo.client.java.CommonList;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 import org.collectionspace.services.nuxeo.extension.thumbnail.ThumbnailConstants;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.config.service.ListResultField;
@@ -560,7 +560,7 @@ public class NuxeoBlobUtils {
        static private CoreSessionInterface getRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
                        RepositoryClient<PoxPayloadIn, PoxPayloadOut> repositoryClient) {
                CoreSessionInterface result = null;             
-               RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;
+               RepositoryClientImpl nuxeoClient = (RepositoryClientImpl)repositoryClient;
                
                try {
                        result = nuxeoClient.getRepositorySession(ctx);
@@ -574,7 +574,7 @@ public class NuxeoBlobUtils {
        static private void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
                        RepositoryClient<PoxPayloadIn, PoxPayloadOut> repositoryClient,
                        CoreSessionInterface repoSession) throws TransactionException {
-               RepositoryJavaClientImpl nuxeoClient = (RepositoryJavaClientImpl)repositoryClient;
+               RepositoryClientImpl nuxeoClient = (RepositoryClientImpl)repositoryClient;
                nuxeoClient.releaseRepositorySession(ctx, repoSession);
        }
        
index 94110d4e58ae651222c5d7c304d2447c8fc0cdca..a0a7af84baca112c9a5a721564608ec4cbf4eda1 100644 (file)
@@ -15,7 +15,7 @@ import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.repository.RepositoryClient;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -52,7 +52,7 @@ public class RelationUtils {
         // relations_common:subjectRefName = 'urn:cspace:core.collectionspace.org:placeauthorities:name(place):item:name(Amystan1348082103923)\'Amystan\''"
         String query = String.format("%s:%s = '%s'", IRelationsManager.SERVICE_COMMONPART_NAME, targetField, escapedRefName);
 
-        RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient;
+        RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl) repoClient;
         DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(ctx, repoSession,
                 docTypes, query, orderByClause, pageSize, pageNum, computeTotal);
         DocumentModelList docList = docListWrapper.getWrappedObject();
index fa9cf3a533d646301017cb3c68c31af121326c88..bf6316622a42f298e15092c8f19f996aea71b309 100644 (file)
@@ -28,11 +28,11 @@ import java.util.List;
 
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.DocumentException;
+import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.storage.StorageClient;
 import org.collectionspace.services.config.tenant.RepositoryDomainType;
-
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
 //
 // All of these Nuxeo specific classes should not be here.  This is supposed to be
@@ -155,4 +155,27 @@ public interface RepositoryClient<IT, OT> extends StorageClient {
             String where,
             int pageSize, int pageNum, boolean computeTotal)
             throws DocumentNotFoundException, DocumentException;
+
+    /**
+     * Reindex a single resource/document.
+     * 
+     * @param ctx
+     * @param id
+     * @param handler
+     * @throws DocumentNotFoundException
+     * @throws DocumentException
+     */
+       boolean reindex(DocumentHandler handler, String csid, String indexid)
+                       throws DocumentNotFoundException, DocumentException;
+
+       /**
+        * Reindex all resources/documents of a specified type
+        * 
+        * @param ctx
+        * @param handler
+        * @throws DocumentNotFoundException
+        * @throws DocumentException
+        */
+       boolean reindex(DocumentHandler handler, String indexid)
+                       throws DocumentNotFoundException, DocumentException;
 }
index 8e907a1d18fd97324d31435923cc53dc8007f2ba..afa8886f0ec2b25f1fce87b76ade47cefc6835c3 100644 (file)
@@ -32,6 +32,7 @@ import java.security.Principal;
 import java.util.HashMap;
 import java.util.Set;
 
+
 //import org.jboss.resteasy.core.ResourceMethod;
 import org.jboss.resteasy.core.ResourceMethodInvoker;
 import org.jboss.resteasy.core.ServerResponse;
@@ -53,6 +54,7 @@ import org.collectionspace.authentication.AuthN;
 import org.collectionspace.services.authorization.AuthZ;
 import org.collectionspace.services.authorization.CSpaceResource;
 import org.collectionspace.services.authorization.URIResourceImpl;
+import org.collectionspace.services.client.index.IndexClient;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.CollectionSpaceResource;
@@ -167,7 +169,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                                } else {
                                        //
                                        // They passed the first round of security checks, so now let's check to see if they're trying
-                                       // to perform a workflow state change and make sure they are allowed to to this.
+                                       // to perform a workflow state change or fulltext reindex and make sure they are allowed to to this.
                                        //
                                        if (uriPath.contains(WorkflowClient.SERVICE_PATH) == true) {
                                                String workflowProxyResource = SecurityUtils.getWorkflowResourceName(request);
@@ -179,7 +181,18 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                                                                        Response.Status.FORBIDDEN).entity(uriPath + " " + httpMethod).type("text/plain").build();
                                                        throw new CSWebApplicationException(response);
                                                }
+                                       } else  if (uriPath.contains(IndexClient.SERVICE_PATH) == true) {
+                                               String indexProxyResource = SecurityUtils.getIndexResourceName(request);
+                                               res = new URIResourceImpl(AuthN.get().getCurrentTenantId(), indexProxyResource, httpMethod);
+                                               if (authZ.isAccessAllowed(res) == false) {
+                                                       logger.error("Access to " + resName + ":" + res.getId() + " is NOT allowed to "
+                                                                       + " user=" + AuthN.get().getUserId());
+                                                       Response response = Response.status(
+                                                                       Response.Status.FORBIDDEN).entity(uriPath + " " + httpMethod).type("text/plain").build();
+                                                       throw new CSWebApplicationException(response);
+                                               }
                                        }
+
                                }
                                //
                                // Login to Nuxeo
index 64ad4e5f516908921a1a0063e67b765c66b6db82..42e52b11db22e956047de7478baf07077f90920c 100644 (file)
@@ -32,6 +32,7 @@ import java.util.StringTokenizer;
 import org.collectionspace.services.authorization.AuthZ;
 import org.collectionspace.services.authorization.CSpaceResource;
 import org.collectionspace.services.authorization.URIResourceImpl;
+import org.collectionspace.services.client.index.IndexClient;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.config.service.ServiceBindingType;
 
@@ -42,7 +43,6 @@ import org.collectionspace.authentication.AuthN;
 import org.collectionspace.authentication.spi.AuthNContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import org.jboss.crypto.digest.DigestCallback;
 import org.jboss.resteasy.spi.HttpRequest;
 import org.jboss.security.Base64Encoder;
@@ -120,6 +120,37 @@ public class SecurityUtils {
        return result;
     }
     
+    public static String getIndexResourceName(HttpRequest request) {
+       String result = null;
+                       
+       UriInfo uriInfo = request.getUri();
+       String indexSubResName = SecurityUtils.getResourceName(uriInfo);
+       String resEntity = SecurityUtils.getResourceEntity(indexSubResName);
+       
+               MultivaluedMap<String, String> pathParams = uriInfo.getPathParameters();
+               String indexId = pathParams.getFirst(IndexClient.INDEX_ID_PARAM);
+               if (indexId != null  && pathParams.containsKey("csid")) {
+                       // e.g., intakes/*/index/fulltext
+               result = resEntity + "/*/" + IndexClient.SERVICE_NAME + "/" + indexId;
+               } else if (indexId != null) {
+                       // e.g., intakes/index/fulltext
+               result = resEntity + IndexClient.SERVICE_NAME + "/" + indexId;                  
+               } else {
+                       // e.g., intakes
+                       result = resEntity;
+               }
+               
+               //
+               // Overriding the result from above.
+               //
+               // Until we build out more permissions for the index resource,
+               // we're just going to return the index resource name.
+               //
+               result = IndexClient.SERVICE_NAME;
+       
+       return result;
+    }    
+    
        /**
         * Gets the resource name.
         *
@@ -154,7 +185,7 @@ public class SecurityUtils {
                }
                
                // FIXME: REM
-               // Since the hjid (HyperJaxb3 generated IDs are not unique strings in URIs that also have a CSID,
+               // Since the hjid (HyperJaxb3 generated IDs) are not unique strings in URIs that also have a CSID,
                // we need to replace hjid last.  We can fix this by having HyperJaxb3 generate UUID.
                // Assumption : path param name for csid is lowercase
                //
index 74be6d1cd66f803af86539d086a9c9245e6afd7f..6804ec811776bab152e1a6ab93b29f88deb67aa2 100644 (file)
@@ -68,7 +68,7 @@ import org.collectionspace.services.common.relation.RelationUtils;
 import org.collectionspace.services.common.repository.RepositoryClient;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 import org.collectionspace.services.common.security.SecurityUtils;
 import org.collectionspace.services.config.service.ServiceBindingType;
 import org.collectionspace.services.jaxb.AbstractCommonList;
@@ -262,7 +262,7 @@ public class RefNameServiceUtils {
         Map<String, ServiceBindingType> queriedServiceBindings = new HashMap<String, ServiceBindingType>();
         Map<String, List<AuthRefConfigInfo>> authRefFieldsByService = new HashMap<String, List<AuthRefConfigInfo>>();
 
-        RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient;
+        RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl) repoClient;
         try {
             // Ignore any provided page size and number query parameters in
             // the following call, as they pertain to the list of authority
@@ -419,7 +419,7 @@ public class RefNameServiceUtils {
         final String ORDER_BY_VALUE = CollectionSpaceClient.CORE_CREATED_AT  // "collectionspace_core:createdAt";
                                           + ", " + IQueryManager.NUXEO_UUID; // CSPACE-6333: Add secondary sort on uuid, in case records have the same createdAt timestamp.
 
-        if (repoClient instanceof RepositoryJavaClientImpl == false) {
+        if (repoClient instanceof RepositoryClientImpl == false) {
             throw new InternalError("updateAuthorityRefDocs() called with unknown repoClient type!");
         }
         
@@ -454,7 +454,7 @@ public class RefNameServiceUtils {
                                queriedServiceBindings, authRefFieldsByService, // Perform the refName updates on the list of document models
                         newRefName);
                 if (nRefsFoundThisPage > 0) {
-                    ((RepositoryJavaClientImpl) repoClient).saveDocListWithoutHandlerProcessing(ctx, repoSession, docList, true); // Flush the document model list out to Nuxeo storage
+                    ((RepositoryClientImpl) repoClient).saveDocListWithoutHandlerProcessing(ctx, repoSession, docList, true); // Flush the document model list out to Nuxeo storage
                     nRefsFound += nRefsFoundThisPage;
                 }
 
@@ -531,7 +531,7 @@ public class RefNameServiceUtils {
             query += " AND " + whereClauseAdditions;
         }
         // Now we have to issue the search
-        RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient;
+        RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl) repoClient;
         DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(ctx, repoSession,
                 docTypes, query, orderByClause, pageSize, pageNum, computeTotal);
         // Now we gather the info for each document into the list and return
diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CSReindexFulltextRoot.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CSReindexFulltextRoot.java
new file mode 100644 (file)
index 0000000..fe2251f
--- /dev/null
@@ -0,0 +1,60 @@
+package org.collectionspace.services.nuxeo.client.java;
+
+import java.io.Serializable;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.DocumentHandler;
+import org.collectionspace.services.nuxeo.util.ReindexFulltextRoot;
+import org.collectionspace.services.nuxeo.util.ReindexFulltextRoot.ReindexInfo;
+import org.nuxeo.ecm.core.api.IterableQueryResult;
+import org.nuxeo.ecm.core.api.NuxeoException;
+import org.nuxeo.ecm.core.api.NuxeoPrincipal;
+import org.nuxeo.ecm.core.query.QueryFilter;
+import org.nuxeo.ecm.core.query.sql.NXQL;
+import org.nuxeo.ecm.core.storage.StorageException;
+import org.nuxeo.runtime.transaction.TransactionHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*
+ * Use the inherited reindexFulltext() method to reindex the Nuxeo full-text index.
+ */
+public class CSReindexFulltextRoot extends ReindexFulltextRoot {
+
+       /** The logger. */
+       private final Logger logger = LoggerFactory.getLogger(CSReindexFulltextRoot.class);
+       protected String repoQuery;
+
+       public CSReindexFulltextRoot(CoreSessionInterface repoSession, String repoQuery) {
+               this.coreSession = repoSession.getCoreSession();
+               this.repoQuery = repoQuery;
+       }
+       
+       
+       @Override
+    protected List<ReindexInfo> getInfos() throws StorageException {
+        getLowLevelSession();
+        List<ReindexInfo> infos = new ArrayList<ReindexInfo>();
+//        String query = "SELECT ecm:uuid, ecm:primaryType FROM Document"
+//                + " WHERE ecm:isProxy = 0"
+//                + " AND ecm:currentLifeCycleState <> 'deleted'"
+//                + " ORDER BY ecm:uuid";
+        IterableQueryResult it = session.queryAndFetch(this.repoQuery, NXQL.NXQL,
+                QueryFilter.EMPTY);
+        try {
+            for (Map<String, Serializable> map : it) {
+                Serializable id = map.get(NXQL.ECM_UUID);
+                String type = (String) map.get(NXQL.ECM_PRIMARYTYPE);
+                infos.add(new ReindexInfo(id, type));
+            }
+        } finally {
+            it.close();
+        }
+        return infos;
+    }    
+
+}
index d5d342499a82c8989dba86c9a74478034291e270..dfce1ff4e19919a0a03e813f760d8082bdc68246 100644 (file)
@@ -29,6 +29,7 @@ import java.util.List;
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.commons.lang.StringUtils;
+
 import org.collectionspace.services.client.Profiler;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.IQueryManager;
@@ -59,12 +60,14 @@ import org.collectionspace.services.lifecycle.StateList;
 import org.collectionspace.services.lifecycle.TransitionDef;
 import org.collectionspace.services.lifecycle.TransitionDefList;
 import org.collectionspace.services.lifecycle.TransitionList;
+
 import org.nuxeo.ecm.core.NXCore;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
 import org.nuxeo.ecm.core.api.model.PropertyException;
 import org.nuxeo.ecm.core.lifecycle.LifeCycleService;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index 830814d2ee1143202bfbf2d77a297633a079705c..a3e93d0359f04033c5e679ef8593e1f1f75f8e7d 100644 (file)
@@ -182,7 +182,7 @@ public abstract class NuxeoDocumentModelHandler<T> extends RemoteDocumentModelHa
                CommonList commonList = new CommonList();
                String markRtSbj = null;
                CoreSessionInterface repoSession = null;
-               RepositoryJavaClientImpl repoClient = null;
+               RepositoryClientImpl repoClient = null;
                boolean releaseRepoSession = false;
 
                AbstractServiceContextImpl ctx = (AbstractServiceContextImpl) getServiceContext();
@@ -193,8 +193,8 @@ public abstract class NuxeoDocumentModelHandler<T> extends RemoteDocumentModelHa
 
                try {
                        if (markRtSbj != null) {
-                               repoClient = (RepositoryJavaClientImpl) this.getRepositoryClient(ctx);
-                               RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl) repoClient;
+                               repoClient = (RepositoryClientImpl) this.getRepositoryClient(ctx);
+                               RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl) repoClient;
                                repoSession = this.getRepositorySession();
                                if (repoSession == null) {
                                        repoSession = repoClient.getRepositorySession(ctx);
index 6f81c24a6e163ccc1366acf61c3def2f4e5d278c..83de91744c2d6d1015a2e73a928653f3028f4d1a 100644 (file)
@@ -547,7 +547,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
        String returnValue = null;
 
        try{ 
-               RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
+               RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {
                        repoSession = repoClient.getRepositorySession();
@@ -619,7 +619,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
                
                boolean releaseRepoSession = false;
                ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
-               RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
+               RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
                CoreSessionInterface repoSession = this.getRepositorySession();
                if (repoSession == null) {
                        repoSession = repoClient.getRepositorySession(ctx);
similarity index 98%
rename from services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java
rename to services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryClientImpl.java
index 33246138ff6c8a8f08ab2cb2b50fe5aebe4ded34..2ca71a3cfdb6a459af10624f7e9fd524b3a77170 100644 (file)
@@ -71,7 +71,6 @@ import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
 import org.apache.chemistry.opencmis.server.shared.ThresholdOutputStreamFactory;
-
 import org.nuxeo.common.utils.IdUtils;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -85,24 +84,23 @@ import org.nuxeo.ecm.core.api.PathRef;
 import org.nuxeo.runtime.transaction.TransactionRuntimeException;
 import org.nuxeo.ecm.core.opencmis.bindings.NuxeoCmisServiceFactory;
 import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * RepositoryJavaClient is used to perform CRUD operations on documents in Nuxeo
+ * RepositoryClientImpl is used to perform CRUD operations on documents in Nuxeo
  * repository using Remote Java APIs. It uses
  *
  * @see DocumentHandler as IOHandler with the client.
  *
  * $LastChangedRevision: $ $LastChangedDate: $
  */
-public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn, PoxPayloadOut> {
+public class RepositoryClientImpl implements RepositoryClient<PoxPayloadIn, PoxPayloadOut> {
        
     /**
      * The logger.
      */
-    private final Logger logger = LoggerFactory.getLogger(RepositoryJavaClientImpl.class);
+    private final Logger logger = LoggerFactory.getLogger(RepositoryClientImpl.class);
 //    private final Logger profilerLogger = LoggerFactory.getLogger("remperf");
 //    private String foo = Profiler.createLogger();
     public static final String NUXEO_CORE_TYPE_DOMAIN = "Domain";
@@ -120,7 +118,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
     /**
      * Instantiates a new repository java client impl.
      */
-    public RepositoryJavaClientImpl() {
+    public RepositoryClientImpl() {
         //Empty constructor
     }
 
@@ -220,7 +218,45 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
         }
 
     }
+    
 
+    @Override
+    public boolean reindex(DocumentHandler handler, String csid, String indexid) throws DocumentNotFoundException, DocumentException
+    {
+       boolean result = true;
+       ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = handler.getServiceContext();
+       return result;
+    }
+    
+    @Override
+    public boolean reindex(DocumentHandler handler, String indexid) throws DocumentNotFoundException, DocumentException
+    {
+       boolean result = true;
+        CoreSessionInterface repoSession = null;
+        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = handler.getServiceContext();
+        
+        try {
+            repoSession = getRepositorySession(ctx);
+            try {
+            } catch (ClientException ce) {
+            }
+            //
+            // Set repository session to handle the document
+            //
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception ", e);
+            }
+            throw new NuxeoDocumentException(e);
+        } finally {
+            if (repoSession != null) {
+                releaseRepositorySession(ctx, repoSession);
+            }
+        }
+        
+       return result;
+    }
+    
     /**
      * get document from the Nuxeo repository
      *
@@ -963,7 +999,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
 
         // FIXME: Get all of the following values from appropriate external constants.
         //
-        // At present, the two constants below are duplicated in both RepositoryJavaClientImpl
+        // At present, the two constants below are duplicated in both RepositoryClientImpl
         // and in AuthorityItemDocumentModelHandler.
         final String TERM_GROUP_LIST_NAME = "TERM_GROUP_LIST_NAME";
         final String TERM_GROUP_TABLE_NAME_PARAM = "TERM_GROUP_TABLE_NAME";
diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/util/ReindexFulltextRoot.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/util/ReindexFulltextRoot.java
new file mode 100644 (file)
index 0000000..968d7a3
--- /dev/null
@@ -0,0 +1,312 @@
+/*
+ * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others.
+ * 
+ * This code was moved into CollectionSpace to be compatible with the
+ * Nuxeo 6.0-HF21 jar files.  The original code can be found on
+ * 
+ * GitHub.com here: https://github.com/nuxeo/nuxeo-reindex-fulltext
+ *
+ * Licensed 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.
+ *
+ * Contributors:
+ *     Florent Guillaume
+ */
+package org.collectionspace.services.nuxeo.util;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuxeo.ecm.core.api.AbstractSession;
+import org.nuxeo.ecm.core.api.CoreSession;
+import org.nuxeo.ecm.core.api.IterableQueryResult;
+import org.nuxeo.ecm.core.api.NuxeoException;
+import org.nuxeo.ecm.core.api.NuxeoPrincipal;
+import org.nuxeo.ecm.core.event.EventService;
+import org.nuxeo.ecm.core.query.QueryFilter;
+import org.nuxeo.ecm.core.query.sql.NXQL;
+import org.nuxeo.ecm.core.storage.FulltextConfiguration;
+import org.nuxeo.ecm.core.storage.StorageException;
+import org.nuxeo.ecm.core.storage.sql.Model;
+import org.nuxeo.ecm.core.storage.sql.Node;
+import org.nuxeo.ecm.core.storage.sql.Session;
+import org.nuxeo.ecm.core.storage.sql.SimpleProperty;
+import org.nuxeo.ecm.core.storage.sql.coremodel.SQLFulltextExtractorWork;
+import org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession;
+import org.nuxeo.ecm.core.work.api.Work;
+import org.nuxeo.ecm.core.work.api.WorkManager;
+import org.nuxeo.ecm.core.work.api.WorkManager.Scheduling;
+import org.nuxeo.ecm.webengine.jaxrs.session.SessionFactory;
+import org.nuxeo.runtime.api.Framework;
+import org.nuxeo.runtime.transaction.TransactionHelper;
+
+/**
+ * JAX-RS component used to do fulltext reindexing of the whole database.
+ *
+ * @since 5.6
+ */
+@Path("reindexFulltext")
+public class ReindexFulltextRoot {
+
+    public static Log log = LogFactory.getLog(ReindexFulltextRoot.class);
+
+    protected static final String DC_TITLE = "dc:title";
+
+    protected static final int DEFAULT_BATCH_SIZE = 100;
+
+    @Context
+    protected HttpServletRequest request;
+
+    protected CoreSession coreSession;
+
+    protected Session session;
+
+    protected FulltextConfiguration fulltextConfiguration;
+
+    public static class ReindexInfo {
+        public final Serializable id;
+
+        public final String type;
+
+        public ReindexInfo(Serializable id, String type) {
+            this.id = id;
+            this.type = type;
+        }
+    }
+
+    @GET
+    public String get(@QueryParam("batchSize") int batchSize, @QueryParam("batch") int batch) throws StorageException {
+        coreSession = SessionFactory.getSession(request);
+        return reindexFulltext(batchSize, batch);
+    }
+
+    /**
+     * Launches a fulltext reindexing of the database.
+     *
+     * @param batchSize the batch size, defaults to 100
+     * @param batch if present, the batch number to process instead of all
+     *            batches; starts at 1
+     * @return when done, ok + the total number of docs
+     * @throws StorageException 
+     */
+    public String reindexFulltext(int batchSize, int batch) throws StorageException {
+        Principal principal = coreSession.getPrincipal();
+        if (!(principal instanceof NuxeoPrincipal)) {
+            return "unauthorized";
+        }
+        NuxeoPrincipal nuxeoPrincipal = (NuxeoPrincipal) principal;
+        if (!nuxeoPrincipal.isAdministrator()) {
+            return "unauthorized";
+        }
+
+        log("Reindexing starting");
+        if (batchSize <= 0) {
+            batchSize = DEFAULT_BATCH_SIZE;
+        }
+        List<ReindexInfo> infos = getInfos();
+        int size = infos.size();
+        int numBatches = (size + batchSize - 1) / batchSize;
+        if (batch < 0 || batch > numBatches) {
+            batch = 0; // all
+        }
+        batch--;
+
+        log("Reindexing of %s documents, batch size: %s, number of batches: %s",
+                size, batchSize, numBatches);
+        if (batch >= 0) {
+            log("Reindexing limited to batch: %s", batch + 1);
+        }
+
+        boolean tx = TransactionHelper.isTransactionActive();
+        if (tx) {
+            TransactionHelper.commitOrRollbackTransaction();
+        }
+
+        int n = 0;
+        int errs = 0;
+        for (int i = 0; i < numBatches; i++) {
+            if (batch >= 0 && batch != i) {
+                continue;
+            }
+            int pos = i * batchSize;
+            int end = pos + batchSize;
+            if (end > size) {
+                end = size;
+            }
+            List<ReindexInfo> batchInfos = infos.subList(pos, end);
+            log("Reindexing batch %s/%s, first id: %s", i + 1, numBatches,
+                    batchInfos.get(0).id);
+            try {
+                doBatch(batchInfos);
+            } catch (NuxeoException e) {
+                log.error("Error processing batch " + i + 1, e);
+                errs++;
+            }
+            n += end - pos;
+        }
+
+        log("Reindexing done");
+        if (tx) {
+            TransactionHelper.startTransaction();
+        }
+        return "done: " + n + " total: " + size + " batch_errors: " + errs;
+    }
+
+    protected void log(String format, Object... args) {
+        log.warn(String.format(format, args));
+    }
+
+    /**
+     * This has to be called once the transaction has been started.
+     * @throws StorageException 
+     */
+    protected void getLowLevelSession() throws StorageException {
+        try {
+            SQLSession s = (SQLSession) ((AbstractSession) coreSession).getSession();
+            Field f2 = SQLSession.class.getDeclaredField("session");
+            f2.setAccessible(true);
+            session = (Session) f2.get(s);
+            fulltextConfiguration = session.getModel().getFulltextConfiguration();
+        } catch (ReflectiveOperationException e) {
+            throw new NuxeoException(e);
+        }
+    }
+
+    protected List<ReindexInfo> getInfos() throws StorageException {
+        getLowLevelSession();
+        List<ReindexInfo> infos = new ArrayList<ReindexInfo>();
+        String query = "SELECT ecm:uuid, ecm:primaryType FROM Document"
+                + " WHERE ecm:isProxy = 0"
+                + " AND ecm:currentLifeCycleState <> 'deleted'"
+                + " ORDER BY ecm:uuid";
+        IterableQueryResult it = session.queryAndFetch(query, NXQL.NXQL,
+                QueryFilter.EMPTY);
+        try {
+            for (Map<String, Serializable> map : it) {
+                Serializable id = map.get(NXQL.ECM_UUID);
+                String type = (String) map.get(NXQL.ECM_PRIMARYTYPE);
+                infos.add(new ReindexInfo(id, type));
+            }
+        } finally {
+            it.close();
+        }
+        return infos;
+    }
+
+    protected void doBatch(List<ReindexInfo> infos) throws StorageException {
+        boolean tx;
+        boolean ok;
+
+        // transaction for the sync batch
+        tx = TransactionHelper.startTransaction();
+
+        getLowLevelSession(); // for fulltextInfo
+        List<Serializable> ids = new ArrayList<Serializable>(infos.size());
+        Set<String> asyncIds = new HashSet<String>();
+        Model model = session.getModel();
+        for (ReindexInfo info : infos) {
+            ids.add(info.id);
+            if (fulltextConfiguration.isFulltextIndexable(info.type)) {
+                asyncIds.add(model.idToString(info.id));
+            }
+        }
+        ok = false;
+        try {
+            runSyncBatch(ids, asyncIds);
+            ok = true;
+        } finally {
+            if (tx) {
+                if (!ok) {
+                    TransactionHelper.setTransactionRollbackOnly();
+                    log.error("Rolling back sync");
+                }
+                TransactionHelper.commitOrRollbackTransaction();
+            }
+        }
+
+        runAsyncBatch(asyncIds);
+
+        // wait for async completion after transaction commit
+        Framework.getLocalService(EventService.class).waitForAsyncCompletion();
+    }
+
+    /*
+     * Do this at the low-level session level because we may have to modify
+     * things like versions which aren't usually modifiable, and it's also good
+     * to bypass all listeners.
+     */
+    protected void runSyncBatch(List<Serializable> ids, Set<String> asyncIds) throws StorageException {
+        getLowLevelSession();
+
+        session.getNodesByIds(ids); // batch fetch
+
+        Map<Serializable, String> titles = new HashMap<Serializable, String>();
+        for (Serializable id : ids) {
+            Node node = session.getNodeById(id);
+            if (asyncIds.contains(id)) {
+                node.setSimpleProperty(Model.FULLTEXT_JOBID_PROP, id);
+            }
+            SimpleProperty prop;
+            try {
+                prop = node.getSimpleProperty(DC_TITLE);
+            } catch (IllegalArgumentException e) {
+                continue;
+            }
+            String title = (String) prop.getValue();
+            titles.put(id, title);
+            prop.setValue(title + " ");
+        }
+        session.save();
+
+        for (Serializable id : ids) {
+            Node node = session.getNodeById(id);
+            SimpleProperty prop;
+            try {
+                prop = node.getSimpleProperty(DC_TITLE);
+            } catch (IllegalArgumentException e) {
+                continue;
+            }
+            prop.setValue(titles.get(id));
+        }
+        session.save();
+    }
+
+    protected void runAsyncBatch(Set<String> asyncIds)
+            {
+        if (asyncIds.isEmpty()) {
+            return;
+        }
+        String repositoryName = coreSession.getRepositoryName();
+        WorkManager workManager = Framework.getLocalService(WorkManager.class);
+        for (String id : asyncIds) {
+            Work work = new SQLFulltextExtractorWork(repositoryName, id);
+            // schedule immediately, we're outside a transaction
+            workManager.schedule(work, Scheduling.IF_NOT_SCHEDULED, false);
+        }
+    }
+
+}
diff --git a/services/index/3rdparty/build.xml b/services/index/3rdparty/build.xml
new file mode 100644 (file)
index 0000000..99de72c
--- /dev/null
@@ -0,0 +1,127 @@
+
+<project name="index.3rdparty" default="package" basedir=".">
+    <description>
+        Index service to manage repository indexes.
+    </description>
+  <!-- set global properties for this build -->
+    <property name="services.trunk" value="../../.."/>
+    <!-- environment should be declared before reading build.properties -->
+    <property environment="env" />
+    <property file="${services.trunk}/build.properties" />
+    <property name="mvn.opts" value="-V" />
+    <property name="src" location="src"/>
+
+    <condition property="osfamily-unix">
+        <os family="unix" />
+    </condition>
+    <condition property="osfamily-windows">
+        <os family="windows" />
+    </condition>
+
+    <target name="init" >
+    <!-- Create the time stamp -->
+        <tstamp/>
+    </target>
+
+    <target name="package" depends="package-unix,package-windows"
+  description="Package CollectionSpace Services" />
+    <target name="package-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="package-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="install" depends="install-unix,install-windows"
+  description="Install" />
+    <target name="install-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="install-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    
+    <target name="clean" depends="clean-unix,clean-windows"
+  description="Delete target directories" >
+        <delete dir="${build}"/>
+    </target>
+    <target name="clean-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="clean-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />
+    <target name="test-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="test-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="deploy" depends="install"
+    description="deploy index in ${jee.server.nuxeo}">
+        <ant antfile="nuxeo-platform-cs-index/build.xml" target="deploy" inheritall="false"/>
+    </target>
+
+    <target name="undeploy"
+    description="undeploy index from ${jee.server.nuxeo}">
+        <ant antfile="nuxeo-platform-cs-index/build.xml" target="undeploy" inheritall="false"/>
+    </target>
+
+    <target name="dist"
+    description="generate distribution for index" depends="package">
+        <ant antfile="nuxeo-platform-cs-index/build.xml" target="dist" inheritall="false"/>
+    </target>
+
+
+</project>
diff --git a/services/index/3rdparty/nuxeo-platform-cs-index/build.xml b/services/index/3rdparty/nuxeo-platform-cs-index/build.xml
new file mode 100644 (file)
index 0000000..1b5efb6
--- /dev/null
@@ -0,0 +1,138 @@
+<project name="nuxeo-platform-cs-index" default="package" basedir=".">
+    <description>
+        index nuxeo document type
+    </description>
+    <!-- set global properties for this build -->
+    <property name="services.trunk" value="../../../.."/>
+    <!-- environment should be declared before reading build.properties -->
+    <property environment="env" />
+    <property file="${services.trunk}/build.properties" />
+    <property name="mvn.opts" value="-V" />
+    <property name="src" location="src"/>
+    <property name="nuxeo.index.jar"
+        value="org.collectionspace.services.index.3rdparty.nuxeo-${cspace.release}.jar"/>
+    <property name="nuxeo.index.jars.all"
+        value="org.collectionspace.services.index.3rdparty.nuxeo-*.jar"/>
+
+    <condition property="osfamily-unix">
+        <os family="unix" />
+    </condition>
+    <condition property="osfamily-windows">
+        <os family="windows" />
+    </condition>
+
+    <target name="init" >
+        <!-- Create the time stamp -->
+        <tstamp/>
+    </target>
+
+    <target name="package" depends="package-unix,package-windows"
+        description="Package CollectionSpace Services" />
+    <target name="package-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="package-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="install" depends="install-unix,install-windows"
+        description="Install" />
+    <target name="install-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="install-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="clean" depends="clean-unix,clean-windows"
+        description="Delete target directories" >
+        <delete dir="${build}"/>
+    </target>
+    <target name="clean-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="clean-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />
+    <target name="test-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="test-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="deploy" depends="install"
+        description="deploy index doctype in ${jee.server.nuxeo}">
+        <copy file="${basedir}/target/${nuxeo.index.jar}"
+        todir="${jee.deploy.nuxeo.plugins}"/>
+    </target>
+
+    <target name="undeploy"
+        description="undeploy index doctype from ${jee.server.nuxeo}">
+        <delete>
+            <fileset dir="${jee.deploy.nuxeo.plugins}">
+                <include name="${nuxeo.index.jars.all}"/>
+            </fileset>
+        </delete>
+    </target>
+
+
+    <target name="dist"
+        description="generate distribution for index doctype" depends="package">
+        <copy todir="${services.trunk}/${dist.deploy.nuxeo.plugins}">
+            <fileset file="${basedir}/target/${nuxeo.index.jar}"/>
+        </copy>
+    </target>
+
+</project>
+
diff --git a/services/index/3rdparty/nuxeo-platform-cs-index/pom.xml b/services/index/3rdparty/nuxeo-platform-cs-index/pom.xml
new file mode 100644 (file)
index 0000000..aa57723
--- /dev/null
@@ -0,0 +1,42 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.collectionspace.services</groupId>
+               <artifactId>org.collectionspace.services.index.3rdparty</artifactId>
+               <version>4.4-SNAPSHOT</version>
+       </parent>
+    
+    <artifactId>org.collectionspace.services.index.3rdparty.nuxeo</artifactId>
+    <name>services.index.3rdparty.nuxeo</name>
+    <packaging>jar</packaging>
+    <description>
+        Index Nuxeo Document Type
+    </description>
+
+    <build>
+               <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+               </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifestFile> src/main/resources/META-INF/MANIFEST.MF </manifestFile>
+                        <manifestEntries>
+                            <Bundle-Version>${eclipseVersion}</Bundle-Version>
+                            <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
+                        </manifestEntries>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/META-INF/MANIFEST.MF b/services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..5085172
--- /dev/null
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0 
+Bundle-ManifestVersion: 1 
+Bundle-Name: NuxeoCS
+Bundle-SymbolicName: org.collectionspace.index;singleton:=true 
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-Vendor: Nuxeo 
+Require-Bundle: org.nuxeo.runtime, 
+ org.nuxeo.ecm.core.api, 
+ org.nuxeo.ecm.core,
+ org.nuxeo.ecm.core.api,
+ org.nuxeo.ecm.platform.types.api,
+ org.nuxeo.ecm.platform.versioning.api,
+ org.nuxeo.ecm.platform.ui,
+ org.nuxeo.ecm.platform.forms.layout.client,
+ org.nuxeo.ecm.platform.ws,
+ org.collectionspace.collectionspace_core
+Provide-Package: org.collectionspace.index
+Nuxeo-Component: OSGI-INF/core-types-contrib.xml
+
diff --git a/services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/OSGI-INF/core-types-contrib.xml b/services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/OSGI-INF/core-types-contrib.xml
new file mode 100644 (file)
index 0000000..0e8f685
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<component name="org.collectionspace.index.coreTypes">
+  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+    <schema name="index_common" prefix="index_common" src="schemas/index_common.xsd"/>
+  </extension>
+</component>
diff --git a/services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/OSGI-INF/deployment-fragment.xml b/services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/OSGI-INF/deployment-fragment.xml
new file mode 100644 (file)
index 0000000..1d37c1b
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<fragment>
+
+  <extension target="application#MODULE">
+    <module>
+      <java>${bundle.fileName}</java>
+    </module>
+  </extension>
+
+</fragment>
\ No newline at end of file
diff --git a/services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/schemas/item_common.xsd b/services/index/3rdparty/nuxeo-platform-cs-index/src/main/resources/schemas/item_common.xsd
new file mode 100644 (file)
index 0000000..f8f0a56
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+    Index schema (XSD)
+    
+    Entity  : Index
+    Part    : Common
+    Used for: Nuxeo EP core document type
+
+    $LastChangedRevision: 2316 $
+    $LastChangedDate: 2010-06-02 16:03:51 -0700 (Wed, 02 Jun 2010) $
+-->
+
+<xs:schema 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:ns="http://collectionspace.org/index/"
+    xmlns="http://collectionspace.org/index/"
+    targetNamespace="http://collectionspace.org/index/"
+    version="0.1">
+    <!--  Index Information Group -->
+       <xs:element name="indexPolicy" type="xs:string"/>
+</xs:schema>
diff --git a/services/index/3rdparty/pom.xml b/services/index/3rdparty/pom.xml
new file mode 100644 (file)
index 0000000..9098423
--- /dev/null
@@ -0,0 +1,22 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>org.collectionspace.services.index</artifactId>
+        <groupId>org.collectionspace.services</groupId>
+        <version>4.4-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.collectionspace.services.index.3rdparty</artifactId>
+    <name>services.index.3rdparty</name>
+    <packaging>pom</packaging>
+    
+    <description>
+        3rd party build for index service
+    </description>
+
+    <modules>
+        <module>nuxeo-platform-cs-index</module>
+    </modules>
+</project>
diff --git a/services/index/build.xml b/services/index/build.xml
new file mode 100644 (file)
index 0000000..cd78c98
--- /dev/null
@@ -0,0 +1,123 @@
+
+<project name="index" default="package" basedir=".">
+    <description>
+        index service
+    </description>
+  <!-- set global properties for this build -->
+    <property name="services.trunk" value="../.."/>
+    <!-- environment should be declared before reading build.properties -->
+    <property environment="env" />
+    <property file="${services.trunk}/build.properties" />
+    <property name="mvn.opts" value="-V" />
+    <property name="src" location="src"/>
+
+    <condition property="osfamily-unix">
+        <os family="unix" />
+    </condition>
+    <condition property="osfamily-windows">
+        <os family="windows" />
+    </condition>
+
+    <target name="package" depends="package-unix,package-windows"
+  description="Package CollectionSpace Services" />
+  
+    <target name="package-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    
+    <target name="package-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+
+    <target name="install" depends="install-unix,install-windows"
+  description="Install" />
+    <target name="install-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="install-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="clean" depends="clean-unix,clean-windows"
+  description="Delete target directories" >
+        <delete dir="${build}"/>
+    </target>
+    <target name="clean-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="clean-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />
+    <target name="test-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="test-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="deploy" depends="install"
+        description="deploy index">
+        <ant antfile="3rdparty/build.xml" target="deploy" inheritall="false"/>
+    </target>
+
+    <target name="undeploy"
+        description="undeploy index service">
+        <ant antfile="3rdparty/build.xml" target="undeploy" inheritall="false"/>
+    </target>
+
+    <target name="dist" depends="package"
+        description="distribute index service">
+        <ant antfile="3rdparty/build.xml" target="dist" inheritall="false"/>
+    </target>
+</project>
diff --git a/services/index/client/pom.xml b/services/index/client/pom.xml
new file mode 100644 (file)
index 0000000..6d167c4
--- /dev/null
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>org.collectionspace.services.index</artifactId>
+        <version>4.4-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.collectionspace.services.index.client</artifactId>
+    <name>services.index.client</name>
+    
+    <dependencies>
+        <!-- keep slf4j dependencies on the top -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+<!-- CollectionSpace dependencies -->
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.common</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.dimension.client</artifactId> <!-- Dimension instances are used as a unit-tests targets -->
+            <version>${project.version}</version>
+        </dependency>
+<!-- External dependencies -->        
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxrs</artifactId>
+            <!-- filter out unwanted jars -->
+            <exclusions>
+                <exclusion>
+                    <groupId>tjws</groupId>
+                    <artifactId>webserver</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxb-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-multipart-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <finalName>collectionspace-services-index-client</finalName>
+    </build>
+</project>
diff --git a/services/index/client/src/test/java/org/collectionspace/services/client/test/IndexServiceTest.java b/services/index/client/src/test/java/org/collectionspace/services/client/test/IndexServiceTest.java
new file mode 100644 (file)
index 0000000..98b5a62
--- /dev/null
@@ -0,0 +1,202 @@
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright Â© 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * 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.collectionspace.services.client.test;
+
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.client.CollectionSpaceClient;
+import org.collectionspace.services.client.PayloadOutputPart;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.index.IndexCommon;
+import org.collectionspace.services.client.DimensionClient;
+import org.collectionspace.services.client.index.IndexClient;
+import org.collectionspace.services.dimension.DimensionsCommon;
+import org.jboss.resteasy.client.ClientResponse;
+import org.testng.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ObjectExitServiceTest, carries out tests against a deployed and running ObjectExit Service. <p/>
+ * $LastChangedRevision:  $
+ * $LastChangedDate:  $
+ */
+public class IndexServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, IndexCommon> {
+
+    private final String CLASS_NAME = IndexServiceTest.class.getName();
+    private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+    private String knownResourceId = null;
+
+    @Override
+       public String getServicePathComponent() {
+               return IndexClient.SERVICE_PATH_COMPONENT;
+       }
+
+       @Override
+       protected String getServiceName() {
+               return IndexClient.SERVICE_NAME;
+       }
+    
+    @Override
+    protected CollectionSpaceClient getClientInstance() {
+        return new DimensionClient();
+    }
+
+    //
+    // Test overrides
+    //
+    
+       @Override
+       public void create(String testName) throws Exception {
+               String csid = this.createTestObject(testName);
+               if (this.knownResourceId == null) {
+                       this.knownResourceId = csid;
+               }
+       }
+
+    @Override
+    public void read(String testName) throws Exception {
+//        setupRead();
+//        DimensionClient client = new DimensionClient();
+//        Response res = client.getIndex(knownResourceId);
+//        try {
+//             assertStatusCode(res, testName);
+//             PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
+//             IndexCommon indexsCommon = (IndexCommon) extractPart(input, IndexClient.SERVICE_COMMONPART_NAME, IndexCommon.class);
+//             if (logger.isDebugEnabled() == true) {
+//                     logger.debug("Index payload is: " + input.getXmlPayload());
+//             }
+//             Assert.assertNotNull(indexsCommon);
+//        } finally {
+//             if (res != null) {
+//                res.close();
+//            }
+//        }
+    }
+    
+    //
+    // FIXME: REM - This test should be a subclass of BaseServiceTest and *not* AbstractPoxServiceTestImpl
+    //
+    
+    @Override
+    public void update(String testName) throws Exception {
+        setupUpdate();
+    }    
+
+    @Override
+    public void delete(String testName) throws Exception {
+       // Do nothing.  N/A
+    }
+        
+    public void searchIndexDeleted(String testName) throws Exception {
+       // Do nothing.  N/A
+    }    
+
+       @Override
+       public void readList(String testName) throws Exception {
+               // Do nothing.  N/A
+       }       
+               
+       @Override
+    public void readPaginatedList(String testName) throws Exception {
+               // Do nothing.  N/A
+       }
+
+       @Override
+       public void CRUDTests(String testName) {
+               // TODO Auto-generated method stub              
+       }
+
+       @Override
+       protected IndexCommon updateInstance(IndexCommon commonPartObject) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       protected void compareUpdatedInstances(IndexCommon original,
+                       IndexCommon updated) throws Exception {
+               // TODO Auto-generated method stub
+               
+       }
+    
+       /*
+        * (non-Javadoc)
+        * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+        */
+       @Override
+       public void createList(String testName) throws Exception {
+               //empty N/A
+       }
+    
+    public void testSubmitRequest() {
+       // Do nothing.  N/A
+    }
+
+    // ---------------------------------------------------------------
+    // Utility methods used by tests above
+    // ---------------------------------------------------------------
+    
+    @Override
+    protected PoxPayloadOut createInstance(String identifier) {
+        String dimensionsCommonPartName = new DimensionClient().getCommonPartName();
+       return createInstance(identifier, dimensionsCommonPartName);
+    }    
+    
+       @Override
+       protected PoxPayloadOut createInstance(String commonPartName,
+                       String identifier) {
+               return createDimensionInstance(commonPartName, identifier);
+       }
+    
+       /*
+        * We're using a DimensionsCommon instance to test the index service.
+        */
+    private PoxPayloadOut createDimensionInstance(String dimensionValue) {
+        String commonPartName = new DimensionClient().getCommonPartName();
+        return createDimensionInstance(commonPartName, dimensionValue);
+    }
+       
+       /*
+        * We're using a DimensionsCommon instance to test the index service.
+        */
+    private PoxPayloadOut createDimensionInstance(String commonPartName,
+               String dimensionValue) {
+        String measurementUnit = "measurementUnit-" + dimensionValue;
+        DimensionsCommon dimensionsCommon = new DimensionsCommon();
+        
+        dimensionsCommon.setMeasurementUnit(measurementUnit);
+        PoxPayloadOut multipart = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
+        PayloadOutputPart commonPart = multipart.addPart(commonPartName, dimensionsCommon);
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("To be created, Dimensions common: " + commonPart.asXML());
+            logger.debug(objectAsXmlString(dimensionsCommon, DimensionsCommon.class));
+        }
+
+        return multipart;
+    }
+       
+}
diff --git a/services/index/client/src/test/resources/log4j.properties b/services/index/client/src/test/resources/log4j.properties
new file mode 100644 (file)
index 0000000..148a3e8
--- /dev/null
@@ -0,0 +1,23 @@
+log4j.rootLogger=debug, stdout, R
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=target/test-client.log
+
+log4j.appender.R.MaxFileSize=100KB
+# Keep one backup file
+log4j.appender.R.MaxBackupIndex=1
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
+
+#packages
+log4j.logger.org.collectionspace=DEBUG
+log4j.logger.org.apache=INFO
+log4j.logger.httpclient=INFO
+log4j.logger.org.jboss.resteasy=INFO
diff --git a/services/index/jaxb/pom.xml b/services/index/jaxb/pom.xml
new file mode 100644 (file)
index 0000000..c62d315
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>org.collectionspace.services.index</artifactId>
+        <groupId>org.collectionspace.services</groupId>
+        <version>4.4-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.index.jaxb</artifactId>
+    <name>services.index.jaxb</name>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
+    </dependencies>
+    
+    <build>
+        <finalName>collectionspace-services-index-jaxb</finalName>
+        <defaultGoal>install</defaultGoal>
+        <plugins>
+            <plugin>
+                <groupId>org.jvnet.jaxb2.maven2</groupId>
+                <artifactId>maven-jaxb2-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>
+
diff --git a/services/index/pom.xml b/services/index/pom.xml
new file mode 100644 (file)
index 0000000..da22a26
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A comment. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>org.collectionspace.services.main</artifactId>
+        <version>4.4-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.collectionspace.services.index</artifactId>
+    <name>services.index</name>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>3rdparty</module>
+        <module>client</module>
+        <module>service</module>
+    </modules>
+
+</project>
+
diff --git a/services/index/service/pom.xml b/services/index/service/pom.xml
new file mode 100644 (file)
index 0000000..2134dcd
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <parent>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>org.collectionspace.services.index</artifactId>        
+        <version>4.4-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.collectionspace.services.index.service</artifactId>
+    <name>services.index.service</name>
+    <packaging>jar</packaging>       
+
+    <dependencies>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <!-- External dependencies -->        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+        </dependency>
+        
+      <!-- javax -->
+
+        <dependency>
+            <groupId>javax.security</groupId>
+            <artifactId>jaas</artifactId>
+            <version>1.0.01</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>dom4j</groupId>
+            <artifactId>dom4j</artifactId>
+            <version>1.6.1</version>
+            <scope>provided</scope>
+        </dependency>
+        
+        <!-- jboss -->
+
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxrs</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>tjws</groupId>
+                    <artifactId>webserver</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxb-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-multipart-provider</artifactId>
+        </dependency>
+        
+        <!-- nuxeo -->
+
+        <dependency>
+            <groupId>org.nuxeo.ecm.core</groupId>
+            <artifactId>nuxeo-core-api</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>jboss-remoting</artifactId>
+                    <groupId>jboss</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <finalName>collectionspace-services-index</finalName>
+    </build>
+</project>
+
diff --git a/services/index/service/src/main/java/org/collectionspace/services/index/IndexResource.java b/services/index/service/src/main/java/org/collectionspace/services/index/IndexResource.java
new file mode 100644 (file)
index 0000000..8fad7f3
--- /dev/null
@@ -0,0 +1,108 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  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.collectionspace.services.index;
+
+import org.collectionspace.services.client.index.IndexClient;
+import org.collectionspace.services.common.CSWebApplicationException;
+import org.collectionspace.services.common.NuxeoBasedResource;
+import org.collectionspace.services.common.ResourceMap;
+import org.collectionspace.services.common.ServiceMessages;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+@Path(IndexClient.SERVICE_PATH)
+@Produces({"application/xml"})
+@Consumes({"application/xml"})
+public class IndexResource extends NuxeoBasedResource {
+
+    @Override
+    public String getServiceName(){
+        return IndexClient.SERVICE_NAME;
+    }
+
+    @Override
+    protected String getVersionString() {
+       final String lastChangeRevision = "$LastChangedRevision: 2108 $";
+       return lastChangeRevision;
+    }
+
+    @Override
+    //public Class<ObjectexitCommon> getCommonPartClass() {
+    public Class<?> getCommonPartClass() {
+       try {
+            return Class.forName("org.collectionspace.services.objectexit.IndexCommon");//.class;
+        } catch (ClassNotFoundException e){
+            return null;
+        }
+    }
+    
+       /*
+        * HTTP Methods
+        */
+    
+       @Override
+       @POST
+       public Response create(@Context ResourceMap resourceMap, @Context UriInfo ui, String xmlPayload) {
+               Response response = Response.status(Response.Status.BAD_REQUEST)
+                               .entity(ServiceMessages.POST_UNSUPPORTED).type("text/plain").build();
+               return response;
+       }
+       
+    @Override
+       @DELETE
+    @Path("{csid}")
+    public Response delete(@PathParam("csid") String csid) {
+               Response response = Response.status(Response.Status.BAD_REQUEST)
+                               .entity(ServiceMessages.DELETE_UNSUPPORTED).type("text/plain")
+                               .build();
+               return response;
+    }
+    
+    
+       /* (non-Javadoc)
+        * @see org.collectionspace.services.common.ResourceBase#getList(javax.ws.rs.core.UriInfo, java.lang.String)
+        * 
+        * The index sub-resource does not support a getList operation.
+        */
+       @Override
+       @GET
+       public AbstractCommonList getList(@Context UriInfo ui) {
+               Response response = Response.status(Response.Status.BAD_REQUEST)
+                               .entity(ServiceMessages.GET_LIST_UNSUPPORTED).type("text/plain")
+                               .build();
+               throw new CSWebApplicationException(response);
+       }
+    
+}
diff --git a/services/index/service/src/main/java/org/collectionspace/services/index/nuxeo/IndexValidatorHandler.java b/services/index/service/src/main/java/org/collectionspace/services/index/nuxeo/IndexValidatorHandler.java
new file mode 100644 (file)
index 0000000..4c378e7
--- /dev/null
@@ -0,0 +1,63 @@
+package org.collectionspace.services.index.nuxeo;
+
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.document.InvalidDocumentException;
+import org.collectionspace.services.common.document.ValidatorHandlerImpl;
+import org.collectionspace.services.index.IndexCommon;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IndexValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, PoxPayloadOut> {
+
+    /** The logger. */
+    private final Logger logger = LoggerFactory.getLogger(IndexValidatorHandler.class);
+    
+    /** Error Messages **/
+    private static final String VALIDATION_ERROR = "The intake record payload was invalid. See log file for more details.";
+    
+       
+    @Override
+    protected Class<?> getCommonPartClass() {
+       return IndexCommon.class;
+    }
+       
+       @Override
+       protected void handleCreate() throws InvalidDocumentException {
+               try {
+                       IndexCommon intakesCommon = (IndexCommon)getCommonPart();
+                       assert(intakesCommon != null);
+       } catch (AssertionError e) {
+               if (logger.isErrorEnabled() == true) {
+                       logger.error(e.getMessage(), e);
+               }
+               throw new InvalidDocumentException(VALIDATION_ERROR, e);
+       }
+       }
+
+       @Override
+       protected void handleGet() throws InvalidDocumentException {
+               // TODO Auto-generated method stub
+               
+       }
+
+       @Override
+       protected void handleGetAll() throws InvalidDocumentException {
+               // TODO Auto-generated method stub
+               
+       }
+
+       @Override
+       protected void handleUpdate() throws InvalidDocumentException {
+               // TODO Auto-generated method stub
+               
+       }
+
+       @Override
+       protected void handleDelete() throws InvalidDocumentException {
+               // TODO Auto-generated method stub
+               
+       }
+
+}
diff --git a/services/index/service/src/test/java/org/collectionspace/services/test/IndexServiceTest.java b/services/index/service/src/test/java/org/collectionspace/services/test/IndexServiceTest.java
new file mode 100644 (file)
index 0000000..aac5563
--- /dev/null
@@ -0,0 +1,10 @@
+package org.collectionspace.services.test;
+
+/**
+ * Placeholder for server-side testing of Index service code.
+ * 
+ * @version $Revision: 2108 $
+ */
+public class IndexServiceTest {
+       //empty
+}
diff --git a/services/index/service/src/test/resources/log4j.xml b/services/index/service/src/test/resources/log4j.xml
new file mode 100644 (file)
index 0000000..52121cb
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+       <appender name="console" class="org.apache.log4j.ConsoleAppender">
+               <param name="Target" value="System.out" />
+               <layout class="org.apache.log4j.TTCCLayout">
+                       <param name="DateFormat" value="ISO8601" />
+               </layout>
+       </appender>
+
+
+       <appender name="unit-tests"
+               class="org.apache.log4j.RollingFileAppender">
+               <param name="File" value="./target/unit-tests.log" />
+               <param name="MaxFileSize" value="10240KB" />
+               <param name="MaxBackupIndex" value="6" />
+               <layout class="org.apache.log4j.TTCCLayout">
+                       <param name="DateFormat" value="ISO8601" />
+               </layout>
+       </appender>
+
+       <logger name="org.apache.commons.httpclient" additivity="false">
+               <level value="warn" />
+               <appender-ref ref="console" />
+               <appender-ref ref="unit-tests" />
+       </logger>
+
+       <logger name="httpclient.wire" additivity="false">
+               <level value="info" />
+               <appender-ref ref="console" />
+               <appender-ref ref="unit-tests" />
+       </logger>
+
+       <root>
+               <priority value="debug" />
+               <appender-ref ref="console" />
+               <appender-ref ref="unit-tests" />
+       </root>
+
+</log4j:configuration>
+
+
+
+
diff --git a/services/jaxb/src/main/resources/index_common.xsd b/services/jaxb/src/main/resources/index_common.xsd
new file mode 100644 (file)
index 0000000..981ea41
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+    Index schema (XSD)
+    
+    Entity  : Index
+    Part    : Common
+    Used for: JAXB binding between XML and Java objects
+
+    $LastChangedRevision: 2316 $
+    $LastChangedDate: 2010-06-02 16:03:51 -0700 (Wed, 02 Jun 2010) $
+-->
+
+<xs:schema 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"
+  xmlns:ns="http://collectionspace.org/services/index"
+  xmlns="http://collectionspace.org/services/index"
+  targetNamespace="http://collectionspace.org/services/index"
+  version="0.1">
+<!--
+    Avoid XmlRootElement nightmare:
+    See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+-->    
+    <!-- index -->
+    <xs:element name="index_common">
+        <xs:complexType>
+            <xs:sequence>
+                <!--  Index Information Group -->
+                <xs:element name="indexPolicy" type="xs:string"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+        
+</xs:schema>
+
index 50d13d1b768acd010d385cdcd49f934d537e5167..9a1aae918c7e6653115a4ddf5394893debfbde17 100644 (file)
@@ -80,6 +80,7 @@
         <module>dimension</module>
         <module>contact</module>
         <module>workflow</module>
+        <module>index</module>
         <module>media</module>
         <module>publicitem</module>        
         <!--module>sdk</module-->
index def69bf10e530a4b36c1ffdf479cad6a373a88fb..b76e574b0843fd1b994aa59ace178e5ef602927f 100644 (file)
@@ -52,7 +52,7 @@ import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.config.service.ServiceBindingType;
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -387,7 +387,7 @@ public class RelationDocumentModelHandler
             // provided as an alternate identifier.
         }
         if (Tools.notBlank(csid)) {
-               RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl)getRepositoryClient(ctx);
+               RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl)getRepositoryClient(ctx);
             DocumentWrapper<DocumentModel> docWrapper = nuxeoRepoClient.getDocFromCsid(ctx, repoSession, csid);
             docModel = docWrapper.getWrappedObject();
         } else { //  if (Tools.isBlank(objectCsid)) {
index fd33314559e6dfe40a88e457afa7c2bca1be8b3c..f320340d9ce7d6412b52ea1183d2d02031e32854 100644 (file)
@@ -75,7 +75,7 @@ import org.collectionspace.services.common.storage.JDBCTools;
 import org.collectionspace.services.jaxb.InvocableJAXBSchema;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.jfree.util.Log;
 import org.nuxeo.ecm.core.api.DocumentModel;
@@ -152,7 +152,7 @@ public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler<Report
                                +invocationMode);
                }
                
-               RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
+               RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {
                        repoSession = repoClient.getRepositorySession(ctx);
index 7394e1dcea8f1ee2d60a31089adb5af7c837ff02..7cfa62505330199bf95051f4ae17dc4425439eaf 100644 (file)
@@ -34,7 +34,7 @@ import javax.ws.rs.core.Response;
 import org.collectionspace.services.nuxeo.client.java.CommonList;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClientImpl;
+import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.client.IQueryManager;
@@ -85,7 +85,7 @@ public class ServiceGroupDocumentModelHandler
        boolean releaseRepoSession = false;
         
        try { 
-               RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
+               RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {
                        repoSession = repoClient.getRepositorySession(ctx);
@@ -100,7 +100,7 @@ public class ServiceGroupDocumentModelHandler
 
                try {
                Map<String, ServiceBindingType> queriedServiceBindings = new HashMap<String, ServiceBindingType>();
-               RepositoryJavaClientImpl nuxeoRepoClient = (RepositoryJavaClientImpl)repoClient;
+               RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl)repoClient;
                // Get the service bindings for this tenant
                TenantBindingConfigReaderImpl tReader =
                        ServiceMain.getInstance().getTenantBindingConfigReader();