Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.PermissionsData


            HttpServletResponse response)
            throws Exception {
       
        YourWebsitesForm form = (YourWebsitesForm)actionForm;       
        UserManager userMgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perms = userMgr.getPermissions(form.getInviteId());
        if (perms != null) {       
            // 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);
        } else {
            ActionErrors errs = new ActionErrors();
            errs.add(null, new ActionError("yourWebsites.permNotFound"));
            saveMessages(request, errs);           
View Full Code Here


        } catch (RollerException re) {
            throw new AtomException("ERROR: getting site's accept range", re);
        }
        if (perms != null) {
            for (Iterator iter=perms.iterator(); iter.hasNext();) {
                PermissionsData perm = (PermissionsData)iter.next();
                String handle = perm.getWebsite().getHandle();
                AtomService.Workspace workspace = new AtomService.Workspace();
                workspace.setTitle(Utilities.removeHTML(perm.getWebsite().getName()));
                service.addWorkspace(workspace);
               
                AtomService.Collection entryCol = new AtomService.Collection();
                entryCol.setTitle("Weblog Entries");
                entryCol.setAccept("entry");
                entryCol.setHref(URLUtilities.getAtomProtocolURL(true)+"/"+handle+"/entries");
                try {                   
                    AtomService.Categories cats = new AtomService.Categories();
                    cats.setFixed(true);
                    cats.setScheme(URLUtilities.getWeblogURL(perm.getWebsite(), null, true));
                    List rollerCats = mRoller.getWeblogManager().getWeblogCategories(perm.getWebsite(), false);
                    for (Iterator it = rollerCats.iterator(); it.hasNext();) {
                        WeblogCategoryData rollerCat = (WeblogCategoryData)it.next();
                        AtomService.Category cat = new AtomService.Category();
                        cat.setTerm(rollerCat.getPath());
                        cat.setLabel(rollerCat.getName());
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

       
        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

                errors.add(ActionErrors.GLOBAL_ERROR,
                        new ActionError("inviteMember.error.userNotFound"));
            } else {
                RollerRequest rreq = RollerRequest.getRollerRequest(request);
                WebsiteData website = rreq.getWebsite();
                PermissionsData perms = umgr.getPermissions(website, user);
                if (perms != null && perms.isPending()) {
                    errors.add(ActionErrors.GLOBAL_ERROR,
                            new ActionError("inviteMember.error.userAlreadyInvited"));
                    request.setAttribute("model", new BasePageModel(
                            "inviteMember.title", request, response, mapping));
                } else if (perms != null) {
View Full Code Here

            BasePageModel pageModel = (BasePageModel)req.getAttribute("model");
            if (pageModel != null) {
                website = pageModel.getWebsite();
            }
           
            PermissionsData permsData = null;
            if (user != null && website != null) {
                permsData = RollerFactory.getRoller()
                .getUserManager().getPermissions(website, user);
            }
            ret = false;
            Iterator perms = mPerms.iterator();
            while (perms.hasNext()) {
                String perm = (String)perms.next();
                if (perm.equals("any")) {
                    ret = true; // any permission will do (including none)
                    break;
                }
                if (permsData != null &&
                        ((perm.equals("admin"&& permsData.has(PermissionsData.ADMIN))
                        || (perm.equals("author"&& permsData.has(PermissionsData.AUTHOR))
                        || (perm.equals("limited") && permsData.has(PermissionsData.LIMITED)))) {
                    ret = true; // user has one of the required permissions
                    break;
                }
            }
        }
View Full Code Here

            Roller roller = RollerFactory.getRoller();
            UserManager umgr = roller.getUserManager();
            UserData user = umgr.getUserByUserName(userName);
            List perms = umgr.getAllPermissions(user);
            for (Iterator it = perms.iterator(); it.hasNext();) {
                PermissionsData perm = (PermissionsData) it.next();
                results.add(WebsiteDataWrapper.wrap(perm.getWebsite()));
            }
        } catch (Exception e) {
            log.error("ERROR: fetching weblog list", e);
        }
        return results;
View Full Code Here

            Roller roller = RollerFactory.getRoller();
            UserManager umgr = roller.getUserManager();
            WebsiteData website = umgr.getWebsiteByHandle(handle);
            List perms = umgr.getAllPermissions(website);
            for (Iterator it = perms.iterator(); it.hasNext();) {
                PermissionsData perm = (PermissionsData) it.next();
                results.add(UserDataWrapper.wrap(perm.getUser()));
            }
        } catch (Exception e) {
            log.error("ERROR: fetching weblog list", e);
        }
        return results;
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

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.