Search in sources :

Example 11 with NavigationBean

use of org.alfresco.web.bean.NavigationBean 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)

Example 12 with NavigationBean

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

the class UserMembersBean method removeOK.

/**
 * Action handler called when the OK button is clicked on the Remove User page
 */
public String removeOK() {
    String outcome = getDefaultFinishOutcome();
    UserTransaction tx = null;
    FacesContext context = FacesContext.getCurrentInstance();
    try {
        tx = Repository.getUserTransaction(context);
        tx.begin();
        // remove the invited User
        if (getPersonAuthority() != null) {
            // clear permissions for the specified Authority
            this.getPermissionService().clearPermission(getNode().getNodeRef(), getPersonAuthority());
        }
        // commit the transaction
        tx.commit();
    } catch (Exception e) {
        // rollback the transaction
        try {
            if (tx != null) {
                tx.rollback();
            }
        } catch (Exception tex) {
        }
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), ERROR_DELETE), e.getMessage()), e);
    }
    // pressing the top level navigation button i.e. My Home
    if (this.getPermissionService().hasPermission(getNode().getNodeRef(), PermissionService.CHANGE_PERMISSIONS) == AccessStatus.DENIED) {
        NavigationBean nb = (NavigationBean) FacesHelper.getManagedBean(context, NavigationBean.BEAN_NAME);
        if (nb != null) {
            try {
                nb.processToolbarLocation(nb.getToolbarLocation(), true);
                outcome = "browse";
            } catch (InvalidNodeRefException refErr) {
                Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NOHOME), Application.getCurrentUser(context).getHomeSpaceId()), refErr);
            } catch (Exception err) {
                Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
            }
        }
    }
    return outcome;
}
Also used : UserTransaction(javax.transaction.UserTransaction) FacesContext(javax.faces.context.FacesContext) NavigationBean(org.alfresco.web.bean.NavigationBean) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 13 with NavigationBean

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

the class UserPreferencesBean method getStartLocations.

/**
 * @return the list of available start locations
 */
public SelectItem[] getStartLocations() {
    FacesContext fc = FacesContext.getCurrentInstance();
    NavigationBean navigator = (NavigationBean) FacesHelper.getManagedBean(fc, "NavigationBean");
    ResourceBundle msg = Application.getBundle(fc);
    List<SelectItem> locations = new ArrayList<SelectItem>(4);
    // add My Alfresco location
    locations.add(new SelectItem(NavigationBean.LOCATION_MYALFRESCO, msg.getString(NavigationBean.MSG_MYALFRESCO)));
    // add My Home location
    locations.add(new SelectItem(NavigationBean.LOCATION_HOME, msg.getString(NavigationBean.MSG_MYHOME)));
    // add Company Home location if visible
    if (navigator.getCompanyHomeVisible()) {
        locations.add(new SelectItem(NavigationBean.LOCATION_COMPANY, msg.getString(NavigationBean.MSG_COMPANYHOME)));
    }
    // add Guest Home location if visible
    if (navigator.getGuestHomeVisible()) {
        locations.add(new SelectItem(NavigationBean.LOCATION_GUEST, msg.getString(NavigationBean.MSG_GUESTHOME)));
    }
    return locations.toArray(new SelectItem[locations.size()]);
}
Also used : FacesContext(javax.faces.context.FacesContext) NavigationBean(org.alfresco.web.bean.NavigationBean) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) ResourceBundle(java.util.ResourceBundle)

Aggregations

NavigationBean (org.alfresco.web.bean.NavigationBean)13 FacesContext (javax.faces.context.FacesContext)7 NodeRef (org.alfresco.service.cmr.repository.NodeRef)5 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)4 UserTransaction (javax.transaction.UserTransaction)3 IOException (java.io.IOException)2 ServiceRegistry (org.alfresco.service.ServiceRegistry)2 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)2 NodeService (org.alfresco.service.cmr.repository.NodeService)2 BrowseBean (org.alfresco.web.bean.BrowseBean)2 Node (org.alfresco.web.bean.repository.Node)2 TreeNode (org.alfresco.web.ui.repo.component.UITree.TreeNode)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ResourceBundle (java.util.ResourceBundle)1 Stack (java.util.Stack)1 StringTokenizer (java.util.StringTokenizer)1 FacesMessage (javax.faces.application.FacesMessage)1