Package org.apache.roller.weblogger.business

Examples of org.apache.roller.weblogger.business.UserManager


            Weblog weblog = getActionWeblog();
           
            // some caches are based on weblog last-modified, so update it
            weblog.setLastModified(new Date());
           
            UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
            umgr.saveWebsite(weblog);
            WebloggerFactory.getWeblogger().flush();
           
            // also notify cache manager
            CacheManager.invalidate(weblog);
View Full Code Here


   
    public String execute() {
       
        // query for templates list
        try {
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
           
            // get current list of templates, minus custom stylesheet
            List<WeblogTemplate> raw = mgr.getPages(getActionWeblog());
            List<WeblogTemplate> pages = new ArrayList<WeblogTemplate>();
            pages.addAll(raw);
            if(getActionWeblog().getTheme().getStylesheet() != null) {
                pages.remove(mgr.getPageByLink(getActionWeblog(),
                        getActionWeblog().getTheme().getStylesheet().getLink()));
            }
            setTemplates(pages);
           
            // build list of action types that may be added
View Full Code Here

            if(!"_decorator".equals(newTemplate.getName())) {
                newTemplate.setDecoratorName("_decorator");
            }
           
            // save the new Template
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
            mgr.savePage( newTemplate );
           
            // if this person happened to create a Weblog template from
            // scratch then make sure and set the defaultPageId
            if(WeblogTemplate.DEFAULT_PAGE.equals(newTemplate.getName())) {
                getActionWeblog().setDefaultPageId(newTemplate.getId());
                mgr.saveWebsite(getActionWeblog());
            }
           
            // flush results to db
            WebloggerFactory.getWeblogger().flush();
           
View Full Code Here

            addError("TemplateEdit.error.actionNull");
        }
       
        // check if template by that name already exists
        try {
            UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
            WeblogTemplate existingPage = umgr.getPageByName(getActionWeblog(), getNewTmplName());
            if(existingPage != null) {
                addError("pagesForm.error.alreadyExists", getNewTmplName());
            }
        } catch (WebloggerException ex) {
            log.error("Error checking for existing template", ex);
View Full Code Here

     * Remove a weblog.
     */
    public String remove() {
       
        try {
            UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
           
            // remove website
            umgr.removeWebsite(getActionWeblog());
            WebloggerFactory.getWeblogger().flush();
           
            CacheManager.invalidate(getActionWeblog());
           
            // TODO: i18n
View Full Code Here

    }
   
   
    public void myPrepare() {
        try {
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
            setTemplate(mgr.getPage(getBean().getId()));
        } catch (WebloggerException ex) {
            log.error("Error looking up template - "+getBean().getId(), ex);
        }
    }
View Full Code Here

                // empty content-type indicates that template uses auto content-type detection
                template.setOutputContentType(null);
            }
           
            // save template and flush
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
            mgr.savePage(template);
            WebloggerFactory.getWeblogger().flush();
           
            // notify caches
            CacheManager.invalidate(template);
           
View Full Code Here

    private void myValidate() {
       
        // if name changed make sure there isn't a conflict
        if(!getTemplate().getName().equals(getBean().getName())) {
            try {
                UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
                if(umgr.getPageByName(getActionWeblog(), getBean().getName()) != null) {
                    addError("pagesForm.error.alreadyExists", getBean().getName());
                }
            } catch (WebloggerException ex) {
                log.error("Error checking page name uniqueness", ex);
            }
        }
       
        // if link changed make sure there isn't a conflict
        if(!StringUtils.isEmpty(getBean().getLink()) &&
                !getBean().getLink().equals(getTemplate().getLink())) {
            try {
                UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
                if(umgr.getPageByLink(getActionWeblog(), getBean().getLink()) != null) {
                    addError("pagesForm.error.alreadyExists", getBean().getLink());
                }
            } catch (WebloggerException ex) {
                log.error("Error checking page link uniqueness", ex);
            }
View Full Code Here

       
        log.info("BEGIN");
       
        try {
       
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
            Weblog weblog = null;

            Weblog testWeblog = new Weblog();
            testUser = TestUtils.getManagedUser(testUser);
            testWeblog.setName("Test Weblog");
            testWeblog.setDescription("Test Weblog");
            testWeblog.setHandle("testweblog");
            testWeblog.setEmailAddress("testweblog@dev.null");
            testWeblog.setEditorPage("editor-text.jsp");
            testWeblog.setBlacklist("");
            testWeblog.setEmailFromAddress("");
            testWeblog.setEditorTheme("basic");
            testWeblog.setLocale("en_US");
            testWeblog.setTimeZone("America/Los_Angeles");
            testWeblog.setDateCreated(new java.util.Date());
            testWeblog.setCreator(testUser);

            // make sure test weblog does not exist
            weblog = mgr.getWebsiteByHandle(testWeblog.getHandle());
            assertNull(weblog);

            // add test weblog
            mgr.addWebsite(testWeblog);
            String id = testWeblog.getId();
            TestUtils.endSession(true);

            // make sure test weblog exists
            weblog = null;
            weblog = mgr.getWebsite(id);
            assertNotNull(weblog);
            assertEquals(testWeblog, weblog);

            // modify weblog and save
            weblog.setName("testtesttest");
            mgr.saveWebsite(weblog);
            TestUtils.endSession(true);

            // make sure changes were saved
            weblog = null;
            weblog = mgr.getWebsite(id);
            assertNotNull(weblog);
            assertEquals("testtesttest", weblog.getName());

            // remove test weblog
            mgr.removeWebsite(weblog);
            TestUtils.endSession(true);

            // make sure weblog no longer exists
            weblog = null;
            weblog = mgr.getWebsite(id);
            assertNull(weblog);
       
        } catch(Throwable t) {
            log.error("Exception running test", t);
            throw (Exception) t;
View Full Code Here

       
        log.info("BEGIN");
        Weblog testWeblog1 = null;
        Weblog testWeblog2 = null;
        try {
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
            Weblog weblog = null;
           
            // add test weblogs
            testWeblog1 = TestUtils.setupWeblog("testWeblog1", testUser);
            testWeblog2 = TestUtils.setupWeblog("testWeblog2", testUser);
            TestUtils.endSession(true);
           
            // lookup by id
            weblog = mgr.getWebsite(testWeblog1.getId());
            assertNotNull(weblog);
            assertEquals(testWeblog1.getHandle(), weblog.getHandle());
           
            // lookup by weblog handle
            weblog = null;
            weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
            assertNotNull(weblog);
            assertEquals(testWeblog1.getHandle(), weblog.getHandle());
           
            // make sure disable weblogs are not returned
            weblog.setEnabled(Boolean.FALSE);
            mgr.saveWebsite(weblog);
            TestUtils.endSession(true);
            weblog = null;
            weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
            assertNull(weblog);
           
            // restore enabled state
            weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle(), Boolean.FALSE);
            weblog.setEnabled(Boolean.TRUE);
            mgr.saveWebsite(weblog);
            TestUtils.endSession(true);
            weblog = null;
            weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
            assertNotNull(weblog);
           
            // get all weblogs for user
            weblog = null;
            List weblogs1 = mgr.getWebsites(TestUtils.getManagedUser(testUser), Boolean.TRUE, Boolean.TRUE, null, null, 0, -1);
            assertEquals(2, weblogs1.size());
            weblog = (Weblog) weblogs1.get(0);
            assertNotNull(weblog);
           
            // testing paging
            List weblogs11 = mgr.getWebsites(TestUtils.getManagedUser(testUser), Boolean.TRUE, Boolean.TRUE, null, null, 0, 1);
            assertEquals(1, weblogs11.size());
            List weblogs12 = mgr.getWebsites(TestUtils.getManagedUser(testUser), Boolean.TRUE, Boolean.TRUE, null, null, 1, 1);
            assertEquals(1, weblogs12.size());
           
            // make sure disabled weblogs are not returned
            weblog.setEnabled(Boolean.FALSE);
            mgr.saveWebsite(weblog);
            TestUtils.endSession(true);
            List weblogs2 = mgr.getWebsites(TestUtils.getManagedUser(testUser), Boolean.TRUE, Boolean.TRUE, null, null, 0, -1);
            assertEquals(1, weblogs2.size());
            weblog = (Weblog) weblogs2.get(0);
            assertNotNull(weblog);
           
            // make sure inactive weblogs are not returned
            weblog.setActive(Boolean.FALSE);
            mgr.saveWebsite(weblog);
            TestUtils.endSession(true);
            List weblogs3 = mgr.getWebsites(TestUtils.getManagedUser(testUser), Boolean.TRUE, Boolean.TRUE, null, null, 0, -1);
            assertEquals(0, weblogs3.size());
           
        } catch(Throwable t) {
            log.error("Exception running test", t);
            throw (Exception) t;
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.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.