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 2009 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.
24 package org.collectionspace.services.authorization;
26 import javax.ws.rs.Consumes;
27 import javax.ws.rs.GET;
28 import javax.ws.rs.Path;
29 import javax.ws.rs.Produces;
30 import javax.ws.rs.DELETE;
31 import javax.ws.rs.POST;
32 import javax.ws.rs.PUT;
33 import javax.ws.rs.PathParam;
34 import javax.ws.rs.QueryParam;
35 import javax.ws.rs.WebApplicationException;
36 import javax.ws.rs.core.Context;
37 import javax.ws.rs.core.MultivaluedMap;
38 import javax.ws.rs.core.Response;
39 import javax.ws.rs.core.UriBuilder;
40 import javax.ws.rs.core.UriInfo;
42 import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
43 //import org.collectionspace.services.common.context.RemoteServiceContextImpl;
44 import org.collectionspace.services.common.ServiceMessages;
45 import org.collectionspace.services.common.context.ServiceContext;
46 import org.collectionspace.services.common.context.ServiceContextFactory;
47 import org.collectionspace.services.common.context.RemoteServiceContextFactory;
48 import org.collectionspace.services.common.document.BadRequestException;
49 import org.collectionspace.services.common.document.DocumentFilter;
50 import org.collectionspace.services.common.document.DocumentNotFoundException;
51 import org.collectionspace.services.common.document.DocumentHandler;
52 import org.collectionspace.services.common.security.UnauthorizedException;
53 import org.collectionspace.services.common.storage.StorageClient;
54 import org.collectionspace.services.common.storage.jpa.JpaStorageClientImpl;
55 import org.jboss.resteasy.util.HttpResponseCodes;
56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory;
59 // TODO: Auto-generated Javadoc
61 * The Class RoleResource.
63 @Path("/authorization/roles")
64 @Consumes("application/xml")
65 @Produces("application/xml")
66 public class RoleResource
67 extends AbstractCollectionSpaceResourceImpl {
69 /** The service name. */
70 final private String serviceName = "authorization/roles";
72 final Logger logger = LoggerFactory.getLogger(RoleResource.class);
73 /** The storage client. */
74 final StorageClient storageClient = new JpaStorageClientImpl();
77 * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
80 protected String getVersionString() {
81 /** The last change revision. */
82 final String lastChangeRevision = "$LastChangedRevision: 1165 $";
83 return lastChangeRevision;
87 * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
90 public String getServiceName() {
95 * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
98 public Class<RoleResource> getCommonPartClass() {
99 return RoleResource.class;
103 * @see org.collectionspace.services.common.CollectionSpaceResource#getServiceContextFactory()
106 public ServiceContextFactory getServiceContextFactory() {
107 return RemoteServiceContextFactory.get();
110 // private <T> ServiceContext createServiceContext(T obj) throws Exception {
111 // ServiceContext ctx = new RemoteServiceContextImpl<T, T>(getServiceName());
112 // ctx.setInput(obj);
113 // ctx.setDocumentType(Role.class.getPackage().getName()); //persistence unit
114 // ctx.setProperty("entity-name", Role.class.getName());
119 * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getStorageClient(org.collectionspace.services.common.context.ServiceContext)
122 public StorageClient getStorageClient(ServiceContext ctx) {
123 //FIXME use ctx to identify storage client
124 return storageClient;
128 // public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
129 // DocumentHandler docHandler = ctx.getDocumentHandler();
130 // docHandler.setCommonPart(ctx.getInput());
131 // return docHandler;
136 * @param input the input
138 * @return the response
141 public Response createRole(Role input) {
143 ServiceContext ctx = createServiceContext(input, Role.class);
144 DocumentHandler handler = createDocumentHandler(ctx);
145 String csid = getStorageClient(ctx).create(ctx, handler);
146 UriBuilder path = UriBuilder.fromResource(RoleResource.class);
147 path.path("" + csid);
148 Response response = Response.created(path.build()).build();
150 } catch (BadRequestException bre) {
151 Response response = Response.status(
152 Response.Status.BAD_REQUEST).entity(ServiceMessages.POST_FAILED
153 + bre.getErrorReason()).type("text/plain").build();
154 throw new WebApplicationException(response);
155 } catch (UnauthorizedException ue) {
156 Response response = Response.status(
157 Response.Status.UNAUTHORIZED).entity(ServiceMessages.POST_FAILED
158 + ue.getErrorReason()).type("text/plain").build();
159 throw new WebApplicationException(response);
160 } catch (Exception e) {
161 if (logger.isDebugEnabled()) {
162 logger.debug("Caught exception in createRole", e);
164 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
165 Response response = Response.status(
166 Response.Status.INTERNAL_SERVER_ERROR).entity(ServiceMessages.POST_FAILED
167 + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
168 throw new WebApplicationException(response);
175 * @param csid the csid
182 @PathParam("csid") String csid) {
183 if (logger.isDebugEnabled()) {
184 logger.debug("getRole with csid=" + csid);
186 if (csid == null || "".equals(csid)) {
187 logger.error("getRole: missing csid!");
188 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
189 ServiceMessages.GET_FAILED + "role csid=").type(
190 "text/plain").build();
191 throw new WebApplicationException(response);
195 ServiceContext ctx = createServiceContext((Role) null, Role.class);
196 DocumentHandler handler = createDocumentHandler(ctx);
197 getStorageClient(ctx).get(ctx, csid, handler);
198 result = (Role) ctx.getOutput();
199 } catch (UnauthorizedException ue) {
200 Response response = Response.status(
201 Response.Status.UNAUTHORIZED).entity(ServiceMessages.GET_FAILED
202 + ue.getErrorReason()).type("text/plain").build();
203 throw new WebApplicationException(response);
204 } catch (DocumentNotFoundException dnfe) {
205 if (logger.isDebugEnabled()) {
206 logger.debug("getRole", dnfe);
208 Response response = Response.status(Response.Status.NOT_FOUND).entity(
209 ServiceMessages.GET_FAILED + "role csid=" + csid).type(
210 "text/plain").build();
211 throw new WebApplicationException(response);
212 } catch (Exception e) {
213 if (logger.isDebugEnabled()) {
214 logger.debug("getRole", e);
216 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
217 Response response = Response.status(
218 Response.Status.INTERNAL_SERVER_ERROR).entity(ServiceMessages.GET_FAILED
219 + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
220 throw new WebApplicationException(response);
223 if (result == null) {
224 Response response = Response.status(Response.Status.NOT_FOUND).entity(
225 ServiceMessages.GET_FAILED + "role csid=" + csid + ": was not found.").type(
226 "text/plain").build();
227 throw new WebApplicationException(response);
233 * Gets the role list.
237 * @return the role list
240 @Produces("application/xml")
241 public RolesList getRoleList(
242 @Context UriInfo ui) {
243 RolesList roleList = new RolesList();
245 ServiceContext ctx = createServiceContext((Role) null, Role.class);
246 DocumentHandler handler = createDocumentHandler(ctx);
247 MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
248 DocumentFilter myFilter = handler.createDocumentFilter();
249 myFilter.setPagination(queryParams);
250 myFilter.setQueryParams(queryParams);
251 handler.setDocumentFilter(myFilter);
252 getStorageClient(ctx).getFiltered(ctx, handler);
253 roleList = (RolesList) handler.getCommonPartList();
254 } catch (UnauthorizedException ue) {
255 Response response = Response.status(
256 Response.Status.UNAUTHORIZED).entity(ServiceMessages.LIST_FAILED
257 + ue.getErrorReason()).type("text/plain").build();
258 throw new WebApplicationException(response);
260 } catch (Exception e) {
261 if (logger.isDebugEnabled()) {
262 logger.debug("Caught exception in getRoleList", e);
264 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
265 Response response = Response.status(
266 Response.Status.INTERNAL_SERVER_ERROR).entity(ServiceMessages.LIST_FAILED
267 + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
268 throw new WebApplicationException(response);
276 * @param csid the csid
277 * @param theUpdate the the update
283 public Role updateRole(
284 @PathParam("csid") String csid,
286 if (logger.isDebugEnabled()) {
287 logger.debug("updateRole with csid=" + csid);
289 if (csid == null || "".equals(csid)) {
290 logger.error("updateRole: missing csid!");
291 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
292 ServiceMessages.PUT_FAILED + "role "
293 + ServiceMessages.MISSING_INVALID_CSID + csid).type(
294 "text/plain").build();
295 throw new WebApplicationException(response);
299 ServiceContext ctx = createServiceContext(theUpdate, Role.class);
300 DocumentHandler handler = createDocumentHandler(ctx);
301 getStorageClient(ctx).update(ctx, csid, handler);
302 result = (Role) ctx.getOutput();
303 } catch (BadRequestException bre) {
304 Response response = Response.status(
305 Response.Status.BAD_REQUEST).entity(ServiceMessages.PUT_FAILED
306 + bre.getErrorReason()).type("text/plain").build();
307 throw new WebApplicationException(response);
308 } catch (UnauthorizedException ue) {
309 Response response = Response.status(
310 Response.Status.UNAUTHORIZED).entity(ServiceMessages.PUT_FAILED
311 + ue.getErrorReason()).type("text/plain").build();
312 throw new WebApplicationException(response);
313 } catch (DocumentNotFoundException dnfe) {
314 if (logger.isDebugEnabled()) {
315 logger.debug("caugth exception in updateRole", dnfe);
317 Response response = Response.status(Response.Status.NOT_FOUND).entity(
318 ServiceMessages.PUT_FAILED + "role csid=" + csid).type(
319 "text/plain").build();
320 throw new WebApplicationException(response);
321 } catch (Exception e) {
322 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
323 Response response = Response.status(
324 Response.Status.INTERNAL_SERVER_ERROR).entity(
325 ServiceMessages.PUT_FAILED
326 + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
327 throw new WebApplicationException(response);
335 * @param csid the csid
337 * @return the response
341 public Response deleteRole(@PathParam("csid") String csid) {
343 if (logger.isDebugEnabled()) {
344 logger.debug("deleteRole with csid=" + csid);
346 if (csid == null || "".equals(csid)) {
347 logger.error("deleteRole: missing csid!");
348 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
349 ServiceMessages.DELETE_FAILED + "role csid=" + csid).type(
350 "text/plain").build();
351 throw new WebApplicationException(response);
354 //FIXME ideally the following two ops should be in the same tx CSPACE-658
355 //delete all relationships for this permission
356 PermissionRoleSubResource subResource =
357 new PermissionRoleSubResource(PermissionRoleSubResource.ROLE_PERMROLE_SERVICE);
358 subResource.deletePermissionRole(csid, SubjectType.PERMISSION);
360 ServiceContext ctx = createServiceContext((Role) null, Role.class);
361 ((JpaStorageClientImpl) getStorageClient(ctx)).deleteWhere(ctx, csid);
362 return Response.status(HttpResponseCodes.SC_OK).build();
363 } catch (UnauthorizedException ue) {
364 Response response = Response.status(
365 Response.Status.UNAUTHORIZED).entity(ServiceMessages.DELETE_FAILED + ue.getErrorReason()).type("text/plain").build();
366 throw new WebApplicationException(response);
368 } catch (DocumentNotFoundException dnfe) {
369 if (logger.isDebugEnabled()) {
370 logger.debug("caught exception in deleteRole", dnfe);
372 Response response = Response.status(Response.Status.NOT_FOUND).entity(
373 ServiceMessages.DELETE_FAILED + "role csid=" + csid).type(
374 "text/plain").build();
375 throw new WebApplicationException(response);
376 } catch (Exception e) {
377 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
378 Response response = Response.status(
379 Response.Status.INTERNAL_SERVER_ERROR).entity(
380 ServiceMessages.DELETE_FAILED + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
381 throw new WebApplicationException(response);
387 * Creates the role permission.
389 * @param method the method
390 * @param roleCsid the role csid
391 * @param input the input
392 * @return the response
395 @Path("{csid}/permroles")
396 public Response createRolePermission(@QueryParam("_method") String method, @PathParam("csid") String roleCsid,
397 PermissionRole input) {
398 if (method != null) {
399 if ("delete".equalsIgnoreCase(method)) {
400 return deleteRolePermission(roleCsid, input);
403 if (logger.isDebugEnabled()) {
404 logger.debug("createRolePermission with roleCsid=" + roleCsid);
406 if (roleCsid == null || "".equals(roleCsid)) {
407 logger.error("createRolePermission: missing roleCsid!");
408 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
409 ServiceMessages.POST_FAILED + "permroles role "
410 + ServiceMessages.MISSING_INVALID_CSID + roleCsid).type(
411 "text/plain").build();
412 throw new WebApplicationException(response);
415 PermissionRoleSubResource subResource =
416 new PermissionRoleSubResource(PermissionRoleSubResource.ROLE_PERMROLE_SERVICE);
417 String permrolecsid = subResource.createPermissionRole(input, SubjectType.PERMISSION);
418 UriBuilder path = UriBuilder.fromResource(PermissionResource.class);
419 path.path(roleCsid + "/permroles/" + permrolecsid);
420 Response response = Response.created(path.build()).build();
422 } catch (BadRequestException bre) {
423 Response response = Response.status(
424 Response.Status.BAD_REQUEST).entity("Create failed reason "
425 + bre.getErrorReason()).type("text/plain").build();
426 throw new WebApplicationException(response);
427 } catch (UnauthorizedException ue) {
428 Response response = Response.status(
429 Response.Status.UNAUTHORIZED).entity("Create failed reason "
430 + ue.getErrorReason()).type("text/plain").build();
431 throw new WebApplicationException(response);
432 } catch (Exception e) {
433 if (logger.isDebugEnabled()) {
434 logger.debug("Caught exception in createRolePermission", e);
436 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
437 Response response = Response.status(
438 Response.Status.INTERNAL_SERVER_ERROR).entity(
439 ServiceMessages.POST_FAILED
440 + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
441 throw new WebApplicationException(response);
446 * Gets the role permission.
448 * @param roleCsid the role csid
449 * @param permrolecsid the permrolecsid
450 * @return the role permission
453 @Path("{csid}/permroles")
454 public PermissionRole getRolePermission(
455 @PathParam("csid") String roleCsid) {
456 if (logger.isDebugEnabled()) {
457 logger.debug("getRolePermission with roleCsid=" + roleCsid);
459 if (roleCsid == null || "".equals(roleCsid)) {
460 logger.error("getRolePermission: missing roleCsid!");
461 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
462 ServiceMessages.GET_FAILED + "permroles role "
463 + ServiceMessages.MISSING_INVALID_CSID + roleCsid).type(
464 "text/plain").build();
465 throw new WebApplicationException(response);
467 PermissionRole result = null;
469 PermissionRoleSubResource subResource =
470 new PermissionRoleSubResource(PermissionRoleSubResource.ROLE_PERMROLE_SERVICE);
471 //get relationships for a role
472 result = subResource.getPermissionRole(roleCsid, SubjectType.PERMISSION);
473 } catch (UnauthorizedException ue) {
474 Response response = Response.status(
475 Response.Status.UNAUTHORIZED).entity(ServiceMessages.GET_FAILED
476 + ue.getErrorReason()).type("text/plain").build();
477 throw new WebApplicationException(response);
478 } catch (DocumentNotFoundException dnfe) {
479 if (logger.isDebugEnabled()) {
480 logger.debug("getRolePermission", dnfe);
482 Response response = Response.status(Response.Status.NOT_FOUND).entity(
483 ServiceMessages.GET_FAILED + "permroles role csid=" + roleCsid).type(
484 "text/plain").build();
485 throw new WebApplicationException(response);
486 } catch (Exception e) {
487 if (logger.isDebugEnabled()) {
488 logger.debug("getRolePermission", e);
490 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
491 Response response = Response.status(
492 Response.Status.INTERNAL_SERVER_ERROR).entity(
493 ServiceMessages.GET_FAILED
494 + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
495 throw new WebApplicationException(response);
497 if (result == null) {
498 Response response = Response.status(Response.Status.NOT_FOUND).entity(
499 ServiceMessages.GET_FAILED + "permroles role csid=" + roleCsid
500 + ": was not found.").type(
501 "text/plain").build();
502 throw new WebApplicationException(response);
508 @Path("{csid}/permroles/{permrolecsid}")
509 public PermissionRoleRel getRolePermission(
510 @PathParam("csid") String roleCsid,
511 @PathParam("permrolecsid") String permrolecsid) {
512 if (logger.isDebugEnabled()) {
513 logger.debug("getRolePermission with roleCsid=" + roleCsid);
515 if (roleCsid == null || "".equals(roleCsid)) {
516 logger.error("getRolePermission: missing roleCsid!");
517 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
518 ServiceMessages.GET_FAILED + "permroles role "
519 + ServiceMessages.MISSING_INVALID_CSID + roleCsid).type(
520 "text/plain").build();
521 throw new WebApplicationException(response);
523 PermissionRoleRel result = null;
525 PermissionRoleSubResource subResource =
526 new PermissionRoleSubResource(PermissionRoleSubResource.ROLE_PERMROLE_SERVICE);
527 //get relationships for a role
528 result = subResource.getPermissionRoleRel(roleCsid, SubjectType.PERMISSION, permrolecsid);
529 } catch (UnauthorizedException ue) {
530 Response response = Response.status(
531 Response.Status.UNAUTHORIZED).entity(ServiceMessages.GET_FAILED
532 + ue.getErrorReason()).type("text/plain").build();
533 throw new WebApplicationException(response);
534 } catch (DocumentNotFoundException dnfe) {
535 if (logger.isDebugEnabled()) {
536 logger.debug("getRolePermission", dnfe);
538 Response response = Response.status(Response.Status.NOT_FOUND).entity(
539 ServiceMessages.GET_FAILED + "permroles role csid=" + roleCsid).type(
540 "text/plain").build();
541 throw new WebApplicationException(response);
542 } catch (Exception e) {
543 if (logger.isDebugEnabled()) {
544 logger.debug("getRolePermission", e);
546 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
547 Response response = Response.status(
548 Response.Status.INTERNAL_SERVER_ERROR).entity(
549 ServiceMessages.GET_FAILED
550 + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
551 throw new WebApplicationException(response);
553 if (result == null) {
554 Response response = Response.status(Response.Status.NOT_FOUND).entity(
555 ServiceMessages.GET_FAILED + "permroles role csid=" + roleCsid
556 + ": was not found.").type(
557 "text/plain").build();
558 throw new WebApplicationException(response);
564 * Delete role permission.
566 * @param roleCsid the role csid
567 * @param input the input
568 * @return the response
570 public Response deleteRolePermission(String roleCsid, PermissionRole input) {
572 if (logger.isDebugEnabled()) {
573 logger.debug("deleteRolePermission with roleCsid=" + roleCsid);
576 if (roleCsid == null || "".equals(roleCsid)) {
577 logger.error("deleteRolePermission: missing roleCsid!");
578 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
579 ServiceMessages.DELETE_FAILED + "permroles role "
580 + ServiceMessages.MISSING_INVALID_CSID + roleCsid).type(
581 "text/plain").build();
582 throw new WebApplicationException(response);
585 PermissionRoleSubResource subResource =
586 new PermissionRoleSubResource(PermissionRoleSubResource.ROLE_PERMROLE_SERVICE);
587 //delete all relationships for a permission
588 subResource.deletePermissionRole(roleCsid, SubjectType.PERMISSION, input);
589 return Response.status(HttpResponseCodes.SC_OK).build();
590 } catch (UnauthorizedException ue) {
591 Response response = Response.status(
592 Response.Status.UNAUTHORIZED).entity(ServiceMessages.DELETE_FAILED
593 + ue.getErrorReason()).type("text/plain").build();
594 throw new WebApplicationException(response);
595 } catch (DocumentNotFoundException dnfe) {
596 if (logger.isDebugEnabled()) {
597 logger.debug("caught exception in deleteRolePermission", dnfe);
599 Response response = Response.status(Response.Status.NOT_FOUND).entity(
600 ServiceMessages.DELETE_FAILED + "role csid=" + roleCsid).type(
601 "text/plain").build();
602 throw new WebApplicationException(response);
603 } catch (Exception e) {
604 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
605 Response response = Response.status(
606 Response.Status.INTERNAL_SERVER_ERROR).entity(
607 ServiceMessages.DELETE_FAILED
608 + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
609 throw new WebApplicationException(response);
615 * Delete role permission.
617 * @param roleCsid the role csid
618 * @return the response
621 @Path("{csid}/permroles")
622 public Response deleteRolePermission(
623 @PathParam("csid") String roleCsid) {
625 if (logger.isDebugEnabled()) {
626 logger.debug("deleteRolePermission with roleCsid=" + roleCsid);
629 if (roleCsid == null || "".equals(roleCsid)) {
630 logger.error("deleteRolePermission: missing roleCsid!");
631 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
632 ServiceMessages.DELETE_FAILED + "permroles role "
633 + ServiceMessages.MISSING_INVALID_CSID + roleCsid).type(
634 "text/plain").build();
635 throw new WebApplicationException(response);
638 PermissionRoleSubResource subResource =
639 new PermissionRoleSubResource(PermissionRoleSubResource.ROLE_PERMROLE_SERVICE);
640 //delete all relationships for a permission
641 subResource.deletePermissionRole(roleCsid, SubjectType.PERMISSION);
642 return Response.status(HttpResponseCodes.SC_OK).build();
643 } catch (UnauthorizedException ue) {
644 Response response = Response.status(
645 Response.Status.UNAUTHORIZED).entity(ServiceMessages.DELETE_FAILED
646 + ue.getErrorReason()).type("text/plain").build();
647 throw new WebApplicationException(response);
648 } catch (DocumentNotFoundException dnfe) {
649 if (logger.isDebugEnabled()) {
650 logger.debug("caught exception in deleteRolePermission", dnfe);
652 Response response = Response.status(Response.Status.NOT_FOUND).entity(
653 ServiceMessages.DELETE_FAILED + "role csid=" + roleCsid).type(
654 "text/plain").build();
655 throw new WebApplicationException(response);
656 } catch (Exception e) {
657 logger.error(ServiceMessages.UNKNOWN_ERROR_MSG, e);
658 Response response = Response.status(
659 Response.Status.INTERNAL_SERVER_ERROR).entity(
660 ServiceMessages.DELETE_FAILED
661 + ServiceMessages.UNKNOWN_ERROR_MSG).type("text/plain").build();
662 throw new WebApplicationException(response);