Search in sources :

Example 11 with BucketRestRep

use of com.emc.storageos.model.object.BucketRestRep in project coprhd-controller by CoprHD.

the class ObjectBuckets method bucket.

public static void bucket(String bucketId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    BucketRestRep bucket = null;
    if (isBucketId(bucketId)) {
        try {
            bucket = client.objectBuckets().get(uri(bucketId));
        } catch (ViPRHttpException e) {
            if (e.getHttpCode() == 404) {
                flash.error(MessagesUtils.get(UNKNOWN, bucketId));
                buckets(null);
            }
            throw e;
        }
    }
    if (bucket == null) {
        notFound(Messages.get("resources.bucket.notfound"));
    }
    if (bucket.getVirtualArray() != null) {
        // NOSONAR
        // ("Suppressing Sonar violation of Possible null pointer dereference of volume. When volume is null, the previous if condition handles with throw")
        renderArgs.put("virtualArray", VirtualArrayUtils.getVirtualArrayRef(bucket.getVirtualArray()));
    }
    if (bucket.getVirtualPool() != null) {
        renderArgs.put("virtualPool", VirtualPoolUtils.getObjectVirtualPoolRef(bucket.getVirtualPool()));
    }
    Tasks<BucketRestRep> tasksResponse = client.objectBuckets().getTasks(bucket.getId());
    List<Task<BucketRestRep>> tasks = tasksResponse.getTasks();
    renderArgs.put("tasks", tasks);
    render(bucket);
}
Also used : Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BucketRestRep(com.emc.storageos.model.object.BucketRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 12 with BucketRestRep

use of com.emc.storageos.model.object.BucketRestRep in project coprhd-controller by CoprHD.

the class ObjectBuckets method editBucketAce.

public static void editBucketAce(@Required String id) {
    String type = BucketACLForm.extractTypeFromId(id);
    String name = BucketACLForm.extractNameFromId(id);
    String domain = BucketACLForm.extractDomainFromId(id);
    String bucketId = BucketACLForm.extractBucketFromId(id);
    String permissions = BucketACLForm.extractPermissionsFromId(id);
    if ("null".equals(domain)) {
        domain = "";
    }
    BucketACLForm bucketACL = new BucketACLForm();
    bucketACL.type = type;
    bucketACL.domain = domain;
    bucketACL.name = name;
    String[] strPerm = permissions.split("\\|");
    bucketACL.permissions = new HashSet<String>(Arrays.asList(strPerm));
    List<StringOption> permissionOptions = BucketACLForm.getPermissionOptions();
    renderArgs.put("permissionOptions", permissionOptions);
    renderArgs.put("bucketId", bucketId);
    ViPRCoreClient client = BourneUtil.getViprClient();
    BucketRestRep restRep = client.objectBuckets().get(uri(bucketId));
    renderArgs.put("bucketName", restRep.getName());
    renderArgs.put("TYPE", type.toUpperCase());
    render(bucketACL);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) StringOption(util.StringOption) BucketRestRep(com.emc.storageos.model.object.BucketRestRep)

Example 13 with BucketRestRep

use of com.emc.storageos.model.object.BucketRestRep in project coprhd-controller by CoprHD.

the class BucketMapper method map.

public static BucketRestRep map(Bucket from) {
    if (from == null) {
        return null;
    }
    BucketRestRep to = new BucketRestRep();
    mapDataObjectFields(from, to);
    if (null != from.getProject()) {
        to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject().getURI()));
    }
    if (null != from.getTenant()) {
        to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, from.getTenant().getURI()));
    }
    if (null != from.getRetention()) {
        to.setRetention(from.getRetention().toString());
    }
    to.setHardQuota(CapacityUtils.convertBytesToGBInStr(from.getHardQuota()));
    to.setSoftQuota(CapacityUtils.convertBytesToGBInStr(from.getSoftQuota()));
    to.setVirtualPool(toRelatedResource(ResourceTypeEnum.OBJECT_VPOOL, from.getVirtualPool()));
    to.setVirtualArray(toRelatedResource(ResourceTypeEnum.VARRAY, from.getVirtualArray()));
    to.setProtocols(from.getProtocol());
    to.setNamespace(from.getNamespace());
    to.setOwner(from.getOwner());
    to.setPath(from.getPath());
    to.setNativeId(from.getNativeId());
    return to;
}
Also used : BucketRestRep(com.emc.storageos.model.object.BucketRestRep)

Aggregations

BucketRestRep (com.emc.storageos.model.object.BucketRestRep)13 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)7 URI (java.net.URI)4 DeactivateBucket (com.emc.sa.service.vipr.object.tasks.DeactivateBucket)2 BucketDeleteParam (com.emc.storageos.model.object.BucketDeleteParam)2 Task (com.emc.vipr.client.Task)2 CreateBucket (com.emc.sa.service.vipr.object.tasks.CreateBucket)1 SetObjectStorageACL (com.emc.sa.service.vipr.object.tasks.SetObjectStorageACL)1 UpdateBucket (com.emc.sa.service.vipr.object.tasks.UpdateBucket)1 DataObjectRestRep (com.emc.storageos.model.DataObjectRestRep)1 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1 FlashException (controllers.util.FlashException)1 BucketACLDataTable (models.datatable.BucketACLDataTable)1 StringOption (util.StringOption)1