From 1773eeb19d113f92355f1001742928c6eb930c77 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Fri, 12 Mar 2010 22:45:13 +0000 Subject: [PATCH] CSPACE-1084: Deprecating "/search" from CO, Intake, Acquisition and replacing with "?kw" query parameter. For example, instead of "/intakes/search?keywords=rich" use "/intakes?kw=rich" --- .../acquisition/AcquisitionResource.java | 105 ++++++++++++++++- .../CollectionObjectResource.java | 35 ++++-- .../services/common/query/IQueryManager.java | 1 + .../services/intake/IntakeResource.java | 108 +++++++++++++++++- 4 files changed, 231 insertions(+), 18 deletions(-) diff --git a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java index 68cfb54eb..ed0079e1e 100644 --- a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java +++ b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java @@ -62,15 +62,24 @@ import org.nuxeo.ecm.core.api.DocumentModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * The Class AcquisitionResource. + */ @Path("/acquisitions") @Consumes("multipart/mixed") @Produces("multipart/mixed") public class AcquisitionResource extends AbstractCollectionSpaceResourceImpl { + /** The service name. */ final private String serviceName = "acquisitions"; + + /** The logger. */ final Logger logger = LoggerFactory.getLogger(AcquisitionResource.class); + /* (non-Javadoc) + * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString() + */ @Override protected String getVersionString() { /** The last change revision. */ @@ -78,11 +87,17 @@ public class AcquisitionResource return lastChangeRevision; } + /* (non-Javadoc) + * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName() + */ @Override public String getServiceName() { return serviceName; } + /* (non-Javadoc) + * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext) + */ @Override public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { DocumentHandler docHandler = ctx.getDocumentHandler(); @@ -95,10 +110,20 @@ public class AcquisitionResource return docHandler; } + /** + * Instantiates a new acquisition resource. + */ public AcquisitionResource() { // do nothing } + /** + * Creates the acquisition. + * + * @param input the input + * + * @return the response + */ @POST public Response createAcquisition(MultipartInput input) { @@ -124,6 +149,13 @@ public class AcquisitionResource } } + /** + * Gets the acquisition. + * + * @param csid the csid + * + * @return the acquisition + */ @GET @Path("{csid}") public MultipartOutput getAcquisition( @@ -174,10 +206,35 @@ public class AcquisitionResource return result; } + /** + * Gets the acquisition list. + * + * @param ui the ui + * @param keywords the keywords + * + * @return the acquisition list + */ @GET @Produces("application/xml") - public AcquisitionsCommonList getAcquisitionList(@Context UriInfo ui) { - AcquisitionsCommonList acquisitionObjectList = new AcquisitionsCommonList(); + public AcquisitionsCommonList getAcquisitionList(@Context UriInfo ui, + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) { + AcquisitionsCommonList result = null; + if (keywords != null) { + result = searchAcquisitions(keywords); + } else { + result = getAcquisitionsList(); + } + + return result; + } + + /** + * Gets the acquisitions list. + * + * @return the acquisitions list + */ + private AcquisitionsCommonList getAcquisitionsList() { + AcquisitionsCommonList acquisitionObjectList; try { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); DocumentHandler handler = createDocumentHandler(ctx); @@ -198,6 +255,14 @@ public class AcquisitionResource return acquisitionObjectList; } + /** + * Update acquisition. + * + * @param csid the csid + * @param theUpdate the the update + * + * @return the multipart output + */ @PUT @Path("{csid}") public MultipartOutput updateAcquisition( @@ -242,6 +307,13 @@ public class AcquisitionResource return result; } + /** + * Delete acquisition. + * + * @param csid the csid + * + * @return the response + */ @DELETE @Path("{csid}") public Response deleteAcquisition(@PathParam("csid") String csid) { @@ -279,12 +351,31 @@ public class AcquisitionResource } } + /** + * Keywords search acquisitions. + * + * @param ui the ui + * @param keywords the keywords + * + * @return the acquisitions common list + */ @GET @Path("/search") @Produces("application/xml") public AcquisitionsCommonList keywordsSearchAcquisitions(@Context UriInfo ui, @QueryParam (IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) { - AcquisitionsCommonList acquisitionObjectList = new AcquisitionsCommonList(); + return searchAcquisitions(keywords); + } + + /** + * Search acquisitions. + * + * @param keywords the keywords + * + * @return the acquisitions common list + */ + private AcquisitionsCommonList searchAcquisitions(String keywords) { + AcquisitionsCommonList acquisitionObjectList; try { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); DocumentHandler handler = createDocumentHandler(ctx); @@ -318,6 +409,14 @@ public class AcquisitionResource return acquisitionObjectList; } + /** + * Gets the authority refs. + * + * @param csid the csid + * @param ui the ui + * + * @return the authority refs + */ @GET @Path("{csid}/authorityrefs") @Produces("application/xml") diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java index dad878dc1..3ab41c047 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java @@ -212,18 +212,26 @@ public class CollectionObjectResource } return result; } - + + @GET + @Produces("application/xml") + public CollectionobjectsCommonList getCollectionObjectList(@Context UriInfo ui, + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) { + CollectionobjectsCommonList result = null; + if (keywords != null) { + result = searchCollectionObjects(keywords); + } else { + result = getCollectionObjectList(); + } + + return result; + } + /** * Gets the collection object list. - * - * @param ui the ui - * - * @return the collection object list */ - @GET - @Produces("application/xml") - public CollectionobjectsCommonList getCollectionObjectList(@Context UriInfo ui) { - CollectionobjectsCommonList collectionObjectList = new CollectionobjectsCommonList(); + private CollectionobjectsCommonList getCollectionObjectList() { + CollectionobjectsCommonList collectionObjectList; try { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); DocumentHandler handler = createDocumentHandler(ctx); @@ -448,9 +456,8 @@ public class CollectionObjectResource return result; } - - //FIXME: Replace this "search" resource with a keyword "kw" query parameter /** + * This method is deprecated. Use kwSearchCollectionObjects() method instead. * Keywords search collection objects. * * @param keywords the keywords @@ -462,7 +469,11 @@ public class CollectionObjectResource @Produces("application/xml") public CollectionobjectsCommonList keywordsSearchCollectionObjects( @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) { - CollectionobjectsCommonList collectionObjectList = new CollectionobjectsCommonList(); + return searchCollectionObjects(keywords); + } + + private CollectionobjectsCommonList searchCollectionObjects(String keywords) { + CollectionobjectsCommonList collectionObjectList; try { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); DocumentHandler handler = createDocumentHandler(ctx); diff --git a/services/common/src/main/java/org/collectionspace/services/common/query/IQueryManager.java b/services/common/src/main/java/org/collectionspace/services/common/query/IQueryManager.java index 886c3431a..d77dd2b24 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/query/IQueryManager.java +++ b/services/common/src/main/java/org/collectionspace/services/common/query/IQueryManager.java @@ -30,6 +30,7 @@ public interface IQueryManager { final static String SEARCH_LIKE = "LIKE"; final static String SEARCH_TYPE_KEYWORDS = "keywords"; + final static String SEARCH_TYPE_KEYWORDS_KW = "kw"; final static String SEARCH_TYPE_PARTIALTERM = "pt"; final static String ECM_FULLTEXT_LIKE = "ecm:fulltext " + SEARCH_LIKE; final static String SEARCH_QUALIFIER_AND = "AND"; diff --git a/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java b/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java index 718b520bf..0c4005807 100644 --- a/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java +++ b/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java @@ -40,6 +40,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; +import org.collectionspace.services.collectionobject.CollectionobjectsCommonList; import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl; import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.ServiceMain; @@ -64,20 +65,33 @@ import org.nuxeo.ecm.core.api.DocumentModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * The Class IntakeResource. + */ @Path("/intakes") @Consumes("multipart/mixed") @Produces("multipart/mixed") public class IntakeResource extends AbstractCollectionSpaceResourceImpl { + /** The Constant serviceName. */ private final static String serviceName = "intakes"; + + /** The logger. */ final Logger logger = LoggerFactory.getLogger(IntakeResource.class); //FIXME retrieve client type from configuration + /** The Constant CLIENT_TYPE. */ final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType(); + /** + * Instantiates a new intake resource. + */ public IntakeResource() { // do nothing } + /* (non-Javadoc) + * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString() + */ @Override protected String getVersionString() { /** The last change revision. */ @@ -85,11 +99,17 @@ public class IntakeResource extends AbstractCollectionSpaceResourceImpl { return lastChangeRevision; } + /* (non-Javadoc) + * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName() + */ @Override public String getServiceName() { return serviceName; } + /* (non-Javadoc) + * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext) + */ @Override public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { DocumentHandler docHandler = ctx.getDocumentHandler(); @@ -102,6 +122,13 @@ public class IntakeResource extends AbstractCollectionSpaceResourceImpl { return docHandler; } + /** + * Creates the intake. + * + * @param input the input + * + * @return the response + */ @POST public Response createIntake(MultipartInput input) { try { @@ -127,6 +154,13 @@ public class IntakeResource extends AbstractCollectionSpaceResourceImpl { } } + /** + * Gets the intake. + * + * @param csid the csid + * + * @return the intake + */ @GET @Path("{csid}") public MultipartOutput getIntake( @@ -176,10 +210,36 @@ public class IntakeResource extends AbstractCollectionSpaceResourceImpl { return result; } + /** + * Gets the intake list. + * + * @param ui the ui + * @param keywords the keywords + * + * @return the intake list + */ @GET @Produces("application/xml") - public IntakesCommonList getIntakeList(@Context UriInfo ui) { - IntakesCommonList intakeObjectList = new IntakesCommonList(); + public IntakesCommonList getIntakeList(@Context UriInfo ui, + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) { + IntakesCommonList result = null; + + if (keywords != null) { + result = searchIntakes(keywords); + } else { + result = getIntakeList(); + } + + return result; + } + + /** + * Gets the intake list. + * + * @return the intake list + */ + private IntakesCommonList getIntakeList() { + IntakesCommonList intakeObjectList; try { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); DocumentHandler handler = createDocumentHandler(ctx); @@ -200,6 +260,14 @@ public class IntakeResource extends AbstractCollectionSpaceResourceImpl { return intakeObjectList; } + /** + * Gets the authority refs. + * + * @param csid the csid + * @param ui the ui + * + * @return the authority refs + */ @GET @Path("{csid}/authorityrefs") @Produces("application/xml") @@ -259,6 +327,14 @@ public class IntakeResource extends AbstractCollectionSpaceResourceImpl { return intakeObjectList; } + /** + * Update intake. + * + * @param csid the csid + * @param theUpdate the the update + * + * @return the multipart output + */ @PUT @Path("{csid}") public MultipartOutput updateIntake( @@ -300,6 +376,13 @@ public class IntakeResource extends AbstractCollectionSpaceResourceImpl { return result; } + /** + * Delete intake. + * + * @param csid the csid + * + * @return the response + */ @DELETE @Path("{csid}") public Response deleteIntake(@PathParam("csid") String csid) { @@ -337,12 +420,31 @@ public class IntakeResource extends AbstractCollectionSpaceResourceImpl { } } + /** + * Keywords search intakes. + * + * @param ui the ui + * @param keywords the keywords + * + * @return the intakes common list + */ @GET @Path("/search") @Produces("application/xml") public IntakesCommonList keywordsSearchIntakes(@Context UriInfo ui, @QueryParam (IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) { - IntakesCommonList intakesObjectList = new IntakesCommonList(); + return searchIntakes(keywords); + } + + /** + * Search intakes. + * + * @param keywords the keywords + * + * @return the intakes common list + */ + private IntakesCommonList searchIntakes(String keywords) { + IntakesCommonList intakesObjectList; try { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); DocumentHandler handler = createDocumentHandler(ctx); -- 2.47.3