diff --git a/modules/activiti-webapp-cycle/src/main/webapp/components/artifact/artifact.js b/modules/activiti-webapp-cycle/src/main/webapp/components/artifact/artifact.js index db99de6f9340982ad1d1a4612a1e294f93099a01..fa377fd10b0c4fadfc3c092f8d3412e7ad4f2e71 100644 --- a/modules/activiti-webapp-cycle/src/main/webapp/components/artifact/artifact.js +++ b/modules/activiti-webapp-cycle/src/main/webapp/components/artifact/artifact.js @@ -183,10 +183,6 @@ } var optionsMenu = new YAHOO.widget.Button({ type: "menu", label: "Options", name: "options", menu: optionsMenuItems, container: optionsDiv }); } - - var clearDiv = document.createElement('div'); - clearDiv.setAttribute('style', 'clear: both'); - optionsDiv.appendChild(clearDiv); optionsDiv.setAttribute('class', 'active'); }, @@ -233,31 +229,31 @@ var rows = []; for(var i=0; i' + responseJson[i].label + '', Revision: responseJson[i].targetArtifactRevision, Type: '
' + responseJson[i].targetContentType + '
' }; + var row = {Name: '' + responseJson[i].artifact.label + '', Revision: responseJson[i].artifact.targetArtifactRevision, Type: '
' + responseJson[i].artifact.targetContentType + '
' }; rows.push(row); } var linksDataSource = new YAHOO.util.LocalDataSource(rows); diff --git a/modules/activiti-webapp-rest/src/main/java/org/activiti/rest/api/cycle/ContentRepresentationGet.java b/modules/activiti-webapp-rest/src/main/java/org/activiti/rest/api/cycle/ContentRepresentationGet.java index 433ee66ae64d17bdda2c14202aa28a9cca5c9de5..a7420c7ab01aa591a5c180c3b2fd6fb327b67611 100644 --- a/modules/activiti-webapp-rest/src/main/java/org/activiti/rest/api/cycle/ContentRepresentationGet.java +++ b/modules/activiti-webapp-rest/src/main/java/org/activiti/rest/api/cycle/ContentRepresentationGet.java @@ -21,9 +21,12 @@ import java.util.logging.Logger; import javax.servlet.http.HttpSession; import org.activiti.cycle.ContentRepresentation; +import org.activiti.cycle.CycleDefaultMimeType; import org.activiti.cycle.CycleService; +import org.activiti.cycle.RenderInfo; import org.activiti.cycle.RepositoryArtifact; import org.activiti.cycle.impl.CycleServiceImpl; +import org.activiti.cycle.impl.transform.TransformationException; import org.activiti.rest.util.ActivitiRequest; import org.activiti.rest.util.ActivitiWebScript; import org.springframework.extensions.webscripts.Cache; @@ -58,11 +61,15 @@ public class ContentRepresentationGet extends ActivitiWebScript { // Get representation by id to determine whether it is an image... try { + model.put("connectorId", connectorId); + model.put("artifactId", artifactId); + ContentRepresentation contentRepresentation = artifact.getArtifactType().getContentRepresentation(representationId); switch (contentRepresentation.getRenderInfo()) { case IMAGE: case HTML: - // For images and HTML we don't need to send the content, the URL will be put together in the UI + // For images and HTML we don't need to send the content, the URL will + // be put together in the UI // and the content will be requested via ContentGet. break; case HTML_REFERENCE: @@ -72,18 +79,17 @@ public class ContentRepresentationGet extends ActivitiWebScript { String content = this.cycleService.getContent(connectorId, artifactId, contentRepresentation.getId()).asString(); model.put("content", content); } - - model.put("connectorId", connectorId); - model.put("artifactId", artifactId); model.put("renderInfo", contentRepresentation.getRenderInfo().name()); model.put("contentRepresentationId", contentRepresentation.getId()); model.put("contentType", contentRepresentation.getMimeType().getContentType()); - + } catch (TransformationException e) { + // Show errors that occur during transformations as HTML in the UI + model.put("renderInfo", RenderInfo.HTML); + model.put("contentRepresentationId", "Exception"); + model.put("content", e.getRenderContent()); + model.put("contentType", CycleDefaultMimeType.HTML.getContentType()); } catch (Exception ex) { - // we had a problem with a content representation log and go on, - // that this will not prevent other representations to be shown log.log(Level.WARNING, "Exception while loading content representation", ex); - // TODO:Better concept how this is handled in the GUI StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); diff --git a/modules/activiti-webapp-rest/src/main/resources/webscripts/org/activiti/rest/api/cycle/artifact-links.get.json.ftl b/modules/activiti-webapp-rest/src/main/resources/webscripts/org/activiti/rest/api/cycle/artifact-links.get.json.ftl index 13fea022d65f9b669adea05f12bcab47e45f38a2..0a2f78a663622fc4473b8f0db8adbb0a8aedae75 100644 --- a/modules/activiti-webapp-rest/src/main/resources/webscripts/org/activiti/rest/api/cycle/artifact-links.get.json.ftl +++ b/modules/activiti-webapp-rest/src/main/resources/webscripts/org/activiti/rest/api/cycle/artifact-links.get.json.ftl @@ -4,9 +4,11 @@ <#macro printLink link> { - <@printArtifact link.targetArtifact/>, - "targetElementId": "${link.targetElementId}", - "targetElementName": "${link.targetElementName}" + "artifact": { + <@printArtifact link.targetArtifact/>, + "targetElementId": "${link.targetElementId}", + "targetElementName": "${link.targetElementName}" + } }