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;
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations