]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1084: Deprecating "/search" from CO, Intake, Acquisition and replacing with...
authorRichard Millet <richard.millet@berkeley.edu>
Fri, 12 Mar 2010 22:45:13 +0000 (22:45 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Fri, 12 Mar 2010 22:45:13 +0000 (22:45 +0000)
services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java
services/common/src/main/java/org/collectionspace/services/common/query/IQueryManager.java
services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java

index 68cfb54eba7f2154c731d73353af98fa8a006329..ed0079e1ee9df71327a2766899a25580bfb2db29 100644 (file)
@@ -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")
index dad878dc131fc801eb8db210b835f5a22b82f367..3ab41c0479b0dee5150f1899a898ab88272e3b8a 100644 (file)
@@ -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);
index 886c3431a8341c5144b3e39f9ea5d723dcbdd5e5..d77dd2b240d8dfc154f8d4912b43b2db1a65203a 100644 (file)
@@ -30,6 +30,7 @@ public interface IQueryManager {
        \r
        final static String SEARCH_LIKE = "LIKE";\r
     final static String SEARCH_TYPE_KEYWORDS = "keywords";\r
+    final static String SEARCH_TYPE_KEYWORDS_KW = "kw";\r
     final static String SEARCH_TYPE_PARTIALTERM = "pt";\r
        final static String ECM_FULLTEXT_LIKE = "ecm:fulltext " + SEARCH_LIKE;\r
        final static String SEARCH_QUALIFIER_AND = "AND";\r
index 718b520bfdb7c0317682693cb288cf79f1005340..0c4005807d430f08f7260fdc087df9d4066dd4aa 100644 (file)
@@ -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);