use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class CreateRuleWizard method addCondition.
/**
* Adds the condition just setup by the user to the list of conditions for the rule
*/
public void addCondition() {
FacesContext context = FacesContext.getCurrentInstance();
if (logger.isDebugEnabled())
logger.debug("Adding Condition '" + selectedCondition + "'");
IHandler handler = this.conditionHandlers.get(this.selectedCondition);
// this is called from the actions page so there must be a handler
// present so there's no need to check for null
String summary = handler.generateSummary(context, this, this.currentConditionProperties);
if (summary != null) {
this.currentConditionProperties.put(PROP_CONDITION_SUMMARY, summary);
}
if (logger.isDebugEnabled())
logger.debug("Generated Summary - [" + summary + "] + selectedCondition " + this.selectedCondition);
if (this.editingCondition == false) {
this.allConditionsPropertiesList.add(this.currentConditionProperties);
}
// reset the action drop down
this.selectedCondition = null;
// refresh the wizard
goToPage(context, this.returnViewId);
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class EmailSpaceUsersDialog method getUsersGroups.
/**
* Return the List of objects representing the Users and Groups invited to this space.
* The picker is then responsible for rendering a view to represent those users and groups
* which allows the users to select and deselect users and groups, also to expand groups
* to show sub-groups and users.
*
* @return List of Map objects representing the users/groups assigned to the current space
*/
public List<Map> getUsersGroups() {
if (this.usersGroups == null) {
FacesContext context = FacesContext.getCurrentInstance();
UserTransaction tx = null;
try {
tx = Repository.getUserTransaction(context, true);
tx.begin();
// Return all the permissions set against the current node for any authentication
// instance (user/group), walking the parent space inheritance chain.
// Then combine them into a single list for each authentication found.
final String currentAuthority = Application.getCurrentUser(context).getUserName();
Map<String, List<String>> permissionMap = AuthenticationUtil.runAs(new RunAsWork<Map<String, List<String>>>() {
public Map<String, List<String>> doWork() throws Exception {
NodeRef spaceRef = getSpace().getNodeRef();
Map<String, List<String>> permissionMap = new HashMap<String, List<String>>(8, 1.0f);
while (spaceRef != null) {
Set<AccessPermission> permissions = getPermissionService().getAllSetPermissions(spaceRef);
for (AccessPermission permission : permissions) {
// we are only interested in Allow and not Guest/Everyone/owner
if (permission.getAccessStatus() == AccessStatus.ALLOWED && (permission.getAuthorityType() == AuthorityType.USER || permission.getAuthorityType() == AuthorityType.GROUP)) {
String authority = permission.getAuthority();
if (currentAuthority.equals(authority) == false) {
List<String> userPermissions = permissionMap.get(authority);
if (userPermissions == null) {
// create for first time
userPermissions = new ArrayList<String>(4);
permissionMap.put(authority, userPermissions);
}
// add the permission name for this authority
userPermissions.add(permission.getPermission());
}
}
}
// walk parent inheritance chain until root or no longer inherits
if (getPermissionService().getInheritParentPermissions(spaceRef)) {
spaceRef = getNodeService().getPrimaryParent(spaceRef).getParentRef();
} else {
spaceRef = null;
}
}
return permissionMap;
}
}, AuthenticationUtil.SYSTEM_USER_NAME);
// create the structure as a linked list for fast insert/removal of items
this.usersGroups = new LinkedList<Map>();
// node represented by it and use that for our list databinding object
for (String authority : permissionMap.keySet()) {
Map node = buildAuthorityMap(authority, UserMembersBean.roleListToString(context, permissionMap.get(authority)));
if (node != null) {
this.usersGroups.add(node);
}
}
// commit the transaction
tx.commit();
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, Repository.ERROR_NODEREF), new Object[] { refErr.getNodeRef() }));
this.usersGroups = Collections.<Map>emptyList();
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
} catch (Throwable err) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, Repository.ERROR_GENERIC), err.getMessage()), err);
this.usersGroups = Collections.<Map>emptyList();
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
}
}
return this.usersGroups;
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class UsersDialog method getViewItems.
public List<UIListItem> getViewItems() {
FacesContext context = FacesContext.getCurrentInstance();
List<UIListItem> items = new ArrayList<UIListItem>(1);
UIListItem item1 = new UIListItem();
item1.setValue(VIEW_DETAILS);
item1.setLabel(Application.getMessage(context, LABEL_VIEW_DETAILS));
items.add(item1);
return items;
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class UsersDialog method deleteOK.
/**
* Action handler called when the OK button is clicked on the Delete User page
*/
public String deleteOK() {
FacesContext context = FacesContext.getCurrentInstance();
try {
String userName = (String) properties.getPerson().getProperties().get("userName");
// delete the associated Person
properties.getPersonService().deletePerson(userName);
// re-do the search to refresh the list
search();
} catch (Throwable e) {
// rollback the transaction
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, ERROR_DELETE), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
return DIALOG_CLOSE;
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class BaseInviteUsersWizard method getMaximumUsersMsg.
/**
* @return Message to display when the maximum number of users have been returned
*/
public String getMaximumUsersMsg() {
FacesContext context = FacesContext.getCurrentInstance();
String pattern = Application.getMessage(context, MSG_MAX_USERS);
String msg = MessageFormat.format(pattern, Application.getClientConfig(context).getInviteUsersMaxResults());
return Utils.encode(msg);
}
Aggregations