Package org.apache.roller.weblogger

Examples of org.apache.roller.weblogger.WebloggerException


            } catch (WebloggerException ex) {
                log.error("Error getting category by id", ex);
            }
           
            if(cat == null) {
                throw new WebloggerException("Category could not be found - "+getCategoryId());
            } else if(!entry.getWebsite().equals(cat.getWebsite())) {
                throw new WebloggerException("Illegal category, not owned by action weblog");
            } else {
                entry.setCategory(cat);
            }
        } else {
            throw new WebloggerException("No category specified");
        }
       
        // join values from all plugins into a single string
        entry.setPlugins(StringUtils.join(getPlugins(),","));
       
View Full Code Here


        if ("jndi".equals(jpaConfigurationType)) {
            String emfJndiName = "java:comp/env/" + WebloggerConfig.getProperty("jpa.emf.jndi.name");
            try {
                emf = (EntityManagerFactory) new InitialContext().lookup(emfJndiName);
            } catch (NamingException e) {
                throw new WebloggerException("Could not look up EntityManagerFactory in jndi at " + emfJndiName, e);
            }
        } else {

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

            // Add all OpenJPA and Toplinks properties found in WebloggerConfig
            Enumeration keys = WebloggerConfig.keys();
            while (keys.hasMoreElements()) {
                String key = (String) keys.nextElement();
                if (key.startsWith("openjpa.") || key.startsWith("toplink.")) {
                    String value = WebloggerConfig.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("RollerPU", emfProps);
            } catch (PersistenceException pe) {
                logger.error("ERROR: creating entity manager", pe);
                throw new WebloggerException(pe);
            }
        }
    }
View Full Code Here

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

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

    /**
     * Apply ignoreWord/spam filters to all referers in website.
     */
    public void applyRefererFilters(Weblog website)
            throws WebloggerException {
        if (null == website) throw new WebloggerException("website is null");
        if (null == website.getBlacklist()) return;
       
        String[] blacklist = StringUtils.split(
                StringUtils.deleteWhitespace(website.getBlacklist()),",");
        if (blacklist.length == 0) return;
View Full Code Here

     */
    public List getReferersToDate(Weblog website, String date)
            throws WebloggerException {

        if (website==null )
            throw new WebloggerException("website is null");
       
        if (date==null )
            throw new WebloggerException("Date is null");
       
        Query q = strategy.getNamedQuery(
            "WeblogReferrer.getByWebsite&DateString&DuplicateOrderByTotalHitsDesc");
        q.setParameter(1, website);
        q.setParameter(2, date);
View Full Code Here

     * @return List of WeblogReferrer objects.
     * @throws org.apache.roller.weblogger.WebloggerException
     */
    public List getReferersToEntry(String entryid) throws WebloggerException {
        if (null == entryid)
            throw new WebloggerException("entryid is null");
        //TODO: DataMapperPort: Change calling code to pass WeblogEntry instead of id
        // we should change calling code to pass instance of WeblogEntry instead
        // of extracting and passing id. Once that is done, change the code below to
        // skip the load (Please note that the load below will always find the enty in cache)
        Query q = strategy.getNamedQuery(
View Full Code Here

    public static void sendPendingEntryNotice(WeblogEntry entry)
            throws WebloggerException {
       
        Session mailSession = WebloggerStartup.getMailProvider().getSession();
        if(mailSession == null) {
            throw new WebloggerException("Couldn't get mail Session");
        }
       
        try {
            UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
           
View Full Code Here

                                            User user)
            throws WebloggerException {
       
        Session mailSession = WebloggerStartup.getMailProvider().getSession();
        if(mailSession == null) {
            throw new WebloggerException("ERROR: Notification email(s) not sent, "
                    + "Roller's mail session not properly configured");
        }
       
        try {
            UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
           
            String userName = user.getUserName();
            String from = website.getEmailAddress();
            String cc[] = new String[] {from};
            String bcc[] = new String[0];
            String to[] = new String[] {user.getEmailAddress()};
            String subject;
            String content;
           
            // Figure URL to entry edit page
            String rootURL = WebloggerRuntimeConfig.getAbsoluteContextURL();
            String url = rootURL + "/roller-ui/menu.rol";
           
            ResourceBundle resources = ResourceBundle.getBundle(
                    "ApplicationResources",
                    website.getLocaleInstance());
            StringBuffer sb = new StringBuffer();
            sb.append(MessageFormat.format(
                    resources.getString("inviteMember.notificationSubject"),
                    new Object[] {
                website.getName(),
                website.getHandle()})
                );
            subject = sb.toString();
            sb = new StringBuffer();
            sb.append(MessageFormat.format(
                    resources.getString("inviteMember.notificationContent"),
                    new Object[] {
                website.getName(),
                website.getHandle(),
                user.getUserName(),
                url
            }));
            content = sb.toString();
            MailUtil.sendTextMessage(
                    from, to, cc, bcc, subject, content);
        } catch (MessagingException e) {
            throw new WebloggerException("ERROR: Notification email(s) not sent, "
                    + "due to Roller configuration or mail server problem.", e);
        }
    }
View Full Code Here

    public static void sendUserActivationEmail(User user)
            throws WebloggerException {
       
        Session mailSession = WebloggerStartup.getMailProvider().getSession();
        if(mailSession == null) {
            throw new WebloggerException("ERROR: Notification email(s) not sent, "
                    + "Roller's mail session not properly configured");
        }
       
        try {
            ResourceBundle resources = ResourceBundle.getBundle(
                    "ApplicationResources", I18nUtils.toLocale(user.getLocale()));
           
            String from = WebloggerRuntimeConfig.getProperty(
                    "user.account.activation.mail.from");
           
            String cc[] = new String[0];
            String bcc[] = new String[0];
            String to[] = new String[] { user.getEmailAddress() };
            String subject = resources.getString(
                    "user.account.activation.mail.subject");
            String content;
           
            String rootURL = WebloggerRuntimeConfig.getAbsoluteContextURL();
           
            StringBuffer sb = new StringBuffer();
           
            // activationURL=
            String activationURL = rootURL
                    + "/roller-ui/register!activate.rol?activationCode="
                    + user.getActivationCode();
            sb.append(MessageFormat.format(
                    resources.getString("user.account.activation.mail.content"),
                    new Object[] { user.getFullName(), user.getUserName(),
                    activationURL }));
            content = sb.toString();
           
            sendHTMLMessage(from, to, cc, bcc, subject, content);
        } catch (MessagingException e) {
            throw new WebloggerException("ERROR: Problem sending activation email.", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.WebloggerException

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.