1 5 package org.exoplatform.portlets.content.explorer.component; 6 7 import javax.jcr.Node ; 8 import org.exoplatform.portlets.content.explorer.component.model.NodeDescriptor; 9 13 public class UIJCRContentViewer extends UIContentViewer { 14 public UIJCRContentViewer() { 15 16 } 17 18 public void onChange(UIExplorer uiExplorer, NodeDescriptor node) { 19 if(!node.isLeafNode()) { 20 setRendered(false) ; 21 return; 22 } 23 String content = "" ; 24 String mimeType = node.getNodeType() ; 25 try { 26 UIJCRExplorer uiJCRExplorer = (UIJCRExplorer) uiExplorer ; 27 renderer_ = getRenderer(mimeType) ; 28 if (renderer_ != null) { 29 if (mimeType.startsWith("text")) { 30 Node jcrnode = uiJCRExplorer.getCurrentNode() ; 31 Node jcrcontent = jcrnode.getNode("jcr:content") ; 32 content = jcrcontent.getProperty("exo:content").getValue().getString() ; 33 } else { 34 content = "/content/FileContentServlet?path=" + node.getUri() ; 35 } 36 } else { 37 String relativePath = node.getUri(); 38 renderer_ = getRenderer("default") ; 39 content = "/content/FileContentServlet?path=" + relativePath ; 40 } 41 } catch (Exception ex) { 42 renderer_ = getRenderer("text/plain") ; 43 content = org.exoplatform.commons.utils.ExceptionUtil.getExoStackTrace(ex) ; 44 } 45 setContent(content) ; 46 setContentType(mimeType) ; 47 setRendered(true) ; 48 } 49 50 public void onModify(UIExplorer uiExplorer, NodeDescriptor node) { 51 52 } 53 } 54 | Popular Tags |