use of org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException in project so by onap.
the class CatalogDbAdapterRest method getProcessingFlagsImpl.
public Response getProcessingFlagsImpl(String flag) {
ProcessingFlags processingFlags = null;
logger.debug("Flag is: " + flag);
int respStatus = HttpStatus.SC_OK;
try {
processingFlags = processingFlagsRepo.findByFlag(flag);
if (processingFlags == null) {
logger.debug("ProcessingFlag not found");
respStatus = HttpStatus.SC_NOT_FOUND;
} else {
logger.debug("ProcessingFlags processingFlags = {}", processingFlags.toString());
}
return Response.status(respStatus).entity(processingFlags).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
} catch (Exception e) {
logger.error("Exception - queryProcesssingFlags", 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();
}
}
use of org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException in project so by onap.
the class CatalogDbAdapterRest method serviceNetworksImpl.
public Response serviceNetworksImpl(String version, boolean isArray, String networkModelCustomizationUuid, String networkType, String serviceModelUuid, String serviceModelInvariantUuid, String serviceModelVersion) {
QueryServiceNetworks qryResp;
int respStatus = HttpStatus.SC_OK;
String uuid = "";
List<NetworkResourceCustomization> ret = new ArrayList<>();
Service service = null;
try {
if (networkModelCustomizationUuid != null && !"".equals(networkModelCustomizationUuid)) {
uuid = networkModelCustomizationUuid;
ret = networkCustomizationRepo.findByModelCustomizationUUID(networkModelCustomizationUuid);
} else if (networkType != null && !"".equals(networkType)) {
uuid = networkType;
NetworkResource networkResources = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
if (networkResources != null)
ret = networkResources.getNetworkResourceCustomization();
} else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
uuid = serviceModelInvariantUuid;
if (serviceModelVersion != null && !"".equals(serviceModelVersion)) {
service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid);
} else {
service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
}
} else if (serviceModelUuid != null && !"".equals(serviceModelUuid)) {
uuid = serviceModelUuid;
service = serviceRepo.findOneByModelUUID(serviceModelUuid);
} else {
throw (new Exception(NO_MATCHING_PARAMETERS));
}
if (service != null)
ret = service.getNetworkCustomizations();
if (ret == null || ret.isEmpty()) {
logger.debug("serviceNetworks not found");
respStatus = HttpStatus.SC_NOT_FOUND;
qryResp = new QueryServiceNetworks();
} else {
qryResp = new QueryServiceNetworks(ret);
logger.debug("serviceNetworks found qryResp= {}", qryResp);
}
return respond(version, respStatus, isArray, qryResp);
} catch (Exception e) {
logger.error("Exception - queryServiceNetworks", 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();
}
}
use of org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException 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();
}
}
use of org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException in project so by onap.
the class CatalogDbAdapterRest method serviceResources.
@GET
@Path("serviceResources")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Transactional(readOnly = true)
public Response serviceResources(@PathParam("version") String version, @QueryParam("serviceModelUuid") String modelUUID, @QueryParam("serviceModelInvariantUuid") String modelInvariantUUID, @QueryParam("serviceModelVersion") String modelVersion, @QueryParam("filter") String filter) {
QueryServiceMacroHolder qryResp;
int respStatus = HttpStatus.SC_OK;
String uuid = "";
ServiceMacroHolder ret = new ServiceMacroHolder();
try {
if (modelUUID != null && !"".equals(modelUUID)) {
uuid = modelUUID;
logger.debug("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: {}", uuid);
Service serv = serviceRepo.findOneByModelUUID(uuid);
if (serv != null) {
ret.setNetworkResourceCustomizations(new ArrayList(serv.getNetworkCustomizations()));
if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) {
serv.getVnfCustomizations().forEach(vnfCustomization -> vnfCustomization.setResourceInput(null));
}
ret.setVnfResourceCustomizations(new ArrayList(serv.getVnfCustomizations()));
ret.setAllottedResourceCustomizations(new ArrayList(serv.getAllottedCustomizations()));
}
ret.setService(serv);
} else if (modelInvariantUUID != null && !"".equals(modelInvariantUUID)) {
uuid = modelInvariantUUID;
if (modelVersion != null && !"".equals(modelVersion)) {
logger.debug("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: {} serviceModelVersion: {}", uuid, modelVersion);
Service serv = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(modelVersion, uuid);
ret.setService(serv);
} else {
logger.debug("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: {}", uuid);
Service serv = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
ret.setService(serv);
}
} else {
throw (new Exception(NO_MATCHING_PARAMETERS));
}
if (ret.getService() == null) {
logger.debug("serviceMacroHolder not found");
respStatus = HttpStatus.SC_NOT_FOUND;
qryResp = new QueryServiceMacroHolder();
} else {
qryResp = new QueryServiceMacroHolder(ret);
logger.debug("serviceMacroHolder qryResp= {}", qryResp);
}
return respond(version, respStatus, IS_ARRAY, qryResp);
} catch (Exception e) {
logger.error("Exception - queryServiceMacroHolder", 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();
}
}
use of org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException 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