Search in sources :

Example 1 with QueryVfModule

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();
    }
}
Also used : QueryVfModule(org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VfModule(org.onap.so.db.catalog.beans.VfModule) QueryVfModule(org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 CatalogQueryException (org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException)1 QueryVfModule (org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule)1 VfModule (org.onap.so.db.catalog.beans.VfModule)1 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)1 Transactional (org.springframework.transaction.annotation.Transactional)1