From 9d6da6222035d02e3f47aa84bfe342745226985f Mon Sep 17 00:00:00 2001 From: Sanjay Dalal Date: Sat, 23 Jan 2010 00:29:56 +0000 Subject: [PATCH] CSPACE-815 added fine-grained callbacks on prepare and complete mvn test at services M services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java M services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java A services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaDocumentFilter.java M services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClient.java M services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandler.java M services/common/src/main/java/org/collectionspace/services/common/document/DocumentFilter.java M services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java A services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentFilter.java M services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java M services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java M services/account/service/src/main/java/org/collectionspace/services/account/storage/AccountDocumentHandler.java M services/account/service/src/main/java/org/collectionspace/services/account/AccountResource.java M services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java M services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java M services/account/client/src/main/java/org/collectionspace/services/client/AccountProxy.java _M services/organization/service M services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java M services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java M services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java _M services/organization/jaxb _M services/person/service M services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java M services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java M services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java _M services/person/jaxb _M services/person/client M services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java M services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java M services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java M services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java M services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java --- .../services/client/AccountClient.java | 24 +- .../services/client/AccountProxy.java | 5 + .../client/test/AccountServiceTest.java | 98 ++++++- .../services/account/AccountResource.java | 19 +- .../storage/AccountDocumentHandler.java | 19 ++ .../AcquisitionDocumentModelHandler.java | 4 - .../document/AbstractDocumentHandler.java | 94 +++++-- .../common/document/DocumentFilter.java | 248 ++++++++++-------- .../common/document/DocumentHandler.java | 60 ++++- .../common/storage/jpa/JpaDocumentFilter.java | 61 +++++ .../common/storage/jpa/JpaStorageClient.java | 40 +-- .../client/java/DocumentModelHandler.java | 6 + .../client/java/NuxeoDocumentFilter.java | 60 +++++ .../nuxeo/ContactDocumentModelHandler.java | 4 - .../nuxeo/DimensionDocumentModelHandler.java | 4 - .../nuxeo/IntakeDocumentModelHandler.java | 4 - .../organization/OrgAuthorityResource.java | 8 +- .../OrgAuthorityDocumentModelHandler.java | 4 - .../OrganizationDocumentModelHandler.java | 4 - .../person/PersonAuthorityResource.java | 8 +- .../PersonAuthorityDocumentModelHandler.java | 4 - .../nuxeo/PersonDocumentModelHandler.java | 4 - .../nuxeo/RelationDocumentModelHandler.java | 4 - .../vocabulary/VocabularyResource.java | 8 +- .../nuxeo/VocabularyDocumentModelHandler.java | 4 - .../VocabularyItemDocumentModelHandler.java | 4 - 26 files changed, 569 insertions(+), 233 deletions(-) create mode 100644 services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaDocumentFilter.java create mode 100644 services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentFilter.java diff --git a/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java b/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java index dd06c3795..286108e79 100644 --- a/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java +++ b/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java @@ -24,7 +24,6 @@ * 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; import javax.ws.rs.core.Response; @@ -48,13 +47,13 @@ public class AccountClient extends BaseServiceClient { * */ private AccountProxy accountProxy; - - /* (non-Javadoc) - * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent() - */ - public String getServicePathComponent() { - return "accounts"; - } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent() + */ + public String getServicePathComponent() { + return "accounts"; + } /** * @@ -71,10 +70,10 @@ public class AccountClient extends BaseServiceClient { * allow to reset proxy as per security needs */ public void setProxy() { - if(useAuth()){ + if (useAuth()) { accountProxy = ProxyFactory.create(AccountProxy.class, getBaseURL(), getHttpClient()); - }else{ + } else { accountProxy = ProxyFactory.create(AccountProxy.class, getBaseURL()); } @@ -89,6 +88,11 @@ public class AccountClient extends BaseServiceClient { } + public ClientResponse readSearchList(String screenName) { + return accountProxy.readSearchList(screenName); + + } + /** * @param csid * @return diff --git a/services/account/client/src/main/java/org/collectionspace/services/client/AccountProxy.java b/services/account/client/src/main/java/org/collectionspace/services/client/AccountProxy.java index d3a98ad00..940d701a8 100644 --- a/services/account/client/src/main/java/org/collectionspace/services/client/AccountProxy.java +++ b/services/account/client/src/main/java/org/collectionspace/services/client/AccountProxy.java @@ -34,6 +34,7 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; @@ -55,6 +56,10 @@ public interface AccountProxy { @Produces({"application/xml"}) ClientResponse readList(); + @GET + @Produces({"application/xml"}) + ClientResponse readSearchList(@QueryParam("sn") String screenName); + //(C)reate @POST ClientResponse create(AccountsCommon multipart); diff --git a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java index 3939470ae..810a99b60 100644 --- a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java +++ b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java @@ -56,6 +56,8 @@ public class AccountServiceTest extends AbstractServiceTest { // Instance variables specific to this test. private AccountClient client = new AccountClient(); private String knownResourceId = null; + private String resource1Id = null; + private String resource2Id = null; /* * This method is called only by the parent class, AbstractServiceTest @@ -151,6 +153,26 @@ public class AccountServiceTest extends AbstractServiceTest { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class, dependsOnMethods = {"create"}) public void createList(String testName) throws Exception { + + setupCreate(testName); + // Submit the request to the service and store the response. + AccountsCommon account1 = + createAccountInstance("curious", "hithere08", "curious@george.com", true, true, true); + ClientResponse res = client.create(account1); + int statusCode = res.getStatus(); + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + resource1Id = extractId(res); + + AccountsCommon account2 = + createAccountInstance("tom", "hithere09", "tom@jerry.com", true, true, true); + res = client.create(account2); + statusCode = res.getStatus(); + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + resource2Id = extractId(res); } // Failure outcomes @@ -249,20 +271,35 @@ public class AccountServiceTest extends AbstractServiceTest { // Optionally output additional data about list members for debugging. boolean iterateThroughList = true; if (iterateThroughList && logger.isDebugEnabled()) { - List items = - list.getAccountListItem(); - int i = 0; + printList(testName, list); + } + } + + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class, + dependsOnMethods = {"createList", "read"}) + public void readSearchList(String testName) throws Exception { - for (AccountsCommonList.AccountListItem item : items) { - logger.debug(testName + ": list-item[" + i + "] csid=" - + item.getCsid()); - logger.debug(testName + ": list-item[" + i + "] screenName=" - + item.getScreenName()); - logger.debug(testName + ": list-item[" + i + "] URI=" - + item.getUri()); - i++; + // Perform setup. + setupReadList(testName); + + // Submit the request to the service and store the response. + ClientResponse res = client.readSearchList("tom"); + AccountsCommonList list = res.getEntity(); + int statusCode = res.getStatus(); - } + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Optionally output additional data about list members for debugging. + boolean iterateThroughList = true; + if (iterateThroughList && logger.isDebugEnabled()) { + printList(testName, list); } } @@ -577,6 +614,26 @@ public class AccountServiceTest extends AbstractServiceTest { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class, + dependsOnMethods = {"testSubmitRequest", "updateWrongUser"}) + public void deleteList(String testName) throws Exception { + + // Perform setup. + setupDelete(testName); + + ClientResponse res = client.delete(resource1Id); + int statusCode = res.getStatus(); + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + res = client.delete(resource2Id); + statusCode = res.getStatus(); + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + // Failure outcomes @Override @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class, @@ -671,4 +728,21 @@ public class AccountServiceTest extends AbstractServiceTest { return account; } + + private void printList(String testName, AccountsCommonList list) { + List items = + list.getAccountListItem(); + int i = 0; + + for (AccountsCommonList.AccountListItem item : items) { + logger.debug(testName + ": list-item[" + i + "] csid=" + + item.getCsid()); + logger.debug(testName + ": list-item[" + i + "] screenName=" + + item.getScreenName()); + logger.debug(testName + ": list-item[" + i + "] URI=" + + item.getUri()); + i++; + + } + } } diff --git a/services/account/service/src/main/java/org/collectionspace/services/account/AccountResource.java b/services/account/service/src/main/java/org/collectionspace/services/account/AccountResource.java index f2c19f2b6..eb70332ed 100644 --- a/services/account/service/src/main/java/org/collectionspace/services/account/AccountResource.java +++ b/services/account/service/src/main/java/org/collectionspace/services/account/AccountResource.java @@ -31,8 +31,10 @@ import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; +import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; @@ -48,6 +50,7 @@ import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.common.security.UnauthorizedException; import org.collectionspace.services.common.storage.StorageClient; +import org.collectionspace.services.common.storage.jpa.JpaDocumentFilter; import org.jboss.resteasy.util.HttpResponseCodes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,11 +67,11 @@ public class AccountResource @Override protected String getVersionString() { - /** The last change revision. */ - final String lastChangeRevision = "$LastChangedRevision: 1165 $"; - return lastChangeRevision; + /** The last change revision. */ + final String lastChangeRevision = "$LastChangedRevision: 1165 $"; + return lastChangeRevision; } - + @Override public String getServiceName() { return serviceName; @@ -177,12 +180,16 @@ public class AccountResource @GET @Produces("application/xml") - public AccountsCommonList getAccountList(@Context UriInfo ui) { + public AccountsCommonList getAccountList( + @Context UriInfo ui) { AccountsCommonList accountList = new AccountsCommonList(); try { ServiceContext ctx = createServiceContext((AccountsCommonList) null); DocumentHandler handler = createDocumentHandler(ctx); - DocumentFilter myFilter = new DocumentFilter(); + MultivaluedMap queryParams = ui.getQueryParameters(); + DocumentFilter myFilter = handler.createDocumentFilter(); + myFilter.setPagination(queryParams); + myFilter.setQueryParams(queryParams); handler.setDocumentFilter(myFilter); getStorageClient(ctx).getFiltered(ctx, handler); accountList = (AccountsCommonList) handler.getCommonPartList(); diff --git a/services/account/service/src/main/java/org/collectionspace/services/account/storage/AccountDocumentHandler.java b/services/account/service/src/main/java/org/collectionspace/services/account/storage/AccountDocumentHandler.java index afe561ad0..6863aca45 100644 --- a/services/account/service/src/main/java/org/collectionspace/services/account/storage/AccountDocumentHandler.java +++ b/services/account/service/src/main/java/org/collectionspace/services/account/storage/AccountDocumentHandler.java @@ -31,7 +31,9 @@ import org.collectionspace.services.account.AccountsCommonList.AccountListItem; import org.collectionspace.services.account.Status; import org.collectionspace.services.common.document.AbstractDocumentHandler; import org.collectionspace.services.common.document.BadRequestException; +import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.common.storage.jpa.JpaDocumentFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -157,6 +159,23 @@ public class AccountDocumentHandler return null; } + @Override + public DocumentFilter createDocumentFilter() { + return new JpaDocumentFilter(); + } + private void setWhereForGetAll(StringBuilder strBld) { + DocumentFilter filter = getDocumentFilter(); + String screenName = null; + if (screenName != null && !screenName.isEmpty()) { + String ptClause = + "WHERE UPPER(a.screenName)" + + " LIKE " + + ":sn"; + filter.addQueryParam("sn", "%" + screenName.toUpperCase() + "%"); + filter.setWhereClause(ptClause); + } + + } /** * sanitize removes data not needed to be sent to the consumer * @param account diff --git a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java index f720b9e06..ec48ddbc1 100644 --- a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java +++ b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java @@ -62,10 +62,6 @@ public class AcquisitionDocumentModelHandler */ private AcquisitionsCommonList acquisitionList; - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } /** * getCommonPart get associated acquisition diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandler.java b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandler.java index c3c4c9aa4..12821e812 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandler.java @@ -75,6 +75,9 @@ public abstract class AbstractDocumentHandler this.properties = properties; } + @Override + public abstract DocumentFilter createDocumentFilter(); + /** * @return the DocumentFilter */ @@ -92,27 +95,60 @@ public abstract class AbstractDocumentHandler } @Override - public void prepare(Action action) throws Exception { - //no specific action needed + final public void prepare(Action action) throws Exception { + switch (action) { + case CREATE: + prepareCreate(); + break; + + case UPDATE: + prepareUpdate(); + break; + + case GET: + prepareGet(); + break; + + case GET_ALL: + prepareGetAll(); + break; + + } + } + + @Override + public void prepareCreate() throws Exception { + } + + @Override + public void prepareUpdate() throws Exception { + } + + @Override + public void prepareGet() throws Exception { + } + + @Override + public void prepareGetAll() throws Exception { } @Override - public void handle(Action action, DocumentWrapper wrapDoc) throws Exception { - switch(action){ + final public void handle(Action action, DocumentWrapper wrapDoc) throws Exception { + switch (action) { case CREATE: - handleCreate((DocumentWrapper)wrapDoc); + handleCreate((DocumentWrapper) wrapDoc); break; case UPDATE: - handleUpdate((DocumentWrapper)wrapDoc); + handleUpdate((DocumentWrapper) wrapDoc); break; case GET: - handleGet((DocumentWrapper)wrapDoc); + handleGet((DocumentWrapper) wrapDoc); break; case GET_ALL: - handleGetAll((DocumentWrapper)wrapDoc); + handleGetAll((DocumentWrapper) wrapDoc); break; } @@ -131,20 +167,48 @@ public abstract class AbstractDocumentHandler public abstract void handleGetAll(DocumentWrapper wrapDoc) throws Exception; @Override - public void complete(Action action, DocumentWrapper wrapDoc) throws Exception { - switch(action){ - //TODO: add more actions if needed + final public void complete(Action action, DocumentWrapper wrapDoc) throws Exception { + switch (action) { + case CREATE: + completeCreate((DocumentWrapper) wrapDoc); + break; + case UPDATE: - completeUpdate((DocumentWrapper)wrapDoc); + completeUpdate((DocumentWrapper) wrapDoc); + break; + + case GET: + completeGet((DocumentWrapper) wrapDoc); + break; + + case GET_ALL: + completeGetAll((DocumentWrapper) wrapDoc); break; } } + /** + * completeCreate is called by the client to indicate completion of the create call. + * @param wrapDoc + * @throws Exception + */ + @Override + public void completeCreate(DocumentWrapper wrapDoc) throws Exception { + } + @Override public void completeUpdate(DocumentWrapper wrapDoc) throws Exception { //no specific action needed } + @Override + public void completeGet(DocumentWrapper wrapDoc) throws Exception { + } + + @Override + public void completeGetAll(DocumentWrapper wrapDoc) throws Exception { + } + @Override public abstract T extractCommonPart(DocumentWrapper wrapDoc) throws Exception; @@ -180,9 +244,9 @@ public abstract class AbstractDocumentHandler @Override public String getUnQProperty(String qProp) { StringTokenizer tkz = new StringTokenizer(qProp, ":"); - if(tkz.countTokens() != 2){ - String msg = "Property must be in the form xxx:yyy, " + - "e.g. collectionobjects_common:objectNumber"; + if (tkz.countTokens() != 2) { + String msg = "Property must be in the form xxx:yyy, " + + "e.g. collectionobjects_common:objectNumber"; logger.error(msg); throw new IllegalArgumentException(msg); } diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentFilter.java b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentFilter.java index 0379f140b..971b8a423 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentFilter.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentFilter.java @@ -17,7 +17,9 @@ */ package org.collectionspace.services.common.document; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.ws.rs.core.MultivaluedMap; import org.collectionspace.services.common.query.IQueryManager; @@ -28,120 +30,138 @@ import org.collectionspace.services.common.query.IQueryManager; * fetched by a RepositoryClient when calling filtered get methods. */ public class DocumentFilter { - public static final String PAGE_SIZE_PARAM = "pgSz"; - public static final String START_PAGE_PARAM = "pgNum"; - public static final int DEFAULT_PAGE_SIZE_INIT = 40; - public static int defaultPageSize = DEFAULT_PAGE_SIZE_INIT; - protected String whereClause; // Filtering clause. Omit the "WHERE". - protected int startPage; // Pagination offset for list results - protected int pageSize; // Pagination limit for list results - - public DocumentFilter() { - this("", 0, defaultPageSize); // Use empty string for easy concatenation - } - - public DocumentFilter(String whereClause, int startPage, int pageSize) { - this.whereClause = whereClause; - this.startPage = (startPage>0)?startPage:0; - this.pageSize = (pageSize>0)?pageSize:defaultPageSize; - } - - public static DocumentFilter CreatePaginatedDocumentFilter( - MultivaluedMap queryParams) { - String startPageStr = null; - String pageSizeStr = null; - List list = queryParams.remove(PAGE_SIZE_PARAM); - if(list!=null) - pageSizeStr = list.get(0); - list = queryParams.remove(START_PAGE_PARAM); - if(list!=null) - startPageStr = list.get(0); - DocumentFilter newDocFilter = new DocumentFilter(); - if(pageSizeStr!= null) { - try{ newDocFilter.pageSize = Integer.valueOf(pageSizeStr); } - catch(NumberFormatException e){ - throw new NumberFormatException("Bad value for: "+PAGE_SIZE_PARAM); - } - } - if(startPageStr!= null) { - try{ newDocFilter.startPage = Integer.valueOf(startPageStr); } - catch(NumberFormatException e){ - throw new NumberFormatException("Bad value for: "+START_PAGE_PARAM); - } - } - return newDocFilter; - } - - /** - * @return the current default page size for new DocumentFilter instances - */ - public static int getDefaultPageSize() { - return defaultPageSize; - } - - /** - * @param defaultPageSize the working default page size for new DocumentFilter instances - */ - public static void setDefaultPageSize(int defaultPageSize) { - DocumentFilter.defaultPageSize = defaultPageSize; - } - - /** - * @return the WHERE filtering clause - */ - public String getWhereClause() { - return whereClause; - } - - /** - * @param whereClause the filtering clause (do not include "WHERE") - */ - public void setWhereClause(String whereClause) { - this.whereClause = whereClause; - } - - public void appendWhereClause(String whereClause) { - String currentClause = getWhereClause(); - if (currentClause != null) { - String newClause = currentClause.concat(IQueryManager.SEARCH_TERM_SEPARATOR + whereClause); - this.setWhereClause(newClause); - } - } - - /** - * @return the specified (0-based) page offset - */ - public int getStartPage() { - return startPage; - } - - /** - * @param startPage the (0-based) page offset to use - */ - public void setStartPage(int startPage) { - this.startPage = startPage; - } - - /** - * @return the max number of items to return for list requests - */ - public int getPageSize() { - return pageSize; - } - - /** - * @param pageSize the max number of items to return for list requests - */ - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - /** - * @return the offset computed from the startPage and the pageSize - */ - public int getOffset() { - return pageSize*startPage; - } + public static final String PAGE_SIZE_PARAM = "pgSz"; + public static final String START_PAGE_PARAM = "pgNum"; + public static final int DEFAULT_PAGE_SIZE_INIT = 40; + public static int defaultPageSize = DEFAULT_PAGE_SIZE_INIT; + protected String whereClause; // Filtering clause. Omit the "WHERE". + protected int startPage; // Pagination offset for list results + protected int pageSize; // Pagination limit for list results + private MultivaluedMap queryParams; + public DocumentFilter() { + this("", 0, defaultPageSize); // Use empty string for easy concatenation + } + + public DocumentFilter(String whereClause, int startPage, int pageSize) { + this.whereClause = whereClause; + this.startPage = (startPage > 0) ? startPage : 0; + this.pageSize = (pageSize > 0) ? pageSize : defaultPageSize; + } + + public void setPagination(MultivaluedMap queryParams) { + + String startPageStr = null; + String pageSizeStr = null; + List list = queryParams.remove(PAGE_SIZE_PARAM); + if (list != null) { + pageSizeStr = list.get(0); + } + list = queryParams.remove(START_PAGE_PARAM); + if (list != null) { + startPageStr = list.get(0); + } + if (pageSizeStr != null) { + try { + pageSize = Integer.valueOf(pageSizeStr); + } catch (NumberFormatException e) { + throw new NumberFormatException("Bad value for: " + PAGE_SIZE_PARAM); + } + } + if (startPageStr != null) { + try { + startPage = Integer.valueOf(startPageStr); + } catch (NumberFormatException e) { + throw new NumberFormatException("Bad value for: " + START_PAGE_PARAM); + } + } + } + + /** + * @return the current default page size for new DocumentFilter instances + */ + public static int getDefaultPageSize() { + return defaultPageSize; + } + + /** + * @param defaultPageSize the working default page size for new DocumentFilter instances + */ + public static void setDefaultPageSize(int defaultPageSize) { + DocumentFilter.defaultPageSize = defaultPageSize; + } + + /** + * @return the WHERE filtering clause + */ + public String getWhereClause() { + return whereClause; + } + + /** + * @param whereClause the filtering clause (do not include "WHERE") + */ + public void setWhereClause(String whereClause) { + this.whereClause = whereClause; + } + + public void appendWhereClause(String whereClause) { + String currentClause = getWhereClause(); + if (currentClause != null) { + String newClause = currentClause.concat(IQueryManager.SEARCH_TERM_SEPARATOR + whereClause); + this.setWhereClause(newClause); + } + } + + /** + * @return the specified (0-based) page offset + */ + public int getStartPage() { + return startPage; + } + + /** + * @param startPage the (0-based) page offset to use + */ + public void setStartPage(int startPage) { + this.startPage = startPage; + } + + /** + * @return the max number of items to return for list requests + */ + public int getPageSize() { + return pageSize; + } + + /** + * @param pageSize the max number of items to return for list requests + */ + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + /** + * @return the offset computed from the startPage and the pageSize + */ + public int getOffset() { + return pageSize * startPage; + } + + public void addQueryParam(String key, String value) { + queryParams.add(key, value); + } + + public List getQueryParam(String key) { + return queryParams.get(key); + } + + public MultivaluedMap getQueryParams() { + return queryParams; + } + + public void setQueryParams(MultivaluedMap queryParams) { + this.queryParams = queryParams; + } } diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java index 804c7ed45..fb28393e9 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java @@ -73,7 +73,34 @@ public interface DocumentHandler { public void prepare(Action action) throws Exception; /** - * handle is called by the client to hand over the document processing task + * prepareCreate processes documents before creating document in repository + + * @throws Exception + */ + public void prepareCreate() throws Exception; + + /** + * prepareUpdate processes documents for the update of document in repository + * @throws Exception + */ + public void prepareUpdate() throws Exception; + + /** + * prepareGet processes query from repository before retrieving document from + * repository + * @throws Exception + */ + public void prepareGet() throws Exception; + + /** + * prepareGetAll processes query from repository before retrieving document(s) from + * repository + * @throws Exception + */ + public void prepareGetAll() throws Exception; + + /** + * prepare is called by the client to hand over the document processing task * @param action * @param doc wrapped doc * @throws Exception @@ -117,14 +144,34 @@ public interface DocumentHandler { */ public void complete(Action action, DocumentWrapper wrapDoc) throws Exception; + /** + * completeCreate is called by the client to indicate completion of the create call. + * @param wrapDoc + * @throws Exception + */ + public void completeCreate(DocumentWrapper wrapDoc) throws Exception; + /** * completeUpdate is called by the client to indicate completion of the update call. - * this gives opportunity to prepare updated object that should be sent back to the consumer * @param wrapDoc * @throws Exception */ public void completeUpdate(DocumentWrapper wrapDoc) throws Exception; + /** + * completeGetis called by the client to indicate completion of the get call. + * @param wrapDoc + * @throws Exception + */ + public void completeGet(DocumentWrapper wrapDoc) throws Exception; + + /** + * completeGetAll is called by the client to indicate completion of the getall. + * @param wrapDoc + * @throws Exception + */ + public void completeGetAll(DocumentWrapper wrapDoc) throws Exception; + /** * extractCommonPart extracts common part of a CS object from given document. * this is usually called AFTER the get operation is invoked on the repository. @@ -165,7 +212,6 @@ public interface DocumentHandler { */ public void fillCommonPartList(TL obj, DocumentWrapper docWrap) throws Exception; - /** * getProperties * @return @@ -179,6 +225,14 @@ public interface DocumentHandler { */ public void setProperties(Map properties); + /** + * createDocumentFilter is a factory method to create a document + * filter that is relevant to be used with this document handler + * and corresponding storage client + * @return + */ + public DocumentFilter createDocumentFilter(); + /** * getDocumentFilter * @return diff --git a/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaDocumentFilter.java b/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaDocumentFilter.java new file mode 100644 index 000000000..e0d744793 --- /dev/null +++ b/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaDocumentFilter.java @@ -0,0 +1,61 @@ +/** + * 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. + *//** + * 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. + */ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package org.collectionspace.services.common.storage.jpa; + +import org.collectionspace.services.common.document.DocumentFilter; + +/** + * JPA query specific document filter + */ +public class JpaDocumentFilter extends DocumentFilter { + + +} diff --git a/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClient.java b/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClient.java index 3bf24e5f4..4438049ee 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClient.java +++ b/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClient.java @@ -50,6 +50,7 @@ public class JpaStorageClient implements StorageClient { private final Logger logger = LoggerFactory.getLogger(JpaStorageClient.class); protected final static String CS_PERSISTENCE_UNIT = "org.collectionspace.services"; + public JpaStorageClient() { } @@ -200,22 +201,26 @@ public class JpaStorageClient implements StorageClient { try { handler.prepare(Action.GET_ALL); - StringBuilder queryStr = new StringBuilder("SELECT a FROM "); - queryStr.append(getEntityName(ctx)); - queryStr.append(" a"); + StringBuilder strBld = new StringBuilder("SELECT a FROM "); + strBld.append(getEntityName(ctx)); + strBld.append(" a"); //TODO: add tenant id - String where = docFilter.getWhereClause(); - if ((null != where) && (where.length() > 0)) { - queryStr.append(" AND " + where); - } emf = getEntityManagerFactory(); em = emf.createEntityManager(); - Query q = em.createQuery(queryStr.toString()); + String queryStr = strBld.toString(); //for debugging + Query q = em.createQuery(queryStr); //TODO: add tenant id - //TODO: get page - if ((docFilter.getOffset() > 0) || (docFilter.getPageSize() > 0)) { - } else { + String where = docFilter.getWhereClause(); + if ((null != where) && (where.length() > 0)) { + strBld.append(where); } + if (docFilter.getOffset() > 0) { + q.setFirstResult(docFilter.getOffset()); + } + if (docFilter.getPageSize() > 0) { + q.setMaxResults(docFilter.getPageSize()); + } + //FIXME is transaction required for get? em.getTransaction().begin(); List list = q.getResultList(); @@ -346,6 +351,7 @@ public class JpaStorageClient implements StorageClient { protected EntityManagerFactory getEntityManagerFactory() { return getEntityManagerFactory(CS_PERSISTENCE_UNIT); } + protected EntityManagerFactory getEntityManagerFactory( String persistenceUnit) { return Persistence.createEntityManagerFactory(persistenceUnit); @@ -381,8 +387,8 @@ public class JpaStorageClient implements StorageClient { Object r = m.invoke(o); if (logger.isDebugEnabled()) { - logger.debug("getValue returned value=" + r + - " for " + c.getName()); + logger.debug("getValue returned value=" + r + + " for " + c.getName()); } return r; } @@ -415,8 +421,8 @@ public class JpaStorageClient implements StorageClient { Method m = c.getMethod(methodName, argType); Object r = m.invoke(o, argValue); if (logger.isDebugEnabled()) { - logger.debug("completed invocation of " + methodName + - " for " + c.getName()); + logger.debug("completed invocation of " + methodName + + " for " + c.getName()); } return r; } @@ -442,8 +448,8 @@ public class JpaStorageClient implements StorageClient { protected String getEntityName(ServiceContext ctx) { Object o = ctx.getProperty("entity-name"); if (o == null) { - throw new IllegalArgumentException("property entity-name missing in context " + - ctx.toString()); + throw new IllegalArgumentException("property entity-name missing in context " + + ctx.toString()); } return (String) o; diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java index f0ca2fb3d..67f8e88cf 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java @@ -24,6 +24,7 @@ package org.collectionspace.services.nuxeo.client.java; import org.collectionspace.services.common.document.AbstractMultipartDocumentHandler; +import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.nuxeo.client.*; import org.nuxeo.ecm.core.api.DocumentModel; @@ -112,4 +113,9 @@ public abstract class DocumentModelHandler @Override public abstract void setCommonPartList(TL obj); + @Override + public DocumentFilter createDocumentFilter() { + return new NuxeoDocumentFilter(); + } + } diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentFilter.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentFilter.java new file mode 100644 index 000000000..fd74a9334 --- /dev/null +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentFilter.java @@ -0,0 +1,60 @@ +/** + * 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. + *//** + * 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. + */ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package org.collectionspace.services.nuxeo.client.java; + +import org.collectionspace.services.common.document.DocumentFilter; + +/** + * NXQL specific document filter + */ +public class NuxeoDocumentFilter extends DocumentFilter { + +} diff --git a/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java b/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java index f809ec108..af4c9b6dc 100644 --- a/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java +++ b/services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java @@ -61,10 +61,6 @@ public class ContactDocumentModelHandler */ private ContactsCommonList contactList; - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } /** * getCommonPart get associated contact diff --git a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java index df4330dfd..e2c8eff52 100644 --- a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java +++ b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java @@ -61,10 +61,6 @@ public class DimensionDocumentModelHandler */ private DimensionsCommonList intakeList; - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } /** * getCommonPart get associated dimension diff --git a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java index 6f1beae77..2f4cbc695 100644 --- a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java +++ b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java @@ -61,10 +61,6 @@ public class IntakeDocumentModelHandler */ private IntakesCommonList intakeList; - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } /** * getCommonPart get associated intake diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java index a7a275c7f..092cc6131 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java @@ -211,8 +211,8 @@ public class OrgAuthorityResource extends AbstractCollectionSpaceResource { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); MultivaluedMap queryParams = ui.getQueryParameters(); DocumentHandler handler = createDocumentHandler(ctx); - DocumentFilter myFilter = - DocumentFilter.CreatePaginatedDocumentFilter(queryParams); + DocumentFilter myFilter = new DocumentFilter(); + myFilter.setPagination(queryParams); String nameQ = queryParams.getFirst("refName"); if (nameQ != null) { myFilter.setWhereClause("orgauthorities_common:refName='" + nameQ + "'"); @@ -414,8 +414,8 @@ public class OrgAuthorityResource extends AbstractCollectionSpaceResource { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName()); DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid); MultivaluedMap queryParams = ui.getQueryParameters(); - DocumentFilter myFilter = - DocumentFilter.CreatePaginatedDocumentFilter(queryParams); + DocumentFilter myFilter = new DocumentFilter(); + myFilter.setPagination(queryParams); myFilter.setWhereClause(OrganizationJAXBSchema.ORGANIZATIONS_COMMON + ":" + OrganizationJAXBSchema.IN_AUTHORITY + "=" + "'" + parentcsid + "'"); diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java index 4be73cd44..15131cdc9 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java @@ -61,10 +61,6 @@ public class OrgAuthorityDocumentModelHandler */ private OrgauthoritiesCommonList orgAuthorityList; - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } /** * getCommonPart get associated orgAuthority diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java index 5f87b59d2..eed15d509 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java @@ -72,10 +72,6 @@ public class OrganizationDocumentModelHandler this.inAuthority = inAuthority; } - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } @Override public void handleCreate(DocumentWrapper wrapDoc) throws Exception { diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java b/services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java index ff5f5ebca..82415fead 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java @@ -211,8 +211,8 @@ public class PersonAuthorityResource extends AbstractCollectionSpaceResource { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); MultivaluedMap queryParams = ui.getQueryParameters(); DocumentHandler handler = createDocumentHandler(ctx); - DocumentFilter myFilter = - DocumentFilter.CreatePaginatedDocumentFilter(queryParams); + DocumentFilter myFilter = new DocumentFilter(); + myFilter.setPagination(queryParams); String nameQ = queryParams.getFirst("refName"); if (nameQ != null) { myFilter.setWhereClause("personauthorities_common:refName='" + nameQ + "'"); @@ -414,8 +414,8 @@ public class PersonAuthorityResource extends AbstractCollectionSpaceResource { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName()); DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid); MultivaluedMap queryParams = ui.getQueryParameters(); - DocumentFilter myFilter = - DocumentFilter.CreatePaginatedDocumentFilter(queryParams); + DocumentFilter myFilter = new DocumentFilter(); + myFilter.setPagination(queryParams); // Add the where clause "persons_common:inAuthority='" + parentcsid + "'" myFilter.setWhereClause(PersonJAXBSchema.PERSONS_COMMON + ":" + diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java index 799b93dd2..5a435c591 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java @@ -61,10 +61,6 @@ public class PersonAuthorityDocumentModelHandler */ private PersonauthoritiesCommonList personAuthorityList; - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } /** * getCommonPart get associated personAuthority diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java index 3619a3c33..a2e0973ff 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java @@ -78,10 +78,6 @@ public class PersonDocumentModelHandler this.inAuthority = inAuthority; } - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } @Override public void handleCreate(DocumentWrapper wrapDoc) throws Exception { diff --git a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java index b5dadabe7..550546515 100644 --- a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java +++ b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java @@ -64,10 +64,6 @@ public class RelationDocumentModelHandler */ private RelationsCommonList relationList; - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } /** * getCommonObject get associated Relation diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java index 1110ba369..14e2c8037 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java @@ -212,8 +212,8 @@ public class VocabularyResource extends AbstractCollectionSpaceResource { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); MultivaluedMap queryParams = ui.getQueryParameters(); DocumentHandler handler = createDocumentHandler(ctx); - DocumentFilter myFilter = - DocumentFilter.CreatePaginatedDocumentFilter(queryParams); + DocumentFilter myFilter = new DocumentFilter(); + myFilter.setPagination(queryParams); String nameQ = queryParams.getFirst("refName"); if (nameQ != null) { myFilter.setWhereClause("vocabularies_common:refName='" + nameQ + "'"); @@ -415,8 +415,8 @@ public class VocabularyResource extends AbstractCollectionSpaceResource { ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName()); DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid); MultivaluedMap queryParams = ui.getQueryParameters(); - DocumentFilter myFilter = - DocumentFilter.CreatePaginatedDocumentFilter(queryParams); + DocumentFilter myFilter = new DocumentFilter(); + myFilter.setPagination(queryParams); // "vocabularyitems_common:inVocabulary='" + parentcsid + "'"); myFilter.setWhereClause( VocabularyItemJAXBSchema.VOCABULARYITEMS_COMMON + ":" + diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java index b60a31033..6c88da385 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java @@ -61,10 +61,6 @@ public class VocabularyDocumentModelHandler */ private VocabulariesCommonList vocabularyList; - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } /** * getCommonPart get associated vocabulary diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java index 4025fa0cf..279f4dc3f 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java @@ -72,10 +72,6 @@ public class VocabularyItemDocumentModelHandler this.inVocabulary = inVocabulary; } - @Override - public void prepare(Action action) throws Exception { - //no specific action needed - } /** * getCommonPart get associated vocabularyItem -- 2.47.3