use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class AssetOptionService method getAssetOptions.
@POST
@Path("/{assetType}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public AssetOptionsResponse getAssetOptions(@PathParam("assetType") String assetType, AssetOptionsRequest request) {
final Map<String, String> availableAssets = request.getAvailableAssets();
final AssetOptionsContext context = createAssetOptionsContext(request);
final Map<String, String> sanitizedAvailableAssets = SecurityUtils.stripMapXSS(availableAssets);
final String sanitizedAssetType = SecurityUtils.stripXSS(assetType);
log.info("Retrieving asset options for " + sanitizedAssetType + " with available assets : " + StringUtils.join(sanitizedAvailableAssets.keySet(), ", "));
try {
List<AssetOption> options = assetOptionsManager.getOptions(context, sanitizedAssetType, sanitizedAvailableAssets);
AssetOptionsResponse response = new AssetOptionsResponse();
response.setAssetType(sanitizedAssetType);
response.setAvailableAssets(sanitizedAvailableAssets);
response.setOptions(options);
return response;
} catch (IllegalStateException e) {
Response response = Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).type(MediaType.TEXT_PLAIN).build();
throw new WebApplicationException(response);
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404) {
Response response = Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).type(MediaType.TEXT_PLAIN).build();
throw new WebApplicationException(response);
}
throw new WebApplicationException(e);
}
}
use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class BlockExportGroups method exportGroup.
public static void exportGroup(String exportGroupId) {
ViPRCoreClient client = BourneUtil.getViprClient();
ExportGroupRestRep exportGroup = null;
try {
exportGroup = client.blockExports().get(uri(exportGroupId));
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404) {
flash.error(MessagesUtils.get(UNKNOWN, exportGroupId));
exportGroups(null);
}
throw e;
}
VirtualArrayRestRep virtualArray = null;
if (exportGroup != null) {
virtualArray = client.varrays().get(exportGroup.getVirtualArray());
} else {
notFound("Export Group " + exportGroupId);
}
renderArgs.put("volumeDataTable", new BlockExportGroupVolumesDataTable());
renderArgs.put("snapshotDataTable", new BlockExportGroupSnapshotsDataTable());
SimpleHostDataTable hostsDataTable = new SimpleHostDataTable();
NetworkEndpointDataTable initiatorsDataTable = NetworkEndpointDataTable.createDataTable("FC");
initiatorsDataTable.alterColumn("portGroup").hidden().setSearchable(false);
initiatorsDataTable.alterColumn("storageSystem").hidden().setSearchable(false);
initiatorsDataTable.alterColumn("discovered").hidden().setSearchable(false);
HostClusterDataTable clustersDataTable = new HostClusterDataTable();
render(hostsDataTable, initiatorsDataTable, clustersDataTable, exportGroup, virtualArray);
}
use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class ComputeImageServerUtils method getComputeImageServerByName.
public static ComputeImageServerRestRep getComputeImageServerByName(String name) {
try {
ComputeImageServerRestRep computeImageServer = null;
List<ComputeImageServerRestRep> computeImageServersList = getComputeImageServers();
for (ComputeImageServerRestRep cisrr : computeImageServersList) {
if (cisrr.getName().equalsIgnoreCase(name)) {
computeImageServer = cisrr;
}
}
return computeImageServer;
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404) {
return null;
}
throw e;
}
}
use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class CatalogServiceUtils method getCatalogService.
public static CatalogServiceRestRep getCatalogService(URI id) {
ViPRCatalogClient2 catalog = getCatalogClient();
CatalogServiceRestRep service = null;
try {
service = catalog.services().get(id);
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404) {
service = null;
} else {
throw e;
}
}
return service;
}
use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.
the class Maintenance method clusterState.
public static void clusterState() {
request.format = "json";
ClusterInfo clusterInfo = null;
try {
clusterInfo = getClusterState();
Logger.info("cluster status %s", clusterInfo.getCurrentState());
} catch (ViPRHttpException e) {
Common.handleExpiredToken(e);
Logger.error(e, "Failed to get cluster state");
error(e.getHttpCode(), e.getMessage());
} catch (Exception e) {
Logger.error(e, "Failed to get cluster state");
error(e.getMessage());
}
renderJSON(clusterInfo);
}
Aggregations