ServiceTemplateResource extends AbstractComponentInstanceResourceContainingATopology implements IHasName { @GET @Path("injector/options") @Produces( {MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON}) public Response getInjectorOptions() { Splitting splitting = new Splitting(); TTopologyTemplate topologyTemplate = this.getServiceTemplate().getTopologyTemplate(); Map<String, List<TTopologyTemplate>> hostMatchingOptions; Map<String, List<TTopologyTemplate>> connectionMatchingOptions; InjectorReplaceOptions injectionReplaceOptions = new InjectorReplaceOptions(); try { Map<TRequirement, String> requirementsAndMatchingBasisCapabilityTypes = splitting.getOpenRequirementsAndMatchingBasisCapabilityTypeNames(this.getServiceTemplate().getTopologyTemplate()); for (TRequirement req : requirementsAndMatchingBasisCapabilityTypes.keySet()) { System.out.println("open Requirement: " + req.getId()); System.out.println("matchingBasisType: " + requirementsAndMatchingBasisCapabilityTypes.get(req)); } if (requirementsAndMatchingBasisCapabilityTypes.containsValue("Container")) { hostMatchingOptions = splitting.getHostingMatchingOptionsWithDefaultLabeling(topologyTemplate); } else { hostMatchingOptions = null; } if (requirementsAndMatchingBasisCapabilityTypes.containsValue("Endpoint")) { connectionMatchingOptions = splitting.getConnectionInjectionOptions(topologyTemplate); } else { connectionMatchingOptions = null; } injectionReplaceOptions.setTopologyTemplate(topologyTemplate); injectionReplaceOptions.setHostInjectionOptions(hostMatchingOptions); injectionReplaceOptions.setConnectionInjectionOptions(connectionMatchingOptions); if (hostMatchingOptions == null && connectionMatchingOptions == null) { return Response.status(Status.BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity("No need for matching").build(); } } catch (SplittingException e) { LOGGER.error("Could not match", e); return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build(); } return Response.ok().entity(injectionReplaceOptions).build(); } ServiceTemplateResource(ServiceTemplateId id); TServiceTemplate getServiceTemplate(); @Override void setTopology(TTopologyTemplate topologyTemplate, String type); @Path("topologytemplate/") TopologyTemplateResource getTopologyTemplateResource(); @Path("plans/") PlansResource getPlansResource(); @Path("selfserviceportal/") SelfServicePortalResource getSelfServicePortalResource(); @Path("boundarydefinitions/") BoundaryDefinitionsResource getBoundaryDefinitionsResource(); @Override String getName(); @Override Response setName(String name); @GET @ApiOperation(value = "Returns the associated node type, which can be substituted by this service template.") @ApiResponses(value = { @ApiResponse(code = 200, response = QName.class, message = "QName of the form {namespace}localName") }) @Path("substitutableNodeType") @Produces(MediaType.TEXT_PLAIN) Response getSubstitutableNodeTypeAsResponse(); QName getSubstitutableNodeType(); @DELETE @ApiOperation(value = "Removes the association to substitutable node type") @Path("substitutableNodeType") Response deleteSubstitutableNodeType(); @GET @Path("injector/options") @Produces( {MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON}) Response getInjectorOptions(); @POST @Path("injector/replace") @Consumes( {MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON}) @Produces( {MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON}) Response injectNodeTemplates(InjectorReplaceData injectorReplaceData, @Context UriInfo uriInfo); @Path("constraintchecking") @Produces(MediaType.APPLICATION_XML) @POST Response complianceChecking(@Context UriInfo uriInfo); @Path("substitute") @Produces(MediaType.APPLICATION_JSON) @GET ServiceTemplateId substitute(); @POST() @Path("createnewstatefulversion") @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) Response createNewStatefulVersion(); @Path("threatmodeling") @Produces(MediaType.APPLICATION_JSON) @GET ThreatAssessment threatModeling(); @Override void synchronizeReferences(); @Path("parameters") ParameterResource getParameterResource(); @Path("toscalight") @Produces(MediaType.APPLICATION_JSON) @GET Map<String, Object> getToscaLightCompatibility();  }
@Test public void getInjectorOptions() throws Exception { this.setRevisionTo("84d064a2f7390b3274ca8b3641a5902ba4c822d7"); this.assertGet("servicetemplates/http%253A%252F%252Fwinery.opentosca.org%252Ftest%252Fservicetemplates%252Fponyuniverse%252Finjector/FoodandHouseInjectionTest/injector/options", "servicetemplates/ServiceTemplateResource-getInjectionOptions.json"); }