Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.WebsiteData


    /**
     * Convenience method that creates a weblog and stores it.
     */
    public static WebsiteData setupWeblog(String handle, UserData creator) throws Exception {
       
        WebsiteData testWeblog = new WebsiteData();
        testWeblog.setName("Test Weblog");
        testWeblog.setDescription("Test Weblog");
        testWeblog.setHandle(handle);
        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(creator);
       
        // add weblog
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        mgr.addWebsite(testWeblog);
       
        // query for the new weblog and return it
        WebsiteData weblog = mgr.getWebsiteByHandle(handle);
       
        if(weblog == null)
            throw new RollerException("error setting up weblog");
       
        return weblog;
View Full Code Here


     */
    public static void teardownWeblog(String id) throws Exception {
       
        // lookup the weblog
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WebsiteData weblog = mgr.getWebsite(id);
       
        // remove the weblog
        mgr.removeWebsite(weblog);
    }
View Full Code Here

     * Test basic persistence operations ... Create, Update, Delete.
     */
    public void testWeblogCRUD() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WebsiteData weblog = null;
       
        WebsiteData testWeblog = new WebsiteData();
        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);
View Full Code Here

     * Test lookup mechanisms.
     */
    public void testWeblogLookups() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WebsiteData weblog = null;
       
        // add test weblogs
        WebsiteData testWeblog1 = TestUtils.setupWeblog("testWeblog1", testUser);
        WebsiteData 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);
        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(testUser, Boolean.TRUE, Boolean.TRUE);
        assertEquals(2, weblogs1.size());
        weblog = (WebsiteData) weblogs1.get(0);
        assertNotNull(weblog);
       
        // make sure disabled weblogs are not returned
        weblog.setEnabled(Boolean.FALSE);
        mgr.saveWebsite(weblog);
        TestUtils.endSession(true);
        List weblogs2 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE);
        assertEquals(1, weblogs2.size());
        weblog = (WebsiteData) 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(testUser, Boolean.TRUE, Boolean.TRUE);
        assertEquals(0, weblogs3.size());
       
        // remove test weblogs
        TestUtils.teardownWeblog(testWeblog1.getId());
        TestUtils.teardownWeblog(testWeblog2.getId());
        TestUtils.endSession(true);
    }
View Full Code Here

                "America/Los_Angeles",
                new java.util.Date(), // dateCreated
                Boolean.TRUE);
        umgr.addUser(ud);
       
        WebsiteData website = new WebsiteData(
                    username,              // handle
                    ud,                // creator
                    username,              // name
                    username,         // description
                    "dummy@example.com",               // emailAddress
                    "",             // emailFrom
                    "basic",        // theme
                    "en_US_WIN",    // locale
                    "America/Los_Angeles" // timezone
                    );
       
        ThemeManager themeMgr = getRoller().getThemeManager();
        Theme usersTheme = themeMgr.getTheme(website.getEditorTheme());
        themeMgr.saveThemePages(website, usersTheme);
       
        return ud;
    }
View Full Code Here

                    "password",           // password
                    "Test User #"+i,      // fullName
                    "test"+i+"@test.com"  // emailAddress
                    );
            ud.setEnabled(new Boolean(i%2 == 0)); // half of users are disabled
            WebsiteData website = (WebsiteData)umgr.getWebsites(ud, null, null).get(0);
            mWebsitesCreated.add(website);
            mUsersCreated.add(ud);
           
            mLogger.debug("Created user "+ud.getUserName());
           
            // ensure that the first weblog entry created is the newest
            mCalendar = Calendar.getInstance();
            mCalendar.setTime(new Date());
           
            // create categories
            website  = umgr.getWebsite(website.getId());
            WeblogCategoryData rootCat = wmgr.getRootWeblogCategory(website);
            createCategoryPostsAndComments(0, wmgr, ud, website, rootCat);
           
        }
       
View Full Code Here

    //-----------------------------------------------------------------------
    /** Tear down weblogs created in setupTestWeblogs() */
    public void tearDownTestWeblogs() throws Exception {
        UserManager umgr = getRoller().getUserManager();
        for (Iterator siteIter = mWebsitesCreated.iterator(); siteIter.hasNext();) {
            WebsiteData site = (WebsiteData) siteIter.next();
            site = umgr.getWebsite(site.getId());
            if (site != null) {
                umgr.removeWebsite(site);
            }
        }
       
View Full Code Here

        mLogger.debug("try to delete " + deleteMe);
        UserManager umgr = getRoller().getUserManager();
       
        UserData user = umgr.getUserByUsername(deleteMe);
       
        WebsiteData website = (WebsiteData)umgr.getWebsites(user, null, null).get(0);
        umgr.removeWebsite(website);
       
        umgr.removeUser(user);
       
    }
View Full Code Here

   * @return
   */
  public static Locale getDefaultLocale(HttpServletRequest request) {
    mLogger.debug("getDefaultLocale()");
    RollerRequest rreq = RollerRequest.getRollerRequest(request);
    WebsiteData website = rreq.getWebsite();
    if (website==null) {
      return null;
    } else {
      return website.getLocaleInstance();
    }
  }
View Full Code Here

    }
   
    private EntrySet getEntry() throws HandlerException {
        String handle = getUri().getEntryId();
        try {
            WebsiteData wd = getRoller().getUserManager().getWebsiteByHandle(handle);
            if (wd == null) {
                throw new NotFoundException("ERROR: Unknown weblog handle: " + handle);
            }
            WebsiteData[] wds = new WebsiteData[] { wd };
            EntrySet c = toWeblogEntrySet(wds);
View Full Code Here

TOP

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

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.