Search in sources :

Example 21 with InvalidNodeRefException

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);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) MapNode(org.alfresco.web.bean.repository.MapNode) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 22 with InvalidNodeRefException

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;
}
Also used : UserTransaction(javax.transaction.UserTransaction) FacesContext(javax.faces.context.FacesContext) HashSet(java.util.HashSet) Set(java.util.Set) AccessPermission(org.alfresco.service.cmr.security.AccessPermission) ArrayList(java.util.ArrayList) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 23 with InvalidNodeRefException

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);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 24 with InvalidNodeRefException

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();
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIActionLink(org.alfresco.web.ui.common.component.UIActionLink) Node(org.alfresco.web.bean.repository.Node) MapNode(org.alfresco.web.bean.repository.MapNode) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException)

Example 25 with InvalidNodeRefException

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

Aggregations

InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)61 NodeRef (org.alfresco.service.cmr.repository.NodeRef)49 Node (org.alfresco.web.bean.repository.Node)21 FacesContext (javax.faces.context.FacesContext)20 UserTransaction (javax.transaction.UserTransaction)16 MapNode (org.alfresco.web.bean.repository.MapNode)12 InvalidSharedIdException (org.alfresco.service.cmr.quickshare.InvalidSharedIdException)10 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)9 QName (org.alfresco.service.namespace.QName)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 AbortProcessingException (javax.faces.event.AbortProcessingException)8 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)8 UIActionLink (org.alfresco.web.ui.common.component.UIActionLink)8 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)7 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)7 Serializable (java.io.Serializable)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)4