use of com.emc.storageos.model.object.ObjectBucketACLUpdateParams in project coprhd-controller by CoprHD.
the class SetObjectStorageACL method doExecute.
@Override
protected Task<BucketRestRep> doExecute() throws Exception {
ObjectBucketACLUpdateParams aclUpdate = new ObjectBucketACLUpdateParams();
BucketACL aclsToAdd = ObjectStorageUtils.createBucketACLs(acl);
aclUpdate.setAclToAdd(aclsToAdd);
return getClient().objectBuckets().updateBucketACL(bucketId, aclUpdate);
}
use of com.emc.storageos.model.object.ObjectBucketACLUpdateParams in project coprhd-controller by CoprHD.
the class ObjectBuckets method createObjectBucketACLUpdateParams.
private static ObjectBucketACLUpdateParams createObjectBucketACLUpdateParams(String formData) {
String[] uiAcls = formData.split(",");
List<BucketACE> aces = Lists.newArrayList();
for (String uiAce : uiAcls) {
String[] uiData = uiAce.split("~~~");
String uiType = uiData[0];
String uiName = uiData[1];
String uiDomain = uiData[2];
String uiPermissions = uiData[3];
BucketACE bucketAce = new BucketACE();
if (uiDomain != null && !uiDomain.isEmpty() && !"null".equals(uiDomain)) {
bucketAce.setDomain(uiDomain);
}
if (GROUP.equalsIgnoreCase(uiType.trim())) {
bucketAce.setGroup(uiName.trim());
} else if (CUSTOMGROUP.equalsIgnoreCase(uiType.trim())) {
bucketAce.setCustomGroup(uiName.trim());
} else {
bucketAce.setUser(uiName.trim());
}
if (uiPermissions != null && !"".equals(uiPermissions) && !"null".equals(uiPermissions)) {
bucketAce.setPermissions(uiPermissions);
}
aces.add(bucketAce);
}
BucketACL aclToAdd = new BucketACL();
aclToAdd.setBucketACL(aces);
ObjectBucketACLUpdateParams input = new ObjectBucketACLUpdateParams();
input.setAclToAdd(aclToAdd);
return input;
}
use of com.emc.storageos.model.object.ObjectBucketACLUpdateParams in project coprhd-controller by CoprHD.
the class ObjectBuckets method addBucketAcl.
public static void addBucketAcl(String bucketId, BucketACLForm bucketACL, String formAccessControlList) {
if (formAccessControlList == null || formAccessControlList.isEmpty()) {
flash.error(MessagesUtils.get("resources.bucket.acl.invalid.settings"));
listBucketACL(bucketId);
}
ObjectBucketACLUpdateParams updateParam = createObjectBucketACLUpdateParams(formAccessControlList);
ViPRCoreClient client = BourneUtil.getViprClient();
try {
client.objectBuckets().updateBucketACL(uri(bucketId), updateParam);
} catch (Exception e) {
flash.error(e.getMessage(), null);
listBucketACL(bucketId);
}
flash.success(MessagesUtils.get(ADDED));
listBucketACL(bucketId);
}
use of com.emc.storageos.model.object.ObjectBucketACLUpdateParams in project coprhd-controller by CoprHD.
the class ObjectBuckets method deleteAcl.
/**
* This method called When user selects ACLs and hit delete button.
*
* @param aclURL
* URL of the file system share.
* @param ids
* ids of the selected ACL
*/
@FlashException(value = "buckets")
public static void deleteAcl(String bucketId, @As(",") String[] ids) {
BucketACL aclsToDelete = new BucketACL();
List<BucketACE> bucketAcl = Lists.newArrayList();
if (ids != null && ids.length > 0) {
for (String id : ids) {
String type = BucketACLForm.extractTypeFromId(id);
String name = BucketACLForm.extractNameFromId(id);
String domain = BucketACLForm.extractDomainFromId(id);
BucketACE ace = new BucketACE();
if (GROUP.equalsIgnoreCase(type)) {
ace.setGroup(name);
} else if (CUSTOMGROUP.equalsIgnoreCase(type)) {
ace.setCustomGroup(name);
} else {
ace.setUser(name);
}
if (domain != null && !"".equals(domain) && !"null".equals(domain)) {
ace.setDomain(domain);
}
bucketAcl.add(ace);
}
aclsToDelete.setBucketACL(bucketAcl);
ObjectBucketACLUpdateParams input = new ObjectBucketACLUpdateParams();
input.setAclToDelete(aclsToDelete);
ViPRCoreClient client = BourneUtil.getViprClient();
client.objectBuckets().updateBucketACL(uri(bucketId), input);
}
flash.success(MessagesUtils.get(DELETED));
listBucketACL(bucketId);
}
use of com.emc.storageos.model.object.ObjectBucketACLUpdateParams in project coprhd-controller by CoprHD.
the class ObjectBuckets method saveBucketAce.
@FlashException(keep = true, referrer = { "editBucketAce" })
public static void saveBucketAce(BucketACLForm bucketACL) {
String name = params.get("name");
String type = params.get("type");
String domain = params.get("domain");
String bucketId = params.get("bucketId");
Set<String> permissions = bucketACL.permissions;
String strPer = "";
for (String permission : permissions) {
strPer = strPer + permission + "|";
}
if (strPer.length() > 0) {
strPer = strPer.substring(0, strPer.length() - 1);
}
List<BucketACE> acl = Lists.newArrayList();
BucketACE ace = new BucketACE();
BucketACL aclToModify = new BucketACL();
if (GROUP.equalsIgnoreCase(type)) {
ace.setGroup(name);
} else if (CUSTOMGROUP.equalsIgnoreCase(type)) {
ace.setCustomGroup(name);
} else {
ace.setUser(name);
}
ace.setPermissions(strPer);
if (domain != null && !domain.isEmpty()) {
ace.setDomain(domain);
}
acl.add(ace);
aclToModify.setBucketACL(acl);
ObjectBucketACLUpdateParams updateParam = new ObjectBucketACLUpdateParams();
updateParam.setAclToModify(aclToModify);
ViPRCoreClient client = BourneUtil.getViprClient();
client.objectBuckets().updateBucketACL(uri(bucketId), updateParam);
listBucketACL(bucketId);
}
Aggregations