From 505e9843e8610a8e1149bc5cac1ddf8992745c09 Mon Sep 17 00:00:00 2001 From: Erle Czar Mantos Date: Mon, 28 Nov 2016 18:10:20 +0800 Subject: [PATCH] Fixes #449 - https://github.com/eclipse/vorto/issues/449 (#451) * Fixes #449 - https://github.com/eclipse/vorto/issues/449 Signed-off-by: Erle Czar Mantos * Remove print logs. Signed-off-by: Erle Czar Mantos --- .../vorto/repository/RestModelRepository.java | 2 +- .../pom.xml | 4 ++++ server/pom.xml | 5 +++++ .../repository/web/ModelGenerationController.java | 12 +++++++----- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestModelRepository.java b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestModelRepository.java index 7607453faf..9029dd052d 100644 --- a/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestModelRepository.java +++ b/bundles/org.eclipse.vorto.repository/src/org/eclipse/vorto/repository/RestModelRepository.java @@ -193,7 +193,7 @@ public List listGenerators() { public Attachment generateCode(ModelId model, String serviceKey) { try { String url = "generation-router/" + model.getNamespace() + "/" + model.getName() + "/" + model.getVersion() - + "/" + serviceKey; + + "/" + URLEncoder.encode(serviceKey, "utf-8"); Attachment result = httpClient.executeGetAttachment(url); return result; } catch (RepositoryException e) { diff --git a/server/generators/org.eclipse.vorto.codegen.service.prosystfi/pom.xml b/server/generators/org.eclipse.vorto.codegen.service.prosystfi/pom.xml index 1d85de284b..8613fa229a 100644 --- a/server/generators/org.eclipse.vorto.codegen.service.prosystfi/pom.xml +++ b/server/generators/org.eclipse.vorto.codegen.service.prosystfi/pom.xml @@ -17,6 +17,10 @@ org.eclipse.vorto org.eclipse.vorto.codegen + + org.eclipse.vorto + org.eclipse.vorto.codegen.templates.java + org.eclipse.vorto org.eclipse.vorto.codegen.examples.prosystfi diff --git a/server/pom.xml b/server/pom.xml index a81b4ae88e..4744c76fbe 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -67,6 +67,11 @@ org.eclipse.vorto.codegen ${project.version} + + org.eclipse.vorto + org.eclipse.vorto.codegen.templates.java + ${project.version} + org.eclipse.vorto org.eclipse.vorto.editor diff --git a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java b/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java index a84038a406..fd3847ceef 100644 --- a/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java +++ b/server/repo/repo-ui/src/main/java/org/eclipse/vorto/repository/web/ModelGenerationController.java @@ -16,6 +16,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -80,12 +81,13 @@ public void generate( @ApiParam(value = "The namespace of vorto model, e.g. com Map requestParams = new HashMap<>(); request.getParameterMap().entrySet().stream().forEach(x -> requestParams.put(x.getKey(), x.getValue()[0])); - - GeneratedOutput generatedOutput = generatorService.generate(new ModelId(name,namespace,version), serviceKey, requestParams); - response.setHeader(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + generatedOutput.getFileName()); - response.setContentLengthLong(generatedOutput.getSize()); - response.setContentType(APPLICATION_OCTET_STREAM); + try { + GeneratedOutput generatedOutput = generatorService.generate(new ModelId(name,namespace,version), URLDecoder.decode(serviceKey, "utf-8"), requestParams); + response.setHeader(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + generatedOutput.getFileName()); + response.setContentLengthLong(generatedOutput.getSize()); + response.setContentType(APPLICATION_OCTET_STREAM); + IOUtils.copy(new ByteArrayInputStream(generatedOutput.getContent()), response.getOutputStream()); response.flushBuffer(); } catch (IOException e) {