import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.authorization.AccountValue;
import org.collectionspace.services.authorization.AccountRoleRel;
+import org.collectionspace.services.authorization.Permission;
+import org.collectionspace.services.authorization.Role;
import org.collectionspace.services.authorization.SubjectType;
import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
extends AbstractCollectionSpaceResourceImpl<AccountRole, AccountRole> {
final public static String ACCOUNT_ACCOUNTROLE_SERVICE = "accounts/accountroles";
- final public static String ROLE_ACCOUNTROLE_SERVICE = "roles/accountroles";
+ final public static String ROLE_ACCOUNTROLE_SERVICE = "authorization/roles/accountroles";
//this service is never exposed as standalone RESTful service...just use unique
//service name to identify binding
/** The service name. */
*
* @param serviceName qualified service path
*/
- AccountRoleSubResource(String serviceName) {
+ public AccountRoleSubResource(String serviceName) {
this.serviceName = serviceName;
}
ctx.setProperty(ServiceContextProperties.ENTITY_CLASS, AccountRoleRel.class);
//subject name is necessary to indicate if role or account is a subject
ctx.setProperty(ServiceContextProperties.SUBJECT, subject);
+
//set context for the relationship query
- ctx.setProperty(ServiceContextProperties.OBJECT_CLASS, AccountsCommon.class);
- ctx.setProperty(ServiceContextProperties.OBJECT_ID, "account_id");
+ if (subject == SubjectType.ROLE) {
+ ctx.setProperty(ServiceContextProperties.OBJECT_CLASS, AccountsCommon.class);
+ ctx.setProperty(ServiceContextProperties.OBJECT_ID, "account_id");
+ } else if (subject == SubjectType.ACCOUNT) {
+ ctx.setProperty(ServiceContextProperties.OBJECT_CLASS, Role.class);
+ ctx.setProperty(ServiceContextProperties.OBJECT_ID, "role_id");
+ }
+
return ctx;
}
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
+import org.collectionspace.services.account.AccountRoleSubResource;
import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
//import org.collectionspace.services.common.context.RemoteServiceContextImpl;
import org.collectionspace.services.common.ServiceMessages;
throw new WebApplicationException(response);
}
try {
- //FIXME ideally the following two ops should be in the same tx CSPACE-658
+ //FIXME ideally the following three operations should be in the same tx CSPACE-658
//delete all relationships for this permission
- PermissionRoleSubResource subResource =
+ PermissionRoleSubResource permRoleResource =
new PermissionRoleSubResource(PermissionRoleSubResource.ROLE_PERMROLE_SERVICE);
- subResource.deletePermissionRole(csid, SubjectType.PERMISSION);
-
- ServiceContext ctx = createServiceContext((Role) null, Role.class);
+ permRoleResource.deletePermissionRole(csid, SubjectType.PERMISSION);
+ //delete all the account/role relationships associate with this role
+ AccountRoleSubResource accountRoleResource =
+ new AccountRoleSubResource(AccountRoleSubResource.ROLE_ACCOUNTROLE_SERVICE);
+ accountRoleResource.deleteAccountRole(csid, SubjectType.ACCOUNT);
+ //finally, delete the role itself
+ ServiceContext<Role, Role> ctx = createServiceContext((Role) null, Role.class);
((JpaStorageClientImpl) getStorageClient(ctx)).deleteWhere(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (UnauthorizedException ue) {
</service:object>
</tenant:serviceBindings>
<!-- end role-permission service meta-data -->
+
+ <!-- begin role-account service meta-data -->
+ <!-- the following service is same as account/accountroles service -->
+ <!-- except that it is available as a sub resource of the role service -->
+ <tenant:serviceBindings name="authorization/roles/accountroles" version="0.1">
+ <!-- other URI paths using which this service could be accessed -->
+<!-- <service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
+ /authorization/roles/*/accountroles/
+ </service:uriPath>-->
+ <service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.account.storage.AccountRoleDocumentHandler
+ </service:documentHandler>
+ <!--service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler
+ </service:validatorHandler-->
+ <service:object name="AccountRole" version="0.1"
+ xmlns:service='http://collectionspace.org/services/common/service'>
+ <service:part id="0" control_group="Managed"
+ versionable="true" auditable="false"
+ label="accountroles_system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent
+ namespaceURI="http://collectionspace.org/services/common/system"
+ schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd">
+ </service:xmlContent>
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed"
+ versionable="true" auditable="false"
+ label="accountroles" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent
+ namespaceURI="http://collectionspace.org/services/authorization"
+ schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/accounts_roles.xsd">
+ </service:xmlContent>
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+
</tenant:tenantBinding>
<!-- end movingimages.us tenant meta-data -->
</service:object>
</tenant:serviceBindings>
<!-- end role-permission service meta-data -->
+
+ <!-- begin role-account service meta-data -->
+ <!-- the following service is same as account/accountroles service -->
+ <!-- except that it is available as a sub resource of the role service -->
+ <tenant:serviceBindings name="authorization/roles/accountroles" version="0.1">
+ <!-- other URI paths using which this service could be accessed -->
+<!-- <service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
+ /authorization/roles/*/accountroles/
+ </service:uriPath>-->
+ <service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.account.storage.AccountRoleDocumentHandler
+ </service:documentHandler>
+ <!--service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler
+ </service:validatorHandler-->
+ <service:object name="AccountRole" version="0.1"
+ xmlns:service='http://collectionspace.org/services/common/service'>
+ <service:part id="0" control_group="Managed"
+ versionable="true" auditable="false"
+ label="accountroles_system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent
+ namespaceURI="http://collectionspace.org/services/common/system"
+ schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd">
+ </service:xmlContent>
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed"
+ versionable="true" auditable="false"
+ label="accountroles" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent
+ namespaceURI="http://collectionspace.org/services/authorization"
+ schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/accounts_roles.xsd">
+ </service:xmlContent>
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
</tenant:tenantBinding>
+
<!-- end hearstmuseum.berkeley.edu tenant meta-data -->
</tenant:TenantBindingConfig>