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;
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);
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;
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);
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;
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);
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.
// 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;
}
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;
}
}
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));
}
@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";
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;
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);
<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"/>
--- /dev/null
+/**
+ * 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();
+ }
+
+}
--- /dev/null
+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 {
+}
<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 -->
</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">
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;
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;
}
}
+ //======================= 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
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;
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);
+ }
+
}
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;
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);
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);
}
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;
// 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();
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
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;
}
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;
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;
} 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);
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
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;
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;
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.
*
}
// 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
//
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;
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
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!");
}
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;
}
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
--- /dev/null
+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;
+ }
+
+}
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;
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;
CommonList commonList = new CommonList();
String markRtSbj = null;
CoreSessionInterface repoSession = null;
- RepositoryJavaClientImpl repoClient = null;
+ RepositoryClientImpl repoClient = null;
boolean releaseRepoSession = false;
AbstractServiceContextImpl ctx = (AbstractServiceContextImpl) getServiceContext();
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);
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();
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);
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;
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";
/**
* Instantiates a new repository java client impl.
*/
- public RepositoryJavaClientImpl() {
+ public RepositoryClientImpl() {
//Empty constructor
}
}
}
+
+ @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
*
// 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";
--- /dev/null
+/*
+ * (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);
+ }
+ }
+
+}
--- /dev/null
+
+<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>
--- /dev/null
+<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>
+
--- /dev/null
+<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>
--- /dev/null
+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
+
--- /dev/null
+<?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>
--- /dev/null
+<?xml version="1.0"?>
+<fragment>
+
+ <extension target="application#MODULE">
+ <module>
+ <java>${bundle.fileName}</java>
+ </module>
+ </extension>
+
+</fragment>
\ No newline at end of file
--- /dev/null
+<?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>
--- /dev/null
+<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>
--- /dev/null
+
+<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>
--- /dev/null
+<?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>
--- /dev/null
+/**
+ * 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;
+ }
+
+}
--- /dev/null
+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
--- /dev/null
+<?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>
+
--- /dev/null
+<?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>
+
--- /dev/null
+<?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>
+
--- /dev/null
+/**
+ * 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);
+ }
+
+}
--- /dev/null
+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
+
+ }
+
+}
--- /dev/null
+package org.collectionspace.services.test;
+
+/**
+ * Placeholder for server-side testing of Index service code.
+ *
+ * @version $Revision: 2108 $
+ */
+public class IndexServiceTest {
+ //empty
+}
--- /dev/null
+<?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>
+
+
+
+
--- /dev/null
+<?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>
+
<module>dimension</module>
<module>contact</module>
<module>workflow</module>
+ <module>index</module>
<module>media</module>
<module>publicitem</module>
<!--module>sdk</module-->
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;
// 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)) {
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;
+invocationMode);
}
- RepositoryJavaClientImpl repoClient = (RepositoryJavaClientImpl)this.getRepositoryClient(ctx);
+ RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
repoSession = this.getRepositorySession();
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
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;
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);
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();