use of org.eclipse.vorto.repository.client.RepositoryClientException in project vorto by eclipse.
the class DefaultModelGeneration method getGeneratedOutput.
private GeneratedOutput getGeneratedOutput(HttpResponse response) {
try {
String contentDisposition = response.getFirstHeader("Content-Disposition").getValue();
String filename = contentDisposition.substring(contentDisposition.indexOf("filename = ") + "filename = ".length());
long length = response.getEntity().getContentLength();
byte[] content = IOUtils.toByteArray(response.getEntity().getContent());
return new GeneratedOutput(content, filename, length);
} catch (IOException e) {
throw new RepositoryClientException("Error in converting response to GeneratedOutput", e);
}
}
use of org.eclipse.vorto.repository.client.RepositoryClientException in project vorto by eclipse.
the class DefaultModelGeneration method getGeneratorUrl.
private String getGeneratorUrl(String baseUrl, ModelId modelId, String generatorKey, Map<String, String> invocationParams) {
try {
StringBuilder url = new StringBuilder();
url.append(baseUrl).append("/rest/generation-router/").append(modelId.getNamespace()).append("/").append(modelId.getName()).append("/").append(modelId.getVersion()).append("/").append(URLEncoder.encode(generatorKey, "utf-8"));
if (invocationParams != null && !invocationParams.isEmpty()) {
StringJoiner joiner = new StringJoiner("&");
invocationParams.forEach((key, value) -> {
joiner.add(key + "=" + value);
});
url.append("?").append(joiner.toString());
}
return url.toString();
} catch (UnsupportedEncodingException e) {
throw new RepositoryClientException("Error in generating URL for the generator", e);
}
}
Aggregations