use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.
the class ECSObjectStorageDevice method queryDbBucketACL.
private List<ObjectBucketACL> queryDbBucketACL(Bucket bucket) {
try {
ContainmentConstraint containmentConstraint = null;
_log.info("Querying DB for ACL of bucket {} ", bucket.getName());
containmentConstraint = ContainmentConstraint.Factory.getBucketAclsConstraint(bucket.getId());
List<ObjectBucketACL> dbBucketBucketAcl = CustomQueryUtility.queryActiveResourcesByConstraint(_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 doDeleteBucket.
@Override
public BiosCommandResult doDeleteBucket(StorageSystem storageObj, Bucket bucket, String deleteType, final String taskId) {
BiosCommandResult result;
try {
ECSApi objectAPI = getAPI(storageObj);
if (ObjectControllerConstants.DeleteTypeEnum.INTERNAL_DB_ONLY.toString().equalsIgnoreCase(deleteType.toString())) {
_log.info("Inventory only bucket delete {}", bucket.getName());
} else {
objectAPI.deleteBucket(bucket.getName(), bucket.getNamespace());
}
// Deleting the ACL for bucket if any
List<ObjectBucketACL> aclToDelete = queryDbBucketACL(bucket);
if (aclToDelete != null && !aclToDelete.isEmpty()) {
for (ObjectBucketACL ace : aclToDelete) {
ObjectBucketACL dbBucketAcl = new ObjectBucketACL();
if (ace != null) {
dbBucketAcl.setId(ace.getId());
dbBucketAcl.setInactive(true);
_log.info("Marking acl inactive in DB: {}", dbBucketAcl);
_dbClient.updateObject(dbBucketAcl);
}
}
}
bucket.setInactive(true);
_dbClient.persistObject(bucket);
result = BiosCommandResult.createSuccessfulResult();
completeTask(bucket.getId(), taskId, "Bucket deleted successfully!");
} catch (ECSException e) {
_log.error("Delete Bucket : {} failed.", bucket.getName(), e);
result = BiosCommandResult.createErrorResult(e);
completeTask(bucket.getId(), taskId, e);
}
return result;
}
use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.
the class ECSObjectStorageDevice method getExistingBucketAclFromDB.
private ObjectBucketACL getExistingBucketAclFromDB(ObjectBucketACL dbBucketAcl) {
ObjectBucketACL acl = null;
String index = null;
URIQueryResultList result = new URIQueryResultList();
index = dbBucketAcl.getBucketACLIndex();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBucketACLConstraint(index), result);
Iterator<URI> it = result.iterator();
while (it.hasNext()) {
acl = _dbClient.queryObject(ObjectBucketACL.class, it.next());
if (acl != null && !acl.getInactive()) {
_log.info("Existing ACE found in DB: {}", acl);
return acl;
}
}
return null;
}
use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.
the class BucketACLUtility method verifyAddBucketACL.
private void verifyAddBucketACL(List<BucketACE> bucketACEList) {
if (bucketACEList == null) {
return;
}
_log.info("Number of bucket ACE(s) to add {} ", 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;
}
validatePermissions(ace);
if (!ace.canProceedToNextStep()) {
break;
}
// Verify with existing ACL
ObjectBucketACL dbBucketAcl = getExistingACL(ace);
// If same acl exists, don't allow to add again.
if (dbBucketAcl != null) {
_log.error("Duplicate ACL in add request. User/group/customgroup in ACL for bucket already exists: {}", dbBucketAcl);
ace.cancelNextStep(BucketACLOperationErrorType.ACL_EXISTS);
break;
} else // If not found proceed for further verifications.
{
if (ace.canProceedToNextStep()) {
_log.info("No existing ACL found in DB {}", ace);
}
}
}
}
use of com.emc.storageos.db.client.model.ObjectBucketACL in project coprhd-controller by CoprHD.
the class BucketACLUtility method queryACLByIndex.
private ObjectBucketACL queryACLByIndex(String index) {
_log.info("Querying ACL in DB by alternate Id: {}", index);
URIQueryResultList result = new URIQueryResultList();
ObjectBucketACL acl = null;
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBucketACLConstraint(index), result);
Iterator<URI> it = result.iterator();
while (it.hasNext()) {
if (result.iterator().hasNext()) {
acl = dbClient.queryObject(ObjectBucketACL.class, it.next());
if (acl != null && !acl.getInactive()) {
_log.info("Existing ACE found in DB: {}", acl);
break;
}
}
}
return acl;
}
Aggregations