use of com.emc.storageos.model.vdc.VirtualDataCenterModifyParam in project coprhd-controller by CoprHD.
the class VdcApiProxyUserTest method testUpdateVdcWithProxyUser_neg.
@Test
public void testUpdateVdcWithProxyUser_neg() throws Exception {
URI vdcId = proxyClient.vdcs().getAll().get(0).getId();
VirtualDataCenterModifyParam modifyParam = new VirtualDataCenterModifyParam();
modifyParam.setDescription("modified description");
try {
proxyClient.vdcs().update(vdcId, modifyParam);
Assert.fail("proxy user update vdc should fail");
} catch (ServiceErrorException se) {
Assert.assertEquals(se.getHttpCode(), 403);
}
}
use of com.emc.storageos.model.vdc.VirtualDataCenterModifyParam in project coprhd-controller by CoprHD.
the class VirtualDataCenters method save.
@FlashException(keep = true, referrer = { "create", "edit" })
@Restrictions({ @Restrict("SYSTEM_ADMIN"), @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void save(VirtualDataCenterForm vdc) {
vdc.validate("vdc");
if (Validation.hasErrors()) {
Common.handleError();
}
if (vdc.isNew()) {
VirtualDataCenterAddParam vdcToAdd = new VirtualDataCenterAddParam();
vdcToAdd.setName(vdc.name);
vdcToAdd.setApiEndpoint(vdc.apiEndpoint);
vdcToAdd.setDescription(vdc.description);
vdcToAdd.setSecretKey(vdc.secretKey);
try {
vdcToAdd.setCertificateChain(FileUtils.readFileToString(vdc.certChain));
} catch (Exception e) {
flash.error(MessagesUtils.get("vdc.certChain.invalid.error"));
Common.handleError();
}
Task<VirtualDataCenterRestRep> task = VirtualDataCenterUtils.create(vdcToAdd);
flash.put("inProgressTask", task.getTaskResource().getId());
} else {
VirtualDataCenterRestRep currentVDC = VirtualDataCenterUtils.get(vdc.id);
if (currentVDC != null) {
VirtualDataCenterModifyParam vdcToUpdate = new VirtualDataCenterModifyParam();
vdcToUpdate.setName(vdc.name);
vdcToUpdate.setDescription(vdc.description);
Task<VirtualDataCenterRestRep> task = VirtualDataCenterUtils.update(uri(vdc.id), vdcToUpdate);
flash.put("inProgressTask", task.getTaskResource().getId());
}
}
Cache.delete(Common.VDCS);
if (StringUtils.isNotBlank(vdc.referrerUrl)) {
redirect(vdc.referrerUrl);
} else {
list();
}
}
Aggregations