Package org.nxplanner.domain

Examples of org.nxplanner.domain.Role


        try {
            rs = statement.executeQuery("select person_id,role from personrole");
            while (rs.next()) {
                for (int i = 0; i < projects.size(); i++) {
                    Project project = (Project)projects.get(i);
                    Role role = getRole(session, rs.getString("role"));
                    int personId = rs.getInt("person_id");
                    session.save(new RoleAssociation(project.getId(), personId, role.getId()));
                    // Person should have permission to read/edit their own profile
                    session.save(new Permission("system.person", 0, personId, "read%"));
                    session.save(new Permission("system.person", personId, personId, "edit%"));
                }
            }
View Full Code Here


    // TODO move to a utility class
    public static Role getRole(Session session, String rolename) throws HibernateException {
        List roles = session.find("from role in class " +
                Role.class.getName() + " where role.name = ?",
                rolename, Hibernate.STRING);
        Role role = null;
        Iterator roleIterator = roles.iterator();
        if (roleIterator.hasNext()) {
            role = (Role)roleIterator.next();
        }
        return role;
View Full Code Here

    private Role getRole(Session session, String rolename) throws HibernateException {
        List roles = session.find("from role in class " +
                Role.class.getName() + " where role.name = ?",
                rolename, Hibernate.STRING);
        Role role = null;
        Iterator roleIterator = roles.iterator();
        if (roleIterator.hasNext()) {
            role = (Role)roleIterator.next();
        }
        return role;
View Full Code Here

    private void initializeRoles(Session session, User user, Person person)
            throws HibernateException {
        String[] roles = user.getRoles().split(",");
        for (int i = 0; i < roles.length; i++) {
            Role role = getRole(session, roles[i]);
            session.save(new RoleAssociation(0, person.getId(), role.getId()));
        }
    }
View Full Code Here

            }
        }
        Collection roles = SystemAuthorizer.get().
                getRolesForPrincipalOnProject(person.getId(), project.getId(), true);
        for (Iterator iterator = roles.iterator(); iterator.hasNext();) {
            Role role = (Role)iterator.next();
            if (role.getName().equals(rolename)) {
                return;
            }
        }
        fail("missing role: person="+userId+", role="+rolename);
    }
View Full Code Here

    }

    public void testModifiedRoleWhenAuthorizedAndNotSysadmin() throws Exception {
        mockEditorForm.setProjectId(0, PROJECT_ID_STRING);
        mockEditorForm.setProjectRole(0, "role");
        Role role = new Role("role");
        role.setId(111);
        mockRoleAssocationRepository.deleteAllForPersonOnProject(PERSON_ID, PROJECT_ID);
        mockRoleAssocationRepository.insertForPersonOnProject("role", PERSON_ID, PROJECT_ID);
        mockAuthorizer.hasPermission(PROJECT_ID,
                PERSON_ID, "system.project", PROJECT_ID, "admin.edit.role");
        mockAuthorizerControl.setReturnValue(true);
View Full Code Here

                "system.project", projectId, "admin.edit.role");
    }

    private void addRoleAssociationForProject(Session session, int projectId, int personId, String roleName)
            throws HibernateException {
        Role role = getRoleByName(session, roleName);
        if (role != null) {
            session.save(new RoleAssociation(projectId, personId, role.getId()));
        }
    }
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();
        Logger.getRootLogger().setLevel(Level.OFF);
        options = new HashMap();
        ArrayList roles = new ArrayList();
        roles.add(new Role("viewer"));
        person = new Person("foo");
        person.setUserId("userId");
        person.setPassword("KcH6P1khBqP9/JdLSkF/jUTaAJroY6K5oljIkQ==");
        support = new XPlannerTestSupport();
        ThreadSession.set(support.hibernateSession);
View Full Code Here

        support.hibernateSession.getNamedQueryReturnMap.put("security.person.permissions",mockPersonPermissionQuery);
    }

    public void testGetRolesForPrincipalOnProject() throws Exception {
        ArrayList results = new ArrayList();
        Role viewerRole = new Role("viewer");
        viewerRole.setId(1);
        Role editorRole = new Role("editor");
        editorRole.setId(2);
        results.add(viewerRole);
        results.add(editorRole);
        mockProjectPermissionQuery = new MockQuery();
        mockProjectPermissionQuery.listReturn = results;
        support.hibernateSession.getNamedQueryReturn = mockProjectPermissionQuery;
View Full Code Here

        assertRole(roles, "editor", 2);
    }

    private void assertRole(Collection roles, String roleName, int roleId) {
        for (Iterator iterator = roles.iterator(); iterator.hasNext();) {
            Role role = (Role)iterator.next();
            if (role.getName().equals(roleName) && role.getId() == roleId) {
                return;
            }
        }
        fail("role note found: "+roleName);
    }
View Full Code Here

TOP

Related Classes of org.nxplanner.domain.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.