ServiceTemplateResource extends AbstractComponentInstanceResourceContainingATopology implements IHasName { @POST() @Path("createnewstatefulversion") @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response createNewStatefulVersion() { LOGGER.debug("Creating new stateful version of Service Template {}...", this.getId()); ServiceTemplateId id = (ServiceTemplateId) this.getId(); WineryVersion version = VersionUtils.getVersion(id); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss"); WineryVersion newVersion = new WineryVersion( "stateful-" + version.toString() + "-" + dateFormat.format(new Date()), 1, 0 ); ServiceTemplateId newId = new ServiceTemplateId(id.getNamespace().getDecoded(), VersionUtils.getNameWithoutVersion(id) + WineryVersion.WINERY_NAME_FROM_VERSION_SEPARATOR + newVersion.toString(), false); ResourceResult response = RestUtils.duplicate(id, newId); if (response.getStatus() == Status.CREATED) { response.setUri(null); response.setMessage(new QNameApiData(newId)); } LOGGER.debug("Created Service Template {}", newId.getQName()); return response.getResponse(); } 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 createNewStatefulVersion() throws Exception { this.setRevisionTo("eb37f5cfec50c046985eac308e46482ce8bea8e3"); String response = this.assertPostWithNoContent("servicetemplates/http%253A%252F%252Fplain.winery.opentosca.org%252Fservicetemplates/ServiceTemplateWithOneNodeTemplate_w1-wip1/createnewstatefulversion", ContentType.JSON); QNameApiData newId = JacksonProvider.mapper.readValue(response, QNameApiData.class); assertNonNull(newId); WineryVersion version = VersionUtils.getVersion(newId.localname); assertNonNull(version); assertTrue(version.getComponentVersion().startsWith("stateful-w1-wip1-")); }