Package com.cedarsolutions.exception

Examples of com.cedarsolutions.exception.CedarRuntimeException


            if (!StringUtils.isEmpty(emailAddress) && !StringUtils.isEmpty(fullName)) {
                return new InternetAddress(emailAddress, fullName);
            } else if (!StringUtils.isEmpty(emailAddress)) {
                return new InternetAddress(emailAddress);
            } else {
                throw new CedarRuntimeException("Must provide email address; full name is optional.");
            }
        } catch (Exception e) {
            throw new CedarRuntimeException("Unable to create internet address: " + e.getMessage(), e);
        }
    }
View Full Code Here


                                          List<InternetAddress> recipients,
                                          InternetAddress replyTo,
                                          String subject, String plaintext) {
        try {
            if (StringUtils.isEmpty(plaintext)) {
                throw new CedarRuntimeException("Must provide plaintext body.");
            }

            Message message = createBasicMessage(sender, recipients, replyTo, subject);
            message.setText(plaintext);
            return message;
        } catch (CedarRuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to create message: " + e.getMessage(), e);
        }
    }
View Full Code Here

            // Ick!  This is incredibly ugly.  I don't quite understand why there
            // is not an easier way to generate a multipart/alternative message.
            // However, this seems to work, so we'll go with it.

            if (StringUtils.isEmpty(plaintext) || StringUtils.isEmpty(html)) {
                throw new CedarRuntimeException("Must provide HTML and plaintext parts.");
            }

            MimeBodyPart plaintextPart = new MimeBodyPart();
            plaintextPart.setText(plaintext);
            plaintextPart.addHeaderLine("Content-Type: text/plain; charset=\"" + CHARSET + "\"");
            plaintextPart.addHeaderLine("Content-Transfer-Encoding: quoted-printable");

            MimeBodyPart htmlPart = new MimeBodyPart();
            htmlPart.setText(html);
            htmlPart.addHeaderLine("Content-Type: text/html; charset=\"" + CHARSET + "\"");
            htmlPart.addHeaderLine("Content-Transfer-Encoding: quoted-printable");

            Multipart content = new MimeMultipart("alternative");
            content.addBodyPart(plaintextPart);
            content.addBodyPart(htmlPart);

            Message message = createBasicMessage(sender, recipients, replyTo, subject);
            message.setContent(content);
            return message;
        } catch (CedarRuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to create message: " + e.getMessage(), e);
        }
    }
View Full Code Here

                                       List<InternetAddress> recipients,
                                       InternetAddress replyTo,
                                       String subject) throws MessagingException {

        if (sender == null) {
            throw new CedarRuntimeException("Must provide sender.");
        }

        if (recipients == null || recipients.isEmpty()) {
            throw new CedarRuntimeException("Must provide recipients.");
        }

        if (StringUtils.isEmpty(subject)) {
            throw new CedarRuntimeException("Must provide subject.");
        }

        Session session = Session.getDefaultInstance(new Properties(), null);
        Message message = new MimeMessage(session);
        message.setFrom(sender);
View Full Code Here

     */
    public Template getTemplate(String templateDir, String template) {
        try {
            return getEngine(templateDir).getTemplate(template);
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to find template [" + template + "] in [" + templateDir + "]: " + e.getMessage(), e);
        }
    }
View Full Code Here

                engine.setProperty("runtime.log.logsystem.log4j.logger", LOGGER.getName());
                engine.setProperty("runtime.references.strict", "true");
                engine.init();
                this.engines.put(templateDir, engine);
            } catch (Exception e) {
                throw new CedarRuntimeException("Failed to initialize Velocity engine: " + e.getMessage(), e);
            }
        }

        return this.engines.get(templateDir);
    }
View Full Code Here

            ProcessBuilder pb = new ProcessBuilder(command);
            pb.redirectErrorStream(redirectErrorStream);
            pb.directory(new File(workingDirectory));
            return pb.start();
        } catch (Exception e) {
            throw new CedarRuntimeException("Error starting process: " + e.getMessage(), e);
        }
    }
View Full Code Here

     */
    public static String formatJodaDate(DateTime date, String format, Locale locale) {
        try {
            return date == null ? "" : DateTimeFormat.forPattern(format).withLocale(locale).print(date);
        } catch (Exception e) {
            throw new CedarRuntimeException("Unable to format date using format [" + format + "]");
        }
    }
View Full Code Here

     */
    public static DateTime parseJodaDate(String date, String format) {
        try {
            return date == null ? null : DateTimeFormat.forPattern(format).parseDateTime(date);
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to parsed date [" + date + "] using format [" + format + "]");
        }
    }
View Full Code Here

     */
    public static DateTime parseJodaDate(String date, String format, DateTimeZone zone) {
        try {
            return date == null ? null : DateTimeFormat.forPattern(format).withZone(zone).parseDateTime(date);
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to parsed date [" + date + "] using format [" + format + "]");
        }
    }
View Full Code Here

TOP

Related Classes of com.cedarsolutions.exception.CedarRuntimeException

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.