Example usage for org.apache.commons.lang UnhandledException UnhandledException

List of usage examples for org.apache.commons.lang UnhandledException UnhandledException

Introduction

In this page you can find the example usage for org.apache.commons.lang UnhandledException UnhandledException.

Prototype

public UnhandledException(Throwable cause) 

Source Link

Document

Constructs the exception using a cause.

Usage

From source file:ar.com.zauber.commons.web.proxy.impl.dao.properties.persister.FilesystemPropertiesPersister.java

/** @see PropertiesPersister#save(Properties) */
public final void save(final Properties properties) {
    try {//from   w w w  . j av a 2  s. c o  m
        final OutputStream os = new FileOutputStream(file);
        try {
            properties.storeToXML(os, new Date().toString());
        } finally {
            os.close();
        }
    } catch (final IOException e) {
        throw new UnhandledException(e);
    }

}

From source file:ar.com.zauber.commons.message.message.templates.AbstractMessagePartTemplate.java

/** Creates the AbstractMessagePartTemplate. */
public AbstractMessagePartTemplate(final Resource content, final String contentType, final String charset) {
    Validate.notNull(content);//from ww w  .j av a 2s . c o m
    Validate.notEmpty(contentType);

    final ByteArrayOutputStream os = copyResource(content);
    try {
        this.content = os.toString(charset);
    } catch (UnsupportedEncodingException e) {
        throw new UnhandledException(e);
    }
    this.contentType = contentType;
}

From source file:ar.com.zauber.commons.web.proxy.impl.dao.properties.provider.FilesystemPropertiesProvider.java

/** @see PropertiesProvider#getProperties() */
public Properties getProperties() {
    try {// w  w w .  j a  va 2  s . c  o m
        final Properties properties = new Properties();
        final InputStream is = new FileInputStream(file);
        try {
            properties.loadFromXML(is);
            return properties;
        } finally {
            is.close();
        }
    } catch (final IOException e) {
        throw new UnhandledException(e);
    }
}

From source file:ar.com.zauber.commons.spring.web.view.WrappedView.java

/** @see View#render(Map, HttpServletRequest, HttpServletResponse) */
public final void render(final Map model, final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {

    try {//from w  w  w.j  a  va 2s .com
        target.render(model, request, response);
    } catch (final Throwable e) {
        LOGGER.error("Error processing view", e);
        throw new UnhandledException(e);
    }
}

From source file:ar.com.zauber.commons.conversion.ConfigurableJavaBeanConverter.java

/** @see Converter#convert(Object, ConversionContext) */
public final T convert(final S source, final ConversionContext ctx) {
    try {/*from  w ww . j a va2  s.c  om*/
        T targetInstance = this.clazz.newInstance();
        map(source, targetInstance, ctx);
        return targetInstance;
    } catch (InstantiationException e) {
        throw new UnhandledException(e);
    } catch (IllegalAccessException e) {
        throw new UnhandledException(e);
    }
}

From source file:ar.com.zauber.commons.message.message.templates.AbstractMessageTemplate.java

/** Creates the AbstractMessageTemplate. */
public AbstractMessageTemplate(final Resource content, final String subject, final NotificationAddress address,
        final String charset) {
    Validate.notNull(content);//  ww  w . j  a va 2  s.c o m
    Validate.notNull(subject);
    Validate.notNull(address);

    final ByteArrayOutputStream os = copyResource(content);
    try {
        this.content = os.toString(charset);
    } catch (UnsupportedEncodingException e) {
        throw new UnhandledException(e);
    }
    this.subject = subject;
    this.address = address;
}

From source file:ar.com.zauber.commons.xmpp.roster.RosterSyncClosure.java

/** @see Closure#execute(Object) */
public final void execute(final MergeResult<String> closure) {
    final Roster roster = connection.getRoster();

    try {//from ww w .ja v  a  2 s .  c  om
        if (closure.getOperation() == Operation.ADD) {
            roster.createEntry(closure.getEntity(), null, null);
        } else if (closure.getOperation() == Operation.REMOVE) {
            roster.removeEntry(roster.getEntry(closure.getEntity()));
        }
    } catch (final XMPPException e) {
        throw new UnhandledException(e);
    }
}

From source file:com.zaubersoftware.mule.module.jenkins.template.velocity.VelocityTemplate.java

/**
 * Creates the VelocityTemplate./*from   www.  j a  v a  2s .  co m*/
 *
 */
public VelocityTemplate(final Resource content, final String charset) {
    Validate.notNull(content);
    Validate.notNull(charset);

    InputStream is = null;
    try {
        is = content.getInputStream();
        final ByteArrayOutputStream os = new ByteArrayOutputStream();
        IOUtils.copy(is, os);
        os.close();
        message = os.toString(charset);
    } catch (final IOException e) {
        throw new UnhandledException(e);
    } finally {
        IOUtils.closeQuietly(is);
    }
}

From source file:cc.recommenders.evaluation.distribution.Task.java

@Override
public void run() {
    try {//ww w  .j  av a  2  s .  c o m
        try {
            result = callable.call();
        } catch (Exception e) {
            caughtException = e;
        }
        scheduler.finished(this);
    } catch (RemoteException e) {
        throw new UnhandledException(e);
    }
}

From source file:gov.nih.nci.caarray.upgrade.SingleConnectionHibernateHelper.java

/**
 * @param connection//from   www  . jav  a2  s. co m
 */
public void initialize(Connection connection) {
    HibernateSingleConnectionProvider.setConnection(connection);

    InputStream configurationStream = FixIlluminaGenotypingCsvDesignProbeNamesMigrator.class
            .getResourceAsStream("/hibernate.cfg.xml");
    SAXReader reader = new SAXReader();
    reader.setEntityResolver(new org.hibernate.util.DTDEntityResolver());
    Document configurationDocument = null;
    try {
        configurationDocument = reader.read(configurationStream);
    } catch (DocumentException e) {
        throw new UnhandledException(e);
    }
    Node sessionFactoryNode = configurationDocument
            .selectSingleNode("/hibernate-configuration/session-factory");

    Iterator<?> iter = ((Branch) sessionFactoryNode).nodeIterator();
    while (iter.hasNext()) {
        Node currentNode = (Node) iter.next();
        if (currentNode.getNodeType() == Node.ELEMENT_NODE && !currentNode.getName().equals("mapping")) {
            iter.remove();
        }
    }

    DOMWriter domWriter = new DOMWriter();
    org.w3c.dom.Document document = null;
    try {
        document = domWriter.write(configurationDocument);
    } catch (DocumentException e) {
        throw new UnhandledException(e);
    }

    configuration = new AnnotationConfiguration();
    configuration.setProperty(Environment.CONNECTION_PROVIDER,
            "gov.nih.nci.caarray.upgrade.HibernateSingleConnectionProvider");

    configuration.configure(document);

    configuration.setProperty(Environment.TRANSACTION_STRATEGY,
            "org.hibernate.transaction.JDBCTransactionFactory");
    configuration.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
    configuration.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
    configuration.getProperties().remove(Environment.TRANSACTION_MANAGER_STRATEGY);
    configuration.setNamingStrategy(new NamingStrategy());

    sessionFactory = configuration.buildSessionFactory();
}