Search in sources :

Example 6 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class PasswordUtil method validatePasswordforUpdate.

/**
 * Validates a password using the ViPR api call during self update.
 *
 * @param plaintext password to validate
 * @return If validation passes, returns an empty string. If validation fails, returns the validation error message.
 */
public static String validatePasswordforUpdate(String oldPassword, String newPassword) {
    ViPRSystemClient client = BourneUtil.getSysClient();
    try {
        oldPassword = decryptedValue(oldPassword);
        newPassword = decryptedValue(newPassword);
        client.password().validateUpdate(oldPassword, newPassword);
    } catch (ServiceErrorException e) {
        if (e.getHttpCode() == 400 && e.getServiceError() != null) {
            return e.getServiceError().getDetailedMessage();
        }
    } catch (Exception e) {
        Logger.error(e, "Error executing api call to validate password");
        return MessagesUtils.get("setup.password.notValid");
    }
    return StringUtils.EMPTY;
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Example 7 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class Projects method saveProjectACLs.

@Util
private static void saveProjectACLs(String projectId, List<AclEntryForm> aclEntries) {
    List<ACLEntry> currentProjectAcls = ProjectUtils.getACLs(projectId);
    ACLAssignmentChanges changes = new ACLAssignmentChanges();
    changes.getAdd().addAll(AclEntryForm.getAddedAcls(currentProjectAcls, aclEntries));
    changes.getRemove().addAll(AclEntryForm.getRemovedAcls(currentProjectAcls, aclEntries));
    try {
        ProjectUtils.updateACLs(projectId, changes);
    } catch (ViPRException e) {
        Logger.error(e, "Failed to update Project ACLs");
        String errorDesc = e.getMessage();
        if (e instanceof ServiceErrorException) {
            errorDesc = ((ServiceErrorException) e).getDetailedMessage();
        }
        flash.error(MessagesUtils.get("projects.updateProjectACLs.failed", errorDesc));
    }
}
Also used : ACLAssignmentChanges(com.emc.storageos.model.auth.ACLAssignmentChanges) ACLEntry(com.emc.storageos.model.auth.ACLEntry) ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) Util(play.mvc.Util)

Example 8 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class VirtualArrays method saveTenantACLs.

/**
 * Saves tenant ACLs on the virtual array.
 *
 * @param virtualArrayId
 *            the virtual array ID.
 * @param tenants
 *            the tenant ACLs.
 */
private static void saveTenantACLs(String virtualArrayId, List<String> tenants) {
    Set<String> tenantIds = Sets.newHashSet();
    if (tenants != null) {
        tenantIds.addAll(tenants);
    }
    ACLUpdateBuilder builder = new ACLUpdateBuilder(VirtualArrayUtils.getACLs(virtualArrayId));
    builder.setTenants(tenantIds);
    try {
        VirtualArrayUtils.updateACLs(virtualArrayId, builder.getACLUpdate());
    } catch (ViPRException e) {
        Logger.error(e, "Failed to update Virtual Array ACLs");
        String errorDesc = e.getMessage();
        if (e instanceof ServiceErrorException) {
            errorDesc = ((ServiceErrorException) e).getDetailedMessage();
        }
        flash.error(MessagesUtils.get("varrays.updateVarrayACLs.failed", errorDesc));
    }
}
Also used : ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ACLUpdateBuilder(util.builders.ACLUpdateBuilder)

Example 9 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class CustomConfigs method preview.

public static void preview(String configType, String scopeType, String scopeValue, String value) {
    try {
        CustomConfigPreviewRep preview = CustomConfigUtils.generatePreview(configType, scopeType, scopeValue, value);
        renderJSON(preview);
    } catch (ServiceErrorException ex) {
        ServiceErrorRestRep error = ex.getServiceError();
        renderJSON(error);
    }
}
Also used : ServiceErrorRestRep(com.emc.storageos.model.errorhandling.ServiceErrorRestRep) CustomConfigPreviewRep(com.emc.storageos.model.customconfig.CustomConfigPreviewRep) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Example 10 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class TenantModificationTest method providerTenantAdminCreateTenant.

@Test
public void providerTenantAdminCreateTenant() throws Exception {
    ViPRClientHelper viPRClientHelper1 = new ViPRClientHelper(tenantAdminClient);
    try {
        viPRClientHelper1.createTenant("testTenant", "secqe.com", "attr", "value");
        Assert.fail("Provider tenant's TenantAdmin should has no permision to create subtenant");
    } catch (ServiceErrorException see) {
        Assert.assertEquals(see.getCode(), 3000);
        Assert.assertTrue(see.getMessage().contains("Insufficient permissions"));
    }
}
Also used : ViPRClientHelper(com.emc.storageos.usermanagement.util.ViPRClientHelper) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) Test(org.junit.Test)

Aggregations

ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)26 Test (org.junit.Test)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)5 ArrayList (java.util.ArrayList)5 UnManagedVolumeRestRep (com.emc.storageos.model.block.UnManagedVolumeRestRep)4 URI (java.net.URI)4 ViPRException (com.emc.vipr.client.exceptions.ViPRException)3 VolumeCreate (com.emc.storageos.model.block.VolumeCreate)2 ServiceErrorRestRep (com.emc.storageos.model.errorhandling.ServiceErrorRestRep)2 TenantUpdateParam (com.emc.storageos.model.tenant.TenantUpdateParam)2 UserMappingChanges (com.emc.storageos.model.tenant.UserMappingChanges)2 UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)2 ViPRClientHelper (com.emc.storageos.usermanagement.util.ViPRClientHelper)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)2 FlashException (controllers.util.FlashException)2 ACLUpdateBuilder (util.builders.ACLUpdateBuilder)2 ExecutionException (com.emc.sa.engine.ExecutionException)1 CreateBlockVolumeHelper (com.emc.sa.service.vipr.block.CreateBlockVolumeHelper)1 DeactivateBlockExport (com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport)1