Search in sources :

Example 1 with FilePolicyStorageResourceRestRep

use of com.emc.storageos.model.file.policy.FilePolicyStorageResourceRestRep in project coprhd-controller by CoprHD.

the class FilePolicyService method getFilePolicyStorageResources.

/**
 * @brief Get the list of policy storage resources of a file policy.
 *
 * @param id of the file policy.
 * @return List of policy storage resource information.
 */
@GET
@Path("/{id}/policy-storage-resources")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN })
public FilePolicyStorageResources getFilePolicyStorageResources(@PathParam("id") URI id) {
    _log.info("Request recieved to list storage resources for the policy {}", id);
    FilePolicy filepolicy = queryResource(id);
    ArgValidator.checkEntity(filepolicy, id, true);
    FilePolicyStorageResources resources = new FilePolicyStorageResources();
    List<FilePolicyStorageResourceRestRep> policyResources = new ArrayList<FilePolicyStorageResourceRestRep>();
    for (PolicyStorageResource storageRes : FileOrchestrationUtils.getFilePolicyStorageResources(_dbClient, filepolicy)) {
        policyResources.add(FilePolicyMapper.mapPolicyStorageResource(storageRes, filepolicy, _dbClient));
    }
    resources.setStorageResources(policyResources);
    return resources;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) MapFilePolicy(com.emc.storageos.api.mapper.functions.MapFilePolicy) ArrayList(java.util.ArrayList) FilePolicyStorageResourceRestRep(com.emc.storageos.model.file.policy.FilePolicyStorageResourceRestRep) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) FilePolicyStorageResources(com.emc.storageos.model.file.policy.FilePolicyStorageResources) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with FilePolicyStorageResourceRestRep

use of com.emc.storageos.model.file.policy.FilePolicyStorageResourceRestRep in project coprhd-controller by CoprHD.

the class FilePolicyMapper method mapPolicyStorageResource.

public static FilePolicyStorageResourceRestRep mapPolicyStorageResource(PolicyStorageResource from, FilePolicy policy, DbClient dbClient) {
    FilePolicyStorageResourceRestRep resp = new FilePolicyStorageResourceRestRep();
    DbObjectMapper.mapDataObjectFields(from, resp);
    resp.setFilePolicy(DbObjectMapper.toNamedRelatedResource(ResourceTypeEnum.FILE_POLICY, policy.getId(), policy.getFilePolicyName()));
    if (from.getAppliedAt() != null) {
        DataObject appliedAt = dbClient.queryObject(from.getAppliedAt());
        resp.setAppliedAt(DbObjectMapper.toNamedRelatedResource(appliedAt));
    }
    if (from.getNasServer() != null) {
        resp.setNasServer(from.getNasServer());
    }
    if (from.getNativeGuid() != null) {
        resp.setNativeGuid(from.getNativeGuid());
    }
    if (from.getPolicyNativeId() != null) {
        resp.setPolicyNativeId(from.getPolicyNativeId());
    }
    if (from.getResourcePath() != null) {
        resp.setResourcePath(from.getResourcePath());
    }
    if (from.getStorageSystem() != null) {
        resp.setStorageSystem(DbObjectMapper.toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageSystem()));
    }
    return resp;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) FilePolicyStorageResourceRestRep(com.emc.storageos.model.file.policy.FilePolicyStorageResourceRestRep)

Aggregations

FilePolicyStorageResourceRestRep (com.emc.storageos.model.file.policy.FilePolicyStorageResourceRestRep)2 MapFilePolicy (com.emc.storageos.api.mapper.functions.MapFilePolicy)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)1 PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)1 FilePolicyStorageResources (com.emc.storageos.model.file.policy.FilePolicyStorageResources)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1