use of org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar in project so by onap.
the class CatalogDbAdapterRest method serviceToscaCsar.
/**
* Get the tosca csar info from catalog <br>
*
* @param smUuid service model uuid
* @return the tosca csar information of the serivce.
* @since ONAP Beijing Release
*/
@GET
@Path("serviceToscaCsar")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
int respStatus = HttpStatus.SC_OK;
String entity = "";
try {
if (smUuid != null && !"".equals(smUuid)) {
logger.debug("Query Csar by service model uuid: {}", smUuid);
Service service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(smUuid);
if (service != null) {
ToscaCsar toscaCsar = service.getCsar();
if (toscaCsar != null) {
QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
entity = serviceCsar.JSON2(false, false);
} else {
respStatus = HttpStatus.SC_NOT_FOUND;
}
} else {
respStatus = HttpStatus.SC_NOT_FOUND;
}
} else {
throw (new Exception("Incoming parameter is null or blank"));
}
return Response.status(respStatus).entity(entity).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
} catch (Exception e) {
logger.error("Exception during query csar by service model uuid: ", e);
CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(new GenericEntity<CatalogQueryException>(excResp) {
}).build();
}
}
Aggregations