use of com.emc.storageos.model.file.policy.FilePolicyListRestRep in project coprhd-controller by CoprHD.
the class FilePolicyApiTest method testListFileSnapshotPolicies.
@Test
public void testListFileSnapshotPolicies() {
FilePolicyListRestRep filePolicyListResp = rSys.path(FILE_POLICIES).get(FilePolicyListRestRep.class);
Assert.assertNotNull(filePolicyListResp);
List<NamedRelatedResourceRep> filePolicies = filePolicyListResp.getFilePolicies();
for (Iterator<NamedRelatedResourceRep> iterator = filePolicies.iterator(); iterator.hasNext(); ) {
NamedRelatedResourceRep namedRelatedResourceRep = iterator.next();
if (namedRelatedResourceRep.getId().equals(createdFileSnapshotPolicyURI)) {
Assert.assertTrue(true);
return;
}
}
Assert.assertTrue(false);
}
use of com.emc.storageos.model.file.policy.FilePolicyListRestRep in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method listJson.
@FlashException(value = "list", keep = true)
public static void listJson() {
FilePolicyListRestRep viprSchedulePolicies = getViprClient().fileProtectionPolicies().listFilePolicies();
List<ScheculePoliciesDataTable.FileProtectionPolicy> scheculePolicies = Lists.newArrayList();
for (NamedRelatedResourceRep policy : viprSchedulePolicies.getFilePolicies()) {
scheculePolicies.add(new ScheculePoliciesDataTable.FileProtectionPolicy(getViprClient().fileProtectionPolicies().getFilePolicy(policy.getId())));
}
renderJSON(DataTablesSupport.createJSON(scheculePolicies, params));
}
use of com.emc.storageos.model.file.policy.FilePolicyListRestRep in project coprhd-controller by CoprHD.
the class FileProvider method getAllFileSystemLevelPolicies.
private List<FilePolicyRestRep> getAllFileSystemLevelPolicies(AssetOptionsContext ctx) {
ViPRCoreClient client = api(ctx);
List<FilePolicyRestRep> fileSystemPolicies = new ArrayList<FilePolicyRestRep>();
FilePolicyListRestRep policies = client.fileProtectionPolicies().listFilePolicies();
if (policies != null && !policies.getFilePolicies().isEmpty()) {
for (NamedRelatedResourceRep policy : policies.getFilePolicies()) {
FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(policy.getId());
if (policyRestRep != null && policyRestRep.getAppliedAt() != null && policyRestRep.getAppliedAt().equalsIgnoreCase("file_system")) {
fileSystemPolicies.add(policyRestRep);
}
}
}
return fileSystemPolicies;
}
use of com.emc.storageos.model.file.policy.FilePolicyListRestRep in project coprhd-controller by CoprHD.
the class FilePolicyService method getFilePoliciesForGivenUser.
protected FilePolicyListRestRep getFilePoliciesForGivenUser() {
FilePolicyListRestRep filePolicyList = new FilePolicyListRestRep();
List<URI> ids = _dbClient.queryByType(FilePolicy.class, true);
List<FilePolicy> filePolicies = _dbClient.queryObject(FilePolicy.class, ids);
StorageOSUser user = getUserFromContext();
// else only return the list, which input tenant has access.
if (_permissionsHelper.userHasGivenRole(user, null, Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR)) {
for (FilePolicy filePolicy : filePolicies) {
filePolicyList.add(toNamedRelatedResource(filePolicy, filePolicy.getFilePolicyName()));
}
} else {
// otherwise, filter by only authorized to use
URI tenant = null;
tenant = URI.create(user.getTenantId());
Set<FilePolicy> policySet = new HashSet<FilePolicy>();
for (FilePolicy filePolicy : filePolicies) {
if (_permissionsHelper.tenantHasUsageACL(tenant, filePolicy)) {
policySet.add(filePolicy);
}
}
// Also adding vpools which sub-tenants of the user have access to.
List<URI> subtenants = _permissionsHelper.getSubtenantsWithRoles(user);
for (FilePolicy filePolicy : filePolicies) {
if (_permissionsHelper.tenantHasUsageACL(subtenants, filePolicy)) {
policySet.add(filePolicy);
}
}
for (FilePolicy filePolicy : policySet) {
filePolicyList.add(toNamedRelatedResource(filePolicy, filePolicy.getFilePolicyName()));
}
}
return filePolicyList;
}
Aggregations