2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2010 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
25 * To change this template, choose Tools | Templates
26 * and open the template in the editor.
28 package org.collectionspace.services.security.client.test;
30 import java.util.ArrayList;
31 import java.util.Collection;
32 import java.util.Date;
33 import java.util.Hashtable;
34 import java.util.List;
36 import javax.ws.rs.core.MediaType;
37 import javax.ws.rs.core.Response;
38 import org.jboss.resteasy.client.ClientResponse;
40 import org.collectionspace.services.account.AccountsCommon;
41 import org.collectionspace.services.authorization.AccountRole;
42 import org.collectionspace.services.authorization.AccountValue;
43 import org.collectionspace.services.authorization.perms.ActionType;
44 import org.collectionspace.services.authorization.perms.EffectType;
45 import org.collectionspace.services.authorization.perms.Permission;
46 import org.collectionspace.services.authorization.perms.PermissionAction;
47 import org.collectionspace.services.authorization.PermissionRole;
48 import org.collectionspace.services.authorization.PermissionValue;
49 import org.collectionspace.services.authorization.Role;
50 import org.collectionspace.services.authorization.RoleValue;
51 import org.collectionspace.services.client.AccountClient;
52 import org.collectionspace.services.client.AccountFactory;
53 import org.collectionspace.services.client.AccountRoleClient;
54 import org.collectionspace.services.client.AccountRoleFactory;
55 import org.collectionspace.services.client.CollectionSpaceClient;
56 import org.collectionspace.services.client.DimensionClient;
57 import org.collectionspace.services.client.DimensionFactory;
58 import org.collectionspace.services.client.IntakeClient;
59 import org.collectionspace.services.client.PayloadOutputPart;
60 import org.collectionspace.services.client.PermissionClient;
61 import org.collectionspace.services.client.PermissionFactory;
62 import org.collectionspace.services.client.PermissionRoleClient;
63 import org.collectionspace.services.client.PermissionRoleFactory;
64 import org.collectionspace.services.client.PoxPayloadIn;
65 import org.collectionspace.services.client.PoxPayloadOut;
66 import org.collectionspace.services.client.RoleClient;
67 import org.collectionspace.services.client.RoleFactory;
68 import org.collectionspace.services.client.test.BaseServiceTest;
69 import org.collectionspace.services.dimension.DimensionsCommon;
70 import org.collectionspace.services.intake.IntakesCommon;
71 import org.collectionspace.services.jaxb.AbstractCommonList;
73 import org.testng.Assert;
74 import org.testng.annotations.Test;
75 import org.testng.annotations.AfterClass;
76 import org.testng.annotations.BeforeClass;
78 import org.slf4j.Logger;
79 import org.slf4j.LoggerFactory;
82 * AuthorizationServiceTest, carries out tests against a
83 * deployed and running Permission, Role, AccountRole, PermissionRole and
84 * CollectionObject Services.
86 * Pre-requisite : authorization-mgt/client tests seed some permissions used
89 * $LastChangedRevision: 917 $
90 * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
92 public class AuthorizationServiceTest extends BaseServiceTest<AbstractCommonList> {
94 private final String CLASS_NAME = AuthorizationServiceTest.class.getName();
95 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
96 // Instance variables specific to this test.
97 private Hashtable<String, AccountValue> accValues = new Hashtable<String, AccountValue>();
98 //key for permValues is id as there could be several perms for the same resource
99 private Hashtable<String, PermissionValue> permValues = new Hashtable<String, PermissionValue>();
100 //key for roleValues is roleName
101 private Hashtable<String, RoleValue> roleValues = new Hashtable<String, RoleValue>();
102 private String bigbirdPermId;
103 private String elmoPermId;
104 private final static String TEST_SERVICE_NAME = "dimensions";
105 private boolean accountRolesFlipped = false;
107 * This method is called only by the parent class, AbstractServiceTestImpl
111 protected String getServiceName() {
112 // no need to return anything but null since no auth resources are
114 throw new UnsupportedOperationException();
118 protected String getServicePathComponent() {
119 // no need to return anything but null since no auth resources are
121 throw new UnsupportedOperationException();
124 @BeforeClass(alwaysRun = true)
125 public void seedData() {
130 seedPermissionRoles();
133 private void seedPermissions() {
134 String res = TEST_SERVICE_NAME;
136 PermissionAction pac = new PermissionAction();
137 pac.setName(ActionType.CREATE);
138 PermissionAction par = new PermissionAction();
139 par.setName(ActionType.READ);
140 PermissionAction pau = new PermissionAction();
141 pau.setName(ActionType.UPDATE);
144 //bigbird can create, read and update but not delete
145 List<PermissionAction> bbactions = new ArrayList<PermissionAction>();
149 bigbirdPermId = createPermission(res, bbactions, EffectType.PERMIT);
150 PermissionValue bbpv = new PermissionValue();
151 bbpv.setResourceName(res);
152 bbpv.setPermissionId(bigbirdPermId);
153 permValues.put(bbpv.getPermissionId(), bbpv);
156 List<PermissionAction> eactions = new ArrayList<PermissionAction>();
158 elmoPermId = createPermission(res, eactions, EffectType.PERMIT);
159 PermissionValue epv = new PermissionValue();
160 epv.setResourceName(res);
161 epv.setPermissionId(elmoPermId);
162 permValues.put(epv.getPermissionId(), epv);
165 private void seedRoles() {
166 String rn1 = "ROLE_TEST_CM";
167 String r1RoleId = createRole(rn1);
168 RoleValue rv1 = new RoleValue();
169 rv1.setRoleId(r1RoleId);
170 rv1.setRoleName(rn1);
171 roleValues.put(rv1.getRoleName(), rv1);
173 String rn2 = "ROLE_TEST_INTERN";
174 String r2RoleId = createRole(rn2);
175 RoleValue rv2 = new RoleValue();
176 rv2.setRoleId(r2RoleId);
177 rv2.setRoleName(rn2);
178 roleValues.put(rv2.getRoleName(), rv2);
181 private void seedAccounts() {
182 String userId1 = "bigbird2010";
183 String accId1 = createAccount(userId1, "bigbird@cspace.org");
184 AccountValue av1 = new AccountValue();
185 av1.setScreenName(userId1);
186 av1.setUserId(userId1);
187 av1.setAccountId(accId1);
188 accValues.put(av1.getUserId(), av1);
190 String userId2 = "elmo2010";
191 String accId2 = createAccount(userId2, "elmo@cspace.org");
192 AccountValue av2 = new AccountValue();
193 av2.setScreenName(userId2);
194 av2.setUserId(userId2);
195 av2.setAccountId(accId2);
196 accValues.put(av2.getUserId(), av2);
198 String userId3 = "lockedOut";
199 String accId3 = createAccount(userId3, "lockedOut@cspace.org");
200 AccountValue av3 = new AccountValue();
201 av3.setScreenName(userId3);
202 av3.setUserId(userId3);
203 av3.setAccountId(accId3);
204 accValues.put(av3.getUserId(), av3);
207 private void seedAccountRoles() {
209 List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
210 bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
211 createAccountRole(accValues.get("bigbird2010"), bigbirdRoleValues);
213 List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
214 elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
215 createAccountRole(accValues.get("elmo2010"), elmoRoleValues);
218 private void seedPermissionRoles() {
220 List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
221 bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
222 createPermissionRole(permValues.get(bigbirdPermId), bigbirdRoleValues);
224 List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
225 elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
226 createPermissionRole(permValues.get(elmoPermId), elmoRoleValues);
232 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
235 protected CollectionSpaceClient getClientInstance() {
236 // This method is meaningless to this test.
240 // ---------------------------------------------------------------
241 // CRUD tests : CREATE tests
242 // ---------------------------------------------------------------
245 @Test(dataProvider = "testName")
246 public void create(String testName) throws Exception {
250 // Submit the request to the service and store the response.
251 DimensionClient client = new DimensionClient();
252 //bigbird allowed to create
253 client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
254 String identifier = createIdentifier();
255 DimensionsCommon dimension = new DimensionsCommon();
256 dimension.setDimension("dimensionType");
257 dimension.setMeasurementUnit("measurementUnit-" + identifier);
258 dimension.setValueDate(new Date().toString());
259 PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
261 Response res = client.create(multipart);
263 statusCode = res.getStatus();
264 if (logger.isDebugEnabled()) {
265 logger.debug(testName + ": status = " + statusCode);
267 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
268 invalidStatusCodeMessage(testRequestType, statusCode));
269 Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
270 knownResourceId = extractId(res);
271 if (logger.isDebugEnabled()) {
272 logger.debug(testName + ": knownResourceId=" + knownResourceId);
278 // Now verify that elmo cannot create
279 client = new DimensionClient();
280 client.setAuth(true, "elmo2010", true, "elmo2010", true);
281 res = client.create(multipart);
283 statusCode = res.getStatus();
284 if (logger.isDebugEnabled()) {
285 logger.debug(testName + " (verify not allowed): status = " + statusCode);
287 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
288 invalidStatusCodeMessage(testRequestType, statusCode));
289 Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
294 //Finally, verify that elmo has no access to Intakes
295 // Submit the request to the service and store the response.
296 IntakeClient iclient = new IntakeClient();
297 iclient.setAuth(true, "elmo2010", true, "elmo2010", true);
298 multipart = createIntakeInstance(
299 "entryNumber-" + identifier,
300 "entryDate-" + identifier,
301 "depositor-" + identifier);
302 res = iclient.create(multipart);
304 if (logger.isDebugEnabled()) {
305 logger.debug(testName + " (verify create intake not allowed): status = " + statusCode);
307 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
308 invalidStatusCodeMessage(testRequestType, statusCode));
309 Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
316 * Creates the intake instance.
318 * @param entryNumber the entry number
319 * @param entryDate the entry date
320 * @param depositor the depositor
321 * @return the multipart output
323 private PoxPayloadOut createIntakeInstance(String entryNumber,
326 IntakesCommon intake = new IntakesCommon();
327 intake.setEntryNumber(entryNumber);
328 intake.setEntryDate(entryDate);
329 intake.setDepositor(depositor);
331 PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
332 PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
333 commonPart.setLabel(new IntakeClient().getCommonPartName());
335 if(logger.isDebugEnabled()){
336 logger.debug("to be created, intake common");
337 logger.debug(objectAsXmlString(intake, IntakesCommon.class));
343 @Test(dataProvider = "testName",
344 dependsOnMethods = {"delete"})
345 public void verifyCreateWithFlippedRoles(String testName) throws Exception {
349 // Submit the request to the service and store the response.
350 DimensionClient client = new DimensionClient();
351 flipInitialAccountRoles();
353 // Now verify that elmo can create
354 client.setAuth(true, "elmo2010", true, "elmo2010", true);
355 client = new DimensionClient();
357 String identifier = createIdentifier();
358 DimensionsCommon dimension = new DimensionsCommon();
359 dimension.setDimension("dimensionType");
360 dimension.setMeasurementUnit("measurementUnit-" + identifier);
361 dimension.setValueDate(new Date().toString());
362 PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
364 Response res = client.create(multipart);
366 statusCode = res.getStatus();
368 if (logger.isDebugEnabled()) {
369 logger.debug(testName + ": status = " + statusCode);
371 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
372 invalidStatusCodeMessage(testRequestType, statusCode));
373 Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
374 knownResourceId = extractId(res);
375 if (logger.isDebugEnabled()) {
376 logger.debug(testName + ": knownResourceId=" + knownResourceId);
382 //bigbird no longer allowed to create
383 client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
384 res = client.create(multipart);
386 statusCode = res.getStatus();
387 if (logger.isDebugEnabled()) {
388 logger.debug(testName + " (verify not allowed): status = " + statusCode);
390 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
391 invalidStatusCodeMessage(testRequestType, statusCode));
392 Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
397 restoreInitialAccountRoles();
400 // ---------------------------------------------------------------
401 // CRUD tests : READ tests
402 // ---------------------------------------------------------------
404 @Test(dataProvider = "testName",
405 dependsOnMethods = {"create"})
406 public void read(String testName) throws Exception {
410 // Submit the request to the service and store the response.
411 DimensionClient client = new DimensionClient();
412 //elmo allowed to read
413 client.setAuth(true, "elmo2010", true, "elmo2010", true);
414 ClientResponse<String> res = client.read(knownResourceId);
416 assertStatusCode(res, testName);
417 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
418 DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
419 client.getCommonPartName(), DimensionsCommon.class);
420 Assert.assertNotNull(dimension);
423 res.releaseConnection();
428 @Test(dataProvider = "testName",
429 dependsOnMethods = {"read"})
430 public void readLockedOut(String testName) throws Exception {
434 // Submit the request to the service and store the response.
435 DimensionClient client = new DimensionClient();
436 //lockedOut allowed to read
437 client.setAuth(true, "lockedOut", true, "lockedOut", true);
438 ClientResponse<String> res = client.read(knownResourceId);
440 assertStatusCode(res, testName);
443 res.releaseConnection();
448 @Test(dataProvider = "testName",
449 dependsOnMethods = {"read"})
450 public void updateNotAllowed(String testName) throws Exception {
453 // Create a new client and change its AuthN credentials
454 DimensionClient client = new DimensionClient();
455 //elmo not allowed to update
456 client.setAuth(true, "elmo2010", true, "elmo2010", true);
458 // Create a new dimension object
460 DimensionsCommon dimension = new DimensionsCommon();
461 dimension.setDimension("dimensionType");
462 // Update the content of this resource.
463 dimension.setMeasurementUnit("updated-" + dimension.getMeasurementUnit());
464 dimension.setValueDate("updated-" + dimension.getValueDate());
466 // Create and submit the request to the service and store the response.
468 PoxPayloadOut output = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
469 PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), dimension);
470 ClientResponse<String> res = client.update(knownResourceId, output);
472 assertStatusCode(res, testName);
475 res.releaseConnection();
479 // Create another new client with new credentials
481 client = new DimensionClient();
482 //lockedOut not allowed to update
483 client.setAuth(true, "lockedOut", true, "lockedOut", true);
485 // Try the update again.
487 res = client.update(knownResourceId, output);
489 assertStatusCode(res, testName);
492 res.releaseConnection();
498 // ---------------------------------------------------------------
499 // CRUD tests : DELETE tests
500 // ---------------------------------------------------------------
502 @Test(dataProvider = "testName",
503 dependsOnMethods = {"updateNotAllowed"})
504 public void deleteNotAllowed(String testName) throws Exception {
508 // Create a new client and change the AuthN credentials
510 DimensionClient client = new DimensionClient();
511 //bigbird can not delete
512 client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
514 // Try to make a DELETE request
516 ClientResponse<Response> res = client.delete(knownResourceId);
518 assertStatusCode(res, testName);
521 res.releaseConnection();
526 @Test(dataProvider = "testName",
527 dependsOnMethods = {"deleteNotAllowed"})
528 public void delete(String testName) throws Exception {
532 // Submit the request to the service and store the response.
533 DimensionClient client = new DimensionClient();
535 ClientResponse<Response> res = client.delete(knownResourceId);
537 assertStatusCode(res, testName);
540 res.releaseConnection();
545 // ---------------------------------------------------------------
546 // Utility methods used by tests above
547 // ---------------------------------------------------------------
548 @AfterClass(alwaysRun = true)
549 public void cleanUp() {
551 String noTest = System.getProperty("noTestCleanup");
552 if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
553 if (logger.isDebugEnabled()) {
554 logger.debug("Skipping Cleanup phase ...");
558 if (logger.isDebugEnabled()) {
559 logger.debug("Cleaning up temporary resources created for testing ...");
562 deletePermissionRoles();
563 deleteAccountRoles();
564 //FIXME delete on permission deletes all associations with roles
565 //this would delete association with ROLE_ADMINISTRATOR too
566 //deletePermissions();
571 private void deletePermissionRoles() {
572 List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
573 bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
574 deletePermissionRole(permValues.get(bigbirdPermId), bigbirdRoleValues);
576 List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
577 elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
578 deletePermissionRole(permValues.get(elmoPermId), elmoRoleValues);
581 private void deleteAccountRoles() {
582 List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
583 bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
585 List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
586 elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
587 if(!accountRolesFlipped) {
588 deleteAccountRole(accValues.get("bigbird2010"), bigbirdRoleValues);
589 deleteAccountRole(accValues.get("elmo2010"), elmoRoleValues);
591 deleteAccountRole(accValues.get("bigbird2010"), elmoRoleValues);
592 deleteAccountRole(accValues.get("elmo2010"),bigbirdRoleValues );
596 private void flipInitialAccountRoles() {
597 if(!accountRolesFlipped) {
598 List<RoleValue> cmRoleValues = new ArrayList<RoleValue>();
599 List<RoleValue> internRoleValues = new ArrayList<RoleValue>();
600 cmRoleValues.add(roleValues.get("ROLE_TEST_CM"));
601 internRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
603 deleteAccountRole(accValues.get("bigbird2010"), cmRoleValues);
604 deleteAccountRole(accValues.get("elmo2010"), internRoleValues);
606 createAccountRole(accValues.get("bigbird2010"), internRoleValues);
607 createAccountRole(accValues.get("elmo2010"), cmRoleValues);
609 accountRolesFlipped = true;
613 private void restoreInitialAccountRoles() {
614 if(accountRolesFlipped) {
615 List<RoleValue> cmRoleValues = new ArrayList<RoleValue>();
616 List<RoleValue> internRoleValues = new ArrayList<RoleValue>();
617 cmRoleValues.add(roleValues.get("ROLE_TEST_CM"));
618 internRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
620 deleteAccountRole(accValues.get("bigbird2010"), internRoleValues);
621 deleteAccountRole(accValues.get("elmo2010"), cmRoleValues);
623 createAccountRole(accValues.get("bigbird2010"), internRoleValues);
624 createAccountRole(accValues.get("elmo2010"), cmRoleValues);
625 accountRolesFlipped = false;
629 private void deletePermissions() {
631 for (PermissionValue pv : permValues.values()) {
632 deletePermission(pv.getPermissionId());
636 private void deleteRoles() {
637 for (RoleValue rv : roleValues.values()) {
638 deleteRole(rv.getRoleId());
642 private void deleteAccounts() {
644 for (AccountValue av1 : accValues.values()) {
645 deleteAccount(av1.getAccountId());
649 private String createPermission(String resName, EffectType effect) {
650 List<PermissionAction> actions = PermissionFactory.createDefaultActions();
651 return createPermission(resName, actions, effect);
654 private String createPermission(String resName,
655 List<PermissionAction> actions, EffectType effect) {
656 String result = null;
659 PermissionClient permClient = new PermissionClient();
660 Permission permission = PermissionFactory.createPermissionInstance(resName,
661 "default permissions for " + resName, actions, effect, true, true, true);
662 ClientResponse<Response> res = permClient.create(permission);
664 assertStatusCode(res, "CreatePermission");
665 result = extractId(res);
668 res.releaseConnection();
675 private void deletePermission(String permId) {
677 PermissionClient permClient = new PermissionClient();
678 ClientResponse<Response> res = permClient.delete(permId);
680 assertStatusCode(res, "DeletePermission");
683 res.releaseConnection();
688 private String createRole(String roleName) {
689 String result = null;
692 RoleClient roleClient = new RoleClient();
693 Role role = RoleFactory.createRoleInstance(roleName,
694 roleName, //the display name
695 "role for " + roleName, true);
696 ClientResponse<Response> res = roleClient.create(role);
698 assertStatusCode(res, "CreateRole");
699 result = extractId(res);
702 res.releaseConnection();
709 private void deleteRole(String roleId) {
711 RoleClient roleClient = new RoleClient();
712 ClientResponse<Response> res = roleClient.delete(roleId);
714 assertStatusCode(res, "DeleteRole");
717 res.releaseConnection();
722 private String createAccount(String userName, String email) {
723 String result = null;
726 AccountClient accountClient = new AccountClient();
727 AccountsCommon account = AccountFactory.createAccountInstance(
728 userName, userName, userName, email, accountClient.getTenantId(),
729 true, false, true, true);
730 ClientResponse<Response> res = accountClient.create(account);
732 assertStatusCode(res, "CreateAccount");
733 result = extractId(res);
736 res.releaseConnection();
743 private void deleteAccount(String accId) {
745 AccountClient accClient = new AccountClient();
746 ClientResponse<Response> res = accClient.delete(accId);
748 assertStatusCode(res, "DeleteAccount");
751 res.releaseConnection();
756 private String createAccountRole(AccountValue av,
757 Collection<RoleValue> rvs) {
758 String result = null;
761 // Submit the request to the service and store the response.
762 AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
763 av, rvs, true, true);
764 AccountRoleClient client = new AccountRoleClient();
765 ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
767 assertStatusCode(res, "CreateAccountRole");
768 result = extractId(res);
771 res.releaseConnection();
778 private void deleteAccountRole(AccountValue av,
779 Collection<RoleValue> rvs) {
783 // Submit the request to the service and store the response.
784 AccountRoleClient client = new AccountRoleClient();
785 AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
786 av, rvs, true, true);
787 ClientResponse<Response> res = client.delete(av.getAccountId());
789 assertStatusCode(res, "DeleteAccountRole");
792 res.releaseConnection();
797 private String createPermissionRole(PermissionValue pv, Collection<RoleValue> rvs) {
798 String result = null;
801 List<RoleValue> rvls = new ArrayList<RoleValue>();
803 PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
804 pv, rvls, true, true);
805 PermissionRoleClient client = new PermissionRoleClient();
806 ClientResponse<Response> res = client.create(pv.getPermissionId(), permRole);
808 assertStatusCode(res, "CreatePermissionRole");
809 result = extractId(res);
812 res.releaseConnection();
819 private void deletePermissionRole(PermissionValue pv,
820 Collection<RoleValue> rvs) {
821 List<RoleValue> rvls = new ArrayList<RoleValue>();
827 // Submit the request to the service and store the response.
828 PermissionRoleClient client = new PermissionRoleClient();
829 PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
830 pv, rvls, true, true);
831 ClientResponse<Response> res = client.delete(pv.getPermissionId());
833 assertStatusCode(res, "DeletePermissionRole");
836 res.releaseConnection();
842 protected Class<AbstractCommonList> getCommonListType() {
843 throw new UnsupportedOperationException();