Package org.apache.roller.planet.business

Examples of org.apache.roller.planet.business.PlanetManager


   
   
    @Override
    public void myPrepare() {
       
        PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // lookup group we are operating on, if none specified then use default
        if (getGroupHandle() == null) {
            setGroupHandle("all");
        }
       
        try {
            setGroup(pmgr.getGroup(getPlanet(), getGroupHandle()));
        } catch (RollerException ex) {
            log.error("Error looking up planet group - "+getGroupHandle(), ex);
        }
    }
View Full Code Here


    public String save() {
       
        myValidate();
       
        if(!hasActionErrors()) try {
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
           
            // check if this subscription already exists before adding it
            Subscription sub = pmgr.getSubscription(getSubUrl());
            if(sub == null) {
                log.debug("Adding New Subscription - "+getSubUrl());
               
                // sub doesn't exist yet, so we need to fetch it
                FeedFetcher fetcher = PlanetFactory.getPlanet().getFeedFetcher();
                sub = fetcher.fetchSubscription(getSubUrl());
               
                // save new sub
                pmgr.saveSubscription(sub);
            } else {
                log.debug("Adding Existing Subscription - "+getSubUrl());
               
                // Subscription already exists
                addMessage("planetSubscription.foundExisting", sub.getTitle());
            }
           
            // add the sub to the group
            group.getSubscriptions().add(sub);
            sub.getGroups().add(group);
            pmgr.saveGroup(group);
           
            // flush changes
            PlanetFactory.getPlanet().flush();
           
            // clear field after success
View Full Code Here

     */
    public String delete() {
       
        if(getSubUrl() != null) try {
           
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
           
            // remove subscription
            Subscription sub = pmgr.getSubscription(getSubUrl());
            getGroup().getSubscriptions().remove(sub);
            sub.getGroups().remove(getGroup());
            pmgr.saveGroup(getGroup());
            PlanetFactory.getPlanet().flush();
           
            // clear field after success
            setSubUrl(null);
           
View Full Code Here

   
    @Override
    public void myPrepare() {
       
        if(getPlanet() != null && getBean().getId() != null) try {
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
            setGroup(pmgr.getGroupById(getBean().getId()));
        } catch(Exception ex) {
            log.error("Error looking up planet group - "+getBean().getId(), ex);
        }
    }
View Full Code Here

           
            // copy in submitted data
            getBean().copyTo(group);
           
            // save and flush
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
            pmgr.saveGroup(group);
            PlanetFactory.getPlanet().flush();
           
            addMessage("planetGroups.success.saved");
           
        } catch(Exception ex) {
View Full Code Here

     */
    public String delete() {
       
        if(getGroup() != null) {
            try {
                PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
                pmgr.deleteGroup(getGroup());
                PlanetFactory.getPlanet().flush();
               
                addMessage("planetSubscription.success.deleted");
            } catch(Exception ex) {
                log.error("Error deleting planet group - "+getBean().getId());
View Full Code Here

                startDate = cal.getTime();
            }
           
            List results = new ArrayList();
            try {
                PlanetManager planetManager = PlanetFactory.getPlanet().getPlanetManager();
                Planet planet = planetManager.getPlanet("default");
               
                List entries = null;
                if (feedURL != null) {
                    Subscription sub = planetManager.getSubscription(feedURL);
                    entries = planetManager.getEntries(sub, offset, length+1);
                } else if (groupHandle != null) {
                    PlanetGroup group = planetManager.getGroup(planet, groupHandle);
                    entries = planetManager.getEntries(group, startDate, null, offset, length+1);
                } else {
                    PlanetGroup group = planetManager.getGroup(planet, "all");
                    entries = planetManager.getEntries(group, startDate, null, offset, length+1);
                }
               
                // wrap 'em
                int count = 0;
                for (Iterator it = entries.iterator(); it.hasNext();) {
View Full Code Here

     */
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        log.debug("Entering");

        PlanetManager planet = PlanetFactory.getPlanet().getPlanetManager();

        PlanetRequest planetRequest = null;
        try {
            planetRequest = new PlanetRequest(request);
        } catch (Exception e) {
            // some kind of error parsing the request
            log.debug("error creating planet request", e);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        // figure planet last modified date
        Date lastModified = planetCache.getLastModified();

        // Respond with 304 Not Modified if it is not modified.
        if (ModDateHeaderUtil.respondIfNotModified(request, response, lastModified.getTime())) {
            return;
        }

        // set content type
        String accepts = request.getHeader("Accept");
        String userAgent = request.getHeader("User-Agent");
        if (accepts != null && userAgent != null && accepts.indexOf("*/*") != -1 && userAgent.startsWith("Mozilla")) {
            // client is a browser and now that we offer styled feeds we want
            // browsers to load the page rather than popping up the download
            // dialog, so we provide a content-type that browsers will display
            response.setContentType("text/xml");
        } else {
            response.setContentType("application/rss+xml; charset=utf-8");
        }

        // set last-modified date
        ModDateHeaderUtil.setLastModifiedHeader(response, lastModified.getTime());

        // cached content checking
        String cacheKey = PlanetCache.CACHE_ID + ":" + this.generateKey(planetRequest);
        CachedContent entry = (CachedContent) planetCache.get(cacheKey);
        if (entry != null) {
            response.setContentLength(entry.getContent().length);
            response.getOutputStream().write(entry.getContent());
            return;
        }


        // looks like we need to render content
        @SuppressWarnings("unchecked")
        HashMap<String, Object> model = new HashMap();
        try {
            // populate the rendering model
            if (request.getParameter("group") != null) {
                Planet planetObject = planet.getPlanet("default");
                model.put("group", planet.getGroup(planetObject, request.getParameter("group")));
            }
            model.put("planet", planet);
            model.put("date", new Date());
            model.put("utils", new UtilitiesModel());
            model.put("siteName", PlanetRuntimeConfig.getProperty("site.name"));
View Full Code Here

        //RollerConfig.setPlanetCachePath("." + File.separator + "planet-cache");
    }
   
    public void testConfigurationStorage() throws Exception {
       
        PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
       
        {   // retrieve config
            PlanetConfigData config = planet.getConfiguration();
            assertNotNull(config);
            assertEquals("test_title", config.getTitle());
            assertEquals("test_admin_email", config.getAdminEmail());
            assertNull(config.getSiteURL());
        }
        {   // save config
            PlanetConfigData config = planet.getConfiguration();
            config.setSiteURL("http://footest/lskdf/null");
            planet.saveConfiguration(config);
            TestUtils.endSession(true);
        }
        {
            // make sure config was saved
            PlanetConfigData config = planet.getConfiguration();
            assertNotNull(config);
            assertEquals("http://footest/lskdf/null", config.getSiteURL());
        }
    }
View Full Code Here

    }
   
   
    public void testGroupStorage() throws Exception {
       
        PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
       
        {   // save group
            PlanetGroupData group = new PlanetGroupData();
            group.setDescription("test_group_desc");
            group.setHandle("test_handle");
            group.setTitle("test_title");
            planet.saveGroup(group);
            TestUtils.endSession(true);
        }
        {   // retrieve group
            PlanetGroupData group = planet.getGroup("test_handle");
            assertEquals("test_group_desc",group.getDescription());
            assertEquals("test_title",group.getTitle());
            assertTrue(planet.getGroupHandles().size() > 0);
        }
        {   // remove group
            PlanetGroupData group = planet.getGroup("test_handle");
            planet.deleteGroup(group);
            TestUtils.endSession(true);
        }
        {   // verify that it is gone
            PlanetGroupData group = planet.getGroup("test_handle");
            assertNull(group);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.planet.business.PlanetManager

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.