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;
}
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;
}
Aggregations