use of com.emc.storageos.model.object.BucketACL in project coprhd-controller by CoprHD.
the class BucketACLUtility method verifyBucketACL.
public void verifyBucketACL(BucketACLUpdateParams param) {
BucketACL bucketAcl = null;
// Add Payload
bucketAcl = param.getAclToAdd();
validateBucketACL(bucketAcl, BucketACLOperationType.ADD);
reportErrors(param, BucketACLOperationType.ADD);
// Modify Payload
bucketAcl = param.getAclToModify();
validateBucketACL(bucketAcl, BucketACLOperationType.MODIFY);
reportErrors(param, BucketACLOperationType.MODIFY);
// Delete Payload
bucketAcl = param.getAclToDelete();
validateBucketACL(bucketAcl, BucketACLOperationType.DELETE);
reportErrors(param, BucketACLOperationType.DELETE);
}
use of com.emc.storageos.model.object.BucketACL in project coprhd-controller by CoprHD.
the class BucketACLUtility method reportDeleteErrors.
private void reportDeleteErrors(BucketACLUpdateParams param) {
String opName = BucketACLOperationType.DELETE.name();
// Report Add ACL Errors
BucketACL bucketACL = param.getAclToDelete();
if (bucketACL == null || bucketACL.getBucketACL().isEmpty()) {
return;
}
List<BucketACE> bucketACELits = bucketACL.getBucketACL();
for (BucketACE bucketACE : bucketACELits) {
if (!bucketACE.canProceedToNextStep()) {
BucketACLOperationErrorType error = bucketACE.getErrorType();
switch(error) {
case USER_AND_GROUP_AND_CUSTOMGROUP_PROVIDED:
{
throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), bucketACE.getCustomGroup());
}
case USER_AND_GROUP_PROVIDED:
{
throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), bucketACE.getGroup(), null);
}
case USER_AND_CUSTOMGROUP_PROVIDED:
{
throw APIException.badRequests.userGroupAndCustomGroupInACLFound(bucketACE.getUser(), null, bucketACE.getCustomGroup());
}
case GROUP_AND_CUSTOMGROUP_PROVIDED:
{
throw APIException.badRequests.userGroupAndCustomGroupInACLFound(null, bucketACE.getGroup(), bucketACE.getCustomGroup());
}
case USER_OR_GROUP_OR_CUSTOMGROUP_NOT_PROVIDED:
{
throw APIException.badRequests.missingUserOrGroupOrCustomGroupInACE(opName);
}
case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP_CUSTOMGROUP:
{
String userOrGroupOrCustomgroup = bucketACE.getUser();
if (userOrGroupOrCustomgroup == null) {
userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
}
throw APIException.badRequests.multipleACLsWithUserOrGroupOrCustomGroupFound(opName, userOrGroupOrCustomgroup);
}
case MULTIPLE_DOMAINS_FOUND:
{
String domain1 = bucketACE.getDomain();
String userOrGroupOrCustomgroup = bucketACE.getUser();
if (userOrGroupOrCustomgroup == null) {
userOrGroupOrCustomgroup = bucketACE.getGroup() != null ? bucketACE.getGroup() : bucketACE.getCustomGroup();
}
String domain2 = userOrGroupOrCustomgroup.substring(0, userOrGroupOrCustomgroup.indexOf("\\"));
throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
}
case ACL_NOT_FOUND:
{
throw APIException.badRequests.bucketACLNotFound(opName, bucketACE.toString());
}
default:
break;
}
}
}
}
use of com.emc.storageos.model.object.BucketACL in project coprhd-controller by CoprHD.
the class BucketService method getBucketACL.
/**
* Gets the ACL settings for bucket
*
* @param id
* @brief Get ACLs for a bucket
* @return BucketACL
* @throws InternalException
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BucketACL getBucketACL(@PathParam("id") URI id) throws InternalException {
_log.info("Request recieved to get Bucket ACL with Id: {}", id);
// Validate the Bucket
Bucket bucket = null;
ArgValidator.checkFieldUriType(id, Bucket.class, "id");
bucket = _dbClient.queryObject(Bucket.class, id);
ArgValidator.checkEntity(bucket, id, isIdEmbeddedInURL(id));
if (bucket.getVersion() == null) {
syncBucketACL(bucket);
}
BucketACL bucketAcl = new BucketACL();
BucketACLUtility bucketACLUtil = new BucketACLUtility(_dbClient, bucket.getName(), bucket.getId());
List<BucketACE> bucketAces = bucketACLUtil.queryExistingBucketACL();
_log.info("Number of existing ACLs found : {} ", bucketAces.size());
if (!bucketAces.isEmpty()) {
bucketAcl.setBucketACL(bucketAces);
}
return bucketAcl;
}
Aggregations