提交 ed37c645 编写于 作者: N nilspreusker

modified JSON representation of artifact links to make it easier to transform...

modified JSON representation of artifact links to make it easier to transform with XStream, added visualization of transformation exceptions
上级 1e81d401
......@@ -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.length; i++) {
var typeClass;
if(responseJson[i].targetContentType === "image/png" || responseJson[i].targetContentType === "image/gif" || responseJson[i].targetContentType === "image/jpeg") {
if(responseJson[i].artifact.targetContentType === "image/png" || responseJson[i].artifact.targetContentType === "image/gif" || responseJson[i].artifact.targetContentType === "image/jpeg") {
typeClass = "icon-img";
} else if(responseJson[i].targetContentType === "application/xml") {
} else if(responseJson[i].artifact.targetContentType === "application/xml") {
typeClass = "icon-code-red";
} else if(responseJson[i].targetContentType === "text/html") {
} else if(responseJson[i].artifact.targetContentType === "text/html") {
typeClass = "icon-www";
} else if(responseJson[i].targetContentType === "text/plain") {
} else if(responseJson[i].artifact.targetContentType === "text/plain") {
typeClass = "icon-txt";
} else if(responseJson[i].targetContentType === "application/pdf") {
} else if(responseJson[i].artifact.targetContentType === "application/pdf") {
typeClass = "icon-pdf";
} else if(responseJson[i].targetContentType === "application/json;charset=UTF-8") {
} else if(responseJson[i].artifact.targetContentType === "application/json;charset=UTF-8") {
typeClass = "icon-code-blue";
} else if(responseJson[i].targetContentType === "application/msword") {
} else if(responseJson[i].artifact.targetContentType === "application/msword") {
typeClass = "icon-doc";
} else if(responseJson[i].targetContentType === "application/powerpoint") {
} else if(responseJson[i].artifact.targetContentType === "application/powerpoint") {
typeClass = "icon-ppt";
} else if(responseJson[i].targetContentType === "application/excel") {
} else if(responseJson[i].artifact.targetContentType === "application/excel") {
typeClass = "icon-xls";
} else if(responseJson[i].targetContentType === "application/javascript") {
} else if(responseJson[i].artifact.targetContentType === "application/javascript") {
typeClass = "icon-code-blue";
} else {
// Use white page as default icon for all other content types
typeClass = "icon-blank";
}
var row = {Name: '<a class="openArtifactLink" href="#?connectorId=' + responseJson[i].targetConnectorId + '&artifactId=' + responseJson[i].targetArtifactId + '&artifactName=' + responseJson[i].label + '">' + responseJson[i].label + '</a>', Revision: responseJson[i].targetArtifactRevision, Type: '<div class="artifact-type ' + typeClass + '">' + responseJson[i].targetContentType + '</div>' };
var row = {Name: '<a class="openArtifactLink" href="#?connectorId=' + responseJson[i].artifact.targetConnectorId + '&artifactId=' + responseJson[i].artifact.targetArtifactId + '&artifactName=' + responseJson[i].artifact.label + '">' + responseJson[i].artifact.label + '</a>', Revision: responseJson[i].artifact.targetArtifactRevision, Type: '<div class="artifact-type ' + typeClass + '">' + responseJson[i].artifact.targetContentType + '</div>' };
rows.push(row);
}
var linksDataSource = new YAHOO.util.LocalDataSource(rows);
......
......@@ -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));
......
......@@ -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}"
}
}
</#macro>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册