use of org.eclipse.vorto.repository.conversion.ModelIdToModelContentConverter in project vorto by eclipse.
the class ModelController method getModelContent.
@PreAuthorize("isAuthenticated() or hasAuthority('model_viewer')")
@GetMapping("/{modelId:.+}/content")
public ModelContent getModelContent(@ApiParam(value = "The modelId of vorto model, e.g. com.mycompany:Car:1.0.0", required = true) @PathVariable final String modelId) {
final ModelId modelID = ModelId.fromPrettyFormat(modelId);
ModelIdToModelContentConverter converter = new ModelIdToModelContentConverter(this.modelRepositoryFactory);
return converter.convert(modelID, Optional.empty());
}
use of org.eclipse.vorto.repository.conversion.ModelIdToModelContentConverter in project vorto by eclipse.
the class ModelController method getModelContentForTargetPlatform.
@PreAuthorize("isAuthenticated() or hasAuthority('model_viewer')")
@GetMapping("/{modelId:.+}/content/{targetplatformKey}")
public ModelContent getModelContentForTargetPlatform(@ApiParam(value = "The modelId of vorto model, e.g. com.mycompany:Car:1.0.0", required = true) @PathVariable final String modelId, @ApiParam(value = "The key of the targetplatform, e.g. lwm2m", required = true) @PathVariable final String targetplatformKey) {
final ModelId modelID = ModelId.fromPrettyFormat(modelId);
ModelIdToModelContentConverter converter = new ModelIdToModelContentConverter(this.modelRepositoryFactory);
return converter.convert(modelID, Optional.of(targetplatformKey));
}
use of org.eclipse.vorto.repository.conversion.ModelIdToModelContentConverter in project vorto by eclipse.
the class DefaultGeneratorPluginService method doGenerateWithApiVersion2.
private GeneratedOutput doGenerateWithApiVersion2(ModelId modelId, String serviceKey, Map<String, String> requestParams, String baseUrl) {
ModelIdToModelContentConverter converter = new ModelIdToModelContentConverter(this.modelRepositoryFactory);
ModelContent content = converter.convert(modelId, Optional.of(serviceKey));
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Generating with V2. Sending following json content {}", new ObjectMapper().writeValueAsString(content));
}
} catch (JsonProcessingException e) {
LOGGER.trace("Error processing JSON for logging", e);
}
ResponseEntity<byte[]> response = restTemplate.exchange(baseUrl + "/api/2/plugins/generators/{pluginkey}" + attachRequestParams(requestParams), HttpMethod.PUT, new HttpEntity<>(content), byte[].class, serviceKey);
return new GeneratedOutput(response.getBody(), extractFileNameFromHeader(response), response.getHeaders().getContentLength());
}
Aggregations