Search in sources :

Example 36 with InvalidNodeRefException

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

the class NavigationBean method getCurrentNode.

/**
 * @return The current Node object for UI context operations
 */
public Node getCurrentNode() {
    if (this.currentNode == null) {
        if (this.currentNodeId == null) {
            // handle the possibility that we have no current location
            // this is possible in cluster fail-over or due to a missing node
            // default back to the current toolbar root location
            this.processToolbarLocation(this.getToolbarLocation(), false);
        }
        if (s_logger.isDebugEnabled())
            s_logger.debug("Caching properties for node id: " + this.currentNodeId);
        NodeRef nodeRef;
        Node node;
        Map<String, Object> props;
        try {
            // build a node which components on the JSP page can bind too
            nodeRef = new NodeRef(Repository.getStoreRef(), this.currentNodeId);
            node = new Node(nodeRef);
            // early init properties for this node (by getProperties() call)
            // resolve icon in-case one has not been set
            props = node.getProperties();
        } catch (InvalidNodeRefException refErr) {
            FacesContext fc = FacesContext.getCurrentInstance();
            Utils.addErrorMessage(MessageFormat.format(Application.getMessage(fc, ERROR_DELETED_FOLDER), new Object[] { this.currentNodeId }));
            nodeRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc));
            node = new Node(nodeRef);
            props = node.getProperties();
        }
        String icon = (String) props.get("app:icon");
        props.put("icon", icon != null ? icon : CreateSpaceWizard.DEFAULT_SPACE_ICON_NAME);
        String cifsPath = Utils.generateURL(FacesContext.getCurrentInstance(), node, URLMode.CIFS);
        node.getProperties().put("cifsPath", cifsPath == null ? "" : cifsPath);
        // strip file:/// part
        node.getProperties().put("cifsPathLabel", cifsPath == null ? "" : cifsPath.substring(8));
        this.currentNode = node;
    }
    return this.currentNode;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FacesContext(javax.faces.context.FacesContext) Node(org.alfresco.web.bean.repository.Node) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 37 with InvalidNodeRefException

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

the class CheckinCheckoutDialog method setupContentDocument.

/**
 * Setup a content document node context
 *
 * @param id GUID of the node to setup as the content document context
 * @return The Node
 */
protected Node setupContentDocument(String id) {
    if (logger.isDebugEnabled())
        logger.debug("Setup for action, setting current document to: " + id);
    Node node = null;
    try {
        // create the node ref, then our node representation
        NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
        node = new Node(ref);
        // create content URL to the content download servlet with ID and expected filename
        // the myfile part will be ignored by the servlet but gives the browser a hint
        String url = DownloadContentServlet.generateDownloadURL(ref, node.getName());
        node.getProperties().put("url", url);
        node.getProperties().put("workingCopy", node.hasAspect(ContentModel.ASPECT_WORKING_COPY));
        node.getProperties().put("fileType32", FileTypeImageUtils.getFileTypeImage(node.getName(), false));
        // remember the document
        property.setDocument(node);
        // refresh the UI, calling this method now is fine as it basically makes sure certain
        // beans clear the state - so when we finish here other beans will have been reset
        UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
    } catch (InvalidNodeRefException refErr) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
        throw new AbortProcessingException("Invalid node reference");
    }
    return node;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Node(org.alfresco.web.bean.repository.Node) AbortProcessingException(javax.faces.event.AbortProcessingException) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 38 with InvalidNodeRefException

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

the class CheckinCheckoutDialog method editFile.

/**
 * Action handler called to calculate which editing screen to display based on the mimetype
 * of a document. If appropriate, the in-line editing screen will be shown.
 */
public void editFile(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    try {
        if (id != null && id.length() != 0) {
            boolean editingInline = false;
            Node node = setupContentDocument(id);
            if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) && node.getProperties().get(ApplicationModel.PROP_EDITINLINE) != null && ((Boolean) node.getProperties().get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true) {
                // retrieve the content reader for this node
                ContentReader reader = property.getContentService().getReader(node.getNodeRef(), ContentModel.PROP_CONTENT);
                if (reader != null) {
                    editingInline = true;
                    String mimetype = reader.getMimetype();
                    // calculate which editor screen to display
                    if (MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(mimetype) || MimetypeMap.MIMETYPE_XML.equals(mimetype) || MimetypeMap.MIMETYPE_TEXT_CSS.equals(mimetype) || MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype)) {
                        // make content available to the text editing screen
                        property.setEditorOutput(reader.getContentString());
                        // navigate to appropriate screen
                        FacesContext fc = FacesContext.getCurrentInstance();
                        this.navigator.setupDispatchContext(node);
                        fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editTextInline");
                    } else {
                        // make content available to the html editing screen
                        property.setDocumentContent(reader.getContentString());
                        property.setEditorOutput(null);
                        // navigate to appropriate screen
                        FacesContext fc = FacesContext.getCurrentInstance();
                        this.navigator.setupDispatchContext(node);
                        fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editHtmlInline");
                    }
                }
            }
            if (editingInline == false) {
                // normal downloadable document
                FacesContext fc = FacesContext.getCurrentInstance();
                this.navigator.setupDispatchContext(node);
                fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editFile");
            }
        }
    } catch (InvalidNodeRefException refErr) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) ContentReader(org.alfresco.service.cmr.repository.ContentReader) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 39 with InvalidNodeRefException

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

