Search in sources :

Example 6 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class JobScheduleTest method testProcessingExceptionWithRunnable.

@Test
public void testProcessingExceptionWithRunnable() {
    final ProcessingException exception = new ProcessingException("expected JUnit test exception");
    IFuture<Void> future = Jobs.getJobManager().schedule(new IRunnable() {

        @Override
        public void run() throws Exception {
            throw exception;
        }
    }, Jobs.newInput().withRunContext(RunContexts.copyCurrent()).withExceptionHandling(null, false));
    try {
        future.awaitDoneAndGet();
        fail("Exception expected");
    } catch (Exception e) {
        assertSame(exception, e);
        assertTrue(future.isDone());
    }
}
Also used : IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) AssertionException(org.eclipse.scout.rt.platform.util.Assertions.AssertionException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) Test(org.junit.Test)

Example 7 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class AbstractSmartColumn2 method initConfig.

@Override
protected void initConfig() {
    super.initConfig();
    m_contributionHolder = new ContributionComposite(this);
    setSortCodesByDisplayText(getConfiguredSortCodesByDisplayText());
    // code type
    if (getConfiguredCodeType() != null) {
        setCodeTypeClass(getConfiguredCodeType());
    }
    // lazy lookup decorator
    Class<? extends ILookupCall<VALUE>> lookupCallClass = getConfiguredLookupCall();
    if (lookupCallClass != null) {
        ILookupCall<VALUE> call;
        try {
            call = BEANS.get(lookupCallClass);
            setLookupCall(call);
        } catch (Exception e) {
            BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error creating instance of class '" + lookupCallClass.getName() + "'.", e));
        }
    }
}
Also used : ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 8 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class SVGUtility method writeSVGDocument.

public static void writeSVGDocument(SVGDocument doc, OutputStream out, String encoding) {
    try {
        DOMSource domSource = new DOMSource(doc);
        StreamResult streamResult = new StreamResult(out);
        Transformer t = XmlUtility.newTransformer();
        if (encoding != null) {
            t.setOutputProperty("encoding", encoding);
        }
        t.transform(domSource, streamResult);
    } catch (TransformerException e) {
        throw new ProcessingException("Writing SVG Failed", e);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) TransformerException(javax.xml.transform.TransformerException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 9 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class SVGUtility method readSVGDocument.

/**
 * Parses a SVG document read by the given input stream. The document returned can be modified on XML-level. If you
 * need to perform any CSS, text size and and bounding box operations use
 * {@link #readSVGDocumentForGraphicalModification(InputStream)} instead.
 *
 * @param in
 *          input stream the SVG document is read from.
 * @return Returns the SVG document.
 */
public static SVGDocument readSVGDocument(InputStream in) {
    String cn;
    try {
        cn = Class.forName("org.apache.xerces.parsers.SAXParser").getName();
    } catch (ClassNotFoundException t) {
        // NOSONAR
        try {
            cn = Class.forName("com.sun.org.apache.xerces.internal.parsers.SAXParser").getName();
        } catch (ClassNotFoundException e) {
            throw new ProcessingException("Could not find SAXParser", e);
        }
    }
    SAXSVGDocumentFactory documentFactory = new SAXSVGDocumentFactory(cn);
    documentFactory.setValidating(false);
    SVGDocument doc;
    try {
        doc = documentFactory.createSVGDocument(null, in);
    } catch (Exception e) {
        throw new ProcessingException("Reading SVG Failed", e);
    }
    try {
        // needed to make anchors work but only works in dom level 3
        doc.setDocumentURI("urn:svg");
    } catch (RuntimeException e) {
        LOG.debug("Could not set document uri. Dom level seems to be lass than version 3", e);
    }
    return doc;
}
Also used : SAXSVGDocumentFactory(org.apache.batik.dom.svg.SAXSVGDocumentFactory) SVGDocument(org.w3c.dom.svg.SVGDocument) TransformerException(javax.xml.transform.TransformerException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 10 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class JsonSvgField method svgToString.

protected String svgToString(SVGDocument svg) {
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        SVGUtility.writeSVGDocument(svg, out, SVG_ENCODING);
        return new String(out.toByteArray(), SVG_ENCODING);
    } catch (UnsupportedEncodingException | ProcessingException e) {
        throw new UiException("Failed to write SVG document", e);
    }
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UiException(org.eclipse.scout.rt.ui.html.UiException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Aggregations

ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)142 IOException (java.io.IOException)48 MessagingException (javax.mail.MessagingException)21 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)17 File (java.io.File)14 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)12 Folder (javax.mail.Folder)10 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)9 RemoteFile (org.eclipse.scout.rt.shared.services.common.file.RemoteFile)9 NoSuchProviderException (java.security.NoSuchProviderException)8 AssertionException (org.eclipse.scout.rt.platform.util.Assertions.AssertionException)8 FileInputStream (java.io.FileInputStream)7 InputStream (java.io.InputStream)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 FileOutputStream (java.io.FileOutputStream)6 Message (javax.mail.Message)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 OutputStream (java.io.OutputStream)5 HashMap (java.util.HashMap)5