Search in sources :

Example 6 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class NavigatorPluginBean method nodeCollapsed.

/**
 * Sets the state of the node given in the 'nodeRef' parameter to collapsed
 */
public void nodeCollapsed() throws IOException {
    FacesContext context = FacesContext.getCurrentInstance();
    ResponseWriter out = context.getResponseWriter();
    Map params = context.getExternalContext().getRequestParameterMap();
    String nodeRefStr = (String) params.get("nodeRef");
    String area = (String) params.get("area");
    if (logger.isDebugEnabled())
        logger.debug("nodeCollapsed: area = " + area + ", nodeRef = " + nodeRefStr);
    // work out which list to cache the nodes in
    Map<String, TreeNode> currentNodes = getNodesMapForArea(area);
    if (nodeRefStr != null && currentNodes != null) {
        TreeNode treeNode = currentNodes.get(nodeRefStr);
        if (treeNode != null) {
            treeNode.setExpanded(false);
            // we need to return something for the client to be happy!
            out.write("<ok/>");
            if (logger.isDebugEnabled())
                logger.debug("Set node " + treeNode + " to collapsed state");
        }
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ResponseWriter(javax.faces.context.ResponseWriter) TreeNode(org.alfresco.web.ui.repo.component.UITree.TreeNode) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class PortletActionsBean method checkinItem.

@InvokeCommand.ResponseMimetype(value = MimetypeMap.MIMETYPE_HTML)
public void checkinItem() throws Exception {
    FacesContext fc = FacesContext.getCurrentInstance();
    ResponseWriter out = fc.getResponseWriter();
    Map<String, String> requestMap = fc.getExternalContext().getRequestParameterMap();
    String strNodeRef = (String) requestMap.get("noderef");
    if (strNodeRef != null && strNodeRef.length() != 0) {
        try {
            Map<String, Serializable> props = new HashMap<String, Serializable>(2, 1.0f);
            props.put(Version.PROP_DESCRIPTION, "");
            props.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
            Repository.getServiceRegistry(fc).getCheckOutCheckInService().checkin(new NodeRef(strNodeRef), props);
            out.write("OK: " + strNodeRef);
        } catch (Throwable err) {
            out.write("ERROR: " + err.getMessage());
        }
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) ResponseWriter(javax.faces.context.ResponseWriter) HashMap(java.util.HashMap)

Example 8 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class PortletActionsBean method deleteItem.

@InvokeCommand.ResponseMimetype(value = MimetypeMap.MIMETYPE_HTML)
public void deleteItem() throws Exception {
    FacesContext fc = FacesContext.getCurrentInstance();
    ResponseWriter out = fc.getResponseWriter();
    Map<String, String> requestMap = fc.getExternalContext().getRequestParameterMap();
    String strNodeRef = (String) requestMap.get("noderef");
    if (strNodeRef != null && strNodeRef.length() != 0) {
        try {
            Repository.getServiceRegistry(fc).getFileFolderService().delete(new NodeRef(strNodeRef));
            out.write("OK: " + strNodeRef);
        } catch (Throwable err) {
            out.write("ERROR: " + err.getMessage());
        }
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ResponseWriter(javax.faces.context.ResponseWriter)

Example 9 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class PortletActionsBean method checkoutItem.

@InvokeCommand.ResponseMimetype(value = MimetypeMap.MIMETYPE_HTML)
public void checkoutItem() throws Exception {
    FacesContext fc = FacesContext.getCurrentInstance();
    ResponseWriter out = fc.getResponseWriter();
    Map<String, String> requestMap = fc.getExternalContext().getRequestParameterMap();
    String strNodeRef = (String) requestMap.get("noderef");
    if (strNodeRef != null && strNodeRef.length() != 0) {
        try {
            Repository.getServiceRegistry(fc).getCheckOutCheckInService().checkout(new NodeRef(strNodeRef));
            out.write("OK: " + strNodeRef);
        } catch (Throwable err) {
            out.write("ERROR: " + err.getMessage());
        }
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ResponseWriter(javax.faces.context.ResponseWriter)

Example 10 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class TaskInfoBean method sendTaskResources.

/**
 * Returns the resource list for the workflow task identified by the 'taskId'
 * parameter found in the ExternalContext.
 * <p>
 * The result is the formatted HTML to show on the client.
 */
public void sendTaskResources() throws IOException {
    FacesContext context = FacesContext.getCurrentInstance();
    ResponseWriter out = context.getResponseWriter();
    String taskId = (String) context.getExternalContext().getRequestParameterMap().get("taskId");
    if (taskId == null || taskId.length() == 0) {
        throw new IllegalArgumentException("'taskId' parameter is missing");
    }
    WorkflowTask task = this.getWorkflowService().getTaskById(taskId);
    if (task != null) {
        Repository.getServiceRegistry(context).getTemplateService().processTemplate("/alfresco/templates/client/task_resource_panel.ftl", getModel(task), out);
    } else {
        out.write("<span class='errorMessage'>Task could not be found.</span>");
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ResponseWriter(javax.faces.context.ResponseWriter) WorkflowTask(org.alfresco.service.cmr.workflow.WorkflowTask)

Aggregations

ResponseWriter (javax.faces.context.ResponseWriter)88 Map (java.util.Map)16 UIComponent (javax.faces.component.UIComponent)14 FacesContext (javax.faces.context.FacesContext)14 NodeRef (org.alfresco.service.cmr.repository.NodeRef)13 ResourceBundle (java.util.ResourceBundle)10 NodeService (org.alfresco.service.cmr.repository.NodeService)10 Iterator (java.util.Iterator)9 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 List (java.util.List)7 TreeNode (org.alfresco.web.ui.repo.component.UITree.TreeNode)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)5 UserTransaction (javax.transaction.UserTransaction)5 UIModeList (org.alfresco.web.ui.common.component.UIModeList)5 Serializable (java.io.Serializable)4 Node (org.alfresco.web.bean.repository.Node)4 QuickSort (org.alfresco.web.data.QuickSort)3 UIListItem (org.alfresco.web.ui.common.component.UIListItem)3