Package org.apache.roller.planet

Examples of org.apache.roller.planet.PlanetException


        return (SubscriptionEntry) strategy.load(SubscriptionEntry.class, id);
    }

    public List getEntries(Subscription sub, int offset, int len) throws PlanetException {           
        if (sub == null) {
            throw new PlanetException("subscription cannot be null");
        }
        Query q = strategy.getNamedQuery("SubscriptionEntry.getBySubscription");
        q.setParameter(1, sub);
        if (offset != 0) q.setFirstResult(offset);
        if (len != -1) q.setMaxResults(len);
View Full Code Here


    public List getEntries(PlanetGroup group, Date startDate, Date endDate, int offset, int len) throws PlanetException {
        StringBuffer queryString = new StringBuffer();
               
        if (group == null) {
            throw new PlanetException("group cannot be null or empty");
        }
       
        List ret = null;
        try {
            long startTime = System.currentTimeMillis();
           
            StringBuffer sb = new StringBuffer();
            List params = new ArrayList();
            int size = 0;
            sb.append("SELECT e FROM SubscriptionEntry e ");
            sb.append("JOIN e.subscription.groups g ");
                       
            params.add(size++, group.getHandle());
            sb.append("WHERE g.handle = ?").append(size);
           
            if (startDate != null) {
                params.add(size++, new Timestamp(startDate.getTime()));
                sb.append(" AND e.pubTime > ?").append(size);
            }
            if (endDate != null) {
                params.add(size++, new Timestamp(endDate.getTime()));
                sb.append(" AND e.pubTime < :?").append(size);
            }
            sb.append(" ORDER BY e.pubTime DESC");
           
            Query query = strategy.getDynamicQuery(sb.toString());
            for (int i=0; i<params.size(); i++) {
                query.setParameter(i+1, params.get(i));
            }
            if (offset > 0) {
                query.setFirstResult(offset);
            }
            if (len != -1) {
                query.setMaxResults(len);
            }
           
            ret = query.getResultList();
           
            long endTime = System.currentTimeMillis();
           
            log.debug("Generated aggregation of " + ret.size() + " in " + ((endTime-startTime)/1000.0) + " seconds");
           
        } catch (Throwable e) {
            throw new PlanetException(e);
        }
       
        return ret;
    }
View Full Code Here

            // parse the incoming request and extract the relevant data
            pageRequest = new PlanetGroupPageRequest(request);

            planet = pageRequest.getPlanet();
            if(planet == null) {
                throw new PlanetException("unable to lookup planet: "+
                        pageRequest.getPlanetHandle());
            }
           
            group = pageRequest.getGroup();
View Full Code Here

        super.init(initData);
       
        // we expect the init data to contain a weblogRequest object
        PlanetRequest planetRequest = (PlanetRequest) initData.get("planetRequest");
        if(planetRequest == null) {
            throw new PlanetException("expected planetRequest from init data");
        }
       
        // PageModel only works on page requests, so cast planetRequest
        // into a PlanetRequest and if it fails then throw exception
        if(planetRequest instanceof PlanetGroupPageRequest) {
            this.pageRequest = (PlanetGroupPageRequest) planetRequest;
        } else {
            throw new PlanetException("weblogRequest is not a WeblogPageRequest."+
                    "  PageModel only supports page requests.");
        }
    }
View Full Code Here

        super.init(initData);
       
        // we expect the init data to contain a weblogRequest object
        PlanetRequest planetRequest = (PlanetRequest) initData.get("planetRequest");
        if(planetRequest == null) {
            throw new PlanetException("expected planetRequest from init data");
        }
       
        // PageModel only works on page requests, so cast planetRequest
        // into a PlanetRequest and if it fails then throw exception
        if(planetRequest instanceof PlanetGroupFeedRequest) {
            this.feedRequest = (PlanetGroupFeedRequest) planetRequest;
        } else {
            throw new PlanetException("weblogRequest is not a WeblogPageRequest."+
                    "  PageModel only supports page requests.");
        }
    }
View Full Code Here

                } else {
                    log.warn("Error initializing model: " + models[i]);
                }
            } catch (ClassNotFoundException cnfe) {
                if(fail) {
                    throw new PlanetException("Error finding model: " + models[i], cnfe);
                } else {
                    log.warn("Error finding model: " + models[i]);
                }
            } catch (InstantiationException ie) {
                if(fail) {
                    throw new PlanetException("Error insantiating model: " + models[i], ie);
                } else {
                    log.warn("Error insantiating model: " + models[i]);
                }
            } catch (IllegalAccessException iae) {
                if(fail) {
                    throw new PlanetException("Error accessing model: " + models[i], iae);
                } else {
                    log.warn("Error accessing model: " + models[i]);
                }
            }
        }
View Full Code Here

            Planet planet = pMgr.getPlanetById(getPlanetid());
            if(planet != null) {
                group = new PlanetGroup();
                group.setPlanet(planet);
            } else {
                throw new PlanetException("could not determine planet "+getPlanetid());
            }
        }
    }
View Full Code Here

        this.urlStrategy = PlanetFactory.getPlanet().getURLStrategy();
       
        // need a weblog request so that we can know the weblog and locale
        PlanetRequest planetRequest = (PlanetRequest) initData.get("planetRequest");
        if(planetRequest == null) {
            throw new PlanetException("Expected 'planetRequest' init param!");
        }
       
        this.planet = planetRequest.getPlanet();
    }
View Full Code Here

            // Lookup EMF via JNDI: added for Geronimo
            String emfJndiName = "java:comp/env/" + PlanetConfig.getProperty("jpa.emf.jndi.name");
            try {
                emf = (EntityManagerFactory) new InitialContext().lookup(emfJndiName);
            } catch (NamingException e) {
                throw new PlanetException("Could not look up EntityManagerFactory in jndi at " + emfJndiName, e);
            }
        } else {
            DatabaseProvider dbProvider = PlanetStartup.getDatabaseProvider();

            // Add all JPA, OpenJPA, HibernateJPA, etc. properties found
            Properties emfProps = new Properties();
            Enumeration keys = PlanetConfig.keys();
            while (keys.hasMoreElements()) {
                String key = (String) keys.nextElement();
                if (       key.startsWith("javax.persistence.")
                        || key.startsWith("openjpa.")
                        || key.startsWith("hibernate.")) {
                    String value = PlanetConfig.getProperty(key);
                    logger.info(key + ": " + value);
                    emfProps.setProperty(key, value);
                }
            }

            if (dbProvider.getType() == DatabaseProvider.ConfigurationType.JNDI_NAME) {
                emfProps.setProperty("javax.persistence.nonJtaDataSource", dbProvider.getJndiName());

            } else {
                emfProps.setProperty("javax.persistence.jdbc.driver", dbProvider.getJdbcDriverClass());
                emfProps.setProperty("javax.persistence.jdbc.url", dbProvider.getJdbcConnectionURL());
                emfProps.setProperty("javax.persistence.jdbc.user", dbProvider.getJdbcUsername());
                emfProps.setProperty("javax.persistence.jdbc.password", dbProvider.getJdbcPassword());
            }

            try {
                this.emf = Persistence.createEntityManagerFactory("PlanetPU", emfProps);
            } catch (PersistenceException pe) {
                logger.error("ERROR: creating entity manager", pe);
                throw new PlanetException(pe);
            }
        }
    }
View Full Code Here

    public void flush() throws PlanetException {
        try {
            EntityManager em = getEntityManager(true);
            em.getTransaction().commit();
        } catch (PersistenceException pe) {
            throw new PlanetException(pe);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.planet.PlanetException

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.