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;
}
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));
}
}
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));
}
}
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);
}
}
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"));
}
}
Aggregations