package org.alfresco.web.bean.ajax; import java.io.IOException; import java.util.Map; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Bean used by an AJAX control to send information back on the * requested node. * * @author gavinc */ public class NodeInfoBean { private NodeService nodeService; private ContentService contentService; private static final Log logger = LogFactory.getLog(NodeInfoBean.class); /** * Returns information on the node identified by the 'noderef' * parameter found in the ExternalContext. *
* The result is the formatted HTML to show on the client. */ public void sendNodeInfo() throws IOException { FacesContext context = FacesContext.getCurrentInstance(); ResponseWriter out = context.getResponseWriter(); String nodeRef = (String)context.getExternalContext().getRequestParameterMap().get("noderef"); if (nodeRef == null || nodeRef.length() == 0) { throw new IllegalArgumentException("'noderef' parameter is missing"); } NodeRef repoNode = new NodeRef(nodeRef); if (this.nodeService.exists(repoNode)) { // get the client side node representation and its properties Node clientNode = new Node(repoNode); Map props = clientNode.getProperties(); // get the content size Object content = props.get(ContentModel.PROP_CONTENT); // start the containing table out.write("
Summary |
"); out.write(nameColumn); out.write(" | "); if (dataColumn != null) { out.write(dataColumn); } else { out.write(" "); } out.write(" |