import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.relation.RelationsCommon;
-import org.jboss.resteasy.client.ClientResponse;
/**
* The Class CollectionSpaceIntegrationTest.
return Long.toString(identifier);
}
- /**
- * Extract id.
- *
- * @param res the res
- *
- * @return the string
- */
- String extractId(ClientResponse<Response> res) {
- String result = null;
-
- MultivaluedMap mvm = res.getMetadata();
- String uri = (String) ((ArrayList) mvm.get("Location")).get(0);
- verbose("extractId:uri=" + uri);
- String[] segments = uri.split("/");
- result = segments[segments.length - 1];
- verbose("id=" + result);
-
- return result;
- }
-
String extractId(Response res) {
String result = null;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.jboss.resteasy.client.ClientResponse;
-
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.DimensionClient;
import org.collectionspace.services.client.DimensionFactory;
Response workflowResponse = dimensionClient.updateWorkflowWithTransition(
dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
+ workflowResponse.close();
// Finally, try to delete the relationship
// Also, try to soft-delete. This should also fail.
workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_DELETE);
System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
+ workflowResponse.close();
}
@Test void createCollectionObjectRelationshipToManyDimensions() {
// Now try to retrieve the Intake record of the CollectionObject.
//
String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.toString();
- ClientResponse<RelationsCommonList> resultResponse = relationClient.readList(
+ Response resultResponse = relationClient.readList(
collectionObjectCsid,
null, //CollectionobjectsCommon.class.getSimpleName(),
predicate,
RelationsCommonList relationList = null;
try {
Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
- relationList = resultResponse.getEntity();
+ relationList = resultResponse.readEntity(RelationsCommonList.class);
} finally {
resultResponse.close();
}
multiPartResponse = relationClient.read(foundCsid);
int responseStatus = multiPartResponse.getStatus();
Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
- PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(multiPartResponse.readEntity(String.class));
resultRelation = (RelationsCommon) extractPart(input,
relationClient.getCommonPartName(),
RelationsCommon.class);
String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.toString();
RelationsCommonList relationList = null;
for (String collectionObjectCsid : collectionObjectIDList) {
- ClientResponse<RelationsCommonList> resultResponse = relationClient.readList(
+ Response resultResponse = relationClient.readList(
intakeCsid,
null, //IntakesCommon.class.getSimpleName(), //subject
predicate,
try {
Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
- relationList = resultResponse.getEntity();
+ relationList = resultResponse.readEntity(RelationsCommonList.class);
} finally {
resultResponse.close();
}
multiPartResponse = relationClient.read(foundCsid);
int responseStatus = multiPartResponse.getStatus();
Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
- PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(multiPartResponse.readEntity(String.class));
resultRelation = (RelationsCommon) extractPart(input,
relationClient.getCommonPartName(),
RelationsCommon.class);
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.relation.RelationsCommon;
import org.collectionspace.services.relation.RelationshipType;
-import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.plugins.providers.multipart.InputPart;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
return Long.toString(identifier);
}
- /**
- * Extract id.
- *
- * @param res the res
- *
- * @return the string
- */
- String extractId(ClientResponse<Response> res) {
- String result = null;
-
- MultivaluedMap mvm = res.getMetadata();
- String uri = (String) ((ArrayList) mvm.get("Location")).get(0);
- verbose("extractId:uri=" + uri);
- String[] segments = uri.split("/");
- result = segments[segments.length - 1];
- verbose("id=" + result);
-
- return result;
- }
-
String extractId(Response res) {
String result = null;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.jboss.resteasy.util.HttpResponseCodes;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.util.HttpResponseCodes;
+
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.PayloadOutputPart;
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
long totalTime = 0;
- ClientResponse<Response> response;
+ Response response;
for (int i = 0; i < numOfCalls; i++) {
Date startTime = new Date();
response = collectionObjectClient.roundtrip(0);
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.account.AccountsCommonList;
* @return response
* @see org.collectionspace.hello.client.AccountProxy#readList()
*/
- public ClientResponse<AccountsCommonList> readList() {
+ public Response readList() {
return getProxy().readList();
}
- public ClientResponse<AccountsCommonList> readSearchList(String screenName, String uid, String email) {
+ public Response readSearchList(String screenName, String uid, String email) {
return getProxy().readSearchList(screenName, uid, email);
}
* @return response
* @see org.collectionspace.hello.client.AccountProxy#getAccount(java.lang.String)
*/
- public ClientResponse<AccountsCommon> read(String csid) {
+ public Response read(String csid) {
return getProxy().read(csid);
}
* @return response
* @see org.collectionspace.hello.client.AccountProxy#create(org.collectionspace.services.account.AccountsCommon)
*/
- public ClientResponse<Response> create(AccountsCommon multipart) {
+ public Response create(AccountsCommon multipart) {
return getProxy().create(multipart);
}
* @return response
* @see org.collectionspace.hello.client.AccountProxy#updateAccount(java.lang.Long, org.collectionspace.services.account.AccountsCommon)
*/
- public ClientResponse<AccountsCommon> update(String csid, AccountsCommon multipart) {
+ public Response update(String csid, AccountsCommon multipart) {
return getProxy().update(csid, multipart);
}
}
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.account.AccountsCommonList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
@GET
@Produces({"application/xml"})
- ClientResponse<AccountsCommonList> readList();
+ Response readList();
@GET
@Produces({"application/xml"})
- ClientResponse<AccountsCommonList> readSearchList(@QueryParam("sn") String screenName, @QueryParam("uid") String uid, @QueryParam("email") String email);
+ Response readSearchList(@QueryParam("sn") String screenName, @QueryParam("uid") String uid, @QueryParam("email") String email);
//(C)reate
@POST
- ClientResponse<Response> create(AccountsCommon multipart);
+ Response create(AccountsCommon multipart);
//(R)ead
@GET
@Path("/{csid}")
- ClientResponse<AccountsCommon> read(@PathParam("csid") String csid);
+ Response read(@PathParam("csid") String csid);
//(U)pdate
@PUT
@Path("/{csid}")
- ClientResponse<AccountsCommon> update(@PathParam("csid") String csid, AccountsCommon multipart);
+ Response update(@PathParam("csid") String csid, AccountsCommon multipart);
}
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.jaxb.AbstractCommonList;
* @return
* @see
*/
- public ClientResponse<AccountRole> read(String csid, String arcsid) {
+ public Response read(String csid, String arcsid) {
return getProxy().read(csid, arcsid);
}
* @param arcsid the arcsid
* @return the client response
*/
- public ClientResponse<AccountRole> read(String csid) {
+ public Response read(String csid) {
return getProxy().read(csid);
}
* @return
* @see
*/
- public ClientResponse<Response> create(String csid, AccountRole accRole) {
+ public Response create(String csid, AccountRole accRole) {
return getProxy().create(csid, accRole);
}
*
*/
@Override
- public ClientResponse<AccountRole> update(String csid, AccountRole payload) {
+ public Response update(String csid, AccountRole payload) {
throw new RuntimeException("You cannot update an AccountRole object. You must delete and recreate it instead.");
}
* @return
* @see
*/
- public ClientResponse<Response> delete(String csid, AccountRole accRole) {
+ public Response delete(String csid, AccountRole accRole) {
return getProxy().delete(csid, "delete", accRole);
}
* Not supported.
*/
@Override
- public ClientResponse<Response> create(AccountRole payload) {
+ public Response create(AccountRole payload) {
// Use the create(String csid, AccountRole accRole) method instead
throw new UnsupportedOperationException();
}
@Override
- public ClientResponse<AbstractCommonList> readList() {
+ public Response readList() {
throw new UnsupportedOperationException();
}
}
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.authorization.AccountRole;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
//(C)reate
@POST
@Path("/{csid}/accountroles")
- ClientResponse<Response> create(@PathParam("csid") String csid, AccountRole accRole);
+ Response create(@PathParam("csid") String csid, AccountRole accRole);
//(R)ead
@GET
@Path("/{csid}/accountroles")
- ClientResponse<AccountRole> read(@PathParam("csid") String csid);
+ Response read(@PathParam("csid") String csid);
//(R)ead
@GET
@Path("/{csid}/accountroles/{arcsid}")
- ClientResponse<AccountRole> read(@PathParam("csid") String csid,
+ Response read(@PathParam("csid") String csid,
@PathParam("arcsid") String arcsid);
//(D)elete
@POST
@Path("/{csid}/accountroles")
- ClientResponse<Response> delete(@PathParam("csid") String csid,
+ Response delete(@PathParam("csid") String csid,
@QueryParam("_method") String method,
AccountRole accRole);
//(U)pdate
@PUT
@Path("/{csid}/accountroles")
- ClientResponse<AccountRole> update(@PathParam("csid") String csid, AccountRole role);
+ Response update(@PathParam("csid") String csid, AccountRole role);
//(D)elete
@Override
@DELETE
@Path("/{csid}/accountroles")
- ClientResponse<Response> delete(@PathParam("csid") String csid);
+ Response delete(@PathParam("csid") String csid);
}
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.account.Tenant;
import org.collectionspace.services.account.TenantsList;
* @return response
* @see org.collectionspace.hello.client.TenantProxy#readList()
*/
- public ClientResponse<TenantsList> readList() {
+ public Response readList() {
return getProxy().readList();
}
- public ClientResponse<TenantsList> readSearchList(String name, String disabled) {
+ public Response readSearchList(String name, String disabled) {
return getProxy().readSearchList(name, disabled);
}
* @return response
* @see org.collectionspace.hello.client.TenantProxy#getTenant(java.lang.String)
*/
- public ClientResponse<Tenant> read(String id) {
+ public Response read(String id) {
return getProxy().read(id);
}
* @return response
* @see org.collectionspace.hello.client.TenantProxy#create(org.collectionspace.services.account.Tenant)
*/
- public ClientResponse<Response> create(Tenant multipart) {
+ public Response create(Tenant multipart) {
return getProxy().create(multipart);
}
* @return response
* @see org.collectionspace.hello.client.TenantProxy#updateTenant(java.lang.Long, org.collectionspace.services.account.Tenant)
*/
- public ClientResponse<Tenant> update(String id, Tenant multipart) {
+ public Response update(String id, Tenant multipart) {
return getProxy().update(id, multipart);
}
}
import org.collectionspace.services.account.Tenant;
import org.collectionspace.services.account.TenantsList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
@GET
@Produces({"application/xml"})
- ClientResponse<TenantsList> readList();
+ Response readList();
@GET
@Produces({"application/xml"})
- ClientResponse<TenantsList> readSearchList(
+ Response readSearchList(
@QueryParam("name") String name,
@QueryParam("disabled") String disabled);
//(C)reate
@POST
- ClientResponse<Response> create(Tenant multipart);
+ Response create(Tenant multipart);
//(R)ead
@GET
@Path("/{csid}")
- ClientResponse<Tenant> read(@PathParam("id") String id);
+ Response read(@PathParam("id") String id);
//(U)pdate
@PUT
@Path("/{csid}")
- ClientResponse<Tenant> update(@PathParam("id") String id, Tenant multipart);
+ Response update(@PathParam("id") String id, Tenant multipart);
}
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.AfterClass;
AccountRole accRole = createAccountRoleInstance(av,
roleValues.values(), true, true);
AccountRoleClient client = new AccountRoleClient();
- ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
+ Response res = client.create(av.getAccountId(), accRole);
try {
assertStatusCode(res, testName);
knownResourceId = av.getAccountId();
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
AccountRoleClient client = new AccountRoleClient();
- ClientResponse<AccountRole> res = client.read(
+ Response res = client.read(
accValues.get("acc-role-user2").getAccountId());
try {
// Check the status code of the response: does it match
// the expected response(s)?
assertStatusCode(res, testName);
- AccountRole output = res.getEntity();
+ AccountRole output = res.readEntity(AccountRole.class);
if(logger.isDebugEnabled()) {
org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();
String sOutput = objectAsXmlString(objectFactory.createAccountRole(output), AccountRole.class);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
roleValues.values(), true, true);
AccountRoleClient client = new AccountRoleClient();
setupCreate();
- ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
+ Response res = client.create(av.getAccountId(), accRole);
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
setupRead();
- ClientResponse<AccountRole> res = roleClient.readRoleAccounts(
+ Response res = roleClient.readRoleAccounts(
roleValues.get("ROLE_CO1").getRoleId());
try {
// Check the status code of the response: does it match
// the expected response(s)?
assertStatusCode(res, testName);
- AccountRole output = res.getEntity();
+ AccountRole output = res.readEntity(AccountRole.class);
// Now verify that the role has 2 accounts associate to it.
Assert.assertEquals(output.getAccount().size(), 1);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
//
AccountRoleClient client = new AccountRoleClient();
setupRead();
- ClientResponse<AccountRole> readResponse = client.read(
+ Response readResponse = client.read(
accValues.get("acc-role-user1").getAccountId());
AccountRole toDelete = null;
try {
assertStatusCode(readResponse, testName);
- toDelete = readResponse.getEntity();
+ toDelete = readResponse.readEntity(AccountRole.class);
Assert.assertNotNull(toDelete);
} finally {
if (readResponse != null) {
- readResponse.releaseConnection();
+ readResponse.close();
}
}
setupDelete();
- ClientResponse<Response> res = client.delete(
+ Response res = client.delete(
toDelete.getAccount().get(0).getAccountId(), toDelete); // delete form #1
try {
assertStatusCode(readResponse, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
accValues.get("acc-role-user1").getAccountId());
toDelete = null;
try {
- toDelete = readResponse.getEntity();
+ toDelete = readResponse.readEntity(AccountRole.class);
} finally {
if (readResponse != null) {
- readResponse.releaseConnection();
+ readResponse.close();
}
}
String result = null;
setupCreate();
- ClientResponse<Response> res = accClient.create(account);
+ Response res = accClient.create(account);
try {
assertStatusCode(res, "CreateAccount");
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
if (prebuiltAdminCSID == null) {
setupReadList();
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res =
- client.readSearchList(null, this.prebuiltAdminUserId, null);
+ Response res = client.readSearchList(null, this.prebuiltAdminUserId, null);
try {
assertStatusCode(res, "findPrebuiltAdminAccount");
- AccountsCommonList list = res.getEntity();
+ AccountsCommonList list = res.readEntity(AccountsCommonList.class);
List<AccountListItem> items = list.getAccountListItem();
Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
AccountListItem item = items.get(0);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
roleName, //the display name
"role for " + roleName, true);
setupCreate();
- ClientResponse<Response> res = roleClient.create(role);
+ Response res = roleClient.create(role);
try {
assertStatusCode(res, "CreateRole");
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.client.AccountClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.account.AccountsCommon;
"barney@dinoland.com",
client.getTenantId(), true, false, true, true);
- ClientResponse<Response> res = client.create(account);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.create(account);
+ try {
+ int statusCode = res.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
/**
AccountsCommon account =
createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
client.getTenantId(), true, true, true, true);
- ClientResponse<Response> res = client.create(account);
- int statusCode = res.getStatus();
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.create(account);
+ try {
+ int statusCode = res.getStatus();
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
/**
AccountsCommon account =
createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
client.getTenantId(), true, false, false, true);
- ClientResponse<Response> res = client.create(account);
- int statusCode = res.getStatus();
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.create(account);
+ try {
+ int statusCode = res.getStatus();
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
/**
AccountsCommon account =
createAccountInstance("babybop", "babybop", "hithere08", "babybop.dinoland.com",
client.getTenantId(), true, false, true, true);
- ClientResponse<Response> res = client.create(account);
- int statusCode = res.getStatus();
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.create(account);
+ try {
+ int statusCode = res.getStatus();
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
/**
AccountsCommon account =
createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
client.getTenantId(), false, false, true, true);
- ClientResponse<Response> res = client.create(account);
- int statusCode = res.getStatus();
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.create(account);
+ try {
+ int statusCode = res.getStatus();
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
/**
AccountsCommon account =
createAccountInstance("babybop", "babybop", "shpswd", "babybop@dinoland.com",
client.getTenantId(), true, false, true, true);
- ClientResponse<Response> res = client.create(account);
- int statusCode = res.getStatus();
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.create(account);
+ try {
+ int statusCode = res.getStatus();
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
/**
AccountsCommon account =
createAccountInstance("babybop", "babybop", "hithere08", "babybop/dinoland.com",
client.getTenantId(), false, true, false, false);
- ClientResponse<Response> res = client.create(account);
- int statusCode = res.getStatus();
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.create(account);
+ try {
+ int statusCode = res.getStatus();
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
//
AccountsCommon account1 =
createAccountInstance("curious", "curious", "hithere08", "curious@george.com",
client.getTenantId(), true, false, true, true);
- ClientResponse<Response> res = client.create(account1);
- int statusCode = res.getStatus();
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- allResourceIdsCreated.add(extractId(res));
+ Response res = client.create(account1);
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ allResourceIdsCreated.add(extractId(res));
+ } finally {
+ res.close();
+ }
AccountsCommon account2 =
createAccountInstance("tom", "tom", "hithere09", "tom@jerry.com",
client.getTenantId(), true, false, true, true);
res = client.create(account2);
- statusCode = res.getStatus();
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- allResourceIdsCreated.add(extractId(res));
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ allResourceIdsCreated.add(extractId(res));
+ } finally {
+ res.close();
+ }
AccountsCommon account3 =
createAccountInstance("mj", "mj", "hithere10", "mj@dinoland.com",
client.getTenantId(), true, false, true, true);
res = client.create(account3);
- statusCode = res.getStatus();
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- allResourceIdsCreated.add(extractId(res));
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ allResourceIdsCreated.add(extractId(res));
+ } finally {
+ res.close();
+ }
}
//
// Submit the request to the service and store the response.
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res =
+ Response res =
client.readSearchList("tom", null, null);
try {
assertStatusCode(res, testName);
- AccountsCommonList list = res.getEntity();
+ AccountsCommonList list = res.readEntity(AccountsCommonList.class);
Assert.assertEquals(1, list.getAccountListItem().size());
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res = client.readSearchList(null, "tom", null);
+ Response res = client.readSearchList(null, "tom", null);
try {
assertStatusCode(res, testName);
- AccountsCommonList list = res.getEntity();
+ AccountsCommonList list = res.readEntity(AccountsCommonList.class);
Assert.assertEquals(1, list.getAccountListItem().size());
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res = client.readSearchList(null, null, "dinoland");
+ Response res = client.readSearchList(null, null, "dinoland");
try {
assertStatusCode(res, testName);
- AccountsCommonList list = res.getEntity();
+ AccountsCommonList list = res.readEntity(AccountsCommonList.class);
Assert.assertEquals(2, list.getAccountListItem().size());
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res = client.readSearchList("tom", null, "jerry");
+ Response res = client.readSearchList("tom", null, "jerry");
try {
assertStatusCode(res, testName);
- AccountsCommonList list = res.getEntity();
+ AccountsCommonList list = res.readEntity(AccountsCommonList.class);
Assert.assertEquals(1, list.getAccountListItem().size());
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
setupUpdate();
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
-
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
+ Response res = client.read(knownResourceId);
+ AccountsCommon accountFound = null;
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
+ }
+ accountFound = res.readEntity(AccountsCommon.class);
+ Assert.assertNotNull(accountFound);
+ } finally {
+ res.close();
}
- AccountsCommon accountFound =
- (AccountsCommon) res.getEntity();
- Assert.assertNotNull(accountFound);
//create a new account object to test partial updates
AccountsCommon accountToUpdate = new AccountsCommon();
// Submit the request to the service and store the response.
res = client.update(knownResourceId, accountToUpdate);
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);
+ try {
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ AccountsCommon accountUpdated = res.readEntity(AccountsCommon.class);
+ Assert.assertNotNull(accountUpdated);
+
+// Assert.assertEquals(accountUpdated.getPassword(),
+// accountFound.getPassword(),
+// "Data in updated object did not match submitted data.");
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
- Assert.assertNotNull(accountUpdated);
-
-// Assert.assertEquals(accountUpdated.getPassword(),
-// accountFound.getPassword(),
-// "Data in updated object did not match submitted data.");
}
/**
AccountClient client = new AccountClient();
// Submit the request to the service and store the response.
- ClientResponse<AccountsCommon> res = client.update(knownResourceId, accountToUpdate);
- 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);
+ Response res = client.update(knownResourceId, accountToUpdate);
+ try {
+ 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
-
}
/**
// Perform setup.
setupUpdate();
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
-
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
+ Response res = client.read(knownResourceId);
+ AccountsCommon accountFound = null;
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
+ }
+ accountFound = res.readEntity(AccountsCommon.class);
+ } finally {
+ res.close();
}
- AccountsCommon accountFound = (AccountsCommon) res.getEntity();
AccountsCommon accountToUpdate = new AccountsCommon();
accountToUpdate.setCsid(knownResourceId);
// Submit the request to the service and store the response.
res = client.update(knownResourceId, accountToUpdate);
- 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);
+ try {
+ 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
private void findPrebuiltAdminAccount() {
if (prebuiltAdminCSID == null) {
setupReadList();
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res =
- client.readSearchList(null, this.prebuiltAdminUserId, null);
+ Response res = client.readSearchList(null, this.prebuiltAdminUserId, null);
try {
assertStatusCode(res, "findPrebuiltAdminAccount");
- AccountsCommonList list = res.getEntity();
+ AccountsCommonList list = res.readEntity(AccountsCommonList.class);
List<AccountListItem> items = list.getAccountListItem();
Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
AccountListItem item = items.get(0);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
setupUpdate();
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommon> res = client.read(prebuiltAdminCSID);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Did get on Admin Account to update with ID: " + prebuiltAdminCSID);
+ Response res = client.read(prebuiltAdminCSID);
+ AccountsCommon accountFound = null;
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Did get on Admin Account to update with ID: " + prebuiltAdminCSID);
+ }
+ accountFound = res.readEntity(AccountsCommon.class);
+ Assert.assertNotNull(accountFound);
+ } finally {
+ res.close();
}
- AccountsCommon accountFound = (AccountsCommon) res.getEntity();
- Assert.assertNotNull(accountFound);
-
+
//create a new account object to test partial updates
AccountsCommon accountToUpdate = new AccountsCommon();
accountToUpdate.setCsid(prebuiltAdminCSID);
// Submit the request to the service and store the response.
res = client.update(prebuiltAdminCSID, accountToUpdate);
- 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);
+ try {
+ 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ // Note that the error is not returned, it is just ignored
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ AccountsCommon accountUpdated = res.readEntity(AccountsCommon.class);
+ Assert.assertNotNull(accountUpdated);
+
+ Assert.assertFalse(accountUpdated.getEmail().equals(accountToUpdate.getEmail()),
+ "Admin Account (with metadata lock) allowed update to change the email!");
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- // Note that the error is not returned, it is just ignored
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
- Assert.assertNotNull(accountUpdated);
-
- Assert.assertFalse(accountUpdated.getEmail().equals(accountToUpdate.getEmail()),
- "Admin Account (with metadata lock) allowed update to change the email!");
}
client.getTenantId(), true, false, true, true);
account.setMetadataProtection(AccountClient.IMMUTABLE);
account.setRolesProtection(AccountClient.IMMUTABLE);
- ClientResponse<Response> res = client.create(account);
+ Response res = client.create(account);
String testResourceId = null;
try {
assertStatusCode(res, testName);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
setupRead();
// Submit the request to the service and store the response.
- ClientResponse<AccountsCommon> accountRes = client.read(testResourceId);
+ Response accountRes = client.read(testResourceId);
try {
assertStatusCode(accountRes, testName);
- AccountsCommon accountRead = (AccountsCommon) accountRes.getEntity();
+ AccountsCommon accountRead = accountRes.readEntity(AccountsCommon.class);
Assert.assertNotNull(accountRead);
String mdProtection = accountRead.getMetadataProtection();
String rolesProtection = accountRead.getRolesProtection();
"Account allowed create to set the perms protection flag.");
} finally {
if (accountRes != null) {
- accountRes.releaseConnection();
+ accountRes.close();
}
}
accountRes = client.update(testResourceId, accountToUpdate);
try {
assertStatusCode(accountRes, testName);
- AccountsCommon accountUpdated = (AccountsCommon) accountRes.getEntity();
+ AccountsCommon accountUpdated = accountRes.readEntity(AccountsCommon.class);
Assert.assertNotNull(accountUpdated);
if (logger.isDebugEnabled()) {
logger.debug(testName + "Updated account: ");
- logger.debug(objectAsXmlString(accountUpdated,AccountsCommon.class));
+ logger.debug(objectAsXmlString(accountUpdated, AccountsCommon.class));
}
Assert.assertFalse(
AccountClient.IMMUTABLE.equalsIgnoreCase(accountUpdated.getMetadataProtection()),
"Account allowed update of the roles protection flag.");
} finally {
if (accountRes != null) {
- accountRes.releaseConnection();
+ accountRes.close();
}
}
}
setupUpdate();
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
-
- if (logger.isDebugEnabled()) {
- logger.debug("got object to update with ID: " + knownResourceId);
+ Response res = client.read(knownResourceId);
+ AccountsCommon accountFound = null;
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("got object to update with ID: " + knownResourceId);
+ }
+ accountFound = res.readEntity(AccountsCommon.class);
+ } finally {
+ res.close();
}
- AccountsCommon accountFound = (AccountsCommon) res.getEntity();
-
+
//create a new account object to test partial updates
AccountsCommon accountToUpdate = new AccountsCommon();
accountToUpdate.setCsid(knownResourceId);
// Submit the request to the service and store the response.
res = client.update(knownResourceId, accountToUpdate);
- 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);
+ try {
+ 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ AccountsCommon accountUpdated = res.readEntity(AccountsCommon.class);
+ Assert.assertNotNull(accountUpdated);
+
+ Assert.assertEquals(accountUpdated.getStatus(),
+ accountToUpdate.getStatus(),
+ "Data in updated object did not match submitted data.");
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
- Assert.assertNotNull(accountUpdated);
-
- Assert.assertEquals(accountUpdated.getStatus(),
- accountToUpdate.getStatus(),
- "Data in updated object did not match submitted data.");
}
// Failure outcomes
// Note: The ID used in this 'create' call may be arbitrary.
// The only relevant ID may be the one used in updateAccount(), below.
AccountClient client = new AccountClient();
- AccountsCommon account =
- createAccountInstance("simba", "simba", "tiger", "simba@lionking.com",
+ AccountsCommon account = createAccountInstance("simba", "simba", "tiger", "simba@lionking.com",
client.getTenantId(), true, false, true, true);
- ClientResponse<AccountsCommon> res =
- client.update(NON_EXISTENT_ID, account);
- 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);
+ Response res = client.update(NON_EXISTENT_ID, account);
+ try {
+ 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
}
/**
// Note: The ID used in this 'create' call may be arbitrary.
// The only relevant ID may be the one used in updateAccount(), below.
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
-
- if (logger.isDebugEnabled()) {
- logger.debug("got object to update with ID: " + knownResourceId);
+ Response res = client.read(knownResourceId);
+ AccountsCommon accountToUpdate = null;
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("got object to update with ID: " + knownResourceId);
+ }
+ accountToUpdate = res.readEntity(AccountsCommon.class);
+ Assert.assertNotNull(accountToUpdate);
+ } finally {
+ res.close();
}
- AccountsCommon accountToUpdate =
- (AccountsCommon) res.getEntity();
- Assert.assertNotNull(accountToUpdate);
accountToUpdate.setUserId("barneyFake");
if (logger.isDebugEnabled()) {
}
res = client.update(knownResourceId, accountToUpdate);
- 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);
+ try {
+ 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
// ---------------------------------------------------------------
// Check the status code of the response: does it match
// the expected response(s)?
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
acquisition = (AcquisitionsCommon) extractPart(input,
acquisitionClient.getCommonPartName(), AcquisitionsCommon.class);
Assert.assertNotNull(acquisition);
//
// Get the auth refs and check them
//
- res = acquisitionClient.getAuthorityRefs(knownResourceId);
+ res = acquisitionClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
assertStatusCode(res, testName);
- list = (AuthorityRefList)res.getEntity();
+ list = res.readEntity(AuthorityRefList.class);
Assert.assertNotNull(list);
} finally {
if (res != null) {
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
res.close();
}
}
Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
res.close();
}
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
AcquisitionsCommon updatedAcquisition =
(AcquisitionsCommon) extractPart(input,
client.getCommonPartName(), AcquisitionsCommon.class);
// Check the status code of the response: does it match
// the expected response(s)?
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
if (logger.isDebugEnabled()) {
logger.debug(testName + ": Reading Common part ...");
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.authorization.perms.Permission;
import org.collectionspace.services.authorization.perms.PermissionsList;
* @return
* @see org.collectionspace.hello.client.PermissionProxy#readList()
*/
- public ClientResponse<PermissionsList> readList() {
+ public Response readList() {
return getProxy().readList();
}
- public ClientResponse<PermissionsList> readSearchList(String resourceName) {
+ public Response readSearchList(String resourceName) {
return getProxy().readSearchList(resourceName);
}
* @return
* @see org.collectionspace.hello.client.PermissionProxy#getAccount(java.lang.String)
*/
- public ClientResponse<Permission> read(String csid) {
+ public Response read(String csid) {
return getProxy().read(csid);
}
* @return
* @see org.collectionspace.hello.client.PermissionProxy#create(org.collectionspace.services.permission.Permission)
*/
- public ClientResponse<Response> create(Permission permission) {
+ public Response create(Permission permission) {
return getProxy().create(permission);
}
* @return
* @see org.collectionspace.hello.client.PermissionProxy#updateAccount(java.lang.Long, org.collectionspace.services.permission.Permission)
*/
- public ClientResponse<Permission> update(String csid, Permission permission) {
+ public Response update(String csid, Permission permission) {
return getProxy().update(csid, permission);
}
}
import org.collectionspace.services.authorization.perms.Permission;
import org.collectionspace.services.authorization.perms.PermissionsList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
@GET
@Produces({"application/xml"})
- ClientResponse<PermissionsList> readList();
+ Response readList();
@GET
- ClientResponse<PermissionsList> readSearchList(@QueryParam("res") String resourceName);
+ Response readSearchList(@QueryParam("res") String resourceName);
//(C)reate
@POST
- ClientResponse<Response> create(Permission permission);
+ Response create(Permission permission);
//(R)ead
@GET
@Path("/{csid}")
- ClientResponse<Permission> read(@PathParam("csid") String csid);
+ Response read(@PathParam("csid") String csid);
//(U)pdate
@PUT
@Path("/{csid}")
- ClientResponse<Permission> update(@PathParam("csid") String csid, Permission permission);
+ Response update(@PathParam("csid") String csid, Permission permission);
}
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.authorization.PermissionRole;
/**
* @return the client response
* @see
*/
- public ClientResponse<PermissionRole> read(String csid, String prcsid) {
+ public Response read(String csid, String prcsid) {
return getProxy().read(csid, prcsid);
}
* @return the client response
* @see
*/
- public ClientResponse<PermissionRole> read(String csid) {
+ public Response read(String csid) {
return getProxy().read(csid);
}
* @return the client response
* @see
*/
- public ClientResponse<Response> create(String csid, PermissionRole permRole) {
+ public Response create(String csid, PermissionRole permRole) {
return getProxy().create(csid, permRole);
}
* @param permRole the perm role
* @return the client response
*/
- public ClientResponse<Response> delete(String csid, PermissionRole permRole) {
+ public Response delete(String csid, PermissionRole permRole) {
return getProxy().delete(csid, "delete", permRole);
}
@Override
- public ClientResponse<Response> create(PermissionRole payload) {
+ public Response create(PermissionRole payload) {
throw new UnsupportedOperationException(); //method not supported nor needed
}
@Override
- public ClientResponse<PermissionRole> update(String csid,
+ public Response update(String csid,
PermissionRole payload) {
throw new UnsupportedOperationException(); //method not supported nor needed
}
@Override
- public ClientResponse<PermissionRole> readList() {
+ public Response readList() {
throw new UnsupportedOperationException(); //method not supported nor needed
}
}
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-
import org.collectionspace.services.authorization.PermissionRole;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
//(C)reate
@POST
@Path("/{csid}/permroles")
- ClientResponse<Response> create(@PathParam("csid") String csid, PermissionRole permRole);
+ Response create(@PathParam("csid") String csid, PermissionRole permRole);
//(R)ead
@GET
@Path("/{csid}/permroles")
- ClientResponse<PermissionRole> read(@PathParam("csid") String csid);
+ Response read(@PathParam("csid") String csid);
//(R)ead
@GET
@Path("/{csid}/permroles/{prcsid}")
- ClientResponse<PermissionRole> read(@PathParam("csid") String csid,
+ Response read(@PathParam("csid") String csid,
@PathParam("prcsid") String prcsid);
//(D)elete
@DELETE
@Path("/{csid}/permroles")
- ClientResponse<Response> delete(@PathParam("csid") String csid);
+ Response delete(@PathParam("csid") String csid);
//(D)elete - with a payload
@POST
@Path("/{csid}/permroles")
- ClientResponse<Response> delete(@PathParam("csid") String csid,
+ Response delete(@PathParam("csid") String csid,
@QueryParam("_method") String method,
PermissionRole permRole);
}
import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.authorization.Role;
import org.collectionspace.services.authorization.RolesList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* A RoleClient.
return SERVICE_PATH_COMPONENT;
}
- public ClientResponse<RolesList> readList() {
+ public Response readList() {
return getProxy().readList();
}
- public ClientResponse<RolesList> readSearchList(String roleName) {
+ public Response readSearchList(String roleName) {
return getProxy().readSearchList(roleName);
}
- public ClientResponse<Role> read(String csid) {
+ public Response read(String csid) {
return getProxy().read(csid);
}
- public ClientResponse<AccountRole> readRoleAccounts(String csid) {
+ public Response readRoleAccounts(String csid) {
return getProxy().readRoleAccounts(csid);
}
* @param role the role
* @return the client response
*/
- public ClientResponse<Response> create(Role role) {
+ public Response create(Role role) {
return getProxy().create(role);
}
* @param role
* @return
*/
- public ClientResponse<Role> update(String csid, Role role) {
+ public Response update(String csid, Role role) {
return getProxy().update(csid, role);
}
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.authorization.PermissionRole;
// TODO: Auto-generated Javadoc
* @return the client response
* @see
*/
- public ClientResponse<PermissionRole> read(String csid) {
+ public Response read(String csid) {
return getProxy().read(csid);
}
* @param prcsid the prcsid
* @return the client response
*/
- public ClientResponse<PermissionRole> read(String csid, String prcsid) {
+ public Response read(String csid, String prcsid) {
return getProxy().read(csid, prcsid);
}
* @return the client response
* @see
*/
- public ClientResponse<Response> create(String csid, PermissionRole permRole) {
+ public Response create(String csid, PermissionRole permRole) {
return getProxy().create(csid, permRole);
}
* @param permRole the perm role
* @return the client response
*/
- public ClientResponse<Response> delete(String csid, PermissionRole permRole) {
+ public Response delete(String csid, PermissionRole permRole) {
return getProxy().delete(csid, "delete", permRole);
}
@Override
- public ClientResponse<Response> create(PermissionRole payload) {
+ public Response create(PermissionRole payload) {
throw new UnsupportedOperationException(); //method not supported nor needed
}
@Override
- public ClientResponse<PermissionRole> update(String csid,
+ public Response update(String csid,
PermissionRole payload) {
throw new UnsupportedOperationException(); //method not supported nor needed
}
@Override
- public ClientResponse<PermissionRole> readList() {
+ public Response readList() {
throw new UnsupportedOperationException(); //method not supported nor needed
}
}
import org.collectionspace.services.authorization.PermissionRole;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
//(C)reate
@POST
@Path("/{csid}/permroles")
- ClientResponse<Response> create(@PathParam("csid") String csid, PermissionRole permRole);
+ Response create(@PathParam("csid") String csid, PermissionRole permRole);
//(R)ead
@GET
@Path("/{csid}/permroles")
- ClientResponse<PermissionRole> read(@PathParam("csid") String csid);
+ Response read(@PathParam("csid") String csid);
//(R)ead
@GET
@Path("/{csid}/permroles/{prcsid}")
- ClientResponse<PermissionRole> read(@PathParam("csid") String csid,
+ Response read(@PathParam("csid") String csid,
@PathParam("prcsid") String prcsid);
//(D)elete
@DELETE
@Path("/{csid}/permroles")
- ClientResponse<Response> delete(@PathParam("csid") String csid);
+ Response delete(@PathParam("csid") String csid);
//(D)elete - with a payload
@POST
@Path("/{csid}/permroles")
- ClientResponse<Response> delete(@PathParam("csid") String csid,
+ Response delete(@PathParam("csid") String csid,
@QueryParam("_method") String method,
PermissionRole permRole);
}
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-
-import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.authorization.Role;
import org.collectionspace.services.authorization.RolesList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
@GET
@Produces({"application/xml"})
- ClientResponse<RolesList> readList();
+ Response readList();
@GET
- ClientResponse<RolesList> readSearchList(@QueryParam("r") String roleName);
+ Response readSearchList(@QueryParam("r") String roleName);
//(C)reate
@POST
- ClientResponse<Response> create(Role role);
+ Response create(Role role);
//(R)ead
@GET
@Path("/{csid}")
- ClientResponse<Role> read(@PathParam("csid") String csid);
+ Response read(@PathParam("csid") String csid);
//(R)ead accounts associate with this role
@GET
@Path("{csid}/accountroles")
- ClientResponse<AccountRole> readRoleAccounts(@PathParam("csid") String csid);
+ Response readRoleAccounts(@PathParam("csid") String csid);
//(U)pdate
@PUT
@Path("/{csid}")
- ClientResponse<Role> update(@PathParam("csid") String csid, Role role);
+ Response update(@PathParam("csid") String csid, Role role);
}
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.ServiceRequestType;
-import org.jboss.resteasy.client.ClientResponse;
-
import org.testng.Assert;
import org.testng.annotations.Test;
PermissionRole permRole = createPermissionRoleInstance(pv,
roleValues.values(), true, true);
PermissionRoleClient client = new PermissionRoleClient();
- ClientResponse<Response> res = null;
+
+ Response res = client.create(pv.getPermissionId(), permRole);
try {
- res = client.create(pv.getPermissionId(), permRole);
int statusCode = res.getStatus();
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
PermissionRoleClient client = new PermissionRoleClient();
- ClientResponse<PermissionRole> res = null;
+ Response res = client.read(
+ permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
try {
- res = client.read(
- permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
int statusCode = res.getStatus();
// Check the status code of the response: does it match
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- PermissionRole output = (PermissionRole) res.getEntity();
+ PermissionRole output = res.readEntity(PermissionRole.class);
Assert.assertNotNull(output);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
PermissionRoleClient client = new PermissionRoleClient();
- ClientResponse<PermissionRole> res = null;
+ Response res = null;
try {
res = client.read(NON_EXISTENT_ID);
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
PermissionRoleClient client = new PermissionRoleClient();
- ClientResponse<PermissionRole> res = null;
+ Response res = null;
try {
res = client.read(
permValues.get(TEST_SERVICE_NAME + TEST_MARKER + NO_REL_SUFFIX).getPermissionId());
// Check the status code of the response: does it match
// the expected response(s)?
assertStatusCode(res, testName);
- PermissionRole output = (PermissionRole) res.getEntity();
+ PermissionRole output = res.readEntity(PermissionRole.class);
String sOutput = objectAsXmlString(output, PermissionRole.class);
if (logger.isDebugEnabled()) {
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
//
PermissionRoleClient client = new PermissionRoleClient();
- ClientResponse<PermissionRole> readResponse = client.read(
+ Response readResponse = client.read(
permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
PermissionRole toDelete = null;
try {
- toDelete = readResponse.getEntity();
+ toDelete = readResponse.readEntity(PermissionRole.class);
} finally {
- readResponse.releaseConnection();
+ readResponse.close();
}
- ClientResponse<Response> res = client.delete(
+ Response res = client.delete(
toDelete.getPermission().get(0).getPermissionId(), toDelete);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
toDelete = null;
try {
- toDelete = readResponse.getEntity();
+ toDelete = readResponse.readEntity(PermissionRole.class);
} finally {
- readResponse.releaseConnection();
+ readResponse.close();
}
Response deleteRes = client.delete(toDelete.getPermission().get(0).getPermissionId());
"default permissions for " + resName,
actions, effect, true, true, true);
String id = null;
- ClientResponse<Response> res = null;
+ Response res = permClient.create(permission);
try {
- res = permClient.create(permission);
-
int statusCode = res.getStatus();
if (logger.isDebugEnabled()) {
logger.debug("createPermission: resName=" + resName
id = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
return id;
Role role = RoleFactory.createRoleInstance(roleName,
roleName, //the display name
"role for " + roleName, true);
- ClientResponse<Response> res = null;
+ Response res = null;
String id = null;
try {
res = roleClient.create(role);
id = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return id;
}
import org.collectionspace.services.client.PermissionFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.ServiceRequestType;
-import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
import org.testng.annotations.Test;
true,
true);
PermissionClient client = new PermissionClient();
- ClientResponse<Response> res = client.create(permission);
- int statusCode = res.getStatus();
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.create(permission);
+ try {
+ int statusCode = res.getStatus();
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
/**
// Submit the request to the service and store the response.
PermissionClient client = new PermissionClient();
- ClientResponse<PermissionsList> res = client.readSearchList("acquisition");
+ Response res = client.readSearchList("acquisition");
try {
assertStatusCode(res, testName);
- PermissionsList list = res.getEntity(PermissionsList.class);
+ PermissionsList list = res.readEntity(PermissionsList.class);
int EXPECTED_ITEMS = 2 + 4; //2 seeded base resource permissions and 4 workflow-related permissions
int actual = list.getPermission().size();
if (logger.isDebugEnabled()) {
Assert.assertEquals(list.getPermission().size(), EXPECTED_ITEMS);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
}
PermissionClient client = new PermissionClient();
// Submit the request to the service and store the response.
- ClientResponse<Permission> res = client.update(knownResourceId, permToUpdate);
+ Response res = client.update(knownResourceId, permToUpdate);
int statusCode = res.getStatus();
// Check the status code of the response: does it match the expected response(s)?
if (logger.isDebugEnabled()) {
}
PermissionClient client = new PermissionClient();
// Submit the request to the service and store the response.
- ClientResponse<Permission> res = client.update(knownResourceId, permToUpdate);
+ Response res = client.update(knownResourceId, permToUpdate);
int statusCode = res.getStatus();
// Check the status code of the response: does it match the expected response(s)?
if (logger.isDebugEnabled()) {
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- Permission permUpdated = (Permission) res.getEntity();
+ Permission permUpdated = res.readEntity(Permission.class);
Assert.assertNotNull(permUpdated);
int updated_actions = permToUpdate.getAction().size();
if (logger.isDebugEnabled()) {
true,
true,
true);
- ClientResponse<Permission> res =
- client.update(NON_EXISTENT_ID, permission);
- 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);
+ Response res = client.update(NON_EXISTENT_ID, permission);
+ try {
+ 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
logger.debug("to be created, permission");
logger.debug(objectAsXmlString(permission, Permission.class));
}
+
return permission;
}
import org.collectionspace.services.client.RoleFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.ServiceRequestType;
-import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
import org.testng.annotations.Test;
PermissionRole permRole = createPermissionRoleInstance(rv,
permValues.values(), true, true);
RolePermissionClient client = new RolePermissionClient();
- ClientResponse<Response> res = null;
+ Response res = client.create(rv.getRoleId(), permRole);
try {
- res = client.create(rv.getRoleId(), permRole);
int statusCode = res.getStatus();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
RolePermissionClient client = new RolePermissionClient();
- ClientResponse<PermissionRole> res = null;
+ Response res = client.read(roleValues.get(getRoleName()).getRoleId());
try {
- res = client.read(roleValues.get(getRoleName()).getRoleId());
int statusCode = res.getStatus();
// Check the status code of the response: does it match
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- PermissionRole output = (PermissionRole) res.getEntity();
+ PermissionRole output = res.readEntity(PermissionRole.class);
Assert.assertNotNull(output);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
RolePermissionClient client = new RolePermissionClient();
- ClientResponse<PermissionRole> res = null;
+ Response res = client.read(NON_EXISTENT_ID);
try {
-
- res = client.read(NON_EXISTENT_ID);
int statusCode = res.getStatus();
// Check the status code of the response: does it match
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
setupRead();
// Submit the request to the service and store the response.
RolePermissionClient client = new RolePermissionClient();
- ClientResponse<PermissionRole> res = null;
+ Response res = client.read(roleValues.get(getRoleName() + NO_REL_SUFFIX).getRoleId());
try {
-
- res = client.read(roleValues.get(getRoleName() + NO_REL_SUFFIX).getRoleId());
int statusCode = res.getStatus();
// Check the status code of the response: does it match
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
- PermissionRole output = (PermissionRole) res.getEntity();
+ PermissionRole output = res.readEntity(PermissionRole.class);
String sOutput = objectAsXmlString(output, PermissionRole.class);
if (logger.isDebugEnabled()) {
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
setupDelete();
rv = roleValues.get(getRoleName());
- ClientResponse<PermissionRole> readResponse = client.read(rv.getRoleId());
- PermissionRole toDelete = readResponse.getEntity();
- readResponse.releaseConnection();
+ Response readResponse = client.read(rv.getRoleId());
+ PermissionRole toDelete = null;
+ try {
+ toDelete = readResponse.readEntity(PermissionRole.class);
+ } finally {
+ readResponse.close();
+ }
rv = toDelete.getRole().get(0);
- ClientResponse<Response> res = null;
+ Response res = client.delete(rv.getRoleId(), toDelete);
try {
- res = client.delete(
- rv.getRoleId(), toDelete);
int statusCode = res.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
Permission permission = PermissionFactory.createPermissionInstance(resName,
"default permissions for " + resName,
actions, effect, true, true, true);
- ClientResponse<Response> res = null;
+ Response res = null;
String id = null;
try {
res = permClient.create(permission);
id = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
return id;
roleName, //the display name
"role for " + roleName, true);
role.setRoleGroup("something");
- ClientResponse<Response> res = null;
+ Response res = null;
String id = null;
try {
res = roleClient.create(role);
import org.collectionspace.services.authorization.RolesList;
import org.collectionspace.services.client.RoleFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
-import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
import org.testng.annotations.Test;
RoleClient client = new RoleClient();
Role role = createRoleInstance(knownRoleName, "All users are required to be in this role",
true);
- ClientResponse<Response> res = client.create(role);
+ Response res = client.create(role);
try {
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
Role role = createRoleInstance(knownRoleName + "_" + knownRoleDisplayName,
- "all users are required to be in this role",
- true);
+ "all users are required to be in this role", true);
role.setDisplayName(knownRoleDisplayName);
- ClientResponse<Response> res = client.create(role);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Store the ID returned from this create operation
- // for additional tests below.
- String csid = extractId(res);
- allResourceIdsCreated.add(csid);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": csid=" + csid);
+ Response res = client.create(role);
+ try {
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ //
+ // Specifically:
+ // Does it fall within the set of valid status codes?
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Store the ID returned from this create operation
+ // for additional tests below.
+ String csid = extractId(res);
+ allResourceIdsCreated.add(csid);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": csid=" + csid);
+ }
+ } finally {
+ res.close();
}
}
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
Role role = createRoleInstance(knownRoleName,
- "role users",
- true);
- ClientResponse<Response> res = client.create(role);
- int statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": Role with name \"" +
- knownRoleName + "\" should already exist, so this request should fail.");
- logger.debug(testName + ": status = " + statusCode);
- logger.debug(testName + ": " + res);
+ "role users", true);
+ Response res = client.create(role);
+ try {
+ int statusCode = res.getStatus();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": Role with name \"" +
+ knownRoleName + "\" should already exist, so this request should fail.");
+ logger.debug(testName + ": status = " + statusCode);
+ logger.debug(testName + ": " + res);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
/**
"role users with non-unique display name",
true);
role.setDisplayName(knownRoleDisplayName);
- ClientResponse<Response> res = client.create(role);
- int statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": Role with name \"" +
- knownRoleName + "\" should already exist, so this request should fail.");
- logger.debug(testName + ": status = " + statusCode);
- logger.debug(testName + ": " + res);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- if (statusCode != Response.Status.BAD_REQUEST.getStatusCode()) {
- // If the test fails then we've just created a Role that we need to delete, so
- // store the ID returned from this create operation.
- String csid = extractId(res);
- allResourceIdsCreated.add(csid);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": csid=" + csid);
- }
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ Response res = client.create(role);
+ try {
+ int statusCode = res.getStatus();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": Role with name \"" +
+ knownRoleName + "\" should already exist, so this request should fail.");
+ logger.debug(testName + ": status = " + statusCode);
+ logger.debug(testName + ": " + res);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ if (statusCode != Response.Status.BAD_REQUEST.getStatusCode()) {
+ // If the test fails then we've just created a Role that we need to delete, so
+ // store the ID returned from this create operation.
+ String csid = extractId(res);
+ allResourceIdsCreated.add(csid);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": csid=" + csid);
+ }
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ }
+ } finally {
+ res.close();
}
}
Role role = createRoleInstance("",
"role for users",
false);
- ClientResponse<Response> res = client.create(role);
- int statusCode = res.getStatus();
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.create(role);
+ try {
+ int statusCode = res.getStatus();
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
//to not cause uniqueness violation for role, createList is removed
//create a role with lowercase role name without role prefix
//the service should make it upper case and add the role prefix
Role role1 = createRoleInstance(verifyRoleName,
- "collection manager",
- true);
- ClientResponse<Response> res = client.create(role1);
- int statusCode = res.getStatus();
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- verifyResourceId = extractId(res);
- allResourceIdsCreated.add(verifyResourceId);
+ "collection manager", true);
+ Response res = client.create(role1);
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ verifyResourceId = extractId(res);
+ allResourceIdsCreated.add(verifyResourceId);
+ } finally {
+ res.close();
+ }
Role role2 = createRoleInstance("ROLE_COLLECTIONS_CURATOR_TEST",
- "collections curator",
- true);
+ "collections curator", true);
res = client.create(role2);
- statusCode = res.getStatus();
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- allResourceIdsCreated.add(extractId(res));
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ allResourceIdsCreated.add(extractId(res));
+ } finally {
+ res.close();
+ }
Role role3 = createRoleInstance("ROLE_MOVINGIMAGE_ADMIN_TEST",
- "moving image admin",
- true);
+ "moving image admin", true);
res = client.create(role3);
- statusCode = res.getStatus();
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- allResourceIdsCreated.add(extractId(res));
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ allResourceIdsCreated.add(extractId(res));
+ } finally {
+ res.close();
+ }
}
// Failure outcomes
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
- ClientResponse<Role> res = client.read(knownResourceId);
- 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);
+ Response res = client.read(knownResourceId);
+ try {
+ 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ Role output = res.readEntity(Role.class);
+ Assert.assertNotNull(output);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- Role output = (Role) res.getEntity();
- Assert.assertNotNull(output);
}
@Test(dataProvider = "testName",
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
- ClientResponse<Role> res = client.read(verifyResourceId);
+ Response res = client.read(verifyResourceId);
try {
int statusCode = res.getStatus();
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- Role output = (Role) res.getEntity();
+ Role output = res.readEntity(Role.class);
Assert.assertNotNull(output);
//FIXME: Tenant ID of "1" should not be hard coded
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
- ClientResponse<Role> res = client.read(NON_EXISTENT_ID);
+ Response res = client.read(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
- ClientResponse<RolesList> res = client.readList();
+ Response res = client.readList();
try {
// Check the status code of the response: does it match
// the expected response(s)?
assertStatusCode(res, testName);
- RolesList list = res.getEntity();
+ RolesList list = res.readEntity(RolesList.class);
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
if (iterateThroughList && logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
- ClientResponse<RolesList> res = client.readSearchList("movingImage");
+ Response res = client.readSearchList("movingImage");
try {
assertStatusCode(res, testName);
- RolesList list = res.getEntity();
+ RolesList list = res.readEntity(RolesList.class);
int EXPECTED_ITEMS = 1;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": received = " + list.getRole().size()
}
RoleClient client = new RoleClient();
// Submit the request to the service and store the response.
- ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
+ Response res = client.update(knownResourceId, roleToUpdate);
try {
// Check the status code of the response: does it match the expected response(s)?
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
- Role roleUpdated = (Role) res.getEntity();
+ Role roleUpdated = res.readEntity(Role.class);
Assert.assertNotNull(roleUpdated);
Assert.assertEquals(roleUpdated.getDescription(),
// Submit the create request to the service and store the response.
//
RoleClient client = new RoleClient();
- ClientResponse<Response> res = client.create(role);
+ Response res = client.create(role);
String testResourceId = null;
try {
int statusCode = res.getStatus();
// Next, read back the role we just created.
setupRead();
// Submit the request to the service and store the response.
- ClientResponse<Role> roleRes = client.read(testResourceId);
+ Response roleRes = client.read(testResourceId);
try {
int statusCode = roleRes.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- Role roleRead = (Role) roleRes.getEntity();
+ Role roleRead = roleRes.readEntity(Role.class);
Assert.assertNotNull(roleRead);
String mdProtection = roleRead.getMetadataProtection();
String permsProtection = roleRead.getPermsProtection();
Assert.assertEquals(statusCode, testExpectedStatusCode);
- Role roleUpdated = (Role) roleRes.getEntity();
+ Role roleUpdated = roleRes.readEntity(Role.class);
Assert.assertNotNull(roleUpdated);
if (logger.isDebugEnabled()) {
logger.debug(testName + "Updated role: ");
}
RoleClient client = new RoleClient();
// Submit the request to the service and store the response.
- ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
+ Response res = client.update(knownResourceId, roleToUpdate);
try {
int statusCode = res.getStatus();
// Check the status code of the response: does it match the expected response(s)?
Role role = createRoleInstance("ROLE_XXX",
"xxx",
true);
- ClientResponse<Role> res =
- client.update(NON_EXISTENT_ID, role);
+ Response res = client.update(NON_EXISTENT_ID, role);
try {
int statusCode = res.getStatus();
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
/**
* Blob proxied service calls
*/
- public ClientResponse<Response> createBlobFromFormData(MultipartFormDataOutput formDataOutput) {
+ public Response createBlobFromFormData(MultipartFormDataOutput formDataOutput) {
return getProxy().createBlobFromFormData(formDataOutput);
}
- public ClientResponse<Response> createBlobFromURI(String blobUri) {
+ public Response createBlobFromURI(String blobUri) {
return getProxy().createBlobFromURI("".getBytes(), blobUri);
}
- public ClientResponse<Response> getBlobContent(String csid) {
+ public Response getBlobContent(String csid) {
return getProxy().getBlobContent(csid);
}
- public ClientResponse<Response> getDerivativeContent(
+ public Response getDerivativeContent(
@PathParam("csid") String csid,
@PathParam("derivativeTerm") String derivativeTerm) {
return getProxy().getDerivativeContent(csid, derivativeTerm);
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
public interface BlobProxy extends CollectionSpaceCommonListPoxProxy {
//(C)reate
@POST
- ClientResponse<Response> createBlobFromURI(byte[] xmlPayload,
+ Response createBlobFromURI(byte[] xmlPayload,
@QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri);
//(C)reate
@POST
@Consumes("multipart/form-data")
- ClientResponse<Response> createBlobFromFormData(MultipartFormDataOutput formDataOutput);
+ Response createBlobFromFormData(MultipartFormDataOutput formDataOutput);
@GET
@Path("{csid}/content")
- ClientResponse<Response> getBlobContent(@PathParam("csid") String csid);
+ Response getBlobContent(@PathParam("csid") String csid);
@GET
@Path("{csid}/derivatives/{derivativeTerm}/content")
- public ClientResponse<Response> getDerivativeContent(
+ public Response getDerivativeContent(
@PathParam("csid") String csid,
@PathParam("derivativeTerm") String derivativeTerm);
}
\ No newline at end of file
BlobsCommon blob = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
blob = (BlobsCommon) extractPart(input, blobClient.getCommonPartName(), BlobsCommon.class);
Assert.assertNotNull(blob);
logger.debug(objectAsXmlString(blob, BlobsCommon.class));
res = blobClient.getAuthorityRefs(knownResourceId);
try {
assertStatusCode(res, testName);
- AuthorityRefList list = (AuthorityRefList)res.getEntity();
+ AuthorityRefList list = res.readEntity(AuthorityRefList.class);
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
logger.debug("Authority references, found " + numAuthRefsFound);
// Delete Person resource(s) (before PersonAuthority resources).
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- personAuthClient.deleteItem(personAuthCSID, resourceId);
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
// Delete PersonAuthority resource(s).
// Note: Any non-success response is ignored and not reported.
BlobClient blobClient = new BlobClient();
for (String resourceId : blobIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- blobClient.delete(resourceId);
+ blobClient.delete(resourceId).close();
}
}
}
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.Profiler;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
Thread.sleep(3000); // sleep for 3 seconds
for (int i = 0; i < allGeneratedImages.size(); i++) {
- ClientResponse<Response> res = client.getDerivativeContent(allGeneratedImages.get(i), "Thumbnail");
- assertStatusCode(res, testName);
- logger.debug(String.format("Performed GET operation on Thumbnail derivative of image blob ID = '%s'.",
- allGeneratedImages.get(i)));
+ Response res = client.getDerivativeContent(allGeneratedImages.get(i), "Thumbnail");
+ try {
+ assertStatusCode(res, testName);
+ logger.debug(String.format("Performed GET operation on Thumbnail derivative of image blob ID = '%s'.",
+ allGeneratedImages.get(i)));
+ } finally {
+ res.close();
+ }
}
}
URL url = jpegFile.toURI().toURL();
profiler.start();
- ClientResponse<Response> res = client.createBlobFromURI("http://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg");//url.toString());
+ Response res = client.createBlobFromURI("http://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg");//url.toString());
try {
profiler.stop();
assertStatusCode(res, testName);
allGeneratedImages.add(csid);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
if (children != null && children.length > 0) {
for (File child : children) {
if (isBlobbable(child) == true) {
- ClientResponse<Response> res = null;
+ Response res = null;
String mimeType = this.getMimeType(child);
logger.debug("Processing file URI: " + child.getAbsolutePath());
logger.debug("MIME type is: " + mimeType);
// Create the blob
//
BlobClient client = new BlobClient();
- ClientResponse<Response> res = null;
+ Response res = null;
res = client.createBlobFromURI(uri);
String blobCsid = null;
try {
<artifactId>httpclient</artifactId>
<version>4.3.3</version>
</dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ </dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.FileUtils;
-import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.plugins.providers.multipart.InputPart;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
import org.slf4j.Logger;
Response.Status.NOT_FOUND.getStatusCode();
protected static final int STATUS_OK =
Response.Status.OK.getStatusCode();
-
- /**
- * Extract id.
- *
- * @param res the res
- * @return the string
- */
- static public String extractId(ClientResponse<Response> res) {
- MultivaluedMap<String, Object> mvm = res.getMetadata();
- return extractIdFromResponseMetadata(mvm);
- }
/**
* Extract id.
@Override
@GET
@Produces({"application/xml"})
- ClientResponse<AbstractCommonList> readIncludeDeleted(
+ Response readIncludeDeleted(
@QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
@Override
@GET
@Produces({"application/xml"})
- ClientResponse<AbstractCommonList> keywordSearchIncludeDeleted(
+ Response keywordSearchIncludeDeleted(
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
@QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
@Override
@GET
@Produces({ "application/xml" })
- ClientResponse<AbstractCommonList> advancedSearchIncludeDeleted(
+ Response advancedSearchIncludeDeleted(
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_AS) String whereClause,
@QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
}
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.jaxb.AbstractCommonList;
/**
}
@Override
- public ClientResponse<Response> create(Object payload) {
+ public Response create(Object payload) {
throw new UnsupportedOperationException();
}
@Override
- public ClientResponse<Object> update(String csid, Object payload) {
+ public Response update(String csid, Object payload) {
throw new UnsupportedOperationException();
}
@Override
- public ClientResponse<Object> read(String csid) {
+ public Response read(String csid) {
throw new UnsupportedOperationException();
}
@Override
- public ClientResponse<AbstractCommonList> readList() {
+ public Response readList() {
throw new UnsupportedOperationException();
}
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
+ } finally {
+ res.close();
+ }
+ res = client.readItem(knownResourceId, knownItemResourceId);
+ try {
// Retrieve the updated resource and verify that the parent did not change
- res = client.readItem(knownResourceId, knownItemResourceId);
AUTHORITY_ITEM_TYPE updatedVocabularyItem = extractItemCommonPartValue(res);
Assert.assertNotNull(updatedVocabularyItem);
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.io.FileUtils;
-import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
// FIXME: Move some or all of the methods below to a common client and
// server utilities package, when this package becomes available.
- /**
- * Extract id.
- *
- * @param res the res
- * @return the string
- */
- static protected String extractId(ClientResponse<Response> res) {
- MultivaluedMap<String, Object> mvm = res.getMetadata();
- String uri = (String) ((List<Object>) mvm.get("Location")).get(0);
- if (logger.isDebugEnabled()) {
- logger.debug("extractId:uri=" + uri);
- }
- String[] segments = uri.split("/");
- String id = segments[segments.length - 1];
- if (logger.isDebugEnabled()) {
- logger.debug("id=" + id);
- }
- return id;
- }
-
/**
* Extract id.
*
}
return className;
}
-
- public int assertStatusCode(ClientResponse<?> res, String testName) {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- logger.debug(testName + ": status = " + statusCode);
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- return statusCode;
- }
public int assertStatusCode(Response res, String testName) {
int statusCode = res.getStatus();
package org.collectionspace.services.client.workflow;
import javax.ws.rs.core.Response;
-
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.client.AbstractCommonListPoxServiceClientImpl;
-import org.jboss.resteasy.client.ClientResponse;
/**
* WorkflowClient.java
*/
@Override
- public ClientResponse<AbstractCommonList> readList() {
+ public Response readList() {
throw new UnsupportedOperationException();
}
* @see org.collectionspace.services.client.AbstractServiceClientImpl#delete(java.lang.String)
*/
@Override
- public ClientResponse<Response> delete(String csid) {
+ public Response delete(String csid) {
throw new UnsupportedOperationException();
}
*/
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
import javax.ws.rs.core.Response;
// FIXME: http://issues.collectionspace.org/browse/CSPACE-1684
* @see org.collectionspace.services.client.CollectionObjectProxy#roundtrip()
* @return the client response< response>
*/
- public ClientResponse<Response> roundtrip(int ms) {
+ public Response roundtrip(int ms) {
getLogger().debug(">>>>Roundtrip start.");
- ClientResponse<Response> result = getProxy().roundtrip(ms);
+ Response result = getProxy().roundtrip(ms);
getLogger().debug("<<<<Roundtrip stop.");
return result;
}
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
// FIXME: http://issues.collectionspace.org/browse/CSPACE-1684
@GET
@Path("/{ms}/roundtrip")
@Produces({"application/xml"})
- ClientResponse<Response> roundtrip(@PathParam("ms") int ms);
+ Response roundtrip(@PathParam("ms") int ms);
/**
* Keyword search.
<service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
<service:documentHandler xmlns:service="http://collectionspace.org/services/config/service">org.collectionspace.services.dimension.nuxeo.DimensionDocumentModelHandler
</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/config/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>dimension</service:element>
+ <service:xpath>dimension</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
<service:object xmlns:service="http://collectionspace.org/services/config/service" name="Dimension"
version="1.0">
<service:part id="0" control_group="Managed" versionable="true" auditable="false" label="dimensions-system"
try {
assertStatusCode(res, testName);
// Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
conditioncheckCommon = (ConditionchecksCommon) extractPart(input,
conditioncheckClient.getCommonPartName(), ConditionchecksCommon.class);
Assert.assertNotNull(conditioncheckCommon);
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = (AuthorityRefList)res2.getEntity();
+ list = res2.readEntity(AuthorityRefList.class);
Assert.assertNotNull(list);
} finally {
if (res2 != null) {
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
Response res = client.read(knownResourceId);
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
ContactsCommon contact = (ContactsCommon) extractPart(input,
client.getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(contact);
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
contact = (ContactsCommon) extractPart(input,
client.getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(contact);
ContactsCommon updatedContact = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
updatedContact = (ContactsCommon) extractPart(input,
client.getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(updatedContact);
*/
package org.collectionspace.services.client;
-import javax.ws.rs.core.Response;
-
-import org.collectionspace.services.dimension.DimensionsCommonList;
-import org.jboss.resteasy.client.ClientResponse;
-
/**
* A DimensionClient.
* @version $Revision:$
*/
-public class DimensionClient extends AbstractPoxServiceClientImpl<DimensionsCommonList, DimensionProxy> {
+public class DimensionClient extends AbstractCommonListPoxServiceClientImpl<DimensionProxy> {
public static final String SERVICE_NAME = "dimensions";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
@Override
public Class<DimensionProxy> getProxyClass() {
return DimensionProxy.class;
- }
-
- /*
- * Proxied service calls
- */
-
- public Response readList() {
- DimensionProxy proxy = (DimensionProxy)getProxy();
- return proxy.readList();
- }
+ }
}
package org.collectionspace.services.client;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
-
-import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.dimension.DimensionsCommonList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
@Path("/dimensions/")
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public interface DimensionProxy extends CollectionSpacePoxProxy<DimensionsCommonList> {
- @GET
- @Produces({"application/xml"})
- Response readList();
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<DimensionsCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<DimensionsCommonList> keywordSearchIncludeDeleted(
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
+public interface DimensionProxy extends CollectionSpaceCommonListPoxProxy {
+ // Intentionally left blank
}
//import java.util.ArrayList;
import java.math.BigDecimal;
-import java.util.List;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.DimensionClient;
import org.collectionspace.services.client.DimensionFactory;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.dimension.DimensionsCommon;
-import org.collectionspace.services.dimension.DimensionsCommonList;
+import org.collectionspace.services.jaxb.AbstractCommonList;
import org.testng.Assert;
-//import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class DimensionServiceTest extends AbstractPoxServiceTestImpl<DimensionsCommonList, DimensionsCommon> {
+public class DimensionServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, DimensionsCommon> {
/** The logger. */
private final String CLASS_NAME = DimensionServiceTest.class.getName();
protected CollectionSpaceClient getClientInstance() {
return new DimensionClient();
}
-
- @Override
- protected Class<DimensionsCommonList> getCommonListType() {
- return DimensionsCommonList.class;
- }
-
- /*
- * This method gets called by the parent's method public void readList(String testName)
- */
- protected void printList(String testName, DimensionsCommonList list) {
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- List<DimensionsCommonList.DimensionListItem> items =
- list.getDimensionListItem();
- int i = 0;
- for (DimensionsCommonList.DimensionListItem item : items) {
- logger.debug(testName + ": list-item[" + i + "] csid="
- + item.getCsid());
- logger.debug(testName + ": list-item[" + i + "] objectNumber="
- + item.getDimension());
- logger.debug(testName + ": list-item[" + i + "] URI="
- + item.getUri());
- i++;
- }
- }
- }
protected void compareInstances(DimensionsCommon original, DimensionsCommon updated) throws Exception {
Assert.assertEquals(original.getValueDate(),
*/
package org.collectionspace.services.dimension.nuxeo;
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.dimension.DimensionJAXBSchema;
-import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.dimension.DimensionsCommon;
-import org.collectionspace.services.dimension.DimensionsCommonList;
-import org.collectionspace.services.dimension.DimensionsCommonList.DimensionListItem;
-
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
/**
* DimensionDocumentModelHandler
* $LastChangedDate: $
*/
public class DimensionDocumentModelHandler
- extends RemoteDocumentModelHandlerImpl<DimensionsCommon, DimensionsCommonList> {
-
- private final Logger logger = LoggerFactory.getLogger(DimensionDocumentModelHandler.class);
- /**
- * dimension is used to stash JAXB object to use when handle is called
- * for Action.CREATE, Action.UPDATE or Action.GET
- */
- private DimensionsCommon dimension;
- /**
- * intakeList is stashed when handle is called
- * for ACTION.GET_ALL
- */
- private DimensionsCommonList intakeList;
-
-
- /**
- * getCommonPart get associated dimension
- * @return
- */
- @Override
- public DimensionsCommon getCommonPart() {
- return dimension;
- }
-
- /**
- * setCommonPart set associated dimension
- * @param dimension
- */
- @Override
- public void setCommonPart(DimensionsCommon dimension) {
- this.dimension = dimension;
- }
-
- /**
- * getCommonPartList get associated dimension (for index/GET_ALL)
- * @return
- */
- @Override
- public DimensionsCommonList getCommonPartList() {
- return intakeList;
- }
-
- @Override
- public void setCommonPartList(DimensionsCommonList intakeList) {
- this.intakeList = intakeList;
- }
-
- @Override
- public DimensionsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
- throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void fillCommonPart(DimensionsCommon intakeObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public DimensionsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- DimensionsCommonList coList = extractPagingInfo(new DimensionsCommonList(), wrapDoc) ;
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("dimension|uri|csid");
- List<DimensionsCommonList.DimensionListItem> list = coList.getDimensionListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- DimensionListItem ilistItem = new DimensionListItem();
- ilistItem.setDimension((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- DimensionJAXBSchema.DIMENSION));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri(getServiceContextPath() + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
- /**
- * getQProperty converts the given property to qualified schema property
- * @param prop
- * @return
- */
- @Override
- public String getQProperty(String prop) {
- return DimensionConstants.NUXEO_SCHEMA_NAME + ":" + prop;
- }
-
+ extends NuxeoDocumentModelHandler<DimensionsCommon> {
+
}
-
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
// Operations on ID Generators
- public ClientResponse<Response> create(String xmlPayload) {
+ public Response create(String xmlPayload) {
return getProxy().create(xmlPayload);
}
- public ClientResponse<String> read(String csid) {
+ public Response read(String csid) {
return getProxy().read(csid);
}
- public ClientResponse<String> readList() {
+ public Response readList() {
return getProxy().readList();
}
@Override
- public ClientResponse<Response> delete(String csid) {
+ public Response delete(String csid) {
return getProxy().delete(csid);
}
// Operations on IDs
- public ClientResponse<String> createId(String csid) {
+ public Response createId(String csid) {
return getProxy().createId(csid);
}
@Override
- public ClientResponse<String> update(String csid, String payload) {
+ public Response update(String csid, String payload) {
throw new UnsupportedOperationException("ID client does not support an update operation."); }
}
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
/**
* IDProxy.
@POST
@Consumes({"application/xml"})
@Produces({"*/*"})
- ClientResponse<Response> create(String xmlPayload);
+ Response create(String xmlPayload);
//(R)ead ID Generator
@GET
@Path("/{csid}")
@Produces({"application/xml"})
- ClientResponse<String> read(@PathParam("csid") String csid);
+ Response read(@PathParam("csid") String csid);
// Read (L)ist of ID Generators
@GET
@Produces({"application/xml"})
- ClientResponse<String> readList();
+ Response readList();
//(D)elete ID Generator
@DELETE
@Path("/{csid}")
@Override
- ClientResponse<Response> delete(@PathParam("csid") String csid);
+ Response delete(@PathParam("csid") String csid);
// Operations on IDs
//(C)reate ID
@POST
@Path("/{csid}/ids")
- ClientResponse<String> createId(@PathParam("csid") String csid);
+ Response createId(@PathParam("csid") String csid);
}
String xmlPayload = getSampleSerializedIdGenerator();
logger.debug("payload=\n" + xmlPayload);
- ClientResponse<Response> res = client.create(xmlPayload);
+ Response res = client.create(xmlPayload);
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// Submit the request to the service and store the response.
IdClient client = new IdClient();
- ClientResponse<String> res = client.createId(knownResourceId);
+ Response res = client.createId(knownResourceId);
String generatedId = null;
try {
assertStatusCode(res, testName);
- generatedId = res.getEntity();
+ generatedId = res.readEntity(String.class);
Assert.assertNotNull(generatedId);
Assert.assertFalse(generatedId.isEmpty());
if (logger.isDebugEnabled()) {
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Create a second ID. Verify that it is different from the first.
res = client.createId(knownResourceId);
try {
assertStatusCode(res, testName);
- String secondGeneratedId = res.getEntity();
+ String secondGeneratedId = res.readEntity(String.class);
Assert.assertNotNull(secondGeneratedId);
Assert.assertFalse(secondGeneratedId.isEmpty());
Assert.assertFalse(secondGeneratedId.equals(generatedId));
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
IdClient client = new IdClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
int statusCode = res.getStatus();
// Check the status code of the response: does it match
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- String entity = res.getEntity();
+ String entity = res.readEntity(String.class);
Assert.assertNotNull(entity);
if (logger.isDebugEnabled()) {
logger.debug("entity body=\r" + entity);
// Submit the request to the service and store the response.
IdClient client = new IdClient();
- ClientResponse<String> res = client.readList();
- 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(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
+ Response res = client.readList();
+ try {
+ 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(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
- String entity = res.getEntity();
- Assert.assertNotNull(entity);
- if (logger.isDebugEnabled()) {
- logger.debug("entity body=\r" + entity);
+ String entity = res.readEntity(String.class);
+ Assert.assertNotNull(entity);
+ if (logger.isDebugEnabled()) {
+ logger.debug("entity body=\r" + entity);
+ }
+ } finally {
+ res.close();
}
-
}
// Failure outcomes
// Submit the request to the service and store the response.
IdClient client = new IdClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
+ Response res = client.delete(knownResourceId);
int statusCode = res.getStatus();
// Check the status code of the response: does it match
@Produces({"application/xml"})
@Consumes({"application/xml"})
public interface IntakeProxy extends CollectionSpaceCommonListPoxProxy {
+ // Intentionally left blank
}
Response res = intakeClient.read(knownResourceId);
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
IntakesCommon intake = (IntakesCommon) extractPart(input,
intakeClient.getCommonPartName(), IntakesCommon.class);
Assert.assertNotNull(intake);
AuthorityRefList list = null;
try {
assertStatusCode(res, testName);
- list = (AuthorityRefList)res.getEntity();
+ list = res.readEntity(AuthorityRefList.class);
} finally {
if (res != null) {
res.close();
import org.collectionspace.services.intake.CurrentLocationGroupList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
+
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
}
Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
res.close();
}
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
res.close();
}
createOrgRefs();
IntakeClient intakeClient = new IntakeClient();
- PoxPayloadOut multipart = createIntakeInstance(
+ PoxPayloadOut intakePayload = createIntakeInstance(
"entryNumber-" + identifier,
CURRENT_DATE_UTC,
currentOwnerRefName,
insurerRefName,
valuerRefName );
- Response res = intakeClient.create(multipart);
+ Response res = intakeClient.create(intakePayload);
try {
int statusCode = res.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
+ String newIntakeId = extractId(res);
+ Assert.assertNotNull(newIntakeId, "Could not create a new Intake record.");
+
+ // Store the ID returned from the first resource created
+ // for additional tests below.
+ if (knownIntakeId == null) {
+ knownIntakeId = newIntakeId;
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownIntakeId=" + knownIntakeId);
+ }
+ }
+
+ // Store the IDs from every resource created by tests,
+ // so they can be deleted after tests have been run.
+ intakeIdsCreated.add(newIntakeId);
} finally {
res.close();
}
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownIntakeId == null){
- knownIntakeId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownIntakeId=" + knownIntakeId);
- }
- }
-
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- intakeIdsCreated.add(extractId(res));
}
/**
PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
ORGANIZATION_AUTHORITY_NAME, ORGANIZATION_AUTHORITY_NAME, orgAuthClient.getCommonPartName());
Response res = orgAuthClient.create(multipart);
- int statusCode = res.getStatus();
-
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, STATUS_CREATED);
- orgAuthCSID = extractId(res);
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, STATUS_CREATED);
+ orgAuthCSID = extractId(res);
+ Assert.assertNotNull(orgAuthCSID, "Could not create a new Organization authority record.");
+ } finally {
+ res.close();
+ }
currentOwnerOrgCSID = createOrganization("olivierOwnerCompany", "Olivier Owner Company", "Olivier Owner Company");
orgIdsCreated.add(currentOwnerOrgCSID);
}
protected String createOrganization(String shortId, String shortName, String longName) {
+ String result = null;
+
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
Map<String, String> orgInfo = new HashMap<String,String>();
orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId);
orgInfo, orgTerms, orgAuthClient.getItemCommonPartName());
Response res = orgAuthClient.createItem(orgAuthCSID, multipart);
- int statusCode = res.getStatus();
-
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, STATUS_CREATED);
- return extractId(res);
+ try {
+ int statusCode = res.getStatus();
+
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, STATUS_CREATED);
+ result = extractId(res);
+ } finally {
+ res.close();
+ }
+
+ return result;
}
// Success outcomes
AuthorityRefDocList list = null;
try {
assertStatusCode(refDocListResp, testName);
- list = (AuthorityRefDocList)refDocListResp.getEntity();
+ list = refDocListResp.readEntity(AuthorityRefDocList.class);
Assert.assertNotNull(list);
} finally {
if (refDocListResp != null) {
try {
assertStatusCode(res, testName);
// Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
loaninCommon = (LoansinCommon) extractPart(input,
loaninClient.getCommonPartName(), LoansinCommon.class);
Assert.assertNotNull(loaninCommon);
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = (AuthorityRefList)res2.getEntity();
+ list = res2.readEntity(AuthorityRefList.class);
Assert.assertNotNull(list);
} finally {
if (res2 != null) {
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
import org.collectionspace.services.loanout.LoansoutCommon;
import org.collectionspace.services.person.PersonTermGroup;
-import org.jboss.resteasy.client.ClientResponse;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
newId = extractId(res);
+ Assert.assertNotNull(newId, "Could not create a new LoanOut record.");
} finally {
res.close();
}
try {
assertStatusCode(res, testName);
// Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
loanoutCommon = (LoansoutCommon) extractPart(input,
loanoutClient.getCommonPartName(), LoansoutCommon.class);
Assert.assertNotNull(loanoutCommon);
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = (AuthorityRefList)res2.getEntity();
+ list = res2.readEntity(AuthorityRefList.class);
} finally {
if (res2 != null) {
res2.close();
// Delete Person resource(s) (before PersonAuthority resources).
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- personAuthClient.deleteItem(personAuthCSID, resourceId);
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
// Delete PersonAuthority resource(s).
// Note: Any non-success response is ignored and not reported.
if (personAuthCSID != null) {
- personAuthClient.delete(personAuthCSID);
+ personAuthClient.delete(personAuthCSID).close();
// 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);
+ loanoutClient.delete(resourceId).close();
}
}
}
try {
assertStatusCode(res, testName);
// Get the common part of the response and verify that it is not null.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
if (payloadInputPart != null) {
loanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
try {
assertStatusCode(res, testName);
// Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
if (payloadInputPart != null) {
loanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
try {
assertStatusCode(res, testName);
// Extract the updated common part from the response.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
if (payloadInputPart != null) {
updatedLoanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
LocationsCommon location = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
location = (LocationsCommon) extractPart(input,
client.getItemCommonPartName(), LocationsCommon.class);
Assert.assertNotNull(location);
* Creates a new blob resource from the form data and associates it with an existing media resource
*
*/
- public ClientResponse<Response> createBlobFromFormData(String csid, // this is the Media resource CSID
+ public Response createBlobFromFormData(String csid, // this is the Media resource CSID
MultipartFormDataOutput formDataOutput) {
return getProxy().createBlobFromFormData(csid, formDataOutput);
}
* Creates a new blob
*
*/
- public ClientResponse<Response> createBlobFromUri(String csid, String blobUri) {
+ public Response createBlobFromUri(String csid, String blobUri) {
return getProxy().createBlobFromUri(csid, blobUri, blobUri); //send the URI as both a query param and as content
}
/*
* Create both a new media record
*/
- public ClientResponse<Response> createMediaAndBlobWithUri(PoxPayloadOut xmlPayload, String blobUri, boolean purgeOriginal) {
+ public Response createMediaAndBlobWithUri(PoxPayloadOut xmlPayload, String blobUri, boolean purgeOriginal) {
return getProxy().createMediaAndBlobWithUri(xmlPayload.getBytes(), blobUri, purgeOriginal);
}
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
import javax.ws.rs.Consumes;
@POST
@Path("{csid}")
@Consumes("multipart/form-data")
- ClientResponse<Response> createBlobFromFormData(@PathParam("csid") String csid,
+ Response createBlobFromFormData(@PathParam("csid") String csid,
MultipartFormDataOutput formDataOutput);
@POST
@Path("{csid}")
@Produces("application/xml")
@Consumes("application/xml")
- ClientResponse<Response>createBlobFromUri(@PathParam("csid") String csid,
+ Response createBlobFromUri(@PathParam("csid") String csid,
@QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri,
String emptyXML); //this "emptyXML" param is needed to force RESTEasy to produce a Content-Type header for this POST
@POST
@Produces("application/xml")
@Consumes("application/xml")
- ClientResponse<Response>createMediaAndBlobWithUri(byte[] xmlPayload,
+ Response createMediaAndBlobWithUri(byte[] xmlPayload,
@QueryParam(BlobClient.BLOB_URI_PARAM) String blobUri,
@QueryParam(BlobClient.BLOB_PURGE_ORIGINAL) boolean purgeOriginal);
}
MediaCommon media = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
media = (MediaCommon) extractPart(input, mediaClient.getCommonPartName(), MediaCommon.class);
Assert.assertNotNull(media);
logger.debug(objectAsXmlString(media, MediaCommon.class));
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = (AuthorityRefList)res2.getEntity();
+ list = res2.readEntity(AuthorityRefList.class);
} finally {
if (res2 != null) {
res2.close();
// Delete Person resource(s) (before PersonAuthority resources).
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- personAuthClient.deleteItem(personAuthCSID, resourceId);
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
// Delete PersonAuthority resource(s).
// Note: Any non-success response is ignored and not reported.
//
if (blobFile != null) {
client = new MediaClient();
- ClientResponse<Response> res = null;
+ Response res = null;
String mimeType = this.getMimeType(blobFile);
logger.debug("Processing file URI: " + blobFile.getAbsolutePath());
logger.debug("MIME type is: " + mimeType);
if (fromUri == true) {
URL childUrl = blobFile.toURI().toURL();
- res = client.createBlobFromUri(mediaCsid,
- childUrl.toString());
+ res = client.createBlobFromUri(mediaCsid, childUrl.toString());
} else {
MultipartFormDataOutput formData = new MultipartFormDataOutput();
OutputPart outputPart = formData.addFormData("file",
blobFile, MediaType.valueOf(mimeType));
- res = client
- .createBlobFromFormData(mediaCsid, formData);
+ res = client.createBlobFromFormData(mediaCsid, formData);
}
try {
assertStatusCode(res, testName);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
} else {
public void createMediaAndBlobWithUri(String testName) throws Exception {
MediaClient client = new MediaClient();
PoxPayloadOut multipart = createMediaInstance(createIdentifier());
- ClientResponse<Response> mediaRes = client.createMediaAndBlobWithUri(multipart, PUBLIC_URL_DECK, true); // purge the original
+ Response mediaRes = client.createMediaAndBlobWithUri(multipart, PUBLIC_URL_DECK, true); // purge the original
String mediaCsid = null;
try {
assertStatusCode(mediaRes, testName);
// allResourceIdsCreated.add(mediaCsid); // Re-enable this and also add code to delete the associated blob
} finally {
if (mediaRes != null) {
- mediaRes.releaseConnection();
+ mediaRes.close();
}
}
}
// setupCreate();
// MediaClient client = new MediaClient();
// PoxPayloadOut multipart = createMediaInstance(createIdentifier());
-// ClientResponse<Response> res = client.create(multipart);
+// Response res = client.create(multipart);
// assertStatusCode(res, testName);
// String csid = extractId(res);
//
package org.collectionspace.services.client;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
+import javax.ws.rs.core.Response;
/**
* MovementClient.java
* @return
* @see org.collectionspace.services.client.MovementProxy#readList(java.lang.String)
*/
- public ClientResponse<AbstractCommonList> readListSortedBy(String sortFieldName) {
+ public Response readListSortedBy(String sortFieldName) {
return getProxy().readListSortedBy(sortFieldName);
}
* @return
* @see org.collectionspace.services.client.MovementProxy#keywordSearchSortedBy(java.lang.String, java.lang.String)
*/
- public ClientResponse<AbstractCommonList> keywordSearchSortedBy(String keywords, String sortFieldName) {
+ public Response keywordSearchSortedBy(String keywords, String sortFieldName) {
return getProxy().keywordSearchSortedBy(keywords, sortFieldName);
}
}
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.jaxb.AbstractCommonList;
/**
* MovementProxy.java
// Sorted list
@GET
@Produces({"application/xml"})
- ClientResponse<AbstractCommonList> readListSortedBy(
+ Response readListSortedBy(
@QueryParam(IClientQueryParams.ORDER_BY_PARAM) String sortFieldName);
@Override
@GET
@Produces({"application/xml"})
- ClientResponse<AbstractCommonList> readIncludeDeleted(
+ Response readIncludeDeleted(
@QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
@Override
@GET
@Produces({"application/xml"})
- ClientResponse<AbstractCommonList> keywordSearchIncludeDeleted(
+ Response keywordSearchIncludeDeleted(
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
@QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
@GET
@Produces({"application/xml"})
- ClientResponse<AbstractCommonList> keywordSearchSortedBy(
+ Response keywordSearchSortedBy(
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
@QueryParam(IClientQueryParams.ORDER_BY_PARAM) String sortFieldName);
}
try {
assertStatusCode(res, testName);
// Extract and return the common part of the record.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PayloadInputPart payloadInputPart = input.getPart(movementClient.getCommonPartName());
if (payloadInputPart != null) {
movementCommon = (MovementsCommon) payloadInputPart.getBody();
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = (AuthorityRefList)res2.getEntity();
+ list = res2.readEntity(AuthorityRefList.class);
} finally {
if (res2 != null) {
res2.close();
// Delete Person resource(s) (before PersonAuthority resources).
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- personAuthClient.deleteItem(personAuthCSID, resourceId);
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
// Delete PersonAuthority resource(s).
// Note: Any non-success response is ignored and not reported.
if (personAuthCSID != null) {
- personAuthClient.delete(personAuthCSID);
+ personAuthClient.delete(personAuthCSID).close();
}
// Delete Movement resource(s).
MovementClient movementClient = new MovementClient();
for (String resourceId : movementIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- movementClient.delete(resourceId);
+ movementClient.delete(resourceId).close();
}
}
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
final String EMPTY_SORT_FIELD_NAME = "";
- ClientResponse<AbstractCommonList> res =
- client.readListSortedBy(EMPTY_SORT_FIELD_NAME);
+ Response res = client.readListSortedBy(EMPTY_SORT_FIELD_NAME);
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
- ClientResponse<AbstractCommonList> res =
- client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE);
+ Response res = client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE);
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
final String INVALID_SORT_ORDER_IDENTIFIER = "NO_DIRECTION";
- ClientResponse<AbstractCommonList> res =
- client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE
+ Response res = client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE
+ " " + INVALID_SORT_ORDER_IDENTIFIER);
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
try {
assertStatusCode(res, testName);
// Extract and return the common part of the record.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
if (payloadInputPart != null) {
movementCommon = (MovementsCommon) payloadInputPart.getBody();
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
- ClientResponse<AbstractCommonList> res = client.readListSortedBy(sortFieldName);
+ Response res = client.readListSortedBy(sortFieldName);
AbstractCommonList list = null;
try {
assertStatusCode(res, testName);
- list = res.getEntity();
+ list = res.readEntity(AbstractCommonList.class);
} finally {
if (res != null) {
res.close();
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
- ClientResponse<AbstractCommonList> res =
- client.keywordSearchSortedBy(keywords, sortFieldName);
+ Response res = client.keywordSearchSortedBy(keywords, sortFieldName);
AbstractCommonList list = null;
try {
assertStatusCode(res, testName);
- list = res.getEntity();
+ list = res.readEntity(AbstractCommonList.class);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
import org.collectionspace.services.objectexit.ObjectexitCommon;
import org.collectionspace.services.person.PersonTermGroup;
-import org.jboss.resteasy.client.ClientResponse;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
PoxPayloadOut multipart = createObjectExitInstance(depositorRefName,
"exitNumber-" + identifier, CURRENT_DATE_UTC);
Response res = objectexitClient.create(multipart);
+ String newId = null;
try {
assertStatusCode(res, testName);
+ newId = extractId(res);
+ Assert.assertNotNull(newId, "Could not create a new ObjectExit record.");
if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
- knownResourceId = extractId(res);
+ knownResourceId = newId;
}
} finally {
if (res != null) {
res.close();
}
}
- objectexitIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
+
+ objectexitIdsCreated.add(newId);// Store the IDs from every resource created; delete on cleanup
}
protected void createPersonRefs() {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified.
- PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
+ PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
+ PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
Response res = personAuthClient.create(multipart);
try {
assertStatusCode(res, "createPersonRefs (not a surefire test)");
ObjectexitCommon objectexit = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
objectexit = (ObjectexitCommon) extractPart(input, objectexitClient.getCommonPartName(), ObjectexitCommon.class);
Assert.assertNotNull(objectexit);
logger.debug(objectAsXmlString(objectexit, ObjectexitCommon.class));
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = (AuthorityRefList)res2.getEntity();
+ list = res2.readEntity(AuthorityRefList.class);
} finally {
if (res2 != null) {
res2.close();
// Delete Person resource(s) (before PersonAuthority resources).
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- personAuthClient.deleteItem(personAuthCSID, resourceId);
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
// Delete PersonAuthority resource(s).
// Note: Any non-success response is ignored and not reported.
if (personAuthCSID != null) {
- personAuthClient.delete(personAuthCSID);
+ personAuthClient.delete(personAuthCSID).close();
// Delete Loans In resource(s).
ObjectExitClient objectexitClient = new ObjectExitClient();
for (String resourceId : objectexitIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- objectexitClient.delete(resourceId);
+ objectexitClient.delete(resourceId).close();
}
}
}
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.common</artifactId>
<optional>true</optional>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.client</artifactId>
* @return
*/
public static String getOrgRefName(String inAuthority, String csid, OrgAuthorityClient client){
- if(client==null)
+ if (client == null) {
client = new OrgAuthorityClient();
+ }
+
Response res = client.readItem(inAuthority, csid);
try {
int statusCode = res.getStatus();
OrganizationsCommon organization = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
organization = (OrganizationsCommon) extractPart(input,
orgAuthClient.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(organization);
assertStatusCode(res, testName);
//FIXME: remove the following try catch once Aron fixes signatures
try {
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
new OrgAuthorityClient().getCommonPartName(), OrgauthoritiesCommon.class);
if (logger.isDebugEnabled()) {
try {
assertStatusCode(res, testName);
// Check whether we've received a organization.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(organization);
try {
assertStatusCode(res, testName);
// Check whether organization has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
organization = (OrganizationsCommon) extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(organization);
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.jaxb</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.authority.jaxb</artifactId>
import org.collectionspace.services.person.PersonsCommon;
import org.collectionspace.services.person.PersonauthoritiesCommon;
import org.collectionspace.services.person.SchoolOrStyleList;
-import org.jboss.resteasy.client.ClientResponse;
-//import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+import org.collectionspace.services.person.StructuredDateGroup;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.collectionspace.services.person.StructuredDateGroup;
/**
* The Class PersonAuthorityClientUtils.
}
//FIXME: remove the following try catch once Aron fixes signatures
try {
- PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(String.class));
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PersonauthoritiesCommon personAuthority =
(PersonauthoritiesCommon) CollectionSpaceClientUtils.extractPart(input,
client.getCommonPartName(), PersonauthoritiesCommon.class);
}
//FIXME: remove the following try catch once Aron fixes signatures
try {
- PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(String.class));
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PersonsCommon person =
(PersonsCommon) CollectionSpaceClientUtils.extractPart(input,
client.getItemCommonPartName(), PersonsCommon.class);
logger.debug("id=" + id);
}
return id;
- }
-
- public static String extractId(ClientResponse<Response> res) {
- MultivaluedMap<String, Object> mvm = res.getMetadata();
- // FIXME: This may throw an NPE if the Location: header isn't present
- String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);
- if(logger.isDebugEnabled()){
- logger.debug("extractId:uri=" + uri);
- }
- String[] segments = uri.split("/");
- String id = segments[segments.length - 1];
- if(logger.isDebugEnabled()){
- logger.debug("id=" + id);
- }
- return id;
- }
-
+ }
/**
* Returns an error message indicating that the status code returned by a
assertStatusCode(res, testName);
//FIXME: remove the following try catch once Aron fixes signatures
try {
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
client.getCommonPartName(), PersonauthoritiesCommon.class);
Assert.assertNotNull(personAuthority);
try {
assertStatusCode(res, testName);
// Check whether we've received a person.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PersonsCommon person = (PersonsCommon) extractPart(input,
client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(person);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
if (logger.isDebugEnabled()) {
logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
}
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
try {
assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
+ knownItemResourceId
+ " in PersonAuthority: " + knownResourceId);
}
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
try {
assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
PlacesCommon place= null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
place = (PlacesCommon) extractPart(input,
client.getItemCommonPartName(), PlacesCommon.class);
Assert.assertNotNull(place);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
*/
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
+import javax.ws.rs.core.Response;
+
import org.collectionspace.services.relation.RelationsCommonList;
/**
*
* @return the client response
*/
- public ClientResponse<RelationsCommonList> readList() {
+ public Response readList() {
return getProxy().readList();
}
* @param objectType
* @return the client response
*/
- public ClientResponse<RelationsCommonList> readList(String subjectCsid,
+ public Response readList(String subjectCsid,
String subjectType,
String predicate,
String objectCsid,
return getProxy().readList(subjectCsid, subjectType, predicate, objectCsid, objectType);
}
- public ClientResponse<RelationsCommonList> readList(String subjectCsid,
+ public Response readList(String subjectCsid,
String subjectType,
String predicate,
String objectCsid,
import org.collectionspace.services.client.IRelationsManager;
import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.jboss.resteasy.client.ClientResponse;
import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
/**
* @version $Revision:$
@GET
@Produces({"application/xml"})
- ClientResponse<RelationsCommonList> readList();
+ Response readList();
@Override
@GET
@Produces({"application/xml"})
- ClientResponse<RelationsCommonList> readIncludeDeleted(
+ Response readIncludeDeleted(
@QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
@Override
@GET
@Produces({"application/xml"})
- ClientResponse<RelationsCommonList> keywordSearchIncludeDeleted(
+ Response keywordSearchIncludeDeleted(
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
@QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
@GET
@Produces({"application/xml"})
- ClientResponse<RelationsCommonList> readList(
+ Response readList(
@QueryParam(IRelationsManager.SUBJECT_QP) String subjectCsid,
@QueryParam(IRelationsManager.SUBJECT_TYPE_QP) String subjectType,
@QueryParam(IRelationsManager.PREDICATE_QP) String predicate,
@GET
@Produces({"application/xml"})
- ClientResponse<RelationsCommonList> readList(
+ Response readList(
@QueryParam(IRelationsManager.SUBJECT_QP) String subjectCsid,
@QueryParam(IRelationsManager.SUBJECT_TYPE_QP) String subjectType,
@QueryParam(IRelationsManager.PREDICATE_QP) String predicate,
*/
package org.collectionspace.services.client;
-import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
-
import org.collectionspace.services.common.invocable.InvocationContext;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* A ReportClient.
* @return
* @see org.collectionspace.services.client.ReportProxy#getReport()
*/
- public ClientResponse<AbstractCommonList> readListFiltered(
+ public Response readListFiltered(
String docType, String mode) {
return getProxy().readListFiltered(docType, mode);
}
- public ClientResponse<Response> publishReport(String csid,
+ public Response publishReport(String csid,
InvocationContext invContext) {
return getProxy().publishReport(csid, invContext);
}
import javax.ws.rs.core.Response;
import org.collectionspace.services.common.invocable.InvocationContext;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
@GET
@Produces({"application/xml"})
- ClientResponse<AbstractCommonList> readListFiltered(
+ Response readListFiltered(
@QueryParam(IQueryManager.SEARCH_TYPE_DOCTYPE) String docType,
@QueryParam(IQueryManager.SEARCH_TYPE_INVOCATION_MODE) String mode);
@POST
@Path("{csid}/publish")
- ClientResponse<Response> publishReport(@PathParam("csid") String csid,
+ Response publishReport(@PathParam("csid") String csid,
InvocationContext invContext);
}
invocationContext.setMode("single");
invocationContext.setSingleCSID(acquisitionCsid);
- ClientResponse<Response> res = client.publishReport(reportCsid, invocationContext);
- int statusCode = res.getStatus();
- setupCreate();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.publishReport(reportCsid, invocationContext);
+ try {
+ int statusCode = res.getStatus();
+ setupCreate();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ String publicItemCsid = extractId(res);
+ Assert.assertNotNull(publicItemCsid);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- String publicItemCsid = extractId(res);
- Assert.assertNotNull(publicItemCsid);
}
/* (non-Javadoc)
// Submit the request to the service and store the response.
ReportClient client = new ReportClient();
- ClientResponse<AbstractCommonList> res = client.readListFiltered(testDocType, "single");
+ Response res = client.readListFiltered(testDocType, "single");
AbstractCommonList list = null;
try {
assertStatusCode(res, testName);
- list = res.getEntity();
+ list = res.readEntity(AbstractCommonList.class);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
+
List<AbstractCommonList.ListItem> items = list.getListItem();
// We must find the basic one we created
boolean fFoundBaseItem = false;
break;
}
}
- if(!fFoundBaseItem) {
+
+ if (!fFoundBaseItem) {
Assert.fail("readListFiltered failed to return base item");
}
res = client.readListFiltered("Intake", "single");
try {
assertStatusCode(res, testName);
- list = res.getEntity();
+ list = res.readEntity(AbstractCommonList.class);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
res = client.readListFiltered(testDocType, "group");
try {
assertStatusCode(res, testName);
- list = res.getEntity();
+ list = res.readEntity(AbstractCommonList.class);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authority.jaxb</artifactId>
+ <optional>true</optional>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
AccountsCommon account =
createAccountInstance("barney", "barney08", "barney@dinoland.com",
accountClient.getTenantId(), false);
- ClientResponse<Response> res = accountClient.create(account);
+ Response res = accountClient.create(account);
try {
int statusCode = res.getStatus();
AccountsCommon account =
createAccountInstance("george", "george08", "george@curiousland.com",
accountClient.getTenantId(), false);
- ClientResponse<Response> res = accountClient.create(account);
- int statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": george status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Store the ID returned from this create operation
- // for additional tests below.
- georgeAccountId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": georgeAccountId=" + georgeAccountId);
+ Response res = accountClient.create(account);
+ try {
+ int statusCode = res.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": george status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Store the ID returned from this create operation
+ // for additional tests below.
+ georgeAccountId = extractId(res);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": georgeAccountId=" + georgeAccountId);
+ }
+ } finally {
+ res.close();
}
- res.releaseConnection();
+
//deactivate
setupUpdate();
account.setStatus(Status.INACTIVE);
}
// Submit the request to the service and store the response.
- ClientResponse<AccountsCommon> res1 = accountClient.update(georgeAccountId, account);
- statusCode = res1.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res1 = accountClient.update(georgeAccountId, account);
+ try {
+ int statusCode = res1.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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ } finally {
+ res1.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
- res1.releaseConnection();
}
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.authorization.AccountRole;
Response res = client.read(knownResourceId);
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
client.getCommonPartName(), DimensionsCommon.class);
Assert.assertNotNull(dimension);
PermissionClient permClient = new PermissionClient();
Permission permission = PermissionFactory.createPermissionInstance(resName,
"default permissions for " + resName, actions, effect, true, true, true);
- ClientResponse<Response> res = permClient.create(permission);
+ Response res = permClient.create(permission);
try {
assertStatusCode(res, "CreatePermission");
result = extractId(res);
Role role = RoleFactory.createRoleInstance(roleName,
roleName, //the display name
"role for " + roleName, true);
- ClientResponse<Response> res = roleClient.create(role);
+ Response res = roleClient.create(role);
try {
assertStatusCode(res, "CreateRole");
result = extractId(res);
AccountsCommon account = AccountFactory.createAccountInstance(
userName, userName, userName, email, accountClient.getTenantId(),
true, false, true, true);
- ClientResponse<Response> res = accountClient.create(account);
+ Response res = accountClient.create(account);
try {
assertStatusCode(res, "CreateAccount");
result = extractId(res);
AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
av, rvs, true, true);
AccountRoleClient client = new AccountRoleClient();
- ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
+ Response res = client.create(av.getAccountId(), accRole);
try {
assertStatusCode(res, "CreateAccountRole");
result = extractId(res);
PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
pv, rvls, true, true);
PermissionRoleClient client = new PermissionRoleClient();
- ClientResponse<Response> res = client.create(pv.getPermissionId(), permRole);
+ Response res = client.create(pv.getPermissionId(), permRole);
try {
assertStatusCode(res, "CreatePermissionRole");
result = extractId(res);
import java.util.Hashtable;
import java.util.List;
import javax.ws.rs.core.Response;
+
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.authorization.AccountValue;
import org.collectionspace.services.client.test.BaseServiceTest;
import org.collectionspace.services.dimension.DimensionsCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
import org.testng.annotations.Test;
Response res = client.read(id);
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
result = (DimensionsCommon) extractPart(input,
client.getCommonPartName(), DimensionsCommon.class);
} finally {
"default permissions for " + resName,
actions, effect, true, true, true);
permission.setTenantId(tenantId);
- ClientResponse<Response> res = permClient.create(permission);
+ Response res = permClient.create(permission);
try {
assertStatusCode(res, "CreatePermission");
result = extractId(res);
roleName, //the display name
"role for " + roleName, true);
role.setTenantId(tenantId);
- ClientResponse<Response> res = roleClient.create(role);
+ Response res = roleClient.create(role);
try {
assertStatusCode(res, "CreateRole");
result = extractId(res);
AccountsCommon account = AccountFactory.createAccountInstance(
userName, userName, userName, email, tenantId,
true, false, true, true);
- ClientResponse<Response> res = accountClient.create(account);
+ Response res = accountClient.create(account);
try {
assertStatusCode(res, "CreateAccount");
result = extractId(res);
AccountRoleClient client = new AccountRoleClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
client.setAuth(true, ui.userName, true, ui.password, true);
- ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
+ Response res = client.create(av.getAccountId(), accRole);
try {
assertStatusCode(res, "CreateAccountRole");
result = extractId(res);
PermissionRoleClient client = new PermissionRoleClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
client.setAuth(true, ui.userName, true, ui.password, true);
- ClientResponse<Response> res = client.create(pv.getPermissionId(), permRole);
+ Response res = client.create(pv.getPermissionId(), permRole);
try {
assertStatusCode(res, "createPermissionRole");
result = extractId(res);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Reading part " + partLabel + " ...");
}
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
PayloadInputPart payloadInputPart = input.getPart(partLabel);
Assert.assertNotNull(payloadInputPart,
"Part " + partLabel + " was unexpectedly null.");
try {
assertStatusCode(res, testName);
// Check whether Taxonomy has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
taxon = (TaxonCommon) extractPart(input,
client.getItemCommonPartName(), TaxonCommon.class);
Assert.assertNotNull(taxon);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn((String)res.getEntity());
+ input = new PoxPayloadIn(res.readEntity(String.class));
} finally {
if (res != null) {
res.close();
try {
assertStatusCode(res, testName);
// Check whether Person has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
vitem = (VocabularyitemsCommon) extractPart(input,
client.getItemCommonPartName(), VocabularyitemsCommon.class);
Assert.assertNotNull(vitem);
WorksCommon work = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
work = (WorksCommon) extractPart(input,
client.getItemCommonPartName(), WorksCommon.class);
Assert.assertNotNull(work);
Response res = client.getWorkflow(knownResourceId);
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
WorkflowCommon workflowsCommon = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
if (logger.isDebugEnabled() == true) {
logger.debug("Workflow payload is: " + input.getXmlPayload());