提交 0b36679c 编写于 作者: N nilspreusker

added visualization of transformation errors to content-get

上级 014982c5
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
*/ */
package org.activiti.rest.api.cycle; package org.activiti.rest.api.cycle;
import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.Date; import java.util.Date;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
...@@ -22,11 +24,11 @@ import org.activiti.cycle.CycleDefaultMimeType; ...@@ -22,11 +24,11 @@ import org.activiti.cycle.CycleDefaultMimeType;
import org.activiti.cycle.CycleService; import org.activiti.cycle.CycleService;
import org.activiti.cycle.RepositoryArtifact; import org.activiti.cycle.RepositoryArtifact;
import org.activiti.cycle.impl.CycleServiceImpl; import org.activiti.cycle.impl.CycleServiceImpl;
import org.activiti.cycle.impl.transform.TransformationException;
import org.activiti.rest.util.ActivitiRequest; import org.activiti.rest.util.ActivitiRequest;
import org.activiti.rest.util.ActivitiStreamingWebScript; import org.activiti.rest.util.ActivitiStreamingWebScript;
import org.springframework.extensions.webscripts.WebScriptResponse; import org.springframework.extensions.webscripts.WebScriptResponse;
/** /**
* *
* @author Nils Preusker (nils.preusker@camunda.com) * @author Nils Preusker (nils.preusker@camunda.com)
...@@ -83,9 +85,14 @@ public class ContentGet extends ActivitiStreamingWebScript { ...@@ -83,9 +85,14 @@ public class ContentGet extends ActivitiStreamingWebScript {
} }
} }
InputStream content;
try {
content = this.cycleService.getContent(artifact.getConnectorId(), artifact.getNodeId(), contentRepresentation.getId()).asInputStream();
} catch (TransformationException e) {
content = new ByteArrayInputStream(e.getRenderContent().getBytes());
}
streamResponse(res, content, new Date(0),
// TODO: what is a good way to determine the etag? Using a fake one... // TODO: what is a good way to determine the etag? Using a fake one...
streamResponse(res, this.cycleService.getContent(artifact.getConnectorId(), artifact.getNodeId(), contentRepresentation.getId()).asInputStream(), new Date(
0),
"W/\"647-1281077702000\"", attach, attachmentFileName, contentType); "W/\"647-1281077702000\"", attach, attachmentFileName, contentType);
} }
......
...@@ -86,7 +86,6 @@ public class ContentRepresentationGet extends ActivitiWebScript { ...@@ -86,7 +86,6 @@ public class ContentRepresentationGet extends ActivitiWebScript {
// Show errors that occur during transformations as HTML in the UI // Show errors that occur during transformations as HTML in the UI
model.put("renderInfo", RenderInfo.HTML); model.put("renderInfo", RenderInfo.HTML);
model.put("contentRepresentationId", representationId); model.put("contentRepresentationId", representationId);
model.put("content", e.getRenderContent());
model.put("contentType", CycleDefaultMimeType.HTML.getContentType()); model.put("contentType", CycleDefaultMimeType.HTML.getContentType());
} catch (Exception ex) { } catch (Exception ex) {
log.log(Level.WARNING, "Exception while loading content representation", ex); log.log(Level.WARNING, "Exception while loading content representation", ex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册