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 {
249 // Submit the request to the service and store the response.
250 DimensionClient client = new DimensionClient();
251 //bigbird allowed to create
252 client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
253 String identifier = createIdentifier();
254 DimensionsCommon dimension = new DimensionsCommon();
255 dimension.setDimension("dimensionType");
256 dimension.setMeasurementUnit("measurementUnit-" + identifier);
257 dimension.setValueDate(new Date().toString());
258 PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
260 ClientResponse<Response> res = client.create(multipart);
262 int 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);
275 // Now verify that elmo cannot create
276 client = new DimensionClient();
277 client.setAuth(true, "elmo2010", true, "elmo2010", true);
278 res = client.create(multipart);
280 statusCode = res.getStatus();
281 if (logger.isDebugEnabled()) {
282 logger.debug(testName + " (verify not allowed): status = " + statusCode);
284 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
285 invalidStatusCodeMessage(testRequestType, statusCode));
286 Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
288 //Finally, verify that elmo has no access to Intakes
289 // Submit the request to the service and store the response.
290 IntakeClient iclient = new IntakeClient();
291 iclient.setAuth(true, "elmo2010", true, "elmo2010", true);
292 multipart = createIntakeInstance(
293 "entryNumber-" + identifier,
294 "entryDate-" + identifier,
295 "depositor-" + identifier);
296 res = iclient.create(multipart);
297 if (logger.isDebugEnabled()) {
298 logger.debug(testName + " (verify create intake not allowed): status = " + statusCode);
300 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
301 invalidStatusCodeMessage(testRequestType, statusCode));
302 Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
307 * Creates the intake instance.
309 * @param entryNumber the entry number
310 * @param entryDate the entry date
311 * @param depositor the depositor
312 * @return the multipart output
314 private PoxPayloadOut createIntakeInstance(String entryNumber,
317 IntakesCommon intake = new IntakesCommon();
318 intake.setEntryNumber(entryNumber);
319 intake.setEntryDate(entryDate);
320 intake.setDepositor(depositor);
322 PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
323 PayloadOutputPart commonPart =
324 multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
325 commonPart.setLabel(new IntakeClient().getCommonPartName());
327 if(logger.isDebugEnabled()){
328 logger.debug("to be created, intake common");
329 logger.debug(objectAsXmlString(intake, IntakesCommon.class));
335 @Test(dataProvider = "testName",
336 dependsOnMethods = {"delete"})
337 public void verifyCreateWithFlippedRoles(String testName) throws Exception {
340 // Submit the request to the service and store the response.
341 DimensionClient client = new DimensionClient();
342 flipInitialAccountRoles();
344 // Now verify that elmo can create
345 client.setAuth(true, "elmo2010", true, "elmo2010", true);
346 client = new DimensionClient();
348 String identifier = createIdentifier();
349 DimensionsCommon dimension = new DimensionsCommon();
350 dimension.setDimension("dimensionType");
351 dimension.setMeasurementUnit("measurementUnit-" + identifier);
352 dimension.setValueDate(new Date().toString());
353 PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
355 ClientResponse<Response> res = client.create(multipart);
357 int statusCode = res.getStatus();
359 if (logger.isDebugEnabled()) {
360 logger.debug(testName + ": status = " + statusCode);
362 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
363 invalidStatusCodeMessage(testRequestType, statusCode));
364 Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
365 knownResourceId = extractId(res);
366 if (logger.isDebugEnabled()) {
367 logger.debug(testName + ": knownResourceId=" + knownResourceId);
370 //bigbird no longer allowed to create
371 client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
372 res = client.create(multipart);
374 statusCode = res.getStatus();
375 if (logger.isDebugEnabled()) {
376 logger.debug(testName + " (verify not allowed): status = " + statusCode);
378 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
379 invalidStatusCodeMessage(testRequestType, statusCode));
380 Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
381 restoreInitialAccountRoles();
384 // ---------------------------------------------------------------
385 // CRUD tests : READ tests
386 // ---------------------------------------------------------------
388 @Test(dataProvider = "testName",
389 dependsOnMethods = {"create"})
390 public void read(String testName) throws Exception {
394 // Submit the request to the service and store the response.
395 DimensionClient client = new DimensionClient();
396 //elmo allowed to read
397 client.setAuth(true, "elmo2010", true, "elmo2010", true);
398 ClientResponse<String> res = client.read(knownResourceId);
400 assertStatusCode(res, testName);
401 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
402 DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
403 client.getCommonPartName(), DimensionsCommon.class);
404 Assert.assertNotNull(dimension);
407 res.releaseConnection();
412 @Test(dataProvider = "testName",
413 dependsOnMethods = {"read"})
414 public void readLockedOut(String testName) throws Exception {
418 // Submit the request to the service and store the response.
419 DimensionClient client = new DimensionClient();
420 //lockedOut allowed to read
421 client.setAuth(true, "lockedOut", true, "lockedOut", true);
422 ClientResponse<String> res = client.read(knownResourceId);
424 assertStatusCode(res, testName);
427 res.releaseConnection();
432 @Test(dataProvider = "testName",
433 dependsOnMethods = {"read"})
434 public void updateNotAllowed(String testName) throws Exception {
437 // Create a new client and change its AuthN credentials
438 DimensionClient client = new DimensionClient();
439 //elmo not allowed to update
440 client.setAuth(true, "elmo2010", true, "elmo2010", true);
442 // Create a new dimension object
444 DimensionsCommon dimension = new DimensionsCommon();
445 dimension.setDimension("dimensionType");
446 // Update the content of this resource.
447 dimension.setMeasurementUnit("updated-" + dimension.getMeasurementUnit());
448 dimension.setValueDate("updated-" + dimension.getValueDate());
450 // Create and submit the request to the service and store the response.
452 PoxPayloadOut output = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
453 PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), dimension);
454 ClientResponse<String> res = client.update(knownResourceId, output);
456 assertStatusCode(res, testName);
459 res.releaseConnection();
463 // Create another new client with new credentials
465 client = new DimensionClient();
466 //lockedOut not allowed to update
467 client.setAuth(true, "lockedOut", true, "lockedOut", true);
469 // Try the update again.
471 res = client.update(knownResourceId, output);
473 assertStatusCode(res, testName);
476 res.releaseConnection();
482 // ---------------------------------------------------------------
483 // CRUD tests : DELETE tests
484 // ---------------------------------------------------------------
486 @Test(dataProvider = "testName",
487 dependsOnMethods = {"updateNotAllowed"})
488 public void deleteNotAllowed(String testName) throws Exception {
492 // Create a new client and change the AuthN credentials
494 DimensionClient client = new DimensionClient();
495 //bigbird can not delete
496 client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
498 // Try to make a DELETE request
500 ClientResponse<Response> res = client.delete(knownResourceId);
502 assertStatusCode(res, testName);
505 res.releaseConnection();
510 @Test(dataProvider = "testName",
511 dependsOnMethods = {"deleteNotAllowed"})
512 public void delete(String testName) throws Exception {
516 // Submit the request to the service and store the response.
517 DimensionClient client = new DimensionClient();
519 ClientResponse<Response> res = client.delete(knownResourceId);
521 assertStatusCode(res, testName);
524 res.releaseConnection();
529 // ---------------------------------------------------------------
530 // Utility methods used by tests above
531 // ---------------------------------------------------------------
532 @AfterClass(alwaysRun = true)
533 public void cleanUp() {
535 String noTest = System.getProperty("noTestCleanup");
536 if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
537 if (logger.isDebugEnabled()) {
538 logger.debug("Skipping Cleanup phase ...");
542 if (logger.isDebugEnabled()) {
543 logger.debug("Cleaning up temporary resources created for testing ...");
546 deletePermissionRoles();
547 deleteAccountRoles();
548 //FIXME delete on permission deletes all associations with roles
549 //this would delete association with ROLE_ADMINISTRATOR too
550 //deletePermissions();
555 private void deletePermissionRoles() {
556 List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
557 bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
558 deletePermissionRole(permValues.get(bigbirdPermId), bigbirdRoleValues);
560 List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
561 elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
562 deletePermissionRole(permValues.get(elmoPermId), elmoRoleValues);
565 private void deleteAccountRoles() {
566 List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
567 bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
569 List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
570 elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
571 if(!accountRolesFlipped) {
572 deleteAccountRole(accValues.get("bigbird2010"), bigbirdRoleValues);
573 deleteAccountRole(accValues.get("elmo2010"), elmoRoleValues);
575 deleteAccountRole(accValues.get("bigbird2010"), elmoRoleValues);
576 deleteAccountRole(accValues.get("elmo2010"),bigbirdRoleValues );
580 private void flipInitialAccountRoles() {
581 if(!accountRolesFlipped) {
582 List<RoleValue> cmRoleValues = new ArrayList<RoleValue>();
583 List<RoleValue> internRoleValues = new ArrayList<RoleValue>();
584 cmRoleValues.add(roleValues.get("ROLE_TEST_CM"));
585 internRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
587 deleteAccountRole(accValues.get("bigbird2010"), cmRoleValues);
588 deleteAccountRole(accValues.get("elmo2010"), internRoleValues);
590 createAccountRole(accValues.get("bigbird2010"), internRoleValues);
591 createAccountRole(accValues.get("elmo2010"), cmRoleValues);
593 accountRolesFlipped = true;
597 private void restoreInitialAccountRoles() {
598 if(accountRolesFlipped) {
599 List<RoleValue> cmRoleValues = new ArrayList<RoleValue>();
600 List<RoleValue> internRoleValues = new ArrayList<RoleValue>();
601 cmRoleValues.add(roleValues.get("ROLE_TEST_CM"));
602 internRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
604 deleteAccountRole(accValues.get("bigbird2010"), internRoleValues);
605 deleteAccountRole(accValues.get("elmo2010"), cmRoleValues);
607 createAccountRole(accValues.get("bigbird2010"), internRoleValues);
608 createAccountRole(accValues.get("elmo2010"), cmRoleValues);
609 accountRolesFlipped = false;
613 private void deletePermissions() {
615 for (PermissionValue pv : permValues.values()) {
616 deletePermission(pv.getPermissionId());
620 private void deleteRoles() {
621 for (RoleValue rv : roleValues.values()) {
622 deleteRole(rv.getRoleId());
626 private void deleteAccounts() {
628 for (AccountValue av1 : accValues.values()) {
629 deleteAccount(av1.getAccountId());
633 private String createPermission(String resName, EffectType effect) {
634 List<PermissionAction> actions = PermissionFactory.createDefaultActions();
635 return createPermission(resName, actions, effect);
638 private String createPermission(String resName,
639 List<PermissionAction> actions, EffectType effect) {
640 String result = null;
643 PermissionClient permClient = new PermissionClient();
644 Permission permission = PermissionFactory.createPermissionInstance(resName,
645 "default permissions for " + resName, actions, effect, true, true, true);
646 ClientResponse<Response> res = permClient.create(permission);
648 assertStatusCode(res, "CreatePermission");
649 result = extractId(res);
652 res.releaseConnection();
659 private void deletePermission(String permId) {
661 PermissionClient permClient = new PermissionClient();
662 ClientResponse<Response> res = permClient.delete(permId);
664 assertStatusCode(res, "DeletePermission");
667 res.releaseConnection();
672 private String createRole(String roleName) {
673 String result = null;
676 RoleClient roleClient = new RoleClient();
677 Role role = RoleFactory.createRoleInstance(roleName,
678 roleName, //the display name
679 "role for " + roleName, true);
680 ClientResponse<Response> res = roleClient.create(role);
682 assertStatusCode(res, "CreateRole");
683 result = extractId(res);
686 res.releaseConnection();
693 private void deleteRole(String roleId) {
695 RoleClient roleClient = new RoleClient();
696 ClientResponse<Response> res = roleClient.delete(roleId);
698 assertStatusCode(res, "DeleteRole");
701 res.releaseConnection();
706 private String createAccount(String userName, String email) {
707 String result = null;
710 AccountClient accountClient = new AccountClient();
711 AccountsCommon account = AccountFactory.createAccountInstance(
712 userName, userName, userName, email, accountClient.getTenantId(),
713 true, false, true, true);
714 ClientResponse<Response> res = accountClient.create(account);
716 assertStatusCode(res, "CreateAccount");
717 result = extractId(res);
720 res.releaseConnection();
727 private void deleteAccount(String accId) {
729 AccountClient accClient = new AccountClient();
730 ClientResponse<Response> res = accClient.delete(accId);
732 assertStatusCode(res, "DeleteAccount");
735 res.releaseConnection();
740 private String createAccountRole(AccountValue av,
741 Collection<RoleValue> rvs) {
742 String result = null;
745 // Submit the request to the service and store the response.
746 AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
747 av, rvs, true, true);
748 AccountRoleClient client = new AccountRoleClient();
749 ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
751 assertStatusCode(res, "CreateAccountRole");
752 result = extractId(res);
755 res.releaseConnection();
762 private void deleteAccountRole(AccountValue av,
763 Collection<RoleValue> rvs) {
767 // Submit the request to the service and store the response.
768 AccountRoleClient client = new AccountRoleClient();
769 AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
770 av, rvs, true, true);
771 ClientResponse<Response> res = client.delete(av.getAccountId());
773 assertStatusCode(res, "DeleteAccountRole");
776 res.releaseConnection();
781 private String createPermissionRole(PermissionValue pv, Collection<RoleValue> rvs) {
782 String result = null;
785 List<RoleValue> rvls = new ArrayList<RoleValue>();
787 PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
788 pv, rvls, true, true);
789 PermissionRoleClient client = new PermissionRoleClient();
790 ClientResponse<Response> res = client.create(pv.getPermissionId(), permRole);
792 assertStatusCode(res, "CreatePermissionRole");
793 result = extractId(res);
796 res.releaseConnection();
803 private void deletePermissionRole(PermissionValue pv,
804 Collection<RoleValue> rvs) {
805 List<RoleValue> rvls = new ArrayList<RoleValue>();
811 // Submit the request to the service and store the response.
812 PermissionRoleClient client = new PermissionRoleClient();
813 PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
814 pv, rvls, true, true);
815 ClientResponse<Response> res = client.delete(pv.getPermissionId());
817 assertStatusCode(res, "DeletePermissionRole");
820 res.releaseConnection();
826 protected Class<AbstractCommonList> getCommonListType() {
827 throw new UnsupportedOperationException();