Package org.apache.roller.planet.business

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


    /**
     * Load relevant form data if possible.
     */
    public void prepare() throws Exception {
       
        PlanetManager pMgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // load existing planet
        if(getPlanetid() != null && !"".equals(getPlanetid())) {
            log.debug("Loading Planet ... "+getPlanetid());
            this.planet = pMgr.getPlanetById(getPlanetid());
        } else {
            // new planet
            log.debug("No planet specified, constructing new one");
            this.planet = new Planet();
        }
View Full Code Here


        if(this.planet != null) {
            // save planet
            log.debug("Saving Planet ...");
           
            try {
                PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
                pmgr.savePlanet(this.planet);
                PlanetFactory.getPlanet().flush();
               
                // need to set planetid attribute
                setPlanetid(this.planet.getId());
            } catch (PlanetException ex) {
View Full Code Here

       
        if(getGroupid() != null && !"".equals(getGroupid())) {
            // delete a planet group
            log.debug("Deleting Planet Group ... "+getGroupid());
           
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
            try {
                PlanetGroup group = pmgr.getGroupById(getGroupid());
                this.planet = group.getPlanet();
                this.planet.getGroups().remove(group);
                pmgr.savePlanet(this.planet);
                pmgr.deleteGroup(group);
                PlanetFactory.getPlanet().flush();
               
                setSuccess("PlanetForm.message.groupDeleteSucceeded", group.getHandle());
                return INPUT;
            } catch (PlanetException ex) {
View Full Code Here

   
    /**
     * Load relevant Subscription if possible.
     */
    public void prepare() throws Exception {
        PlanetManager pMgr = PlanetFactory.getPlanet().getPlanetManager();
        if(getSubid() != null && !"".equals(getSubid())) {
            // load a planet subscription
            log.debug("Loading Planet Subscription ...");
           
            subscription = pMgr.getSubscriptionById(getSubid());
        } else {
            subscription = new Subscription();
        }
    }
View Full Code Here

    // TODO: Validation - make sure that html is not allowed in title
    public String save() {
        // save a subscription
        log.debug("Saving Planet Subscription ...");
       
        PlanetManager pMgr = PlanetFactory.getPlanet().getPlanetManager();
        try {
            if(this.subscription.getId() == null) {
                // adding a new sub to a group, so make sure we have a group
                PlanetGroup group = pMgr.getGroupById(getGroupid());
                if(group == null) {
                    setError("PlanetSubscriptionForm.error.groupNull");
                    return INPUT;
                }
               
                // check if this subscription already exists before adding it
                Subscription sub = pMgr.getSubscription(this.subscription.getFeedURL());
                if(sub != null) {
                    this.subscription = sub;
                } else {
                    pMgr.saveSubscription(this.subscription);
                   
                    // set subid now that we have one
                    setSubid(this.subscription.getId());
                }
               
                // add the sub to the group
                group.getSubscriptions().add(this.subscription);
                this.subscription.getGroups().add(group);
                pMgr.saveGroup(group);
               
            } else {
                // updating and existing subscription, so just save it
                pMgr.saveSubscription(this.subscription);
            }
           
            // flush changes
            PlanetFactory.getPlanet().flush();
        } catch (PlanetException ex) {
View Full Code Here

    public static Planet setupPlanet(String handle) throws Exception {
       
        Planet testPlanet = new Planet(handle, handle, handle);
       
        // store
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        mgr.savePlanet(testPlanet);
       
        // flush
        PlanetFactory.getPlanet().flush();
       
        // query to make sure we return the persisted object
        Planet planet = mgr.getPlanet(handle);
       
        if(planet == null)
            throw new PlanetException("error inserting new planet");
       
        return planet;
View Full Code Here

     * Convenience method for removing a planet.
     */
    public static void teardownPlanet(String id) throws Exception {
       
        // lookup
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        Planet planet = mgr.getPlanetById(id);
       
        // remove
        mgr.deletePlanet(planet);
       
        // flush
        PlanetFactory.getPlanet().flush();
    }
View Full Code Here

     * Convenience method that creates a group and stores it.
     */
    public static PlanetGroup setupGroup(Planet planet, String handle)
            throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // make sure we are using a persistent object
        Planet testPlanet = mgr.getPlanetById(planet.getId());
       
        // store
        PlanetGroup testGroup = new PlanetGroup(testPlanet, handle, handle, handle);
        testPlanet.getGroups().add(testGroup);
        mgr.saveGroup(testGroup);
       
        // flush
        PlanetFactory.getPlanet().flush();
       
        // query to make sure we return the persisted object
        PlanetGroup group = mgr.getGroupById(testGroup.getId());
       
        if(group == null)
            throw new PlanetException("error inserting new group");
       
        return group;
View Full Code Here

     * Convenience method for removing a group.
     */
    public static void teardownGroup(String id) throws Exception {
       
        // lookup
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        PlanetGroup group = mgr.getGroupById(id);
       
        // remove
        mgr.deleteGroup(group);
        group.getPlanet().getGroups().remove(group);
       
        // flush
        PlanetFactory.getPlanet().flush();
    }
View Full Code Here

     * Convenience method that creates a sub and stores it.
     */
    public static Subscription setupSubscription(String feedUrl)
            throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // store
        Subscription testSub = new Subscription();
        testSub.setFeedURL(feedUrl);
        testSub.setTitle(feedUrl);
        mgr.saveSubscription(testSub);
       
        // flush
        PlanetFactory.getPlanet().flush();
       
        // query to make sure we return the persisted object
        Subscription sub = mgr.getSubscriptionById(testSub.getId());
       
        if(sub == null)
            throw new PlanetException("error inserting new subscription");
       
        return sub;
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.