Package org.apache.roller.business

Examples of org.apache.roller.business.UserManager


       
        StatCount s2 = (StatCount)list.get(1);
        assertEquals(1L, s2.getCount());  
    }
    public void testGetUserNameLetterMap() throws Exception {       
        UserManager mgr = RollerFactory.getRoller().getUserManager();     
        Map map = mgr.getUserNameLetterMap();   
        assertNotNull(map.get("a"));
        assertNotNull(map.get("b"));
        assertNull(map.get("c"));
    }
View Full Code Here


        assertNotNull(map.get("a"));
        assertNotNull(map.get("b"));
        assertNull(map.get("c"));
    }
    public void testGetWeblogLetterMap() throws Exception {       
        UserManager mgr = RollerFactory.getRoller().getUserManager();     
        Map map = mgr.getWeblogHandleLetterMap();   
        assertNotNull(map.get("a"));
        assertNotNull(map.get("b"));
        assertNull(map.get("c"));
    }
View Full Code Here

                    try {
                        String username = rses.getAuthenticatedUser().getUserName();
                       
                        website.setEditorTheme(newTheme);
                       
                        UserManager userMgr = RollerFactory.getRoller().getUserManager();
                        userMgr.saveWebsite(website);
                        RollerFactory.getRoller().flush();
                       
                        mLogger.debug("Saved theme "+newTheme+" for "+username);
                       
                        // make sure to flush the page cache so ppl can see the change
View Full Code Here

    /**
     * Test basic persistence operations ... Create, Update, Delete
     */
    public void testTemplateCRUD() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WeblogTemplate template = null;
       
        // create template
        mgr.savePage(testPage);
        TestUtils.endSession(true);
       
        // check that create was successful
        template = null;
        template = mgr.getPageByName(testWeblog, testPage.getName());
        assertNotNull(template);
        assertEquals(testPage.getContents(), template.getContents());
       
        // update template
        template.setName("testtesttest");
        mgr.savePage(template);
        TestUtils.endSession(true);
       
        // check that update was successful
        template = null;
        template = mgr.getPageByName(testWeblog, "testtesttest");
        assertNotNull(template);
        assertEquals(testPage.getContents(), template.getContents());
       
        // delete template
        mgr.removePage(template);
        TestUtils.endSession(true);
       
        // check that delete was successful
        template = null;
        template = mgr.getPageByName(testWeblog, testPage.getName());
        assertNull(template);
    }
View Full Code Here

    /**
     * Test lookup mechanisms ... id, name, link, weblog
     */
    public void testPermissionsLookups() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WeblogTemplate page = null;
       
        // create page
        mgr.savePage(testPage);
        String id = testPage.getId();
        TestUtils.endSession(true);
       
        // lookup by id
        page = mgr.getPage(id);
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup by name
        page = null;
        page = mgr.getPageByName(testWeblog, testPage.getName());
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup by link
        page = null;
        page = mgr.getPageByLink(testWeblog, testPage.getLink());
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup all pages for weblog
        List pages = mgr.getPages(testWeblog);
        assertNotNull(pages);
        assertEquals(1, pages.size());
       
        // delete page
        mgr.removePage(page);
        TestUtils.endSession(true);
    }
