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