Examples of UserRolePrivilege


Examples of org.sete.domain.UserRolePrivilege

    }

    private void createUserRolePrivileges(UserRoleType.Key roleKey,
                                          Map<PrivilegeActionType.Key, List<UserPrivilegeType.Key>> auths) {

        UserRolePrivilege p = new UserRolePrivilege();
        p.setUserRoleType(TypeUtil.forKey(UserRoleType.class, roleKey.getKey()));

        Set<UserPrivilege> privs = new HashSet<UserPrivilege>();
        UserPrivilege up = null;
        PrivilegeActionType pat = null;

        for(PrivilegeActionType.Key ak : auths.keySet()) {
            pat = TypeUtil.forKey(PrivilegeActionType.class, ak.getKey());
            for(UserPrivilegeType.Key pk : auths.get(ak)) {
                up = new UserPrivilege();
                up.setUserPrivilegeType(TypeUtil.forKey(UserPrivilegeType.class, pk.getKey()));
                up.setPrivilegeActionType(pat);
                privs.add(up);
            }
        }

        p.setUserPrivileges(privs);
        baseDao.saveOrUpdate(p);
    }
View Full Code Here

Examples of org.sete.domain.UserRolePrivilege

        roleService.updateUserRole(urvo);

        //and check the results
        EasyMock.verify(roleDao);
       
        final UserRolePrivilege urp = roleDao.getAllUserRoles().get(0);
        assertTrue( "judge".equals(urp.getUserRoleType().getKey()) );
        assertTrue( 1 == urp.getUserPrivileges().size() );
       
        final UserPrivilege up = (UserPrivilege)urp.getUserPrivileges().iterator().next();
        assertTrue( "manageMyProject".equals(up.getUserPrivilegeType().getKey()) );
        assertTrue( "r".equals(up.getPrivilegeActionType().getKey()) );
    }
View Full Code Here

Examples of org.sete.domain.UserRolePrivilege

        roleService.updateUserRole(urvo);

        //and check the results
        EasyMock.verify(roleDao);
       
        final UserRolePrivilege urp = roleDao.getAllUserRoles().get(0);
        assertTrue( "judge".equals(urp.getUserRoleType().getKey()) );
        assertTrue( 1 == urp.getUserPrivileges().size() );
       
        final UserPrivilege up = (UserPrivilege)urp.getUserPrivileges().iterator().next();
        assertTrue( "manageJudgeResults".equals(up.getUserPrivilegeType().getKey()) );
        assertTrue( "r".equals(up.getPrivilegeActionType().getKey()) );
    }
View Full Code Here

Examples of org.sete.domain.UserRolePrivilege

   

    private void prepareMockData( final UserRoleDao roleDao,
                                  final String roleKey, final String privKey, final String actionKey )
    {
        final UserRolePrivilege urpExistent = TestUtils.createUserRolePrivilege(roleKey, privKey, actionKey);
       
        final List<UserRolePrivilege> rolePrivList = new ArrayList<UserRolePrivilege>(1);
        rolePrivList.add(urpExistent);
    
        EasyMock.reset( roleDao );
View Full Code Here

Examples of org.sete.domain.UserRolePrivilege

        testUser.setFirstName("Johnny");
        testUser.setLastName("Mohseni");
        testUser.setLoginName("Johnny");
        testUser.setPassword("sete");
        Set<UserRolePrivilege> urps = new HashSet<UserRolePrivilege>();
        UserRolePrivilege urp = new UserRolePrivilege();
        urp.setUserRoleType(TypeUtil.forKey(UserRoleType.class, "student"));
        urps.add(urp);
        testUser.setUserRolePrivileges(urps);
              
        //set "mocked" dao Object that talks to database
        service.setUserDao(userDao);
View Full Code Here

Examples of org.sete.domain.UserRolePrivilege

    }

    private void createUserRolePrivileges(UserRoleType.Key roleKey,
                                          List<UserPrivilegeType.Key> privKeys,
                                          List<PrivilegeActionType.Key> actionKeys) {
        UserRolePrivilege p = new UserRolePrivilege();
        p.setUserRoleType(TypeUtil.forKey(UserRoleType.class, roleKey.getKey()));

        Set<UserPrivilege> privs = new HashSet<UserPrivilege>();
        UserPrivilege up = null;

        for(UserPrivilegeType.Key pk : privKeys) {
            up = new UserPrivilege();
            up.setUserPrivilegeType(TypeUtil.forKey(UserPrivilegeType.class, pk.getKey()));
            for(PrivilegeActionType.Key ak : actionKeys) {
                up.setPrivilegeActionType(TypeUtil.forKey(PrivilegeActionType.class, ak.getKey()));
            }
            privs.add(up);
        }

        p.setUserPrivileges(privs);
        baseDao.saveOrUpdate(p);
    }
