Search in sources :

Example 1 with FilePolicyList

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

the class FileService method getFileSystemPolicy.

/**
 * Get Policy for file system
 *
 * @param id
 *            the URN of a ViPR File system
 * @brief Show file system
 * @return File system Policy details
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/file-policies")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public FilePolicyList getFileSystemPolicy(@PathParam("id") URI id) {
    FilePolicyList fpList = new FilePolicyList();
    List<FilePolicyRestRep> fpRestList = new ArrayList<FilePolicyRestRep>();
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare fs = queryResource(id);
    StringSet fpolicies = fs.getFilePolicies();
    for (String fpolicy : fpolicies) {
        FilePolicyRestRep fpRest = new FilePolicyRestRep();
        URI fpURI = URI.create(fpolicy);
        if (fpURI != null) {
            SchedulePolicy fp = _permissionsHelper.getObjectById(fpURI, SchedulePolicy.class);
            if (fp != null) {
                ArgValidator.checkEntityNotNull(fp, fpURI, isIdEmbeddedInURL(fpURI));
                getFilePolicyRestRep(fpRest, fp, fs);
            }
        }
        fpRestList.add(fpRest);
    }
    fpList.setFilePolicies(fpRestList);
    return fpList;
}
Also used : FilePolicyList(com.emc.storageos.model.file.FilePolicyList) FilePolicyRestRep(com.emc.storageos.model.file.FilePolicyRestRep) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) SchedulePolicy(com.emc.storageos.db.client.model.SchedulePolicy) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)1 SchedulePolicy (com.emc.storageos.db.client.model.SchedulePolicy)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 FilePolicyList (com.emc.storageos.model.file.FilePolicyList)1 FilePolicyRestRep (com.emc.storageos.model.file.FilePolicyRestRep)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1