use of org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule in project so by onap.
the class CatalogDbAdapterRest method vfModules.
@GET
@Path("vfModules")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Transactional(readOnly = true)
public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) {
QueryVfModule qryResp;
int respStatus = HttpStatus.SC_OK;
List<VfModuleCustomization> ret = null;
try {
if (vfModuleModelName != null && !"".equals(vfModuleModelName)) {
VfModule vfModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc(vfModuleModelName);
if (vfModule != null)
ret = vfModule.getVfModuleCustomization();
} else {
throw (new Exception(NO_MATCHING_PARAMETERS));
}
if (ret == null || ret.isEmpty()) {
logger.debug("vfModules not found");
respStatus = HttpStatus.SC_NOT_FOUND;
qryResp = new QueryVfModule();
} else {
qryResp = new QueryVfModule(ret);
if (logger.isDebugEnabled())
logger.debug("vfModules tojsonstring is: {}", qryResp.JSON2(false, false));
}
return Response.status(respStatus).entity(qryResp.JSON2(false, false)).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
} catch (Exception e) {
logger.error("Exception during query VfModules by vfModuleModuleName: ", 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