Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

JBPM-3924 - Fixed image (png and svg) that are stored in guvnor to use #13

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -120,7 +120,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
resp.setContentType("text/plain"); resp.setContentType("text/plain");
resp.getWriter().write("<object data=\"data:application/pdf;base64," + Base64.encodeBase64(bout.toByteArray()) + "\" type=\"application/pdf\"></object>"); resp.getWriter().write("<object data=\"data:application/pdf;base64," + Base64.encodeBase64(bout.toByteArray()) + "\" type=\"application/pdf\"></object>");
} else { } else {
storeInRepository(uuid, rawSvg, transformto, processid, repository); storeInRepository(uuid, formattedSvg, transformto, processid, repository);


resp.setContentType("application/pdf"); resp.setContentType("application/pdf");
if (processid != null) { if (processid != null) {
Expand Down Expand Up @@ -446,7 +446,7 @@ private void addBpmnDiInfo(Definitions def, String gpd) {
} }
} }


private void storeInRepository(String uuid, String rawSvg, String transformto, String processid, Repository repository) { private void storeInRepository(String uuid, String formattedSvg, String transformto, String processid, Repository repository) {
try { try {
if(processid != null) { if(processid != null) {
Asset<byte[]> processAsset = repository.loadAsset(uuid); Asset<byte[]> processAsset = repository.loadAsset(uuid);
Expand Down Expand Up @@ -475,14 +475,14 @@ private void storeInRepository(String uuid, String rawSvg, String transformto, S
if (transformto.equals(TO_PDF)) { if (transformto.equals(TO_PDF)) {
PDFTranscoder t = new PDFTranscoder(); PDFTranscoder t = new PDFTranscoder();
TranscoderInput input = new TranscoderInput(new StringReader( TranscoderInput input = new TranscoderInput(new StringReader(
rawSvg)); formattedSvg));
TranscoderOutput output = new TranscoderOutput(outputStream); TranscoderOutput output = new TranscoderOutput(outputStream);
t.transcode(input, output); t.transcode(input, output);
} else if (transformto.equals(TO_PNG)) { } else if (transformto.equals(TO_PNG)) {
PNGTranscoder t = new PNGTranscoder(); PNGTranscoder t = new PNGTranscoder();
t.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen"); t.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen");
TranscoderInput input = new TranscoderInput(new StringReader( TranscoderInput input = new TranscoderInput(new StringReader(
rawSvg)); formattedSvg));
TranscoderOutput output = new TranscoderOutput(outputStream); TranscoderOutput output = new TranscoderOutput(outputStream);
try { try {
t.transcode(input, output); t.transcode(input, output);
Expand All @@ -492,7 +492,7 @@ private void storeInRepository(String uuid, String rawSvg, String transformto, S
} }
} else if(transformto.equals(TO_SVG)) { } else if(transformto.equals(TO_SVG)) {
OutputStreamWriter outStreamWriter = new OutputStreamWriter(outputStream); OutputStreamWriter outStreamWriter = new OutputStreamWriter(outputStream);
outStreamWriter.write(rawSvg); outStreamWriter.write(formattedSvg);
outStreamWriter.close(); outStreamWriter.close();
} }
AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Byte); AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Byte);
Expand Down