the class DisplayPathConverter method getAsString.

/**
 * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
 */
public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException {
    String result = "";
    if (value != null) {
        try {
            NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
            Path path = null;
            if (value instanceof NodeRef) {
                path = nodeService.getPath((NodeRef) value);
            } else if (value instanceof Path) {
                path = (Path) value;
            }
            if (path != null) {
                result = Repository.getNamePath(nodeService, path, null, "/", null);
            }
        } catch (AccessDeniedException accessErr) {
        // use default if this occurs
        } catch (InvalidNodeRefException nodeErr) {
        // use default if this occurs
        }
    }
    return result;
}
Also used : Path(org.alfresco.service.cmr.repository.Path) NodeRef(org.alfresco.service.cmr.repository.NodeRef) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) NodeService(org.alfresco.service.cmr.repository.NodeService) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 40 with InvalidNodeRefException

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

the class AlfrescoNavigationHandler method handleDispatch.

private void handleDispatch(FacesContext context, String fromAction, String outcome, Node dispatchNode) {
    if (dispatchNode != null) {
        if (logger.isDebugEnabled())
            logger.debug("Found node with type '" + dispatchNode.getType().toString() + "' in dispatch context");
        // get the current view id
        String viewId = context.getViewRoot().getViewId();
        // see if there is any navigation config for the node type
        ConfigService configSvc = Application.getConfigService(context);
        NavigationConfigElement navigationCfg = null;
        try {
            Config nodeConfig = configSvc.getConfig(dispatchNode);
            navigationCfg = (NavigationConfigElement) nodeConfig.getConfigElement(NavigationElementReader.ELEMENT_NAVIGATION);
        } catch (InvalidNodeRefException e) {
            if (logger.isDebugEnabled())
                logger.debug("Invalid node reference: " + dispatchNode);
        }
        if (navigationCfg != null) {
            // see if there is config for the current view state
            NavigationResult navResult = navigationCfg.getOverride(viewId, outcome);
            if (navResult != null) {
                if (logger.isDebugEnabled())
                    logger.debug("Found navigation config: " + navResult);
                if (navResult.isOutcome()) {
                    navigate(context, fromAction, navResult.getResult());
                } else {
                    String newViewId = navResult.getResult();
                    if (newViewId.equals(viewId) == false) {
                        if (logger.isDebugEnabled())
                            logger.debug("Dispatching to new view id: " + newViewId);
                        goToView(context, newViewId);
                    } else {
                        if (logger.isDebugEnabled())
                            logger.debug("New view id is the same as the current one so setting outcome to null");
                        navigate(context, fromAction, null);
                    }
                }
            } else {
                if (logger.isDebugEnabled())
                    logger.debug("No override configuration found for current view or outcome");
                navigate(context, fromAction, outcome);
            }
        } else {
            if (logger.isDebugEnabled())
                logger.debug("No navigation configuration found for node");
            navigate(context, fromAction, outcome);
        }
        // reset the dispatch context
        ((NavigationBean) context.getExternalContext().getSessionMap().get(NavigationBean.BEAN_NAME)).resetDispatchContext();
    } else {
        if (logger.isDebugEnabled())
            logger.debug("No dispatch context found");
        // pass off to the original handler
        navigate(context, fromAction, outcome);
    }
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) NavigationBean(org.alfresco.web.bean.NavigationBean) WizardConfig(org.alfresco.web.config.WizardsConfigElement.WizardConfig) DialogConfig(org.alfresco.web.config.DialogsConfigElement.DialogConfig) Config(org.springframework.extensions.config.Config) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) NavigationResult(org.alfresco.web.config.NavigationResult) NavigationConfigElement(org.alfresco.web.config.NavigationConfigElement)

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