View Full Code Here

Examples of org.sete.domain.UserRolePrivilege

     * @return Set<UserRolePrivilege>
     */
    private Set<UserRolePrivilege> buildUserRolePrivileges(CreateSeteUserVo vo) {
      //Set User Roles --
      Set<UserRolePrivilege> rolePrivs = new HashSet<UserRolePrivilege>();
      UserRolePrivilege urp = null;
      for(String pk: vo.getUserRoles()){
        urp = userRolePrivilegeDao.findRolePrivilege(pk);
        if(urp != null) {
                    rolePrivs.add(urp);
        }
View Full Code Here

Examples of org.sete.domain.UserRolePrivilege

    /**create a UserRolePrivilege object with the passed parameters*/
    static public UserRolePrivilege createUserRolePrivilege( final String roleKey,
                                                       final String privilegeKey,
                                                       final String actionKey )
    {
        final UserRolePrivilege urp = new UserRolePrivilege();
        {
            final UserRoleType urt = new UserRoleType();
            urt.setKey(roleKey);
            urp.setUserRoleType( urt );

            final Set userPrivs = new HashSet();
            {
                final UserPrivilege up = new UserPrivilege();
                {
                    final UserPrivilegeType upt = new UserPrivilegeType();
                    upt.setKey(privilegeKey);
                    up.setUserPrivilegeType( upt );

                    final PrivilegeActionType pat = new PrivilegeActionType();
                    pat.setKey(actionKey);
                    up.setPrivilegeActionType( pat );
                }

                userPrivs.add(up);
            }

            urp.setUserPrivileges( userPrivs );
        }

        return urp;
    }
View Full Code Here

Examples of org.sete.domain.UserRolePrivilege

    {
        //load again user roles with privileges
        final List<UserRolePrivilege> userRoles = userRoleDao.getAllUserRoles();

        //find the one we have to update
        UserRolePrivilege foundRolePriv = null;
        {
            for( final UserRolePrivilege urp : userRoles )
            {
                if( urp.getUserRoleType().getKey().equals(vo.getUserRole()) )
                {
                    foundRolePriv = urp;
                    break;
                }
            }
        }

        if( null == foundRolePriv )
        {
            throw new RuntimeException(" Unexpected error: could not find UserRolePrivilege with key='" + vo.getUserRole() + "'");
        }

        //and update/add role privileges for the user role we found
        {
            for(final RolePrivilegeVo rpvo: vo.getUserRolePrivileges())
            {
                //see whether this user privilege is for update or for add
                UserPrivilege foundUserPrivilege = null;
                for(final UserPrivilege up: foundRolePriv.getUserPrivileges())
                {
                    if( up.getUserPrivilegeType().getKey().equals(rpvo.getUserRolePrivilege()) )
                    {
                        foundUserPrivilege = up;
                        break;
                    }
                }

                if( null == foundUserPrivilege )
                {
                    foundUserPrivilege = new UserPrivilege();
                    UserPrivilegeType.Key uptKey = UserPrivilegeType.Key.findKey(rpvo.getUserRolePrivilege());
                    foundUserPrivilege.setUserPrivilegeType(UserPrivilegeType.forKey(uptKey));
                    foundRolePriv.getUserPrivileges().add(foundUserPrivilege);
                }

                PrivilegeActionType.Key patKey = PrivilegeActionType.Key.findKey(rpvo.getPrivilegeActions());
                foundUserPrivilege.setPrivilegeActionType(PrivilegeActionType.forKey(patKey));
            }
        }

        //and delete the ones that weren't updated or added
        {
            final Iterator it = foundRolePriv.getUserPrivileges().iterator();
            while(it.hasNext())
            {
                final UserPrivilege urp = (UserPrivilege)it.next();

                //see whether it was in vo
View Full Code Here

Examples of org.sete.domain.UserRolePrivilege

    /**test 1 object load: one UserRolePrivilege("judge") with one UserPrivilege("projScore") of "rw" allowed actions*/
    private void testOneUserRoleLoad(final UserRoleDao roleDao, final UserRoleServiceImpl roleService)
    {
        final ArrayList<UserRolePrivilege> rolePrivList = new ArrayList<UserRolePrivilege>(1);
        final UserRolePrivilege urp = TestUtils.createUserRolePrivilege("judge", "projScore", "rw");
        rolePrivList.add(urp);
       
        EasyMock.reset( roleDao );
        EasyMock.expect( roleDao.getAllUserRoles() ).andReturn( rolePrivList ).anyTimes();
        EasyMock.replay( roleDao );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.