Search in sources :

Example 1 with TransformerInfoException

use of org.alfresco.repo.content.transform.TransformerInfoException in project acs-community-packaging by Alfresco.

the class NodeInfoBean method sendNodeInfo.

/**
 * Returns information on the node identified by the 'noderef'
 * parameter found in the ExternalContext. If no noderef is supplied, then the template
 * is executed without context.
 * <p>
 * The result is the formatted HTML to show on the client.
 */
public void sendNodeInfo() throws IOException {
    FacesContext context = FacesContext.getCurrentInstance();
    ResponseWriter out = context.getResponseWriter();
    Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap();
    String strNodeRef = (String) requestMap.get("noderef");
    String strTemplate = (String) requestMap.get("template");
    if (strTemplate == null || strTemplate.length() == 0) {
        strTemplate = "node_summary_panel.ftl";
    }
    NodeRef nodeRef = null;
    if (strNodeRef != null && strNodeRef.length() != 0) {
        nodeRef = new NodeRef(strNodeRef);
        if (this.getNodeService().exists(nodeRef) == false) {
            out.write("<span class='errorMessage'>Node could not be found in the repository!</span>");
            return;
        }
    }
    try {
        Repository.getServiceRegistry(context).getTemplateService().processTemplate("/alfresco/templates/client/" + strTemplate, getModel(nodeRef, requestMap), out);
    } catch (TemplateException ex) {
        // Try to catch TransformerInfoException to display it in NodeInfo pane.
        // Fix bug reported in https://issues.alfresco.com/jira/browse/ETWOTWO-440
        Throwable cause = ex.getCause();
        while (cause != null) {
            cause = cause.getCause();
            if (cause instanceof TransformerInfoException) {
                out.write("<tr><td colspan=\"2\"><span class='errorMessage'>" + cause.getMessage() + "</span></td></tr>");
                return;
            }
        }
        throw ex;
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ResponseWriter(javax.faces.context.ResponseWriter) TemplateException(org.alfresco.service.cmr.repository.TemplateException) TransformerInfoException(org.alfresco.repo.content.transform.TransformerInfoException)

Aggregations

FacesContext (javax.faces.context.FacesContext)1 ResponseWriter (javax.faces.context.ResponseWriter)1 TransformerInfoException (org.alfresco.repo.content.transform.TransformerInfoException)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 TemplateException (org.alfresco.service.cmr.repository.TemplateException)1