Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.PermissionsData


       
        if (website == null) throw new RollerException("Website cannot be null");
        if (user == null) throw new RollerException("User cannot be null");
       
        Iterator perms = website.getPermissions().iterator();
        PermissionsData target = null;
        while (perms.hasNext()) {
            PermissionsData pd = (PermissionsData)perms.next();
            if (pd.getUser().getId().equals(user.getId())) {
                target = pd;
                break;
            }
        }
        if (target == null) throw new RollerException("User not member of website");
View Full Code Here


            throws Exception
    {
        YourWebsitesForm form = (YourWebsitesForm)actionForm;
       
        UserManager userMgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perms = userMgr.getPermissions(form.getInviteId());
       
        // TODO ROLLER_2.0: notify inviter that invitee has accepted invitation 
        // TODO EXCEPTIONS: better exception handling
        perms.setPending(false);
        userMgr.savePermissions(perms);
        RollerFactory.getRoller().flush();
       
        ActionMessages msgs = new ActionMessages();
        msgs.add(null, new ActionMessage(
                "yourWebsites.accepted", perms.getWebsite().getHandle()));
        saveMessages(request, msgs);
       
        request.setAttribute("model",
                new YourWebsitesPageModel(request, response, mapping));
        ActionForward forward = mapping.findForward("yourWebsites.page");
View Full Code Here

            throws Exception
    {
        YourWebsitesForm form = (YourWebsitesForm)actionForm;
       
        UserManager userMgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perms = userMgr.getPermissions(form.getInviteId());
       
        // TODO ROLLER_2.0: notify inviter that invitee has declined invitation
        // TODO EXCEPTIONS: better exception handling here
        userMgr.removePermissions(perms);
        RollerFactory.getRoller().flush();
       
        ActionMessages msgs = new ActionMessages();
        msgs.add(null, new ActionMessage(
                "yourWebsites.declined", perms.getWebsite().getHandle()));
        saveMessages(request, msgs);
       
        request.setAttribute("model",
                new YourWebsitesPageModel(request, response, mapping));
        ActionForward forward = mapping.findForward("yourWebsites.page");
View Full Code Here

        UserData user = rses.getAuthenticatedUser();
        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        WebsiteData website = rreq.getWebsite();
       
        UserManager userMgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perms = userMgr.getPermissions(website, user);
       
        if (perms != null)
        {
            // TODO ROLLER_2.0: notify website members that user has resigned
            // TODO EXCEPTIONS: better exception handling
            userMgr.removePermissions(perms);
            RollerFactory.getRoller().flush();
        }
       
        ActionMessages msgs = new ActionMessages();
        msgs.add(null, new ActionMessage(
                "yourWebsites.resigned", perms.getWebsite().getHandle()));
        saveMessages(request, msgs);
       
        request.setAttribute("model",
                new YourWebsitesPageModel(request, response, mapping));
        ActionForward forward = mapping.findForward("yourWebsites.page");
View Full Code Here

       
        UserManager umgr = RollerFactory.getRoller().getUserManager();
        WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
       
        // grant weblog creator ADMIN permissions
        PermissionsData perms = new PermissionsData();
        perms.setUser(newWeblog.getCreator());
        perms.setWebsite(newWeblog);
        perms.setPending(false);
        perms.setPermissionMask(PermissionsData.ADMIN);
        this.strategy.store(perms);
       
        // add default categories
        WeblogCategoryData rootCat = new WeblogCategoryData(
                null,      // id
View Full Code Here

            UserData user, short mask) throws RollerException {
       
        if (website == null) throw new RollerException("Website cannot be null");
        if (user == null) throw new RollerException("User cannot be null");
       
        PermissionsData perms = new PermissionsData();
        perms.setWebsite(website);
        perms.setUser(user);
        perms.setPermissionMask(mask);
        this.strategy.store(perms);
       
        return perms;
    }
View Full Code Here

     * Test basic persistence operations ... Create, Update, Delete.
     */
    public void testPermissionsCRUD() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perm = null;
       
        // delete permissions
        perm = mgr.getPermissions(testWeblog, testUser);
        assertNotNull(perm);
        mgr.removePermissions(perm);
        TestUtils.endSession(true);
       
        // check that delete was successful
        perm = null;
        perm = mgr.getPermissions(testWeblog, testUser);
        assertNull(perm);
       
        // create permissions
        perm = new PermissionsData();
        perm.setUser(testUser);
        perm.setWebsite(testWeblog);
        perm.setPending(false);
        perm.setPermissionMask(PermissionsData.ADMIN);
        mgr.savePermissions(perm);
        TestUtils.endSession(true);
       
        // check that create was successful
        perm = null;
        perm = mgr.getPermissions(testWeblog, testUser);
        assertNotNull(perm);
        assertEquals(PermissionsData.ADMIN, perm.getPermissionMask());
       
        // update permissions
        perm.setPermissionMask(PermissionsData.LIMITED);
        mgr.savePermissions(perm);
        TestUtils.endSession(true);
       
        // check that update was successful
        perm = null;
        perm = mgr.getPermissions(testWeblog, testUser);
        assertNotNull(perm);
        assertEquals(PermissionsData.LIMITED, perm.getPermissionMask());
    }
View Full Code Here

        // we need a second user for this test
        UserData user = TestUtils.setupUser("foofoo");
        TestUtils.endSession(true);
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perm = null;
        List perms = null;
       
        // get all permissions for a user
        perms = mgr.getAllPermissions(user);
        assertEquals(0, perms.size());
        perms = mgr.getAllPermissions(testUser);
        assertEquals(1, perms.size());
       
        // get all permissions for a weblog
        perms = mgr.getAllPermissions(testWeblog);
        assertEquals(1, perms.size());
       
        perm = new PermissionsData();
        perm.setUser(user);
        perm.setWebsite(testWeblog);
        perm.setPending(true);
        perm.setPermissionMask(PermissionsData.AUTHOR);
        mgr.savePermissions(perm);
       
        // get pending permissions for a user
        perms = mgr.getPendingPermissions(testUser);
        assertEquals(0, perms.size());
        perms = mgr.getPendingPermissions(user);
        assertEquals(1, perms.size());
       
        // get pending permissions for a weblog
        perms = mgr.getPendingPermissions(testWeblog);
        assertEquals(1, perms.size());
       
        // get permissions by id
        String id = perm.getId();
        perm = null;
        perm = mgr.getPermissions(id);
        assertNotNull(perm);
        assertEquals(id, perm.getId());
       
        // get permissions for a specific user/weblog
        perm = null;
        perm = mgr.getPermissions(testWeblog, testUser);
        assertNotNull(perm);
        assertEquals(PermissionsData.ADMIN, perm.getPermissionMask());
        perm = null;
        perm = mgr.getPermissions(testWeblog, user);
        assertNotNull(perm);
        assertEquals(PermissionsData.AUTHOR, perm.getPermissionMask());
        assertEquals(true, perm.isPending());
       
        // cleanup the extra test user
        TestUtils.teardownUser(user.getId());
        TestUtils.endSession(true);
    }
View Full Code Here

        // we need a second user for this test
        UserData user = TestUtils.setupUser("foobee");
        TestUtils.endSession(true);
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perm = null;
        List perms = null;
       
        // invite user to weblog
        perm = mgr.inviteUser(testWeblog, user, PermissionsData.LIMITED);
        String id = perm.getId();
        TestUtils.endSession(true);
       
        // accept invitation
        perm = mgr.getPermissions(testWeblog, user);
        perm.setPending(false);
        mgr.savePermissions(perm);
        TestUtils.endSession(true);
       
        // re-query now that we have changed things
        user = mgr.getUserByUsername(user.getUserName());
View Full Code Here

        List entries = new ArrayList();
        for (int i = 0; i < uds.length; i++) {
            UserData ud = uds[i];
            List permissions = ud.getPermissions();
            for (Iterator j = permissions.iterator(); j.hasNext(); ) {
                PermissionsData pd = (PermissionsData)j.next();
                WebsiteData wd = pd.getWebsite();
                WeblogEntry we = toWeblogEntry(wd);
                entries.add(we);
            }
        }
        wes.setEntries((Entry[])entries.toArray(new Entry[0]));
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.PermissionsData

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.