Skip to content

Commit

Permalink
Fixes #449 - #449 (#451)
Browse files Browse the repository at this point in the history
* Fixes #449 - #449

Signed-off-by: Erle Czar Mantos <[email protected]>

* Remove print logs.

Signed-off-by: Erle Czar Mantos <[email protected]>
  • Loading branch information
Erle Czar Mantos authored and aedelmann committed Nov 28, 2016
1 parent c4e423d commit 505e984
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public List<GeneratorResource> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<groupId>org.eclipse.vorto</groupId>
<artifactId>org.eclipse.vorto.codegen</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.vorto</groupId>
<artifactId>org.eclipse.vorto.codegen.templates.java</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.vorto</groupId>
<artifactId>org.eclipse.vorto.codegen.examples.prosystfi</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
<artifactId>org.eclipse.vorto.codegen</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.vorto</groupId>
<artifactId>org.eclipse.vorto.codegen.templates.java</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.vorto</groupId>
<artifactId>org.eclipse.vorto.editor</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,12 +81,13 @@ public void generate( @ApiParam(value = "The namespace of vorto model, e.g. com

Map<String, String> 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) {
Expand Down

0 comments on commit 505e984

Please sign in to comment.