use of com.emc.vipr.model.catalog.AssetOptionsResponse 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);
}
}
Aggregations