1. Adding additional pagination tests to all Nuxeo based services.
2. Replacing .getAll() calls with .getFiltered
3. Removing dead/deprecated code in many http clients
4. Fixing file refs to test and config files to *not* assume current dir is in classpath.
}
//to not cause uniqueness violation for accRole, createList is removed
- @Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"create"})
+ @Override
public void createList(String testName) throws Exception {
//FIXME: Should this test really be empty? If so, please comment accordingly.
}
/**
*
*/
- private static final AcquisitionClient instance = new AcquisitionClient();
+// private static final AcquisitionClient instance = new AcquisitionClient();
/**
*
*/
*
* @return
*/
- public static AcquisitionClient getInstance() {
- return instance;
- }
+// public static AcquisitionClient getInstance() {
+// return instance;
+// }
/**
* @return
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;
import org.collectionspace.services.common.query.IQueryManager;
import org.collectionspace.services.common.query.QueryManager;
import org.collectionspace.services.common.security.UnauthorizedException;
-import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.jboss.resteasy.util.HttpResponseCodes;
public AcquisitionsCommonList getAcquisitionList(@Context UriInfo ui,
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) {
AcquisitionsCommonList result = null;
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
if (keywords != null) {
- result = searchAcquisitions(keywords);
+ result = searchAcquisitions(queryParams, keywords);
} else {
- result = getAcquisitionsList();
+ result = getAcquisitionsList(queryParams);
}
return result;
*
* @return the acquisitions list
*/
- private AcquisitionsCommonList getAcquisitionsList() {
+ private AcquisitionsCommonList getAcquisitionsList(MultivaluedMap<String, String> queryParams) {
AcquisitionsCommonList acquisitionObjectList;
try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).getAll(ctx, handler);
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
acquisitionObjectList = (AcquisitionsCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
Response response = Response.status(
@GET
@Path("/search")
@Produces("application/xml")
+ @Deprecated
public AcquisitionsCommonList keywordsSearchAcquisitions(@Context UriInfo ui,
@QueryParam (IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) {
- return searchAcquisitions(keywords);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return searchAcquisitions(queryParams, keywords);
}
/**
*
* @return the acquisitions common list
*/
- private AcquisitionsCommonList searchAcquisitions(String keywords) {
+ private AcquisitionsCommonList searchAcquisitions(
+ MultivaluedMap<String, String> queryParams,
+ String keywords) {
AcquisitionsCommonList acquisitionObjectList;
try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
// perform a keyword search
if (logger.isDebugEnabled()) {
logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
}
- getRepositoryClient(ctx).getFiltered(ctx, handler);
- } else {
- getRepositoryClient(ctx).getAll(ctx, handler);
- }
- acquisitionObjectList = (AcquisitionsCommonList) handler.getCommonPartList();
-
+ }
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
+ acquisitionObjectList = (AcquisitionsCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
Response response = Response.status(
Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
DocumentWrapper<DocumentModel> docWrapper =
getRepositoryClient(ctx).getDoc(ctx, csid);
- RemoteDocumentModelHandlerImpl handler
- = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
+ DocumentModelHandler<MultipartInput, MultipartOutput> handler
+ = (DocumentModelHandler<MultipartInput, MultipartOutput>)createDocumentHandler(ctx);
List<String> authRefFields =
((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
+ <property>
+ <name>maven.basedir</name>
+ <value>${basedir}</value>
+ </property>
<property>
<name>log4j.configuration</name>
<value>file:${project.build.directory}/test-classes/log4j.properties</value>
*/
public abstract class AbstractAuthorizationTestImpl {
- final Logger logger = LoggerFactory.getLogger(AbstractAuthorizationTestImpl.class);
+ static protected final String MAVEN_BASEDIR_PROPERTY = "maven.basedir";
+ final Logger logger = LoggerFactory.getLogger(AbstractAuthorizationTestImpl.class);
private org.springframework.jdbc.datasource.DataSourceTransactionManager txManager;
final static String testDataDir = "src/test/resources/test-data/";
+ static String baseDir;
+ static {
+ baseDir = System.getProperty(AbstractAuthorizationTestImpl.MAVEN_BASEDIR_PROPERTY);
+ if (baseDir == null || baseDir.isEmpty()) {
+ baseDir = System.getProperty("user.dir");
+ }
+ baseDir = baseDir + System.getProperty("file.separator");
+ }
/**
* Returns the name of the currently running test.
*/
package org.collectionspace.services.authorization.test;
-import java.util.ArrayList;
-import java.util.List;
+//import java.util.ArrayList;
+//import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+//import org.collectionspace.services.client.test.BaseServiceTest;
import org.collectionspace.services.authorization.AuthZ;
import org.collectionspace.services.authorization.Permission;
import org.collectionspace.services.authorization.PermissionRole;
}
public void seedRoles() throws Exception {
+ //Should this test really be empty?
}
- public void seedPermissions() throws Exception {
-
+ public void seedPermissions() throws Exception {
PermissionsList pcList =
- (PermissionsList) fromFile(PermissionsList.class,
+ (PermissionsList) fromFile(PermissionsList.class, baseDir +
AbstractAuthorizationTestImpl.testDataDir + "test-permissions.xml");
logger.info("read permissions from "
- + AbstractAuthorizationTestImpl.testDataDir + "test-permissions.xml");
+ + baseDir + AbstractAuthorizationTestImpl.testDataDir + "test-permissions.xml");
PermissionsRolesList pcrList =
- (PermissionsRolesList) fromFile(PermissionsRolesList.class,
+ (PermissionsRolesList) fromFile(PermissionsRolesList.class, baseDir +
AbstractAuthorizationTestImpl.testDataDir + "test-permissions-roles.xml");
logger.info("read permissions-roles from "
- + AbstractAuthorizationTestImpl.testDataDir + "test-permissions.xml");
+ + baseDir + AbstractAuthorizationTestImpl.testDataDir + "test-permissions.xml");
AuthZ authZ = AuthZ.get();
for (Permission p : pcList.getPermissions()) {
if (logger.isDebugEnabled()) {
</exclusion>\r
</exclusions>\r
</dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>jaxrs-api</artifactId>\r
+ </dependency> \r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
<artifactId>resteasy-jaxb-provider</artifactId>\r
*/
package org.collectionspace.services.client.test;
-import java.util.List;
+//import java.util.List;
import javax.ws.rs.core.Response;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.AbstractServiceClientImpl;
+//import org.collectionspace.services.client.AbstractServiceClientImpl;
import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Constant DEFAULT_LIST_SIZE. */
static protected final int DEFAULT_LIST_SIZE = 10;
+ static protected final int DEFAULT_PAGINATEDLIST_SIZE = 10;
// // Success outcomes
// /* (non-Javadoc)
ClientResponse<AbstractCommonList> response =
(ClientResponse<AbstractCommonList>)client.readList(Long.toString(pageSize),
Long.toString(pageNumber));
- AbstractCommonList list = this.getAbstractCommonList(response);
int statusCode = response.getStatus();
// Check the status code of the response: does it match
Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
-
+
+ AbstractCommonList list = this.getAbstractCommonList(response);
return list;
}
+ /**
+ * Creates the list.
+ *
+ * @param testName the test name
+ * @param listSize the list size
+ * @throws Exception the exception
+ */
+ protected void createPaginatedList(String testName, int listSize) throws Exception {
+ for (int i = 0; i < listSize; i++) {
+ create(testName);
+ }
+ }
+
+ /*@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ public void leafCeate(String testName) throws Exception {
+ this.create(testName);
+ }*/
+
+ private void assertPaginationInfo(String testName,
+ AbstractCommonList list,
+ long expectedPageNum,
+ long expectedPageSize,
+ long expectedListSize,
+ long expectedTotalItems) {
+ Assert.assertNotNull(list);
+
+ long pageNum = list.getPageNum();
+ Assert.assertEquals(pageNum, expectedPageNum);
+ if (getLogger().isDebugEnabled() == true) {
+ getLogger().debug(testName + ":" + "page number is " + pageNum);
+ }
+
+ long pageSizeReturned = list.getPageSize();
+ Assert.assertEquals(pageSizeReturned, expectedPageSize);
+ if (getLogger().isDebugEnabled() == true) {
+ getLogger().debug(testName + ":" + "page size is " + list.getPageSize());
+ }
+
+ long itemsInPage = list.getItemsInPage();
+ Assert.assertEquals(itemsInPage, expectedListSize);
+ if (getLogger().isDebugEnabled() == true) {
+ getLogger().debug(testName + ":" + "actual items in page was/were " + itemsInPage);
+ }
+
+ long totalItemsReturned = list.getTotalItems();
+ Assert.assertEquals(totalItemsReturned, expectedTotalItems);
+ if (getLogger().isDebugEnabled() == true) {
+ getLogger().debug(testName + ":" + "total number of items is " + list.getTotalItems());
+ }
+ }
+
/**
* Read paginated list.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName")
+ @Test(dataProvider = "testName") /*, dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"leafCeate"}) */
public void readPaginatedList(String testName) throws Exception {
-
// Perform setup.
setupReadList(testName);
-
- long pageSize = DEFAULT_LIST_SIZE / 3; //create 3 pages to iterate over
CollectionSpaceClient client = this.getClientInstance();
- AbstractCommonList list = this.readList(testName, client, pageSize, 0);
- long totalItems = list.getTotalItems();
- long pagesTotal = totalItems / pageSize;
+
+ // Get the current total number of items.
+ // If there are no items then create some
+ AbstractCommonList list = this.readList(testName, client, 1 /*pgSz*/, 0 /*pgNum*/);
+ if (list == null || list.getTotalItems() == 0) {
+ this.createPaginatedList(testName, DEFAULT_PAGINATEDLIST_SIZE);
+ list = this.readList(testName, client, 1 /*pgSz*/, 0 /*pgNum*/);
+ }
+
+ // Print out the current list size to be paginated
+ Assert.assertNotNull(list);
+ long totalItems = list.getTotalItems();
+ Assert.assertFalse(totalItems == 0);
+ if (getLogger().isDebugEnabled() == true) {
+ getLogger().debug(testName + ":" + "created list of " +
+ totalItems + " to be paginated.");
+ }
+
+ long pageSize = totalItems / 3; //create up to 3 pages to iterate over
+ long pagesTotal = pageSize > 0 ? (totalItems / pageSize) : 0;
for (int i = 0; i < pagesTotal; i++) {
list = this.readList(testName, client, pageSize, i);
- if (getLogger().isDebugEnabled() == true) {
- getLogger().debug(testName + ":" + "page number is " + list.getPageNum());
- getLogger().debug(testName + ":" + "page size is " + list.getPageSize());
- getLogger().debug(testName + ":" + "total number of items is " + list.getTotalItems());
- }
+ assertPaginationInfo(testName,
+ list,
+ i, //expected page number
+ pageSize, //expected page size
+ pageSize, //expected num of items in page
+ totalItems);//expected total num of items
}
+ // if there are any remainders be sure to paginate them as well
long mod = totalItems % pageSize;
if (mod != 0) {
list = this.readList(testName, client, pageSize, pagesTotal);
- getLogger().debug(testName + ":" + "page number is " + list.getPageNum());
- getLogger().debug(testName + ":" + "page size is " + list.getPageSize());
- getLogger().debug(testName + ":" + "total number of items is " + list.getTotalItems());
+ assertPaginationInfo(testName,
+ list,
+ pagesTotal, //expected page number
+ pageSize, //expected page size
+ mod, //expected num of items in page
+ totalItems);//expected total num of items
}
-
}
// ---------------------------------------------------------------
*/\r
public abstract class BaseServiceTest {\r
\r
+ //Maven's base directory -i.e., the one containing the current pom.xml\r
+ static protected final String MAVEN_BASEDIR_PROPERTY = "maven.basedir";\r
+ \r
/** The Constant logger. */\r
static protected final Logger logger = LoggerFactory.getLogger(BaseServiceTest.class);\r
\r
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.collectionspace.services.client.AbstractServiceClientImpl;
+//import org.collectionspace.services.client.AbstractServiceClientImpl;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
private String knownResourceId = null;
/** The all resource ids created. */
- private List<String> allResourceIdsCreated = new ArrayList();
+ private List<String> allResourceIdsCreated = new ArrayList<String>();
/** The multivalue. */
private boolean multivalue; //toggle
}
testSubmitRequest(newId);
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.ServiceTest#createList()
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
- for (int i = 0; i < DEFAULT_LIST_SIZE; i++) {
- create(testName);
- }
+ this.createPaginatedList(testName, DEFAULT_LIST_SIZE);
}
// Failure outcomes
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void createWithEmptyEntityBody(String testName) throws Exception {
+ //FIXME: Should this test really be empty?
}
/**
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void createWithWrongXmlSchema(String testName) throws Exception {
+ //FIXME: Should this test really be empty?
}
* @param testName The name of this test method. This name is supplied
* automatically, via reflection, by a TestNG 'data provider' in
* a base class.
+ * @throws Exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void createWithRequiredValuesNullOrEmpty(String testName) throws Exception {
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"read"})
public void updateWithEmptyEntityBody(String testName) throws Exception {
+ //FIXME: Should this test really be empty?
}
/**
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"read"})
public void updateWithMalformedXml(String testName) throws Exception {
+ //FIXME: Should this test really be empty?
}
/* (non-Javadoc)
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"read"})
public void updateWithWrongXmlSchema(String testName) throws Exception {
+ //FIXME: Should this test really be empty?
}
/*
* @param testName The name of this test method. This name is supplied
* automatically, via reflection, by a TestNG 'data provider' in
* a base class.
+ * @throws Exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"read"})
/**
* Tests the code for manually submitting data that is used by several
* of the methods above.
+ * @throws Exception
*/
@Test(dependsOnMethods = {"create", "read"})
public CollectionobjectsCommonList getCollectionObjectList(@Context UriInfo ui,
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) {
CollectionobjectsCommonList result = null;
- MultivaluedMap queryParams = ui.getQueryParameters();
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
if (keywords != null) {
result = searchCollectionObjects(queryParams, keywords);
} else {
/**
* Gets the collection object list.
*/
- private CollectionobjectsCommonList getCollectionObjectList(MultivaluedMap queryParams) {
+ private CollectionobjectsCommonList getCollectionObjectList(MultivaluedMap<String, String> queryParams) {
CollectionobjectsCommonList collectionObjectList;
try {
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
public IntakesCommonList getIntakesCommonList(@Context UriInfo ui,
@PathParam("csid") String csid) {
IntakesCommonList result = null;
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
try {
//
String subjectCsid = csid;
String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.value();
String objectCsid = null;
- NewRelationResource relationResource = new NewRelationResource();
- RelationsCommonList relationsCommonList = relationResource.getRelationList(subjectCsid, predicate, objectCsid);
+ NewRelationResource relationResource = new NewRelationResource();
+ RelationsCommonList relationsCommonList = relationResource.getRelationList(queryParams,
+ subjectCsid, predicate, objectCsid);
//
// Create an array of Intake csid's
@Context UriInfo ui) {
AuthorityRefList authRefList = null;
try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentWrapper<DocumentModel> docWrapper =
getRepositoryClient(ctx).getDoc(ctx, csid);
DocumentModelHandler<MultipartInput, MultipartOutput> docHandler =
@Produces("application/xml")
public CollectionobjectsCommonList keywordsSearchCollectionObjects(@Context UriInfo ui,
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) {
- MultivaluedMap queryParams = ui.getQueryParameters();
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
return searchCollectionObjects(queryParams, keywords);
}
import java.util.Map;
import javax.ws.rs.core.MultivaluedMap;
-import org.collectionspace.authentication.AuthN;
-
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.config.PropertyItemUtils;
/** security context */
private SecurityContext securityContext;
+ /**
+ * Instantiates a new abstract service context impl.
+ */
private AbstractServiceContextImpl() {
- } // private constructor for singleton pattern
+ // private constructor for singleton pattern
+ }
+
// request query params
+ /** The query params. */
private MultivaluedMap<String, String> queryParams;
/**
}
}
- /**
- * getCommonPartLabel get common part label
- * @return
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getCommonPartLabel()
*/
@Override
public String getCommonPartLabel() {
return getCommonPartLabel(getServiceName());
}
- /**
- * getCommonPartLabel get common part label
- * @return
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getCommonPartLabel(java.lang.String)
*/
public String getCommonPartLabel(String schemaName) {
return schemaName.toLowerCase() + PART_LABEL_SEPERATOR + PART_COMMON_LABEL;
overrideDocumentType = docType;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getSecurityContext()
+ */
@Override
public SecurityContext getSecurityContext() {
return securityContext;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getUserId()
+ */
@Override
public String getUserId() {
return securityContext.getUserId();
*/
private DocumentHandler createDocumentHandlerInstance() throws Exception {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- Class c = tccl.loadClass(getDocumentHandlerClass());
+ Class<?> c = tccl.loadClass(getDocumentHandlerClass());
if (DocumentHandler.class.isAssignableFrom(c)) {
docHandler = (DocumentHandler) c.newInstance();
} else {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
for (String clazz : handlerClazzes) {
clazz = clazz.trim();
- Class c = tccl.loadClass(clazz);
+ Class<?> c = tccl.loadClass(clazz);
if (ValidatorHandler.class.isAssignableFrom(c)) {
handlers.add((ValidatorHandler) c.newInstance());
}
return msg.toString();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getQueryParams()
+ */
@Override
public MultivaluedMap<String, String> getQueryParams() {
return this.queryParams;
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#setQueryParams(javax.ws.rs.core.MultivaluedMap)
+ */
@Override
- public void setQueryParams(MultivaluedMap<String, String> queryParams) {
- this.queryParams = queryParams;
+ public void setQueryParams(MultivaluedMap<String, String> theQueryParams) {
+ this.queryParams = theQueryParams;
}
}
// set the page size and page numer
commonList.setPageNum(pageNum);
commonList.setPageSize(pageSize);
- // set the total result size
DocumentModelList docList = wrapDoc.getWrappedObject();
+ // Set num of items in list. this is useful to our testing framework.
+ commonList.setItemsInPage(docList.size());
+ // set the total result size
commonList.setTotalItems(docList.totalSize());
return (TL)commonList;
/**
*
*/
- private static final ContactClient instance = new ContactClient();
+// private static final ContactClient instance = new ContactClient();
/**
*
*
* @return
*/
- public static ContactClient getInstance() {
- return instance;
- }
+// public static ContactClient getInstance() {
+// return instance;
+// }
/**
* @return
import javax.ws.rs.PathParam;
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;
import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
-import org.collectionspace.services.common.context.MultipartServiceContext;
-import org.collectionspace.services.common.context.MultipartServiceContextFactory;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.collectionspace.services.common.document.DocumentHandler;
@GET
@Produces("application/xml")
public ContactsCommonList getContactList(@Context UriInfo ui) {
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
ContactsCommonList contactObjectList = new ContactsCommonList();
try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).getAll(ctx, handler);
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
contactObjectList = (ContactsCommonList) handler.getCommonPartList();
} catch (Exception e) {
if (logger.isDebugEnabled()) {
/**
*
*/
- private static final DimensionClient instance = new DimensionClient();
+// private static final DimensionClient instance = new DimensionClient();
/**
*
*
* @return
*/
- public static DimensionClient getInstance() {
- return instance;
- }
+// public static DimensionClient getInstance() {
+// return instance;
+// }
/**
* @return
// Instance variables specific to this test.
final String SERVICE_PATH_COMPONENT = "dimensions";
private String knownResourceId = null;
- private List<String> allResourceIdsCreated = new ArrayList();
+ private List<String> allResourceIdsCreated = new ArrayList<String>();
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
try {
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).getAll(ctx, handler);
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
dimensionObjectList = (DimensionsCommonList) handler.getCommonPartList();
} catch (Exception e) {
if (logger.isDebugEnabled()) {
/**
*
*/
- private static final IntakeClient instance = new IntakeClient();
+// private static final IntakeClient instance = new IntakeClient();
/**
*
*/
*
* @return
*/
- public static IntakeClient getInstance() {
- return instance;
- }
+// public static IntakeClient getInstance() {
+// return instance;
+// }
/**
* @return
logger.debug("Cleaning up temporary resources created for testing ...");
}
IntakeClient intakeClient = new IntakeClient();
- PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Note: Any non-success responses are ignored and not reported.
for (String resourceId : intakeIdsCreated) {
ClientResponse<Response> res = intakeClient.delete(resourceId);
}
// Delete persons before PersonAuth
+ PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
for (String resourceId : personIdsCreated) {
ClientResponse<Response> res = personAuthClient.deleteItem(personAuthCSID, resourceId);
}
- ClientResponse<Response> res = personAuthClient.delete(personAuthCSID);
+ if (personAuthCSID != null) {
+ personAuthClient.delete(personAuthCSID);
+ }
}
// ---------------------------------------------------------------
import org.collectionspace.services.common.query.QueryManager;
import org.collectionspace.services.common.security.UnauthorizedException;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
try {
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).getAll(ctx, handler);
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
intakeObjectList = (IntakesCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
Response response = Response.status(
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentWrapper<DocumentModel> docWrapper =
getRepositoryClient(ctx).getDoc(ctx, csid);
- RemoteDocumentModelHandlerImpl handler
- = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
+ DocumentModelHandler<MultipartInput, MultipartOutput> handler
+ = (DocumentModelHandler<MultipartInput, MultipartOutput>)createDocumentHandler(ctx);
List<String> authRefFields =
((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
documentFilter.setWhereClause(whereClause);
if (logger.isDebugEnabled()) {
logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
- }
- getRepositoryClient(ctx).getFiltered(ctx, handler);
- } else {
- getRepositoryClient(ctx).getAll(ctx, handler);
- }
- intakesObjectList = (IntakesCommonList) handler.getCommonPartList();
-
+ }
+ }
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
+ intakesObjectList = (IntakesCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
Response response = Response.status(
Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
<xs:sequence>
<xs:element name="pageNum" type="xs:unsignedInt" />
<xs:element name="pageSize" type="xs:unsignedInt" />
+ <!-- "itemsInPage" is useful to our testing framework's unit tests -->
+ <xs:element name="itemsInPage" type="xs:unsignedInt" />
<xs:element name="totalItems" type="xs:unsignedInt" />
</xs:sequence>
</xs:complexType>
</xs:element>
-</xs:schema>
-
+</xs:schema>
\ No newline at end of file
/**
*
*/
- private static final LoaninClient instance = new LoaninClient();
+// private static final LoaninClient instance = new LoaninClient();
/**
*
*/
*
* @return
*/
- public static LoaninClient getInstance() {
- return instance;
- }
+// public static LoaninClient getInstance() {
+// return instance;
+// }
/**
* @return
import org.collectionspace.services.client.PersonAuthorityClient;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.authorityref.AuthorityRefList.AuthorityRefItem;
+//import org.collectionspace.services.common.authorityref.AuthorityRefList.AuthorityRefItem;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanin.LoansinCommon;
-import org.collectionspace.services.loanin.LoansinCommonList;
+//import org.collectionspace.services.loanin.LoansinCommonList;
import org.jboss.resteasy.client.ClientResponse;
final String SERVICE_PATH_COMPONENT = "loansin";
final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
private String knownResourceId = null;
- private List<String> loaninIdsCreated = new ArrayList();
- private List<String> personIdsCreated = new ArrayList();
+ private List<String> loaninIdsCreated = new ArrayList<String>();
+ private List<String> personIdsCreated = new ArrayList<String>();
private int CREATED_STATUS = Response.Status.CREATED.getStatusCode();
private int OK_STATUS = Response.Status.OK.getStatusCode();
private String personAuthCSID = null;
}
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Delete Person resource(s) (before PersonAuthority resources).
- ClientResponse<Response> res;
+
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- res = personAuthClient.deleteItem(personAuthCSID, resourceId);
+ personAuthClient.deleteItem(personAuthCSID, resourceId);
}
+
// Delete PersonAuthority resource(s).
// Note: Any non-success response is ignored and not reported.
- res = personAuthClient.delete(personAuthCSID);
- // Delete Loans In resource(s).
- LoaninClient loaninClient = new LoaninClient();
- for (String resourceId : loaninIdsCreated) {
- // Note: Any non-success responses are ignored and not reported.
- res = loaninClient.delete(resourceId);
+ if (personAuthCSID != null) {
+ personAuthClient.delete(personAuthCSID);
+ // Delete Loans In resource(s).
+ LoaninClient loaninClient = new LoaninClient();
+ for (String resourceId : loaninIdsCreated) {
+ // Note: Any non-success responses are ignored and not reported.
+ loaninClient.delete(resourceId);
+ }
}
}
import org.collectionspace.services.common.query.QueryManager;
import org.collectionspace.services.common.security.UnauthorizedException;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
try {
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).getAll(ctx, handler);
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
loaninObjectList = (LoansinCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
Response response = Response.status(
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentWrapper<DocumentModel> docWrapper =
getRepositoryClient(ctx).getDoc(ctx, csid);
- RemoteDocumentModelHandlerImpl handler
- = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
+ DocumentModelHandler<MultipartInput, MultipartOutput> handler
+ = (DocumentModelHandler<MultipartInput, MultipartOutput>)createDocumentHandler(ctx);
List<String> authRefFields =
((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
*
* @return the loansin common list
*/
- private LoansinCommonList searchLoansin(MultivaluedMap<String, String> queryParams,
+ private LoansinCommonList searchLoansin(
+ MultivaluedMap<String, String> queryParams,
String keywords) {
LoansinCommonList loansinObjectList;
try {
if (logger.isDebugEnabled()) {
logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
}
- getRepositoryClient(ctx).getFiltered(ctx, handler);
- } else {
- getRepositoryClient(ctx).getAll(ctx, handler);
- }
- loansinObjectList = (LoansinCommonList) handler.getCommonPartList();
-
+ }
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
+ loansinObjectList = (LoansinCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
Response response = Response.status(
Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
/**
*
*/
- private static final LoanoutClient instance = new LoanoutClient();
+// private static final LoanoutClient instance = new LoanoutClient();
/**
*
*/
*
* @return
*/
- public static LoanoutClient getInstance() {
- return instance;
- }
+// public static LoanoutClient getInstance() {
+// return instance;
+// }
/**
* @return
import org.collectionspace.services.client.PersonAuthorityClient;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.authorityref.AuthorityRefList.AuthorityRefItem;
+//import org.collectionspace.services.common.authorityref.AuthorityRefList.AuthorityRefItem;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanout.LoansoutCommon;
-import org.collectionspace.services.loanout.LoansoutCommonList;
+//import org.collectionspace.services.loanout.LoansoutCommonList;
import org.jboss.resteasy.client.ClientResponse;
final String SERVICE_PATH_COMPONENT = "loansout";
final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
private String knownResourceId = null;
- private List<String> loanoutIdsCreated = new ArrayList();
- private List<String> personIdsCreated = new ArrayList();
+ private List<String> loanoutIdsCreated = new ArrayList<String>();
+ private List<String> personIdsCreated = new ArrayList<String>();
private int CREATED_STATUS = Response.Status.CREATED.getStatusCode();
private int OK_STATUS = Response.Status.OK.getStatusCode();
private String personAuthCSID = null;
}
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Delete Person resource(s) (before PersonAuthority resources).
- ClientResponse<Response> res;
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- res = personAuthClient.deleteItem(personAuthCSID, resourceId);
+ personAuthClient.deleteItem(personAuthCSID, resourceId);
}
// Delete PersonAuthority resource(s).
// Note: Any non-success response is ignored and not reported.
- res = personAuthClient.delete(personAuthCSID);
- // Delete Loans In resource(s).
- LoanoutClient loanoutClient = new LoanoutClient();
- for (String resourceId : loanoutIdsCreated) {
- // Note: Any non-success responses are ignored and not reported.
- res = loanoutClient.delete(resourceId);
+ if (personAuthCSID != null) {
+ personAuthClient.delete(personAuthCSID);
+ // Delete Loans In resource(s).
+ LoanoutClient loanoutClient = new LoanoutClient();
+ for (String resourceId : loanoutIdsCreated) {
+ // Note: Any non-success responses are ignored and not reported.
+ loanoutClient.delete(resourceId);
+ }
}
}
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.context.MultipartServiceContext;
-import org.collectionspace.services.common.context.MultipartServiceContextFactory;
import org.collectionspace.services.common.context.MultipartServiceContextImpl;
import org.collectionspace.services.common.context.ServiceBindingUtils;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.query.IQueryManager;
import org.collectionspace.services.common.query.QueryManager;
import org.collectionspace.services.common.security.UnauthorizedException;
-import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
try {
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).getAll(ctx, handler);
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
loanoutObjectList = (LoansoutCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
Response response = Response.status(
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentWrapper<DocumentModel> docWrapper =
getRepositoryClient(ctx).getDoc(ctx, csid);
- RemoteDocumentModelHandlerImpl handler
- = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
+ DocumentModelHandler<MultipartInput, MultipartOutput> handler
+ = (DocumentModelHandler<MultipartInput, MultipartOutput>)createDocumentHandler(ctx);
List<String> authRefFields =
((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
if (logger.isDebugEnabled()) {
logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
}
- getRepositoryClient(ctx).getFiltered(ctx, handler);
- } else {
- getRepositoryClient(ctx).getAll(ctx, handler);
- }
+ }
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
loansoutObjectList = (LoansoutCommonList) handler.getCommonPartList();
-
} catch (UnauthorizedException ue) {
Response response = Response.status(
Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
+/**
+ * OrgAuthorityClient.java
+ *
+ * {Purpose of This Class}
+ *
+ * {Other Notes Relating to This Class (Optional)}
+ *
+ * $LastChangedBy: $
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ *
+ * 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 {Contributing Institution}
+ *
+ * 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;
-import javax.ws.rs.PathParam;
+//import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
/**
- * A OrgAuthorityClient.
-
- * @version $Revision:$
+ * The Class OrgAuthorityClient.
*/
public class OrgAuthorityClient extends AbstractServiceClientImpl {
return "orgauthorities";
}
- public String getItemCommonPartName() {
- return getCommonPartName("organizations");
- }
- /**
- *
- */
- private static final OrgAuthorityClient instance = new OrgAuthorityClient();
/**
+ * Gets the item common part name.
*
+ * @return the item common part name
*/
+ public String getItemCommonPartName() {
+ return getCommonPartName("organizations");
+ }
+
+ /** The Constant instance. */ //FIXME: This is wrong. There should NOT be a static instance of the OrgAuthorityClient class
+// private static final OrgAuthorityClient instance = new OrgAuthorityClient();
+
+ /** The org authority proxy. */
private OrgAuthorityProxy orgAuthorityProxy;
/**
- *
- * Default constructor for OrgAuthorityClient class.
- *
+ * Instantiates a new org authority client.
*/
public OrgAuthorityClient() {
ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
setProxy();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
+ */
@Override
public CollectionSpaceProxy getProxy() {
return this.orgAuthorityProxy;
}
/**
- * allow to reset proxy as per security needs
+ * Sets the proxy.
*/
public void setProxy() {
if (useAuth()) {
}
/**
- * FIXME Comment this
+ * Gets the single instance of OrgAuthorityClient.
*
- * @return
+ * @return single instance of OrgAuthorityClient //FIXME: This is wrong. There should NOT be a static instance of the client
*/
- public static OrgAuthorityClient getInstance() {
- return instance;
- }
+// public static OrgAuthorityClient getInstance() {
+// return instance;
+// }
/**
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#readList()
+ * Read list.
+ *
+ * @return the client response
*/
public ClientResponse<OrgauthoritiesCommonList> readList() {
return orgAuthorityProxy.readList();
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#read(java.lang.String)
+ * Read.
+ *
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<MultipartInput> read(String csid) {
return orgAuthorityProxy.read(csid);
}
/**
- * @param name
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#readByName(java.lang.String)
+ * Read by name.
+ *
+ * @param name the name
+ * @return the client response
*/
public ClientResponse<MultipartInput> readByName(String name) {
return orgAuthorityProxy.readByName(name);
}
/**
- * @param orgAuthority
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#createOrgAuthority(org.collectionspace.hello.OrgAuthority)
+ * Creates the.
+ *
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<Response> create(MultipartOutput multipart) {
return orgAuthorityProxy.create(multipart);
}
/**
- * @param csid
- * @param orgAuthority
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#updateOrgAuthority(java.lang.Long, org.collectionspace.hello.OrgAuthority)
+ * Update.
+ *
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
return orgAuthorityProxy.update(csid, multipart);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#deleteOrgAuthority(java.lang.Long)
+ * Delete.
+ *
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<Response> delete(String csid) {
return orgAuthorityProxy.delete(csid);
}
/**
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#readItemList()
+ * Read item list.
+ *
+ * @param vcsid the vcsid
+ * @return the client response
*/
public ClientResponse<OrganizationsCommonList> readItemList(String vcsid) {
return orgAuthorityProxy.readItemList(vcsid);
}
/**
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#readItemListForNamedAuthority()
+ * Read item list for named authority.
+ *
+ * @param specifier the specifier
+ * @return the client response
*/
public ClientResponse<OrganizationsCommonList> readItemListForNamedAuthority(String specifier) {
return orgAuthorityProxy.readItemListForNamedAuthority(specifier);
}
+ /**
+ * Gets the item authority refs.
+ *
+ * @param parentcsid the parentcsid
+ * @param csid the csid
+ * @return the item authority refs
+ */
public ClientResponse<AuthorityRefList> getItemAuthorityRefs(String parentcsid, String csid) {
return orgAuthorityProxy.getItemAuthorityRefs(parentcsid, csid);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#read(java.lang.String)
+ * Read item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<MultipartInput> readItem(String vcsid, String csid) {
return orgAuthorityProxy.readItem(vcsid, csid);
}
/**
- * @param orgAuthority
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#createOrgAuthority(org.collectionspace.hello.OrgAuthority)
+ * Creates the item.
+ *
+ * @param vcsid the vcsid
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<Response> createItem(String vcsid, MultipartOutput multipart) {
return orgAuthorityProxy.createItem(vcsid, multipart);
}
/**
- * @param csid
- * @param orgAuthority
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#updateOrgAuthority(java.lang.Long, org.collectionspace.hello.OrgAuthority)
+ * Update item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<MultipartInput> updateItem(String vcsid, String csid, MultipartOutput multipart) {
return orgAuthorityProxy.updateItem(vcsid, csid, multipart);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.OrgAuthorityProxy#deleteOrgAuthority(java.lang.Long)
+ * Delete item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<Response> deleteItem(String vcsid, String csid) {
return orgAuthorityProxy.deleteItem(vcsid, csid);
}
+ /**
+ * Creates the contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param multipart the multipart
+ * @return the client response
+ */
public ClientResponse<Response> createContact(String parentcsid,
String itemcsid, MultipartOutput multipart) {
return orgAuthorityProxy.createContact(parentcsid, itemcsid, multipart);
}
+ /**
+ * Read contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @return the client response
+ */
public ClientResponse<MultipartInput> readContact(String parentcsid,
String itemcsid, String csid) {
return orgAuthorityProxy.readContact(parentcsid, itemcsid, csid);
}
+ /**
+ * Read contact list.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @return the client response
+ */
public ClientResponse<ContactsCommonList> readContactList(String parentcsid,
String itemcsid) {
return orgAuthorityProxy.readContactList(parentcsid, itemcsid);
}
+ /**
+ * Update contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
+ */
public ClientResponse<MultipartInput> updateContact(String parentcsid,
String itemcsid, String csid, MultipartOutput multipart) {
return orgAuthorityProxy.updateContact(parentcsid, itemcsid, csid, multipart);
}
+ /**
+ * Delete contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @return the client response
+ */
public ClientResponse<Response> deleteContact(String parentcsid,
String itemcsid, String csid) {
return orgAuthorityProxy.deleteContact(parentcsid,
+/**
+ * PersonAuthorityClient.java
+ *
+ * {Purpose of This Class}
+ *
+ * {Other Notes Relating to This Class (Optional)}
+ *
+ * $LastChangedBy: $
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ *
+ * 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 {Contributing Institution}
+ *
+ * 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;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
-import org.collectionspace.services.common.authorityref.AuthorityRefList;
+//import org.collectionspace.services.common.authorityref.AuthorityRefList;
import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.person.PersonauthoritiesCommonList;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
/**
- * A PersonAuthorityClient.
-
- * @version $Revision:$
+ * The Class PersonAuthorityClient.
*/
public class PersonAuthorityClient extends AbstractServiceClientImpl {
return "personauthorities";
}
+ /**
+ * Gets the item common part name.
+ *
+ * @return the item common part name
+ */
public String getItemCommonPartName() {
return getCommonPartName("persons");
}
- /**
- *
- */
- private static final PersonAuthorityClient instance = new PersonAuthorityClient();
+ /** The person authority proxy. */
+// private static final PersonAuthorityClient instance = new PersonAuthorityClient();
+
/**
*
*/
private PersonAuthorityProxy personAuthorityProxy;
/**
- *
- * Default constructor for PersonAuthorityClient class.
- *
+ * Instantiates a new person authority client.
*/
public PersonAuthorityClient() {
ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
setProxy();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
+ */
@Override
public CollectionSpaceProxy getProxy() {
return this.personAuthorityProxy;
}
/**
- * allow to reset proxy as per security needs
+ * Sets the proxy.
*/
public void setProxy() {
if (useAuth()) {
}
/**
- * FIXME Comment this
+ * Read list.
*
- * @return
+ * @return the client response
*/
- public static PersonAuthorityClient getInstance() {
- return instance;
- }
+// public static PersonAuthorityClient getInstance() {
+// return instance;
+// }
/**
- * @return
+ * @return list
* @see org.collectionspace.services.client.PersonAuthorityProxy#readList()
*/
public ClientResponse<PersonauthoritiesCommonList> readList() {
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#read(java.lang.String)
+ * Read.
+ *
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<MultipartInput> read(String csid) {
return personAuthorityProxy.read(csid);
}
/**
- * @param name
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#readByName(java.lang.String)
+ * Read by name.
+ *
+ * @param name the name
+ * @return the client response
*/
public ClientResponse<MultipartInput> readByName(String name) {
return personAuthorityProxy.readByName(name);
}
/**
- * @param personAuthority
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#createPersonAuthority(org.collectionspace.hello.PersonAuthority)
+ * Creates the.
+ *
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<Response> create(MultipartOutput multipart) {
return personAuthorityProxy.create(multipart);
}
/**
- * @param csid
- * @param personAuthority
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#updatePersonAuthority(java.lang.Long, org.collectionspace.hello.PersonAuthority)
+ * Update.
+ *
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
return personAuthorityProxy.update(csid, multipart);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#deletePersonAuthority(java.lang.Long)
+ * Delete.
+ *
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<Response> delete(String csid) {
return personAuthorityProxy.delete(csid);
}
/**
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#readItemList()
+ * Read item list.
+ *
+ * @param vcsid the vcsid
+ * @return the client response
*/
public ClientResponse<PersonsCommonList> readItemList(String vcsid) {
return personAuthorityProxy.readItemList(vcsid);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.IntakeProxy#getAuthorityRefs(java.lang.String)
+ * Gets the referencing objects.
+ *
+ * @param parentcsid the parentcsid
+ * @param csid the csid
+ * @return the referencing objects
*/
public ClientResponse<AuthorityRefDocList> getReferencingObjects(String parentcsid, String csid) {
return personAuthorityProxy.getReferencingObjects(parentcsid, csid);
}
/**
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#readItemListForNamedAuthority()
+ * Read item list for named authority.
+ *
+ * @param specifier the specifier
+ * @return the client response
*/
public ClientResponse<PersonsCommonList> readItemListForNamedAuthority(String specifier) {
return personAuthorityProxy.readItemListForNamedAuthority(specifier);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#read(java.lang.String)
+ * Read item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<MultipartInput> readItem(String vcsid, String csid) {
return personAuthorityProxy.readItem(vcsid, csid);
}
/**
- * @param personAuthority
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#createPersonAuthority(org.collectionspace.hello.PersonAuthority)
+ * Creates the item.
+ *
+ * @param vcsid the vcsid
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<Response> createItem(String vcsid, MultipartOutput multipart) {
return personAuthorityProxy.createItem(vcsid, multipart);
}
/**
- * @param csid
- * @param personAuthority
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#updatePersonAuthority(java.lang.Long, org.collectionspace.hello.PersonAuthority)
+ * Update item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<MultipartInput> updateItem(String vcsid, String csid, MultipartOutput multipart) {
return personAuthorityProxy.updateItem(vcsid, csid, multipart);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.PersonAuthorityProxy#deletePersonAuthority(java.lang.Long)
+ * Delete item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<Response> deleteItem(String vcsid, String csid) {
return personAuthorityProxy.deleteItem(vcsid, csid);
}
+ /**
+ * Creates the contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param multipart the multipart
+ * @return the client response
+ */
public ClientResponse<Response> createContact(String parentcsid,
String itemcsid, MultipartOutput multipart) {
return personAuthorityProxy.createContact(parentcsid, itemcsid, multipart);
}
+ /**
+ * Read contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @return the client response
+ */
public ClientResponse<MultipartInput> readContact(String parentcsid,
String itemcsid, String csid) {
return personAuthorityProxy.readContact(parentcsid, itemcsid, csid);
}
+ /**
+ * Read contact list.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @return the client response
+ */
public ClientResponse<ContactsCommonList> readContactList(String parentcsid,
String itemcsid) {
return personAuthorityProxy.readContactList(parentcsid, itemcsid);
}
+ /**
+ * Update contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
+ */
public ClientResponse<MultipartInput> updateContact(String parentcsid,
String itemcsid, String csid, MultipartOutput multipart) {
return personAuthorityProxy.updateContact(parentcsid, itemcsid, csid, multipart);
}
+ /**
+ * Delete contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @return the client response
+ */
public ClientResponse<Response> deleteContact(String parentcsid,
String itemcsid, String csid) {
return personAuthorityProxy.deleteContact(parentcsid,
<name>log4j.configuration</name>
<value>file:${project.build.directory}/test-classes/log4j.properties</value>
</property>
+ <property>
+ <name>maven.basedir</name>
+ <value>${basedir}</value>
+ </property>
</systemProperties>
</configuration>
</plugin>
*/
public class RelationServiceTest extends AbstractServiceTestImpl {
+ /** The logger. */
private final Logger logger =
LoggerFactory.getLogger(RelationServiceTest.class);
+ /** The SERVIC e_ pat h_ component. */
final String SERVICE_PATH_COMPONENT = "relations";
+
+ /** The known resource id. */
private String knownResourceId = null;
+
+ /** The all resource ids created. */
private List<String> allResourceIdsCreated = new ArrayList<String>();
/* (non-Javadoc)
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+ */
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
@Override
public void create(String testName) throws Exception {
allResourceIdsCreated.add(extractId(res));
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+ */
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"create"})
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+ */
+ @Override
public void createWithEmptyEntityBody(String testName) throws Exception {
+ //Should this test really be empty?
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+ */
+ @Override
public void createWithMalformedXml(String testName) throws Exception {
+ //Should this test really be empty?
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+ */
+ @Override
public void createWithWrongXmlSchema(String testName) throws Exception {
+ //Should this test really be empty?
}
/*
// CRUD tests : READ tests
// ---------------------------------------------------------------
// Success outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+ */
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"create"})
}
// Failure outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+ */
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"read"})
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
+ */
+ @Test(dataProvider = "testName")
+ /*
+ * FIXME: Until the Relation service uses NXQL queries to get results,
+ * we need to skip the pagination tests
+ */
+ @Override
+ public void readPaginatedList(String testName) throws Exception {
+ //Override and skip the pagination tests
+ }
+
// ---------------------------------------------------------------
// CRUD tests : READ_LIST tests
// ---------------------------------------------------------------
// Success outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+ */
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"createList", "read"})
// ---------------------------------------------------------------
// Success outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+ */
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"read"})
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+ */
+ @Override
public void updateWithEmptyEntityBody(String testName) throws Exception {
+ //Should this test really be empty?
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+ */
+ @Override
public void updateWithMalformedXml(String testName) throws Exception {
+ //Should this test really be empty?
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+ */
+ @Override
public void updateWithWrongXmlSchema(String testName) throws Exception {
+ //Should this test really be empty?
}
/*
}
*/
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+ */
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"update", "testSubmitRequest"})
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
// Success outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+ */
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
}
// Failure outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+ */
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"delete"})
// ---------------------------------------------------------------
// RELATE_OBJECT tests
// ---------------------------------------------------------------
+ /**
+ * Relate objects.
+ */
@Test(dependsOnMethods = {"create"})
public void relateObjects() {
+ //Should this test really be empty?
}
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+ */
@Override
public String getServicePathComponent() {
return SERVICE_PATH_COMPONENT;
}
+ /**
+ * Creates the relation instance.
+ *
+ * @param identifier the identifier
+ * @return the multipart output
+ */
private MultipartOutput createRelationInstance(String identifier) {
RelationsCommon relation = new RelationsCommon();
fillRelation(relation, identifier);
/**
* Fills the relation.
- *
+ *
+ * @param relation the relation
* @param identifier the identifier
- *
- * @return the relation
*/
private void fillRelation(RelationsCommon relation, String identifier) {
fillRelation(relation, "Subject-" + identifier,
/**
* Fills the relation.
- *
+ *
+ * @param relation the relation
* @param documentId1 the document id1
* @param documentType1 the document type1
* @param documentId2 the document id2
* @param documentType2 the document type2
* @param rt the rt
- *
- * @return the relation
*/
private void fillRelation(RelationsCommon relation,
String documentId1, String documentType1,
import javax.ws.rs.PathParam;
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;
/**
* Gets the relation.
- *
+ *
+ * @param ui the ui
* @param csid the csid
- *
* @return the relation
*/
@GET
@Path("{csid}")
- public MultipartOutput getRelation(@PathParam("csid") String csid) {
+ public MultipartOutput getRelation(@Context UriInfo ui,
+ @PathParam("csid") String csid) {
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
if (logger.isDebugEnabled()) {
logger.debug("getRelation with csid=" + csid);
}
}
MultipartOutput result = null;
try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, csid, handler);
result = (MultipartOutput) ctx.getOutput();
@GET
@Produces("application/xml")
public RelationsCommonList getRelationList(@Context UriInfo ui) {
- return this.getRelationList(null, null, null);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, null, null, null);
}
/**
@Produces("application/xml")
public RelationsCommonList getRelationList_S(@Context UriInfo ui,
@PathParam("subjectCsid") String subjectCsid) {
- return this.getRelationList(subjectCsid, null, null);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, subjectCsid, null, null);
}
/**
@Produces("application/xml")
public RelationsCommonList getRelationList_P(@Context UriInfo ui,
@PathParam("predicate") String predicate) {
- return this.getRelationList(null, predicate, null);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, null, predicate, null);
}
/**
@Produces("application/xml")
public RelationsCommonList getRelationList_O(@Context UriInfo ui,
@PathParam("objectCsid") String objectCsid) {
- return this.getRelationList(null, null, objectCsid);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, null, null, objectCsid);
}
/**
public RelationsCommonList getRelationList_PS(@Context UriInfo ui,
@PathParam("predicate") String predicate,
@PathParam("subjectCsid") String subjectCsid) {
- return this.getRelationList(subjectCsid, predicate, null);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, subjectCsid, predicate, null);
}
/**
public RelationsCommonList getRelationList_SP(@Context UriInfo ui,
@PathParam("subjectCsid") String subjectCsid,
@PathParam("predicate") String predicate) {
- return this.getRelationList(subjectCsid, predicate, null);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, subjectCsid, predicate, null);
}
/**
public RelationsCommonList getRelationList_PO(@Context UriInfo ui,
@PathParam("predicate") String predicate,
@PathParam("objectCsid") String objectCsid) {
- return this.getRelationList(null, predicate, objectCsid);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, null, predicate, objectCsid);
}
/**
public RelationsCommonList getRelationList_OP(@Context UriInfo ui,
@PathParam("objectCsid") String objectCsid,
@PathParam("predicate") String predicate) {
- return this.getRelationList(null, predicate, objectCsid);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, null, predicate, objectCsid);
}
/**
@PathParam("predicate") String predicate,
@PathParam("subjectCsid") String subjectCsid,
@PathParam("objectCsid") String objectCsid) {
- return this.getRelationList(subjectCsid, predicate, objectCsid);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, subjectCsid, predicate, objectCsid);
}
/**
@PathParam("subjectCsid") String subjectCsid,
@PathParam("predicate") String predicate,
@PathParam("objectCsid") String objectCsid) {
- return this.getRelationList(subjectCsid, predicate, objectCsid);
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ return this.getRelationList(queryParams, subjectCsid, predicate, objectCsid);
}
/*
}
/**
- * Gets the relation list request.
- *
- * @return the relation list request
- *
- * @throws WebApplicationException
- * the web application exception
+ * Gets the relation list.
+ *
+ * @param queryParams the query params
+ * @param subjectCsid the subject csid
+ * @param predicate the predicate
+ * @param objectCsid the object csid
+ * @return the relation list
+ * @throws WebApplicationException the web application exception
*/
- public RelationsCommonList getRelationList(String subjectCsid,
- String predicate, String objectCsid) throws WebApplicationException {
+ public RelationsCommonList getRelationList(
+ MultivaluedMap<String, String> queryParams,
+ String subjectCsid,
+ String predicate,
+ String objectCsid) throws WebApplicationException {
RelationsCommonList relationList = new RelationsCommonList();
try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
DocumentHandler handler = createDocumentHandler(ctx);
Map<String, Object> propsFromPath = handler.getProperties();
propsFromPath.put(IRelationsManager.SUBJECT, subjectCsid);
propsFromPath.put(IRelationsManager.PREDICATE, predicate);
propsFromPath.put(IRelationsManager.OBJECT, objectCsid);
+ // Until we replace this with a search, "getAll()" is better then "getFiltered"
getRepositoryClient(ctx).getAll(ctx, handler);
relationList = (RelationsCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
+/**
+ * VocabularyClient.java
+ *
+ * {Purpose of This Class}
+ *
+ * {Other Notes Relating to This Class (Optional)}
+ *
+ * $LastChangedBy: $
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ *
+ * 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 {Contributing Institution}
+ *
+ * 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;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
/**
- * A VocabularyClient.
-
- * @version $Revision:$
+ * The Class VocabularyClient.
*/
public class VocabularyClient extends AbstractServiceClientImpl {
return "vocabularies";
}
- public String getItemCommonPartName() {
- return getCommonPartName("vocabularyitems");
- }
- /**
- *
- */
- private static final VocabularyClient instance = new VocabularyClient();
/**
+ * Gets the item common part name.
*
+ * @return the item common part name
*/
+ public String getItemCommonPartName() {
+ return getCommonPartName("vocabularyitems");
+ }
+
+ /** The Constant instance. */ //FIXME: This is wrong. There should not be a static instance of the client.
+// private static final VocabularyClient instance = new VocabularyClient();
+
+ /** The vocabulary proxy. */
private VocabularyProxy vocabularyProxy;
/**
- *
- * Default constructor for VocabularyClient class.
- *
+ * Instantiates a new vocabulary client.
*/
public VocabularyClient() {
ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
setProxy();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
+ */
@Override
public CollectionSpaceProxy getProxy() {
return this.vocabularyProxy;
}
/**
- * allow to reset proxy as per security needs
+ * Sets the proxy.
*/
public void setProxy() {
if (useAuth()) {
}
/**
- * FIXME Comment this
+ * Gets the single instance of VocabularyClient.
*
- * @return
+ * @return single instance of VocabularyClient //FIXME: This is wrong. There should not be a static instance of the client.
*/
- public static VocabularyClient getInstance() {
- return instance;
- }
+// public static VocabularyClient getInstance() {
+// return instance;
+// }
/**
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#readList()
+ * Read list.
+ *
+ * @return the client response
*/
public ClientResponse<VocabulariesCommonList> readList() {
return vocabularyProxy.readList();
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#read(java.lang.String)
+ * Read.
+ *
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<MultipartInput> read(String csid) {
return vocabularyProxy.read(csid);
}
/**
- * @param vocabulary
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#createVocabulary(org.collectionspace.hello.Vocabulary)
+ * Creates the.
+ *
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<Response> create(MultipartOutput multipart) {
return vocabularyProxy.create(multipart);
}
/**
- * @param csid
- * @param vocabulary
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#updateVocabulary(java.lang.Long, org.collectionspace.hello.Vocabulary)
+ * Update.
+ *
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
return vocabularyProxy.update(csid, multipart);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#deleteVocabulary(java.lang.Long)
+ * Delete.
+ *
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<Response> delete(String csid) {
return vocabularyProxy.delete(csid);
}
/**
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#readItemList()
+ * Read item list.
+ *
+ * @param vcsid the vcsid
+ * @return the client response
*/
public ClientResponse<VocabularyitemsCommonList> readItemList(String vcsid) {
return vocabularyProxy.readItemList(vcsid);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#read(java.lang.String)
+ * Read item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<MultipartInput> readItem(String vcsid, String csid) {
return vocabularyProxy.readItem(vcsid, csid);
}
/**
- * @param vocabulary
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#createVocabulary(org.collectionspace.hello.Vocabulary)
+ * Creates the item.
+ *
+ * @param vcsid the vcsid
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<Response> createItem(String vcsid, MultipartOutput multipart) {
return vocabularyProxy.createItem(vcsid, multipart);
}
/**
- * @param csid
- * @param vocabulary
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#updateVocabulary(java.lang.Long, org.collectionspace.hello.Vocabulary)
+ * Update item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
*/
public ClientResponse<MultipartInput> updateItem(String vcsid, String csid, MultipartOutput multipart) {
return vocabularyProxy.updateItem(vcsid, csid, multipart);
}
/**
- * @param csid
- * @return
- * @see org.collectionspace.services.client.VocabularyProxy#deleteVocabulary(java.lang.Long)
+ * Delete item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @return the client response
*/
public ClientResponse<Response> deleteItem(String vcsid, String csid) {
return vocabularyProxy.deleteItem(vcsid, csid);