Search in sources :

Example 56 with Service

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();
    }
}
Also used : Service(org.onap.so.db.catalog.beans.Service) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) QueryServiceCsar(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 57 with Service

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();
}
Also used : HashMap(java.util.HashMap) Service(org.onap.so.db.catalog.beans.Service)

Example 58 with Service

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;
}
Also used : ServiceInfo(org.onap.so.db.catalog.beans.ServiceInfo) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service)

Example 59 with Service

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);
}
Also used : Service(org.onap.so.db.catalog.beans.Service) ExternalServiceToInternalService(org.onap.so.db.catalog.beans.ExternalServiceToInternalService) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)

Example 60 with Service

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);
}
Also used : Service(org.onap.so.db.catalog.beans.Service) ExternalServiceToInternalService(org.onap.so.db.catalog.beans.ExternalServiceToInternalService) Test(org.junit.Test) CatalogDbAdapterBaseTest(org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest)

Aggregations

Service (org.onap.so.db.catalog.beans.Service)171 Test (org.junit.Test)135 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)57 File (java.io.File)48 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)47 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)46 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)40 ArrayList (java.util.ArrayList)39 HashMap (java.util.HashMap)37 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)37 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)36 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)29 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)24 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)22 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)19 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)18 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)18 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)18 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)18 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)18