use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class FileSystems method fileSystem.
public static void fileSystem(String fileSystemId) {
ViPRCoreClient client = BourneUtil.getViprClient();
FileShareRestRep fileSystem = null;
try {
fileSystem = client.fileSystems().get(uri(fileSystemId));
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404 || e.getHttpCode() == 400) {
flash.error(MessagesUtils.get(UNKNOWN, fileSystemId));
fileSystems(null);
}
throw e;
}
if (fileSystem != null) {
if (fileSystem.getVirtualArray() != null) {
VirtualArrayRestRep virtualArray = client.varrays().get(fileSystem.getVirtualArray());
renderArgs.put("virtualArray", virtualArray);
}
if (fileSystem.getVirtualPool() != null) {
FileVirtualPoolRestRep virtualPool = client.fileVpools().get(fileSystem.getVirtualPool());
renderArgs.put("virtualPool", virtualPool);
}
if (Security.isSystemAdminOrRestrictedSystemAdmin()) {
if (fileSystem.getStorageSystem() != null) {
StorageSystemRestRep storageSystem = client.storageSystems().get(fileSystem.getStorageSystem());
renderArgs.put("storageSystem", storageSystem);
}
if (fileSystem.getPool() != null) {
StoragePoolRestRep storagePool = client.storagePools().get(fileSystem.getPool());
renderArgs.put("storagePool", storagePool);
}
if (fileSystem.getStoragePort() != null) {
StoragePortRestRep storagePort = client.storagePorts().get(fileSystem.getStoragePort());
renderArgs.put("storagePort", storagePort);
}
}
Tasks<FileShareRestRep> tasksResponse = client.fileSystems().getTasks(fileSystem.getId());
List<Task<FileShareRestRep>> tasks = tasksResponse.getTasks();
renderArgs.put("tasks", tasks);
} else {
notFound(MessagesUtils.get("resources.filesystems.notfound"));
}
renderArgs.put("permissionTypeOptions", PERMISSION_TYPES);
render(fileSystem);
}
use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class Security method authenticated.
/**
* AJAXable method that can be used to determine if the user is authenticated.
*/
public static void authenticated() {
if (StringUtils.isBlank(getAuthToken())) {
renderJSON(false);
}
try {
UserInfo user = getUserInfo();
renderJSON(user != null);
} catch (ViPRHttpException e) {
Logger.error(e, "HTTP Error: %s %s", e.getHttpCode(), e.getMessage());
if (e.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) {
renderJSON(false);
}
// Propogate other errors (502, 503 most importantly)
error(e.getHttpCode(), e.getMessage());
} catch (Exception e) {
Logger.error(e, "Error getting user info");
renderJSON("error");
}
}
use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class OrderUtils method getOrder.
public static OrderRestRep getOrder(URI id) {
ViPRCatalogClient2 catalog = getCatalogClient();
OrderRestRep order = null;
try {
order = catalog.orders().get(id);
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404) {
order = null;
} else {
throw e;
}
}
return order;
}
use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class ExceptionOnErrorFilter method handle.
@Override
public ClientResponse handle(ClientRequest request) throws ClientHandlerException {
ClientResponse response = getNext().handle(request);
int status = response.getStatus();
if (status >= 400 && status < 600) {
if (isSupportedType(response.getType())) {
ServiceErrorRestRep serviceError;
try {
serviceError = response.getEntity(ServiceErrorRestRep.class);
} catch (Exception e) {
// Cause to fall-through to default exception
log.error("Error parsing error message", e);
serviceError = null;
}
if (serviceError != null) {
logAndThrow(new ServiceErrorException(status, serviceError));
}
}
// Fallback for unknown entity types
String content = response.getEntity(String.class);
logAndThrow(new ViPRHttpException(status, content));
}
return response;
}
use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class Common method handleExpiredToken.
@Util
public static void handleExpiredToken(Throwable throwable) {
if (throwable instanceof ViPRHttpException) {
ViPRHttpException ve = (ViPRHttpException) throwable;
if (ve.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) {
Logger.info("Clearing auth token");
// Auth token may have expired
Security.clearAuthToken();
Security.redirectToAuthPage();
}
}
}
Aggregations