Search in sources :

Example 26 with FacesMessage

use of javax.faces.application.FacesMessage in project acs-community-packaging by Alfresco.

the class TrashcanRecoverItemDialog method recoverItem.

private String recoverItem(FacesContext context, String outcome) {
    Node item = property.getItem();
    if (item != null) {
        FacesContext fc = context;
        try {
            String msg;
            FacesMessage errorfacesMsg = null;
            // restore the node - the user may have requested a restore to a
            // different parent
            RestoreNodeReport report;
            if (property.getDestination() == null) {
                report = property.getNodeArchiveService().restoreArchivedNode(item.getNodeRef());
            } else {
                report = property.getNodeArchiveService().restoreArchivedNode(item.getNodeRef(), property.getDestination(), null, null);
            }
            switch(report.getStatus()) {
                case SUCCESS:
                    msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_SUCCESS), item.getName());
                    FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
                    fc.addMessage(RICHLIST_MSG_ID, facesMsg);
                    break;
                case FAILURE_INVALID_PARENT:
                    msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_PARENT), item.getName());
                    errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
                    break;
                case FAILURE_PERMISSION:
                    msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_PERMISSION), item.getName());
                    errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
                    break;
                case FAILURE_INTEGRITY:
                    msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_INTEGRITY), item.getName());
                    errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
                    break;
                case FAILURE_DUPLICATE_CHILD_NODE_NAME:
                    msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_DUPLICATE), item.getName());
                    errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
                    break;
                default:
                    String reason = report.getCause().getMessage();
                    msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_FAILURE), item.getName(), reason);
                    errorfacesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
                    break;
            }
            // screen
            if (errorfacesMsg != null) {
                fc.addMessage(null, errorfacesMsg);
            }
        } catch (Throwable err) {
            // most exceptions will be caught and returned as
            // RestoreNodeReport objects by the service
            String reason = err.getMessage();
            String msg = MessageFormat.format(Application.getMessage(fc, MSG_RECOVERED_ITEM_FAILURE), item.getName(), reason);
            FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
            fc.addMessage(null, facesMsg);
            ReportedException.throwIfNecessary(err);
        }
    }
    return outcome;
}
Also used : RestoreNodeReport(org.alfresco.repo.node.archive.RestoreNodeReport) FacesContext(javax.faces.context.FacesContext) Node(org.alfresco.web.bean.repository.Node) FacesMessage(javax.faces.application.FacesMessage)

Example 27 with FacesMessage

use of javax.faces.application.FacesMessage 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 28 with FacesMessage

use of javax.faces.application.FacesMessage 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)

Example 29 with FacesMessage

use of javax.faces.application.FacesMessage in project acs-community-packaging by Alfresco.

the class DocumentDetailsDialog method unlock.

/**
 * Action Handler to unlock a locked document
 */
public void unlock(final ActionEvent event) {
    final FacesContext fc = FacesContext.getCurrentInstance();
    try {
        RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
        RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>() {

            public Object execute() throws Throwable {
                getLockService().unlock(getNode().getNodeRef());
                String msg = Application.getMessage(fc, MSG_SUCCESS_UNLOCK);
                FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
                String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc);
                fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg);
                getNode().reset();
                return null;
            }
        };
        txnHelper.doInTransaction(callback);
    } catch (Throwable e) {
        Utils.addErrorMessage(MessageFormat.format(Application.getMessage(fc, Repository.ERROR_GENERIC), e.getMessage()), e);
        ReportedException.throwIfNecessary(e);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) FacesMessage(javax.faces.application.FacesMessage)

Example 30 with FacesMessage

use of javax.faces.application.FacesMessage in project acs-community-packaging by Alfresco.

the class Utils method addStatusMessage.

/**
 * Adds a global status message that will be displayed by a Status Message UI component
 *
 * @param severity   Severity of the message
 * @param msg        Text of the message
 */
public static void addStatusMessage(FacesMessage.Severity severity, String msg) {
    FacesContext fc = FacesContext.getCurrentInstance();
    String time = getTimeFormat(fc).format(new Date(System.currentTimeMillis()));
    FacesMessage fm = new FacesMessage(severity, time, msg);
    fc.addMessage(UIStatusMessage.STATUS_MESSAGE, fm);
}
Also used : FacesContext(javax.faces.context.FacesContext) FacesMessage(javax.faces.application.FacesMessage) Date(java.util.Date)

Aggregations

FacesMessage (javax.faces.application.FacesMessage)370 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)43 SQLException (java.sql.SQLException)40 Connection (java.sql.Connection)34 FacesContext (javax.faces.context.FacesContext)25 ArrayList (java.util.ArrayList)24 UIInput (javax.faces.component.UIInput)24 ValidatorException (javax.faces.validator.ValidatorException)24 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)22 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)22 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)19 UserHelper2 (mom.trd.opentheso.bdd.helper.UserHelper2)19 IOException (java.io.IOException)16 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)15 Test (org.junit.Test)13 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)12 Term (mom.trd.opentheso.bdd.datas.Term)11 UploadedFile (org.primefaces.model.UploadedFile)11 HikariDataSource (com.zaxxer.hikari.HikariDataSource)10 Date (java.util.Date)10