use of org.onap.so.db.catalog.beans.Service 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();
}
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class QueryServiceMacroHolder method JSON2.
@Override
public String JSON2(boolean isArray, boolean x) {
Service service = serviceMacroHolder.getService();
if (service == null) {
return "\"serviceResources\": null";
}
StringBuilder buf = new StringBuilder();
Map<String, String> valueMap = new HashMap<>();
put(valueMap, "SERVICE_MODEL_NAME", service.getModelName());
put(valueMap, "SERVICE_MODEL_UUID", service.getModelUUID());
put(valueMap, "SERVICE_MODEL_INVARIANT_ID", service.getModelInvariantUUID());
put(valueMap, "SERVICE_MODEL_VERSION", service.getModelVersion());
put(valueMap, "SERVICE_TYPE", service.getServiceType());
put(valueMap, "SERVICE_ROLE", service.getServiceRole());
put(valueMap, "SERVICE_CATEGORY", service.getCategory());
put(valueMap, "ENVIRONMENT_CONTEXT", service.getEnvironmentContext());
put(valueMap, "WORKLOAD_CONTEXT", service.getWorkloadContext());
put(valueMap, "RESOURCE_ORDER", service.getResourceOrder());
String subitem;
subitem = new QueryServiceVnfs(service.getVnfCustomizations()).JSON2(true, true);
valueMap.put("_SERVICEVNFS_", subitem.replaceAll(LINE_BEGINNING, "\t"));
subitem = new QueryServiceNetworks(service.getNetworkCustomizations()).JSON2(true, true);
valueMap.put("_SERVICENETWORKS_", subitem.replaceAll(LINE_BEGINNING, "\t"));
subitem = new QueryAllottedResourceCustomization(service.getAllottedCustomizations()).JSON2(true, true);
valueMap.put("_SERVICEALLOTTEDRESOURCES_", subitem.replaceAll(LINE_BEGINNING, "\t"));
subitem = new QueryServiceInfo(service.getServiceInfos()).JSON2(true, true);
valueMap.put("_SERVICEINFO_", subitem.replaceAll(LINE_BEGINNING, "\t"));
subitem = new QueryServiceProxyCustomization(service.getServiceProxyCustomizations()).JSON2(true, true);
valueMap.put("_SERVICEPROXY_", subitem.replaceAll(LINE_BEGINNING, "\t"));
buf.append(this.setTemplate(TEMPLATE, valueMap));
return buf.toString();
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class QueryServiceInfoTest method createList.
private List<ServiceInfo> createList() {
Service service = mock(Service.class);
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setId(1);
serviceInfo.setService(service);
serviceInfo.setServiceInput(null);
serviceInfo.setServiceProperties(null);
List<ServiceInfo> serviceInfos = new ArrayList<>();
serviceInfos.add(serviceInfo);
return serviceInfos;
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class CatalogDbClientTest method testGetServiceByIDNotFound.
@Test
public void testGetServiceByIDNotFound() throws Exception {
Service serviceByID = client.getServiceByID(UUID.randomUUID().toString());
assertNull(serviceByID);
}
use of org.onap.so.db.catalog.beans.Service in project so by onap.
the class CatalogDbClientTest method testGetServiceByModelUUIDNotFound.
@Test
public void testGetServiceByModelUUIDNotFound() {
Service service = client.getServiceByModelUUID("Not_Found");
assertNull(service);
}
Aggregations