Search in sources :

Example 1 with VirtualDataCenterModifyParam

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);
    }
}
Also used : ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) URI(java.net.URI) VirtualDataCenterModifyParam(com.emc.storageos.model.vdc.VirtualDataCenterModifyParam) Test(org.junit.Test)

Example 2 with VirtualDataCenterModifyParam

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();
    }
}
Also used : VirtualDataCenterRestRep(com.emc.storageos.model.vdc.VirtualDataCenterRestRep) VirtualDataCenterAddParam(com.emc.storageos.model.vdc.VirtualDataCenterAddParam) FlashException(controllers.util.FlashException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) VirtualDataCenterModifyParam(com.emc.storageos.model.vdc.VirtualDataCenterModifyParam) FlashException(controllers.util.FlashException) Restrictions(controllers.deadbolt.Restrictions)

Aggregations

VirtualDataCenterModifyParam (com.emc.storageos.model.vdc.VirtualDataCenterModifyParam)2 VirtualDataCenterAddParam (com.emc.storageos.model.vdc.VirtualDataCenterAddParam)1 VirtualDataCenterRestRep (com.emc.storageos.model.vdc.VirtualDataCenterRestRep)1 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)1 Restrictions (controllers.deadbolt.Restrictions)1 FlashException (controllers.util.FlashException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URI (java.net.URI)1 Test (org.junit.Test)1