Package org.internna.iwebmvc.model

Examples of org.internna.iwebmvc.model.Role


    @Transactional(propagation = Propagation.REQUIRED)
    @Override public void createAuthority(String authority) {
        Assert.hasText(authority);
        if (!isAuthority(authority)) {
            try {
                Role role = roleClass.newInstance();
                entityManager.persist(role.setRole(authority));
            } catch (Exception ex) {
                throw new IWebMvcException("Could not create new role", ex);
            }
        }
    }
View Full Code Here


    }

    private void updateAuthorities(User user, Collection<? extends Role> roles) {
        if (!CollectionUtils.isEmpty(roles)) {
            for (Role role : roles) {
                Role authority = dao.findAuthority(role.getRole());
                if (authority != null) {
                    if ((user.getRoles() == null) || (!user.getRoles().contains(authority))) {
                        user.addRole(authority);
                        authority.addMember(user);
                    }
                }
            }
        }
        if (!CollectionUtils.isEmpty(user.getRoles())) {
            for (Iterator<? extends Role> it = user.getRoles().iterator(); it.hasNext();) {
                Role role = it.next();
                if (!roles.contains(role)) {
                    it.remove();
                    role.removeMember(user);
                }
            }
        }
        dao.updateUser(user);
        if (!CollectionUtils.isEmpty(user.getRoles()))
View Full Code Here

TOP

Related Classes of org.internna.iwebmvc.model.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.