Search in sources :

Example 91 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class RulesDialog method getIgnoreInheritedRulesLabelId.

/**
 * Gets the label id from the ignore inhertied action
 *
 * @return   the message id
 */
public String getIgnoreInheritedRulesLabelId() {
    FacesContext fc = FacesContext.getCurrentInstance();
    String result = Application.getMessage(fc, MSG_IGNORE_INHERTIED_RULES);
    if (this.getNodeService().hasAspect(this.getSpace().getNodeRef(), RuleModel.ASPECT_IGNORE_INHERITED_RULES) == true) {
        result = Application.getMessage(fc, MSG_INCLUDE_INHERITED_RULES);
    }
    return result;
}
Also used : FacesContext(javax.faces.context.FacesContext)

Example 92 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class RulesDialog method reapplyRules.

/**
 * Reapply the currently defines rules to the
 * @param event ActionEvent
 */
public void reapplyRules(ActionEvent event) {
    boolean toChildren = false;
    UIActionLink link = (UIActionLink) event.getComponent();
    Map<String, String> params = link.getParameterMap();
    String toChildrenStr = params.get("toChildren");
    if (toChildrenStr != null) {
        toChildren = new Boolean(toChildrenStr).booleanValue();
    }
    FacesContext fc = FacesContext.getCurrentInstance();
    UserTransaction tx = null;
    try {
        tx = Repository.getUserTransaction(fc);
        tx.begin();
        // Set the include inherited parameter to match the current filter value
        boolean executeInherited = true;
        if (this.filterModeMode.equals(LOCAL)) {
            executeInherited = false;
        }
        // Reapply the rules
        reapplyRules(this.getSpace().getNodeRef(), executeInherited, toChildren);
        // TODO how do I get the message here ...
        String msg = Application.getMessage(fc, MSG_REAPPLY_RULES_SUCCESS);
        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
        String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc);
        fc.addMessage(formId + ":rulesList", facesMsg);
        // commit the transaction
        tx.commit();
    } catch (Throwable e) {
        // rollback the transaction
        try {
            if (tx != null) {
                tx.rollback();
            }
        } catch (Exception ex) {
        }
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(fc, Repository.ERROR_GENERIC), e.getMessage()), e);
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) FacesContext(javax.faces.context.FacesContext) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) FacesMessage(javax.faces.application.FacesMessage)

Example 93 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class UserMembersBean method finishOK.

/**
 * Action handler called when the Finish button is clicked on the Edit User Roles page
 */
public String finishOK() {
    String outcome = OUTCOME_FINISH;
    FacesContext context = FacesContext.getCurrentInstance();
    // persist new user permissions
    if (this.personRoles != null && getPersonAuthority() != null) {
        UserTransaction tx = null;
        try {
            tx = Repository.getUserTransaction(context);
            tx.begin();
            // clear the currently set permissions for this user
            // and add each of the new permissions in turn
            final NodeRef nodeRef = getNode().getNodeRef();
            if (this.getPermissionService().hasPermission(nodeRef, PermissionService.CHANGE_PERMISSIONS) == AccessStatus.ALLOWED) {
                AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() {

                    public Object doWork() throws Exception {
                        getPermissionService().clearPermission(nodeRef, getPersonAuthority());
                        for (PermissionWrapper wrapper : personRoles) {
                            getPermissionService().setPermission(nodeRef, getPersonAuthority(), wrapper.getPermission(), true);
                        }
                        return null;
                    }
                }, AuthenticationUtil.getSystemUserName());
            }
            tx.commit();
        } catch (Exception err) {
            Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, Repository.ERROR_GENERIC), err.getMessage()), err);
            try {
                if (tx != null) {
                    tx.rollback();
                }
            } catch (Exception tex) {
            }
            outcome = null;
        }
    }
    return outcome;
}
Also used : UserTransaction(javax.transaction.UserTransaction) FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) AuthenticationUtil(org.alfresco.repo.security.authentication.AuthenticationUtil) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 94 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class UserMembersBean method getFilterItems.

/**
 * @see org.alfresco.web.bean.dialog.FilterViewSupport#getFilterItems()
 */
public List<UIListItem> getFilterItems() {
    FacesContext context = FacesContext.getCurrentInstance();
    List<UIListItem> items = new ArrayList<UIListItem>(2);
    UIListItem item1 = new UIListItem();
    item1.setValue(INHERITED);
    item1.setLabel(Application.getMessage(context, INHERITED));
    items.add(item1);
    UIListItem item2 = new UIListItem();
    item2.setValue(LOCAL);
    item2.setLabel(Application.getMessage(context, LOCAL));
    items.add(item2);
    return items;
}
Also used : FacesContext(javax.faces.context.FacesContext) UIListItem(org.alfresco.web.ui.common.component.UIListItem) ArrayList(java.util.ArrayList)

Example 95 with FacesContext

use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.

the class UserMembersBean method inheritPermissionsValueChanged.

/**
 * Inherit parent Space permissions value changed by the user
 */
public void inheritPermissionsValueChanged(ValueChangeEvent event) {
    try {
        // change the value to the new selected value
        boolean inheritPermissions = (Boolean) event.getNewValue();
        this.getPermissionService().setInheritParentPermissions(getNode().getNodeRef(), inheritPermissions);
        // inform the user that the change occured
        FacesContext context = FacesContext.getCurrentInstance();
        String msg;
        if (inheritPermissions) {
            msg = Application.getMessage(context, MSG_SUCCESS_INHERIT);
        } else {
            msg = Application.getMessage(context, MSG_SUCCESS_INHERIT_NOT);
        }
        // pressing the top level navigation button i.e. My Home
        if (this.getPermissionService().hasPermission(getNode().getNodeRef(), PermissionService.CHANGE_PERMISSIONS) == AccessStatus.ALLOWED) {
            FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
            context.addMessage(event.getComponent().getClientId(context), facesMsg);
        } else {
            NavigationBean nb = (NavigationBean) FacesHelper.getManagedBean(context, NavigationBean.BEAN_NAME);
            if (nb != null) {
                try {
                    nb.processToolbarLocation(nb.getToolbarLocation(), true);
                } 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);
                }
            }
        }
    } catch (Throwable e) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) NavigationBean(org.alfresco.web.bean.NavigationBean) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) FacesMessage(javax.faces.application.FacesMessage) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Aggregations

FacesContext (javax.faces.context.FacesContext)361 NodeRef (org.alfresco.service.cmr.repository.NodeRef)61 Node (org.alfresco.web.bean.repository.Node)44 UserTransaction (javax.transaction.UserTransaction)43 ArrayList (java.util.ArrayList)33 HashMap (java.util.HashMap)28 IOException (java.io.IOException)27 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)27 ExternalContext (javax.faces.context.ExternalContext)26 SelectItem (javax.faces.model.SelectItem)26 QName (org.alfresco.service.namespace.QName)25 FacesMessage (javax.faces.application.FacesMessage)24 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)22 Map (java.util.Map)21 ResourceBundle (java.util.ResourceBundle)20 HttpServletResponse (javax.servlet.http.HttpServletResponse)19 MapNode (org.alfresco.web.bean.repository.MapNode)18 UIViewRoot (javax.faces.component.UIViewRoot)17 HttpServletRequest (javax.servlet.http.HttpServletRequest)16 Serializable (java.io.Serializable)15