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.repository.SpringHibernateRepository.java

/** @see Repository#createNew(Reference)*/
@SuppressWarnings("unchecked")
public final <T extends Persistible> T createNew(final Reference<T> aRef) {
    T persistible = null;//from w  w  w.  j  a v a2 s .c o  m

    try {
        persistible = (T) Class.forName(aRef.getClassName()).newInstance();
    } catch (final InstantiationException e) {
        throw new UnhandledException(e);
    } catch (final IllegalAccessException e) {
        throw new UnhandledException(e);
    } catch (final ClassNotFoundException e) {
        throw new UnhandledException(e);
    }

    return persistible;
}

From source file:de.iteratec.iteraplan.presentation.tags.StringEscapeUtilsFunction.java

private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes,
        boolean escapeForwardSlash) {
    if (str == null) {
        return null;
    }//from  w  ww .  j a  v a  2s.c  o m
    try {
        StringWriter writer = new StringWriter(str.length() * 2);
        escapeJavaStyleString(writer, str, escapeSingleQuotes, escapeForwardSlash);
        return writer.toString();
    } catch (IOException ioe) {
        // this should never ever happen while writing to a StringWriter
        throw new UnhandledException(ioe);
    }
}

From source file:ar.com.zauber.commons.web.transformation.processors.impl.DocumentBuilderFactoryDocumentProvider.java

/** @see DocumentProvider#serialize(Document, OutputStream) */
public final void serialize(final Document document, final OutputStream os) {
    try {// w w w .  ja v  a 2 s .  co m
        TransformerFactory.newInstance().newTransformer().transform(new DOMSource(document),
                new StreamResult(os));
        os.flush();
    } catch (IOException e) {
        throw new UnhandledException(e);
    } catch (TransformerException e) {
        throw new UnhandledException(e);
    }
}

From source file:hr.fer.zemris.vhdllab.platform.preference.DatabasePreferences.java

@Override
protected void flushSpi() throws BackingStoreException {
    Properties props = getProperties();
    if (!props.isEmpty()) {
        StringWriter writer = new StringWriter();
        try {//from www .  j  a  v  a2s .  c  o  m
            props.store(writer, null);
        } catch (IOException e) {
            throw new UnhandledException(e);
        }
        PreferencesFile file = getFile();
        String data = writer.toString();
        if (file == null) {
            file = new PreferencesFile(absolutePath(), data);
        } else {
            file.setData(data);
        }
        manager.setFile(file);
    }
}

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

/**
 * @param content/*from w  w  w. ja  v a2  s  .  c  om*/
 * @return
 */
protected final ByteArrayOutputStream copyResource(final Resource content) {
    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    final InputStream is = content.getInputStream();
    try {
        copyLarge(is, os);
    } catch (final IOException e) {
        throw new UnhandledException(e);
    } finally {
        try {
            is.close();
        } catch (final IOException e) {
            throw new UnhandledException(e);
        }
    }
    return os;
}

From source file:ar.com.zauber.commons.xmpp.message.XMPPMessageAttributes.java

/** lee un resource en un string */
private static String read(final Resource resource) {
    Validate.notNull(resource);//from ww  w .j  a v  a 2  s .com
    final InputStream is = resource.getInputStream();
    final ByteArrayOutputStream os = new ByteArrayOutputStream();

    try {
        IOUtils.copy(is, os);
        return os.toString();
    } catch (IOException e) {
        throw new UnhandledException(e);
    } finally {
        IOUtils.closeQuietly(is);
    }
}

From source file:de.awtools.xml.TransformerUtils.java

/**
 * Eine <code>InputStream</code> mit XSL Daten.
 *
 * @param xsltStream <code>InputStream</code> mit XSL Daten.
 * @param resolver Ein <code>URIResolver</code>. Darf <code>null</code>
 *  sein./*from   w w w  .  j  a va 2 s . com*/
 * @return Ein <code>Transformer</code>
 */
public static Transformer getTransformer(final InputStream xsltStream, final URIResolver resolver) {

    Validate.notNull(xsltStream, "xsltStream not set");

    Source source = new StreamSource(xsltStream);
    TransformerFactory factory = TransformerFactory.newInstance();
    if (resolver != null) {
        factory.setURIResolver(resolver);
    }

    try {
        return factory.newTransformer(source);
    } catch (TransformerConfigurationException ex) {
        log.debug("Fehler:", ex);
        throw new UnhandledException(ex);
    }
}

From source file:ar.com.zauber.commons.xmpp.message.XMPPMessageTemplate.java

/** @see XMPPMessage#XMPPMessage(String, String) */
public XMPPMessageTemplate(final Resource defaultContent, final String defaultSubject, final String charset) {
    Validate.notNull(defaultContent); // "" es valido
    Validate.notNull(defaultSubject); // "" es valido
    // charset can be null

    final InputStream is = defaultContent.getInputStream();
    final ByteArrayOutputStream os = new ByteArrayOutputStream();

    try {/*from  w  w w . ja  va2 s.  c om*/
        final Reader reader = (charset == null) ? new InputStreamReader(is)
                : new InputStreamReader(is, charset);
        IOUtils.copy(reader, os);
    } catch (final IOException e) {
        throw new UnhandledException(e);
    } finally {
        IOUtils.closeQuietly(is);
    }
    this.defaultContent = os.toString();
    this.defaultSubject = defaultSubject;
}

From source file:ar.com.zauber.commons.web.proxy.impl.RegexURLRequestMapper.java

/** @see URLRequestMapper#getProxiedURLFromRequest(HttpServletRequest) */
public final URLResult getProxiedURLFromRequest(final HttpServletRequest request) {
    final Matcher m = regex.matcher(getRequestURI(request));
    final URLResult ret;

    if (m.matches()) {
        final String uri = m.replaceAll(replacePattern);
        try {/*from w  w w .j  ava  2s  .co  m*/
            if (base == null) {
                ret = new InmutableURLResult(new URL(uri));
            } else {
                final URLResult r = base.getProxiedURLFromRequest(request);
                if (r.hasResult()) {
                    ret = new InmutableURLResult(new URL(r.getURL().toExternalForm() + uri));
                } else {
                    ret = r;
                }
            }
        } catch (final MalformedURLException e) {
            throw new UnhandledException(e);
        }
    } else {
        ret = new InmutableURLResult();
    }

    return ret;
}

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

/**
 * @param connection the JDBC connection to use
 *//*from  w ww. j a  v  a2s  . c  o  m*/
public void execute(Connection connection) {
    final Injector injector = createInjector();

    final SingleConnectionHibernateHelper hibernateHelper = createHibernateHelper(connection, injector);

    final FileDao fileDao = injector.getInstance(FileDao.class);
    final Set<DesignFileHandler> handlers = getAllDesignHandlers(fileDao);

    final Transaction transaction = hibernateHelper.beginTransaction();
    try {
        final ArrayDao arrayDao = injector.getInstance(ArrayDao.class);

        final List<Long> arrayDesignIds = getArrayDesignIds(hibernateHelper, arrayDao);
        hibernateHelper.getCurrentSession().clear();

        fixArrayDesigns(handlers, arrayDao, arrayDesignIds);

        transaction.commit();
    } catch (final Exception e) {
        transaction.rollback();
        throw new UnhandledException(e);
    }
}