Search in sources :

Example 1 with DocumentDetailsDialog

use of org.alfresco.web.bean.content.DocumentDetailsDialog 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 2 with DocumentDetailsDialog

use of org.alfresco.web.bean.content.DocumentDetailsDialog in project acs-community-packaging by Alfresco.

the class BrowseBean method setupMLContainerContentAction.

/**
 * Action event called by all actions that need to setup a <b>Multilingual</b> Content Document context on the
 * BrowseBean before an action page/wizard is called. The context will be a Node in
 * setDocument() which can be retrieved on the action page from BrowseBean.getDocument().
 */
public void setupMLContainerContentAction(ActionEvent event) {
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String id = params.get("id");
    NodeRef translation = new NodeRef(Repository.getStoreRef(), id);
    // remember the bean from which the action comes
    FacesContext fc = FacesContext.getCurrentInstance();
    DocumentDetailsDialog docDetails = (DocumentDetailsDialog) FacesHelper.getManagedBean(fc, "DocumentDetailsDialog");
    docDetails.setTranslationDocument(new MapNode(translation));
    MultilingualManageDialog mmDialog = (MultilingualManageDialog) FacesHelper.getManagedBean(fc, "MultilingualManageDialog");
    mmDialog.setTranslationDocument(docDetails.getTranslationDocument());
    // set the ml container as the current document
    NodeRef mlContainer = getMultilingualContentService().getTranslationContainer(translation);
    setupContentAction(mlContainer.getId(), true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FacesContext(javax.faces.context.FacesContext) MultilingualManageDialog(org.alfresco.web.bean.ml.MultilingualManageDialog) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) DocumentDetailsDialog(org.alfresco.web.bean.content.DocumentDetailsDialog) MapNode(org.alfresco.web.bean.repository.MapNode)

Aggregations

NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 DocumentDetailsDialog (org.alfresco.web.bean.content.DocumentDetailsDialog)2 MapNode (org.alfresco.web.bean.repository.MapNode)2 FacesContext (javax.faces.context.FacesContext)1 AbortProcessingException (javax.faces.event.AbortProcessingException)1 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)1 MultilingualManageDialog (org.alfresco.web.bean.ml.MultilingualManageDialog)1 Node (org.alfresco.web.bean.repository.Node)1 UIActionLink (org.alfresco.web.ui.common.component.UIActionLink)1