Search in sources :

Example 6 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class BrowseBean method setupContentAction.

/**
 * Public helper to setup action pages with content context
 *
 * @param id     of the content node to setup context for
 */
public void setupContentAction(String id, boolean invalidate) {
    if (id != null && id.length() != 0) {
        if (logger.isDebugEnabled())
            logger.debug("Setup for action, setting current document to: " + id);
        try {
            // create the node ref, then our node representation
            NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
            Node node = new MapNode(ref);
            // store the URL to for downloading the content
            if (ApplicationModel.TYPE_FILELINK.equals(node.getType())) {
                node.addPropertyResolver("url", this.resolverLinkDownload);
                node.addPropertyResolver("downloadUrl", this.resolverLinkDownload);
            } else {
                node.addPropertyResolver("url", this.resolverDownload);
                node.addPropertyResolver("downloadUrl", this.resolverDownload);
            }
            node.addPropertyResolver("webdavUrl", this.resolverWebdavUrl);
            node.addPropertyResolver("cifsPath", this.resolverCifsPath);
            node.addPropertyResolver("fileType32", this.resolverFileType32);
            node.addPropertyResolver("mimetype", this.resolverMimetype);
            node.addPropertyResolver("encoding", this.resolverEncoding);
            node.addPropertyResolver("size", this.resolverSize);
            node.addPropertyResolver("lang", this.resolverLang);
            for (NodeEventListener listener : getNodeEventListeners()) {
                listener.created(node, node.getType());
            }
            // get hold of the DocumentDetailsDialog and reset it
            DocumentDetailsDialog docDetails = (DocumentDetailsDialog) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("DocumentDetailsDialog");
            if (docDetails != null) {
                docDetails.reset();
            }
            // remember the document
            setDocument(node);
            // setup the dispatch context in case it is required
            this.navigator.setupDispatchContext(node);
        } catch (InvalidNodeRefException refErr) {
            Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
            throw new AbortProcessingException("Invalid node reference");
        }
    } else {
        setDocument(null);
    }
    // clear the UI state in preparation for finishing the next action
    if (invalidate == true) {
        // use the context service to notify all registered beans
        UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) DocumentDetailsDialog(org.alfresco.web.bean.content.DocumentDetailsDialog) Node(org.alfresco.web.bean.repository.Node) MapNode(org.alfresco.web.bean.repository.MapNode) AbortProcessingException(javax.faces.event.AbortProcessingException) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) MapNode(org.alfresco.web.bean.repository.MapNode)

Example 7 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class BrowseBean method setupSpaceAction.

/**
 * Public helper to setup action pages with Space context
 *
 * @param id     of the Space node to setup context for
 */
public void setupSpaceAction(String id, boolean invalidate) {
    if (id != null && id.length() != 0) {
        if (logger.isDebugEnabled())
            logger.debug("Setup for action, setting current space to: " + id);
        try {
            // create the node ref, then our node representation
            NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
            Node node = new Node(ref);
            // resolve icon in-case one has not been set
            node.addPropertyResolver("icon", this.resolverSpaceIcon);
            // prepare a node for the action context
            setActionSpace(node);
            // setup the dispatch context in case it is required
            this.navigator.setupDispatchContext(node);
        } catch (InvalidNodeRefException refErr) {
            Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
        }
    } else {
        setActionSpace(null);
    }
    // clear the UI state in preparation for finishing the next action
    if (invalidate == true) {
        // use the context service to notify all registered beans
        UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Node(org.alfresco.web.bean.repository.Node) MapNode(org.alfresco.web.bean.repository.MapNode) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 8 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class CategoriesDialog method getCategories.

/**
 * @return The list of categories Nodes to display. Returns the list root categories or the
 *         list of sub-categories for the current category if set.
 */
public List<Node> getCategories() {
    List<Node> categories;
    UserTransaction tx = null;
    try {
        FacesContext context = FacesContext.getCurrentInstance();
        tx = Repository.getUserTransaction(context, true);
        tx.begin();
        Collection<ChildAssociationRef> refs;
        if (getCategoryRef() == null) {
            // root categories
            refs = getCategoryService().getCategories(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, Depth.IMMEDIATE);
        } else {
            // sub-categories of an existing category
            refs = getCategoryService().getChildren(getCategoryRef(), Mode.SUB_CATEGORIES, Depth.IMMEDIATE);
        }
        categories = new ArrayList<Node>(refs.size());
        for (ChildAssociationRef child : refs) {
            Node categoryNode = new Node(child.getChildRef());
            // force early props init within transaction
            categoryNode.getProperties();
            categories.add(categoryNode);
        }
        // commit the transaction
        tx.commit();
    } catch (InvalidNodeRefException refErr) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { refErr.getNodeRef() }));
        categories = Collections.<Node>emptyList();
        try {
            if (tx != null) {
                tx.rollback();
            }
        } catch (Exception tex) {
        }
    } catch (Throwable err) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
        categories = Collections.<Node>emptyList();
        try {
            if (tx != null) {
                tx.rollback();
            }
        } catch (Exception tex) {
        }
    }
    return categories;
}
Also used : UserTransaction(javax.transaction.UserTransaction) FacesContext(javax.faces.context.FacesContext) Node(org.alfresco.web.bean.repository.Node) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 9 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class CategoriesDialog method setupCategoryAction.

/**
 * Set the Category to be used for next action dialog
 */
public void setupCategoryAction(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    if (id != null && id.length() != 0) {
        if (logger.isDebugEnabled())
            logger.debug("Setup for action, setting current Category to: " + id);
        try {
            // create the node ref, then our node representation
            NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
            Node node = new Node(ref);
            // prepare a node for the action context
            setActionCategory(node);
            // clear datalist cache ready from return from action dialog
            contextUpdated();
        } catch (InvalidNodeRefException refErr) {
            Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 10 with Node

use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.

the class DeleteCategoryDialog method init.

@Override
public void init(Map<String, String> parameters) {
    this.isFinished = false;
    this.categoryFlag = false;
    // retrieve parameters
    String categoryRef = parameters.get(CategoriesDialog.PARAM_CATEGORY_REF);
    // make sure nodeRef was supplied
    ParameterCheck.mandatoryString(CategoriesDialog.PARAM_CATEGORY_REF, categoryRef);
    // create the node
    this.category = new Node(new NodeRef(categoryRef));
    setActionCategory(category);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Node(org.alfresco.web.bean.repository.Node)

Aggregations

Node (org.alfresco.web.bean.repository.Node)145 NodeRef (org.alfresco.service.cmr.repository.NodeRef)81 FacesContext (javax.faces.context.FacesContext)44 MapNode (org.alfresco.web.bean.repository.MapNode)38 UIActionLink (org.alfresco.web.ui.common.component.UIActionLink)28 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)26 UserTransaction (javax.transaction.UserTransaction)22 QName (org.alfresco.service.namespace.QName)22 NodePropertyComparator (org.alfresco.web.ui.common.NodePropertyComparator)18 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)17 ArrayList (java.util.ArrayList)10 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)8 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)8 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)7 TransientNode (org.alfresco.web.bean.repository.TransientNode)7 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 AbortProcessingException (javax.faces.event.AbortProcessingException)6 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)6