use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.
the class BucketACLUtility method getExistingACL.
private ObjectBucketACL getExistingACL(BucketACE requestAcl) {
ObjectBucketACL acl = null;
String domainOfReqAce = requestAcl.getDomain();
if (domainOfReqAce == null) {
domainOfReqAce = "";
}
String userOrGroupOrCustomGroup = requestAcl.getUser();
String type = "user";
if (userOrGroupOrCustomGroup == null) {
userOrGroupOrCustomGroup = requestAcl.getGroup() != null ? requestAcl.getGroup() : requestAcl.getCustomGroup();
type = requestAcl.getGroup() != null ? "group" : "customgroup";
}
// Construct ACL Index
StringBuffer aclIndex = new StringBuffer();
aclIndex.append(this.bucketId).append(domainOfReqAce.toLowerCase()).append(userOrGroupOrCustomGroup.toLowerCase()).append(type);
acl = this.queryACLByIndex(aclIndex.toString());
return acl;
}
use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.
the class BucketACLUtility method verifyDeleteBucketACL.
private void verifyDeleteBucketACL(List<BucketACE> bucketACEList) {
if (bucketACEList == null) {
return;
}
_log.info("Number of bucket ACE(s) to delete {} ", bucketACEList.size());
for (BucketACE ace : bucketACEList) {
ace.proceedToNextStep();
_log.info("Verifying ACL {}", ace.toString());
// Are there same user or group found in other acls. If so, report
// error
verifyUserGroupCustomgroup(ace);
if (!ace.canProceedToNextStep()) {
break;
}
// Verify with existing ACL
ObjectBucketACL dbBucketAcl = getExistingACL(ace);
// If same acl exists, allow to modify
if (dbBucketAcl != null) {
_log.info("Existing ACL found in delete request: {}", dbBucketAcl);
ace.proceedToNextStep();
} else {
// If not found, don't allow to proceed further
if (ace.canProceedToNextStep()) {
_log.error("No existing ACL found in DB to delete {}", ace);
ace.cancelNextStep(BucketACLOperationErrorType.ACL_NOT_FOUND);
}
}
}
}
use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.
the class BucketACLUtility method queryExistingBucketACL.
public List<BucketACE> queryExistingBucketACL() {
List<BucketACE> bucketACEList = new ArrayList<BucketACE>();
List<ObjectBucketACL> dbBucketACL = queryDbBucketACL();
if (dbBucketACL != null) {
Iterator<ObjectBucketACL> dbAclIterator = dbBucketACL.iterator();
while (dbAclIterator.hasNext()) {
ObjectBucketACL dbBucketAce = dbAclIterator.next();
if (bucketId.equals(dbBucketAce.getBucketId())) {
BucketACE ace = new BucketACE();
ace.setBucketName(dbBucketAce.getBucketName());
ace.setDomain(dbBucketAce.getDomain());
ace.setUser(dbBucketAce.getUser());
ace.setGroup(dbBucketAce.getGroup());
ace.setPermissions(dbBucketAce.getPermissions());
ace.setCustomGroup(dbBucketAce.getCustomGroup());
ace.setNamespace(dbBucketAce.getNamespace());
bucketACEList.add(ace);
}
}
}
return bucketACEList;
}
use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.
the class BucketACLUtility method queryDbBucketACL.
private List<ObjectBucketACL> queryDbBucketACL() {
try {
ContainmentConstraint containmentConstraint = null;
_log.info("Querying DB for ACL of bucket {} ", this.bucketName);
containmentConstraint = ContainmentConstraint.Factory.getBucketAclsConstraint(this.bucketId);
List<ObjectBucketACL> dbBucketBucketAcl = CustomQueryUtility.queryActiveResourcesByConstraint(this.dbClient, ObjectBucketACL.class, containmentConstraint);
return dbBucketBucketAcl;
} catch (Exception e) {
_log.error("Error while querying DB for ACL of a bucket {}", e);
}
return null;
}
use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.
the class ECSObjectStorageDevice method updateBucketACLInDB.
private void updateBucketACLInDB(BucketACLUpdateParams param, ObjectDeviceInputOutput args, Bucket bucket) {
try {
// Create new Acl
if (param.getAclToAdd() != null) {
List<BucketACE> aclToAdd = param.getAclToAdd().getBucketACL();
if (aclToAdd != null && !aclToAdd.isEmpty()) {
for (BucketACE ace : aclToAdd) {
ObjectBucketACL dbBucketAcl = new ObjectBucketACL();
dbBucketAcl.setId(URIUtil.createId(ObjectBucketACL.class));
copyToPersistBucketACL(ace, dbBucketAcl, args, bucket.getId());
_log.info("Storing new acl in DB: {}", dbBucketAcl);
_dbClient.createObject(dbBucketAcl);
}
}
}
// Modify existing Acl
if (param.getAclToModify() != null) {
List<BucketACE> aclToModify = param.getAclToModify().getBucketACL();
if (aclToModify != null && !aclToModify.isEmpty()) {
for (BucketACE ace : aclToModify) {
ObjectBucketACL dbBucketAcl = new ObjectBucketACL();
copyToPersistBucketACL(ace, dbBucketAcl, args, bucket.getId());
ObjectBucketACL dbBucketAclTemp = getExistingBucketAclFromDB(dbBucketAcl);
if (dbBucketAclTemp != null) {
dbBucketAcl.setId(dbBucketAclTemp.getId());
_log.info("Modifying acl in DB: {}", dbBucketAcl);
_dbClient.updateObject(dbBucketAcl);
}
}
}
}
// Delete existing Acl
if (param.getAclToDelete() != null) {
List<BucketACE> aclToDelete = param.getAclToDelete().getBucketACL();
if (aclToDelete != null && !aclToDelete.isEmpty()) {
for (BucketACE ace : aclToDelete) {
ObjectBucketACL dbBucketAcl = new ObjectBucketACL();
copyToPersistBucketACL(ace, dbBucketAcl, args, bucket.getId());
ObjectBucketACL dbBuckeAclTemp = getExistingBucketAclFromDB(dbBucketAcl);
if (dbBuckeAclTemp != null) {
dbBucketAcl.setId(dbBuckeAclTemp.getId());
dbBucketAcl.setInactive(true);
_log.info("Marking acl inactive in DB: {}", dbBucketAcl);
_dbClient.updateObject(dbBucketAcl);
}
}
}
}
} catch (Exception e) {
_log.error("Error While executing CRUD Operations {}", e);
}
}
Aggregations