Package org.apache.roller.planet

Examples of org.apache.roller.planet.PlanetException


        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


    public void init(Map initData) throws PlanetException {
       
        // we expect the init data to contain a planetRequest object
        PlanetRequest planetRequest = (PlanetRequest) initData.get("planetRequest");
        if(planetRequest == null) {
            throw new PlanetException("expected planetRequest from init data");
        }
       
        // only works on planet group requests, so cast planetRequest
        // into a PlanetGroupRequest and if it fails then throw exception
        if(planetRequest instanceof PlanetGroupRequest) {
            this.planetGroupRequest = (PlanetGroupRequest) planetRequest;
        } else {
            throw new PlanetException("planetRequest is not a PlanetGroupRequest."+
                    "  PlanetGroupModel only supports planet group requests.");
        }
       
        // extract planet object
        planet = planetGroupRequest.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 {
         
            // Add all JPA, OpenJPA, HibernateJPA, etc. properties found
            Properties emfProps = new Properties();
            Enumeration keys = WebloggerConfig.keys();
            while (keys.hasMoreElements()) {
                String key = (String) keys.nextElement();
                if (       key.startsWith("javax.persistence.")
                        || key.startsWith("openjpa.")
                        || key.startsWith("hibernate.")) {
                    String value = WebloggerConfig.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 {
                emf = Persistence.createEntityManagerFactory("PlanetPU", emfProps);
            } catch (PersistenceException pe) {
                logger.error("ERROR: creating entity manager", 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.