use of org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.
the class DeleteUserDialog method setupUserAction.
public void setupUserAction(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
if (id != null && id.length() != 0) {
if (logger.isDebugEnabled())
logger.debug("Setup for action, setting current Person to: " + id);
try {
// create the node ref, then our node representation
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
Node node = new Node(ref);
// remember the Person node
setPerson(node);
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
}
} else {
setPerson(null);
}
}
use of org.alfresco.service.cmr.repository.InvalidNodeRefException 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 org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.
the class NewUserWizard method startWizardForEdit.
/**
* Action listener called when the wizard is being launched for editing an
* existing node.
*/
public void startWizardForEdit(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
if (id != null && id.length() != 0) {
try {
// create the node ref, then our node representation
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
Node node = new Node(ref);
// remember the Person node
setPerson(node);
// set the wizard in edit mode
this.editMode = true;
// populate the wizard's default values with the current value
// from the node being edited
init();
populate();
// clear the UI state in preparation for finishing the action
// and returning to the main page
invalidateUserList();
if (logger.isDebugEnabled())
logger.debug("Started wizard : " + getWizardTitle() + " for editing");
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
}
} else {
setPerson(null);
}
}
use of org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.
the class TrashcanDialog method setupItemAction.
/**
* Action handler called to prepare the selected item for an action
*/
public void setupItemAction(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
if (id != null && id.length() != 0) {
try {
// create the node ref, then our node representation
NodeRef ref = new NodeRef(getArchiveRootRef().getStoreRef(), id);
Node node = new Node(ref);
node.addPropertyResolver("locationPath", resolverLocationPath);
node.addPropertyResolver("deletedDate", resolverDeletedDate);
node.addPropertyResolver("deletedBy", resolverDeletedBy);
node.addPropertyResolver("isFolder", resolverIsFolder);
node.addPropertyResolver("mimetype", resolverMimetype);
node.addPropertyResolver("size", resolverSize);
node.addPropertyResolver("encoding", resolverEncoding);
if (getDictionaryService().isSubClass(node.getType(), ContentModel.TYPE_FOLDER) == true && getDictionaryService().isSubClass(node.getType(), ContentModel.TYPE_SYSTEM_FOLDER) == false) {
node.addPropertyResolver("icon", this.resolverLargeIcon);
} else {
node.addPropertyResolver("icon", this.resolverFileType32);
}
// prepare a node for the action context
property.setItem(node);
property.setDestination(null);
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
}
} else {
property.setItem(null);
}
// clear the UI state in preparation for finishing the next action
contextUpdated();
}
use of org.alfresco.service.cmr.repository.InvalidNodeRefException 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