use of com.emc.storageos.model.file.policy.FilePolicyCreateParam in project coprhd-controller by CoprHD.
the class FilePolicyApiTest method testCreateSnapshotPolicyInvalidExpireValue.
@Test
public void testCreateSnapshotPolicyInvalidExpireValue() {
FilePolicyCreateParam param = new FilePolicyCreateParam();
setFilePolicyMandatoryParams(param);
FileSnapshotPolicyParam snapshotPolicyParam = new FileSnapshotPolicyParam();
FilePolicyScheduleParams policySchedule = new FilePolicyScheduleParams();
setFilePolicyScheduleParams(policySchedule);
snapshotPolicyParam.setPolicySchedule(policySchedule);
param.setSnapshotPolicyPrams(snapshotPolicyParam);
FileSnapshotPolicyExpireParam snapshotExpireParams = new FileSnapshotPolicyExpireParam();
snapshotExpireParams.setExpireType("HOURS");
// Some invalid value less than 2 hours or greater than 2 years
snapshotExpireParams.setExpireValue(1);
snapshotPolicyParam.setSnapshotExpireParams(snapshotExpireParams);
ClientResponse createFilePolicyResp = rSys.path(FILE_POLICIES).post(ClientResponse.class, param);
Assert.assertEquals(createFilePolicyResp.toString(), HttpStatus.SC_BAD_REQUEST, createFilePolicyResp.getStatus());
}
use of com.emc.storageos.model.file.policy.FilePolicyCreateParam in project coprhd-controller by CoprHD.
the class FilePolicyApiTest method testCreateSnapshotPolicyInvalidExpireType.
@Test
public void testCreateSnapshotPolicyInvalidExpireType() {
FilePolicyCreateParam param = new FilePolicyCreateParam();
setFilePolicyMandatoryParams(param);
FileSnapshotPolicyParam snapshotPolicyParam = new FileSnapshotPolicyParam();
FilePolicyScheduleParams policySchedule = new FilePolicyScheduleParams();
setFilePolicyScheduleParams(policySchedule);
snapshotPolicyParam.setPolicySchedule(policySchedule);
param.setSnapshotPolicyPrams(snapshotPolicyParam);
FileSnapshotPolicyExpireParam snapshotExpireParams = new FileSnapshotPolicyExpireParam();
// Invalid Expire Type
snapshotExpireParams.setExpireType("some_junk_value");
snapshotPolicyParam.setSnapshotExpireParams(snapshotExpireParams);
ClientResponse createFilePolicyResp = rSys.path(FILE_POLICIES).post(ClientResponse.class, param);
Assert.assertEquals(createFilePolicyResp.toString(), HttpStatus.SC_BAD_REQUEST, createFilePolicyResp.getStatus());
}
use of com.emc.storageos.model.file.policy.FilePolicyCreateParam in project coprhd-controller by CoprHD.
the class FilePolicyApiTest method testCreatePolicyWithoutName.
@Test
public void testCreatePolicyWithoutName() {
FilePolicyCreateParam param = new FilePolicyCreateParam();
ClientResponse createFilePolicyResp = rSys.path(FILE_POLICIES).post(ClientResponse.class, param);
Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, createFilePolicyResp.getStatus());
}
use of com.emc.storageos.model.file.policy.FilePolicyCreateParam in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method save.
@FlashException(keep = true, referrer = { "create", "edit" })
public static void save(SchedulePolicyForm schedulePolicy) {
if (schedulePolicy == null) {
Logger.error("No policy parameters passed");
badRequest("No policy parameters passed");
return;
}
schedulePolicy.validate("schedulePolicy");
if (Validation.hasErrors()) {
Common.handleError();
}
schedulePolicy.id = params.get("id");
URI policyId = null;
if (schedulePolicy.isNew()) {
schedulePolicy.tenantId = Models.currentAdminTenant();
FilePolicyCreateParam policyParam = new FilePolicyCreateParam();
updatePolicyParam(schedulePolicy, policyParam, null);
policyParam.setPolicyType(schedulePolicy.policyType);
if (schedulePolicy.description != null && !schedulePolicy.description.isEmpty()) {
policyParam.setPolicyDescription(schedulePolicy.description);
}
FilePolicyCreateResp createdPolicy = getViprClient().fileProtectionPolicies().create(policyParam);
policyId = createdPolicy.getId();
} else {
FilePolicyRestRep schedulePolicyRestRep = getViprClient().fileProtectionPolicies().get(uri(schedulePolicy.id));
FilePolicyUpdateParam input = new FilePolicyUpdateParam();
updatePolicyParam(schedulePolicy, input, schedulePolicyRestRep.getType());
getViprClient().fileProtectionPolicies().update(schedulePolicyRestRep.getId(), input);
policyId = schedulePolicyRestRep.getId();
}
// Update the ACLs
com.emc.vipr.client.core.FileProtectionPolicies filePolicies = getViprClient().fileProtectionPolicies();
schedulePolicy.saveTenantACLs(filePolicies, policyId);
flash.success(MessagesUtils.get("schedulepolicies.saved", schedulePolicy.policyName));
if (StringUtils.isNotBlank(schedulePolicy.referrerUrl)) {
redirect(schedulePolicy.referrerUrl);
} else {
list();
}
}
Aggregations