Search in sources :

Example 11 with InvalidNodeRefException

use of org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.

the class BrowseBean method clickSpacePath.

/**
 * Handler called when a path element is clicked - navigate to the appropriate Space
 */
public void clickSpacePath(ActionEvent event) {
    UINodePath.PathElementEvent pathEvent = (UINodePath.PathElementEvent) event;
    NodeRef ref = pathEvent.NodeReference;
    try {
        // refresh UI based on node selection
        this.updateUILocation(ref);
    } catch (InvalidNodeRefException refErr) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { ref.getId() }));
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UINodePath(org.alfresco.web.ui.repo.component.UINodePath) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 12 with InvalidNodeRefException

use of org.alfresco.service.cmr.repository.InvalidNodeRefException 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 13 with InvalidNodeRefException

use of org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.

the class CategoriesDialog method clickCategory.

/**
 * Action called when a category folder is clicked.
 * Navigate into the category.
 */
public void clickCategory(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    if (id != null && id.length() != 0) {
        try {
            NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
            // refresh UI based on node selection
            updateUILocation(ref);
        } 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) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 14 with InvalidNodeRefException

use of org.alfresco.service.cmr.repository.InvalidNodeRefException 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 15 with InvalidNodeRefException

use of org.alfresco.service.cmr.repository.InvalidNodeRefException 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)

Aggregations

InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)61 NodeRef (org.alfresco.service.cmr.repository.NodeRef)49 Node (org.alfresco.web.bean.repository.Node)21 FacesContext (javax.faces.context.FacesContext)20 UserTransaction (javax.transaction.UserTransaction)16 MapNode (org.alfresco.web.bean.repository.MapNode)12 InvalidSharedIdException (org.alfresco.service.cmr.quickshare.InvalidSharedIdException)10 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)9 QName (org.alfresco.service.namespace.QName)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 AbortProcessingException (javax.faces.event.AbortProcessingException)8 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)8 UIActionLink (org.alfresco.web.ui.common.component.UIActionLink)8 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)7 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)7 Serializable (java.io.Serializable)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)4