use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class EditorController method upload.
/**
* Method exposed to REST to upload a file in an archive under edition.
*
* @param topologyId The id of the topology/archive under edition.
* @param lastOperationId The id of the user last known operation (for optimistic locking edition).
* @param path The path in which to save/override the file in the archive.
* @param file The file to save in the archive.
*/
@ApiIgnore
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/{topologyId:.+}/upload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public RestResponse<TopologyDTO> upload(@PathVariable String topologyId, @RequestParam("lastOperationId") String lastOperationId, @RequestParam("path") String path, @RequestParam(value = "file") MultipartFile file) throws IOException {
if (lastOperationId != null && "null".equals(lastOperationId)) {
lastOperationId = null;
}
try (InputStream artifactStream = file.getInputStream()) {
UpdateFileOperation updateFileOperation = new UpdateFileOperation(path, artifactStream);
updateFileOperation.setPreviousOperationId(lastOperationId);
TopologyDTO topologyDTO = editorService.execute(topologyId, updateFileOperation);
return RestResponseBuilder.<TopologyDTO>builder().data(topologyDTO).build();
}
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class TopologyController method get.
/**
* Retrieve an existing {@link Topology}
*
* @param topologyId The id of the topology to retrieve.
* @return {@link RestResponse}<{@link TopologyDTO}> containing the {@link Topology} and the {@link NodeType} related
* to his {@link NodeTemplate}s
*/
@ApiOperation(value = "Retrieve a topology from it's id.", notes = "Returns a topology with it's details. Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ]")
@RequestMapping(value = "/{topologyId:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<TopologyDTO> get(@PathVariable String topologyId) {
Topology topology = topologyServiceCore.getOrFail(topologyId);
topologyService.checkAccessAuthorizations(topology);
try {
topologyEditionContextManager.init(topologyId);
editorService.checkTopologyRecovery();
return RestResponseBuilder.<TopologyDTO>builder().data(dtoBuilder.buildTopologyDTO(EditionContextManager.get())).build();
} finally {
topologyEditionContextManager.destroy();
}
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class InputPropertiesStepDefinitions method The_topology_should_not_have_the_property_defined_as_input_property.
@Then("^The topology should not have the property \"([^\"]*)\" defined as input property$")
public void The_topology_should_not_have_the_property_defined_as_input_property(String inputId) throws Throwable {
TopologyDTO topologyDTO = JsonUtil.read(Context.getRestClientInstance().get("/rest/v1/topologies/" + Context.getInstance().getTopologyId()), TopologyDTO.class, Context.getJsonMapper()).getData();
Map<String, PropertyDefinition> inputProperties = topologyDTO.getTopology().getInputs();
Assert.assertFalse(inputProperties.containsKey(inputId));
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class InputPropertiesStepDefinitions method The_topology_should_have_the_property_of_the_node_defined_as_input_property.
@Then("^The topology should have the property \"([^\"]*)\" defined as input property$")
public void The_topology_should_have_the_property_of_the_node_defined_as_input_property(String inputId) throws Throwable {
String response = Context.getRestClientInstance().get("/rest/v1/topologies/" + Context.getInstance().getTopologyId());
JavaType restResponseType = Context.getJsonMapper().getTypeFactory().constructParametricType(RestResponse.class, TopologyDTO.class);
TopologyDTO topologyDTO = ((RestResponse<TopologyDTO>) Context.getJsonMapper().readValue(response, restResponseType)).getData();
Map<String, PropertyDefinition> inputProperties = topologyDTO.getTopology().getInputs();
Assert.assertNotNull(inputProperties);
PropertyDefinition inputPropertieDefinition = inputProperties.get(inputId);
Assert.assertNotNull(inputPropertieDefinition);
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class OutputPropertiesStepDefinitions method The_topology_should_not_have_the_capability_property_of_the_capability_for_the_node_defined_as_output_property.
@Then("^The topology should not have the capability property \"([^\"]*)\" of the capability \"([^\"]*)\" for the node \"([^\"]*)\" defined as output property$")
public void The_topology_should_not_have_the_capability_property_of_the_capability_for_the_node_defined_as_output_property(String propertyName, String capabilityId, String nodeName) throws Throwable {
TopologyDTO topologyDTO = getTopologyDTO();
Map<String, Map<String, Set<String>>> outputCapabilityProperties = topologyDTO.getTopology().getOutputCapabilityProperties();
Assert.assertNotNull(outputCapabilityProperties);
Map<String, Set<String>> outputPropertiesOfNode = outputCapabilityProperties.get(nodeName);
Assert.assertNotNull(outputPropertiesOfNode);
Set<String> outputPropertiesOfCapability = outputPropertiesOfNode.get(capabilityId);
Assert.assertNotNull(outputPropertiesOfCapability);
Assert.assertFalse(outputPropertiesOfCapability.contains(propertyName));
}
Aggregations