Package org.apache.roller.planet

Examples of org.apache.roller.planet.PlanetException


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


    throws PlanetException {
        Subscription existing = getSubscription(sub.getFeedURL());
        if (existing == null || (existing.getId().equals(sub.getId()))) {
            strategy.store(sub);
        } else {
            throw new PlanetException("ERROR: duplicate feed URLs not allowed");
        }
    }
View Full Code Here

        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 in "
                    +((endTime-startTime)/1000.0)+" seconds");
           
        } catch (Throwable e) {
            throw new PlanetException(e);
        }
       
        return ret;
    }
View Full Code Here

        if ("jndi".equals(jpaConfigurationType)) {
            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();

            // Pull in any properties defined in JMAEMF.properties config file
            Properties emfProps = loadPropertiesFromResourceName(
                    "JPAEMF.properties", getContextClassLoader());

            // Add all OpenJPA and Toplinks properties found in RollerConfig
            Enumeration keys = PlanetConfig.keys();
            while (keys.hasMoreElements()) {
                String key = (String) keys.nextElement();
                if (key.startsWith("openjpa.") || key.startsWith("toplink.")) {
                    String value = PlanetConfig.getProperty(key);
                    logger.info(key + ": " + value);
                    emfProps.setProperty(key, value);
                }
            }

            if (dbProvider.getType() == DatabaseProvider.ConfigurationType.JNDI_NAME) {
                // We're doing JNDI, so set OpenJPA JNDI name property
                String jndiName = "java:comp/env/" + dbProvider.getJndiName();
                emfProps.setProperty("openjpa.ConnectionFactoryName", jndiName);

            } else {
                // So set JDBD properties for OpenJPA
                emfProps.setProperty("openjpa.ConnectionDriverName", dbProvider.getJdbcDriverClass());
                emfProps.setProperty("openjpa.ConnectionURL", dbProvider.getJdbcConnectionURL());
                emfProps.setProperty("openjpa.ConnectionUserName", dbProvider.getJdbcUsername());
                emfProps.setProperty("openjpa.ConnectionPassword", dbProvider.getJdbcPassword());

                // And Toplink JPA
                emfProps.setProperty("toplink.jdbc.driver", dbProvider.getJdbcDriverClass());
                emfProps.setProperty("toplink.jdbc.url", dbProvider.getJdbcConnectionURL());
                emfProps.setProperty("toplink.jdbc.user", dbProvider.getJdbcUsername());
                emfProps.setProperty("toplink.jdbc.password", dbProvider.getJdbcPassword());

                // And Hibernate JPA
                emfProps.setProperty("hibernate.connection.driver_class", dbProvider.getJdbcDriverClass());
                emfProps.setProperty("hibernate.connection.url", dbProvider.getJdbcConnectionURL());
                emfProps.setProperty("hibernate.connection.username", dbProvider.getJdbcUsername());
                emfProps.setProperty("hibernate.connection.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

        Properties props = new Properties();
        InputStream in = null;
        in = cl.getResourceAsStream(resourceName);
        if (in == null) {
            //TODO: Check how i18n is done in roller
            throw new PlanetException(
                    "Could not locate properties to load " + resourceName);
        }
        try {
            props.load(in);
        } catch (IOException ioe) {
            throw new PlanetException(
                    "Could not load properties from " + resourceName);
        } finally {
            if (in != null) {
                try {
                    in.close();
View Full Code Here

            // parse the incoming request and extract the relevant data
            feedRequest = new PlanetGroupFeedRequest(request);
           
            planet = feedRequest.getPlanet();
            if(planet == null) {
                throw new PlanetException("unable to lookup planet: "+
                        feedRequest.getPlanetHandle());
            }
           
            group = feedRequest.getGroup();
            if(group == null) {
                throw new PlanetException("unable to lookup group: "+
                        feedRequest.getGroupHandle());
            }

        } catch(Exception e) {
            // invalid feed request format or weblog doesn't exist
View Full Code Here

            // parse the incoming request and extract the relevant data
            opmlRequest = new PlanetGroupOpmlRequest(request);

            planet = opmlRequest.getPlanet();
            if(planet == null) {
                throw new PlanetException("unable to lookup planet: "+
                        opmlRequest.getPlanetHandle());
            }
           
            group = opmlRequest.getGroup();
            if(group == null) {
                throw new PlanetException("unable to lookup group: "+
                        opmlRequest.getGroupHandle());
            }

        } catch(Exception e) {
            // invalid feed request format or weblog doesn't exist
View Full Code Here

    throws PlanetException {
        Subscription existing = getSubscription(sub.getFeedURL());
        if (existing == null || (existing.getId().equals(sub.getId()))) {
            strategy.store(sub);
        } else {
            throw new PlanetException("ERROR: duplicate feed URLs not allowed");
        }
    }
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.