View Full Code Here

    public Template getWeblogPage() {
       
        if(weblogPage == null && weblogPageName != null) {
            try {
                UserManager umgr = RollerFactory.getRoller().getUserManager();
                weblogPage = getWeblog().getPageByLink(weblogPageName);               
            } catch (RollerException ex) {
                log.error("Error getting weblog page "+weblogPageName, ex);
            }
        }
View Full Code Here

                new MemberPermissionsPageModel(request, response, mapping);
       
        // Ensure use has admin perms for this weblog
        if (model.getWebsite() != null && rses.isUserAuthorizedToAdmin(model.getWebsite())) {
           
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
           
            Iterator iter = model.getPermissions().iterator();
            int removed = 0;
            int changed = 0;
            while (iter.hasNext()) {
                PermissionsData perms = (PermissionsData)iter.next();
                String sval = request.getParameter("perm-" + perms.getId());
                if (sval != null) {
                    short val = Short.parseShort(sval);
                    UserData user = rses.getAuthenticatedUser();
                    if (perms.getUser().getId().equals(user.getId())
                    && val < perms.getPermissionMask()) {
                        errors.add(null,new ActionError(
                                "memberPermissions.noSelfDemotions"));
                    } else if (val != perms.getPermissionMask()) {
                        if (val == -1) {
                            userMgr.removePermissions(perms);
                            removed++;
                        } else {
                            perms.setPermissionMask(val);
                            userMgr.savePermissions(perms);
                            changed++;
                        }
                    }
                }
            }
View Full Code Here

        throws RollerException {
       
        log.debug("Importing theme "+theme.getName()+" to weblog "+website.getName());
       
        try {
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
           
            Collection templates = theme.getTemplates();
            Iterator iter = templates.iterator();
            ThemeTemplate theme_template = null;
            while ( iter.hasNext() ) {
                theme_template = (ThemeTemplate) iter.next();
               
                WeblogTemplate template = null;
               
                if(theme_template.getName().equals(WeblogTemplate.DEFAULT_PAGE)) {
                    // this is the main Weblog template
                    try {
                        template = userMgr.getPage(website.getDefaultPageId());
                    } catch(Exception e) {
                        // user may not have a default page yet
                    }
                } else {
                    // any other template
                    template = userMgr.getPageByName(website, theme_template.getName());
                }
               
               
                if (template != null) {
                    // User already has page by that name, so overwrite it.
                    template.setContents(theme_template.getContents());
                    template.setLink(theme_template.getLink());
                   
                } else {
                    // User does not have page by that name, so create new page.
                    template = new WeblogTemplate(
                            null,                               // id
                            website,                            // website
                            theme_template.getName(),           // name
                            theme_template.getDescription(),    // description
                            theme_template.getLink(),           // link
                            theme_template.getContents(),       // contents
                            new Date(),                         // last mod
                            theme_template.getTemplateLanguage(), // temp lang
                            theme_template.isHidden(),          // hidden
                            theme_template.isNavbar(),          // navbar
                            theme_template.getDecoratorName()   // decorator
                            );
                    userMgr.savePage( template );
                }
            }
           
            // now update this website's theme to custom
            website.setEditorTheme(Theme.CUSTOM);
           
            // if this is the first time someone is customizing a theme then
            // we need to set a default page
            if(website.getDefaultPageId() == null ||
                    website.getDefaultPageId().trim().equals("") ||
                    website.getDefaultPageId().equals("dummy")) {
                // we have to go back to the db to figure out the id
                WeblogTemplate template = userMgr.getPageByName(website, "Weblog");
                if(template != null) {
                    log.debug("Setting default page to "+template.getId());
                    website.setDefaultPageId(template.getId());
                }
            }
           
            // we also want to set the weblogdayid
            WeblogTemplate dayTemplate = userMgr.getPageByName(website, "_day");
            if(dayTemplate != null) {
                log.debug("Setting default day page to "+dayTemplate.getId());
                website.setWeblogDayPageId(dayTemplate.getId());
            }
           
            // save our updated website
            userMgr.saveWebsite(website);
           
            // now lets import all the theme resources
            FileManager fileMgr = RollerFactory.getRoller().getFileManager();
           
            List resources = theme.getResources();
View Full Code Here

        this.roller = roller;
    }
   
    protected UserData getUserData(String name) throws NotFoundException, InternalException {
        try {
            UserManager mgr = getRoller().getUserManager();
            UserData ud = mgr.getUserByUserName(name, Boolean.TRUE);
            if (ud == null) {
                ud = mgr.getUserByUserName(name, Boolean.FALSE);
            }
            if (ud == null) {
                throw new NotFoundException("ERROR: Unknown user: " + name);
            }
           
View Full Code Here

        return c;
    }
   
    private WeblogEntrySet createWeblogs(WeblogEntrySet c) throws HandlerException {
        try {
            UserManager mgr = getRoller().getUserManager();
            HashMap pages = null; //getRollerContext().readThemeMacros(form.getTheme());
           
            List websiteDatas = new ArrayList();
            for (int i = 0; i < c.getEntries().length; i++) {
                WeblogEntry entry = (WeblogEntry)c.getEntries()[i];
                UserData user = mgr.getUserByUserName(entry.getCreatingUser());
                WebsiteData wd = new WebsiteData(
                        entry.getHandle(),
                        user,
                        entry.getName(),
                        entry.getDescription(),
                        entry.getEmailAddress(),
                        entry.getEmailAddress(),
                        DEFAULT_THEME,
                        entry.getLocale().toString(),
                        entry.getTimezone().getID());
               
                Date dateCreated  = entry.getDateCreated();
                if (dateCreated == null) {
                    dateCreated = new Date();
                }
                wd.setDateCreated(dateCreated);
               
                Boolean enabled = entry.getEnabled();
                if (enabled != null) {
                    wd.setEnabled(enabled);
                }
               
                try {
                    String def = RollerRuntimeConfig.getProperty("users.editor.pages");
                    String[] defs = Utilities.stringToStringArray(def,",");
                    wd.setEditorPage(defs[0]);
                } catch (Exception ex) {
                    log.error("ERROR setting default editor page for weblog", ex);
                }
               
                mgr.addWebsite(wd);
                getRoller().flush();
                CacheManager.invalidate(wd);
                websiteDatas.add(wd);
            }
           
View Full Code Here

TOP

Related Classes of org.apache.roller.business.UserManager

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.