Example usage for java.lang Exception fillInStackTrace

List of usage examples for java.lang Exception fillInStackTrace

Introduction

In this page you can find the example usage for java.lang Exception fillInStackTrace.

Prototype

public synchronized Throwable fillInStackTrace() 

Source Link

Document

Fills in the execution stack trace.

Usage

From source file:org.alfresco.repo.search.impl.noindex.NoIndexIndexer.java

private void trace() {
    if (s_logger.isTraceEnabled()) {
        Exception e = new Exception();
        e.fillInStackTrace();

        StringBuilder sb = new StringBuilder(1024);
        StackTraceUtil.buildStackTrace("Index trace ...", e.getStackTrace(), sb, -1);
        s_logger.trace(sb);// ww w  .  j  a  v  a 2 s. c o  m
    }
}

From source file:org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerBean.java

/**
 * Remove the given definition with its attached schedules.
 *
 * @param def the MeasuremendDefinition to delete
 *//*from   w w  w. jav  a2  s . c  om*/
public void removeMeasurementDefinition(MeasurementDefinition def) {
    // First remove the schedules and associated OOBs.
    List<MeasurementSchedule> schedules = def.getSchedules();
    Iterator<MeasurementSchedule> schedIter = schedules.iterator();
    while (schedIter.hasNext()) {
        MeasurementSchedule sched = schedIter.next();
        if (sched.getBaseline() != null) {
            entityManager.remove(sched.getBaseline());
            sched.setBaseline(null);
        }
        oobManager.removeOOBsForSchedule(subjectManager.getOverlord(), sched);
        sched.getResource().setAgentSynchronizationNeeded();
        entityManager.remove(sched);
        schedIter.remove();
    }

    // Now remove the definition itself.
    try {
        if ((def.getId() != 0) && entityManager.contains(def)) {
            entityManager.remove(def);
        }
    } catch (EntityNotFoundException enfe) {
        if (log.isDebugEnabled()) {
            log.debug("Definition # " + def.getId() + " not found: " + enfe.getMessage());
        }
    } catch (PersistenceException pe) {
        if (log.isDebugEnabled()) {
            log.debug("Exception when deleting Definition # " + def.getId() + ": " + pe.getMessage());
        }
    } catch (Exception e) {
        log.warn(e.fillInStackTrace());
    }
}

From source file:org.uberfire.ext.metadata.io.LuceneSearchIndexTest.java

@Before
public void setup() throws IOException {
    if (!created) {
        final String path = createTempDirectory().getAbsolutePath();
        System.setProperty("org.uberfire.nio.git.dir", path);
        System.out.println(".niogit: " + path);

        for (String repositoryName : getRepositoryNames()) {

            final URI newRepo = URI.create("git://" + repositoryName);

            try {
                ioService().newFileSystem(newRepo, new HashMap<String, Object>());

                //Don't ask, but we need to write a single file first in order for indexing to work
                final Path basePath = getDirectoryPath(repositoryName).resolveSibling("someNewOtherPath");
                ioService().write(basePath.resolve("dummy"), "<none>");
                basePaths.put(repositoryName, basePath);

            } catch (final Exception ex) {
                ex.fillInStackTrace();
                System.out.println(ex.getMessage());
            } finally {
                created = true;//from   w ww  .ja  va 2 s  .c om
            }
        }
    }
}

From source file:org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest.java

@Before
public void setup() throws IOException {
    if (!created) {
        final String repositoryName = getRepositoryName();
        final String path = createTempDirectory().getAbsolutePath();
        System.setProperty("org.uberfire.nio.git.dir", path);
        System.out.println(".niogit: " + path);

        final URI newRepo = URI.create("git://" + repositoryName);

        try {/* w  w w .  j a v  a  2  s  .c o  m*/
            ioService().newFileSystem(newRepo, new HashMap<String, Object>());

            //Don't ask, but we need to write a single file first in order for indexing to work
            basePath = getDirectoryPath().resolveSibling("someNewOtherPath");
            ioService().write(basePath.resolve("dummy"), "<none>");

        } catch (final Exception ex) {
            ex.fillInStackTrace();
            System.out.println(ex.getMessage());
        } finally {
            created = true;
        }
    }
}

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.scripting.actions.LaunchGroovyConsoleAction.java

public void actionPerformed(ActionEvent event) {
    try {//  ww w  . j  av a 2s .c om
        if (groovyConsoleService != null) {
            logger.info("Launching Scripting console...");
            groovyConsoleService.launch();
        }
    } catch (Exception e) {
        String simpleMessage = "Error transitive closure table";
        applicationService.notifyError(simpleMessage, e, Level.WARNING);
        logger.warn(simpleMessage + "Nested exception is : " + e.fillInStackTrace().getMessage());
    }
}

From source file:org.openplans.delayfeeder.RouteStatus.java

private RouteFeedItem getLatestItem(String agency, String route, Session session) {
    RouteFeed feed = getFeed(agency, route, session);
    if (feed == null) {
        return null;
    }/*from  w  w  w . j  a v  a  2 s .c o m*/

    GregorianCalendar now = new GregorianCalendar();
    if (feed.lastFetched == null
            || now.getTimeInMillis() - feed.lastFetched.getTimeInMillis() > FEED_UPDATE_FREQUENCY) {

        try {
            refreshFeed(feed, session);
        } catch (Exception e) {
            e.printStackTrace();
            logger.warn(e.fillInStackTrace());
        }
    }

    Set<RouteFeedItem> list = feed.items;

    if (list.size() == 0) {
        return null;
    }
    RouteFeedItem item = (RouteFeedItem) list.toArray()[0];
    return item;
}

From source file:motej.Mote.java

public Mote(RemoteDevice device) {
    try {/*  w ww . j av a2 s  .c o m*/
        bluetoothAddress = device.getBluetoothAddress();

        outgoing = new OutgoingThread(device.getBluetoothAddress());
        incoming = new IncomingThread(this, device.getBluetoothAddress());

        incoming.start();
        outgoing.start();

        outgoing.sendRequest(new StatusInformationRequest());
        outgoing.sendRequest(new CalibrationDataRequest());
    } catch (Exception ex) {
        throw new RuntimeException(ex.fillInStackTrace());
    }
}

From source file:uk.nhs.cfh.dsp.snomed.converters.compositionalgrammar.parser.SnomedExpressionParserTest.java

/**
 * Test lex and parse./*w  ww .j av a 2 s  . c o m*/
 *
 * @throws Exception the exception
 */
public void testLexAndParse() throws Exception {

    // Parse the test file
    String source = testFile.getAbsolutePath();
    try {
        lexer.setCharStream(new ANTLRFileStream(source, "UTF8"));

        // Using the lexer as the token source, we create a token
        // stream to be consumed by the parser
        //
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        assertNotNull("Token passed by lexer must not be null", tokens);

        // Now we need an instance of our parser
        //
        SnomedExpressionParser parser = new SnomedExpressionParser(tokens);
        assertNotNull("Parser must not be null", parser);

        // Provide some user feedback
        //
        logger.info("    Lexer Start");
        long start = System.currentTimeMillis();
        tokens.LT(1);
        long lexerStop = System.currentTimeMillis();
        logger.info("      Lexed in " + (lexerStop - start) + "ms.");

        // And now we merely invoke the start rule for the parser
        //
        logger.info("    Parser Start");
        long pStart = System.currentTimeMillis();
        SnomedExpressionParser.snomed_return parserReturn = parser.snomed();
        assertNotNull("Parser return must not be null null", parserReturn);
        long stop = System.currentTimeMillis();
        logger.info("      Parsed in " + (stop - pStart) + "ms.");

        // Pick up the generic tree
        //
        CommonTree t = (CommonTree) parserReturn.getTree();
        assertNotNull("AST must not be null", t);
        String treeOutput = t.toStringTree();
        assertNotNull("Tree output must not be null", t);
        logger.info("treeOutput = " + treeOutput);

        CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
        nodes.setTokenStream(tokens);
        assertNotNull("Node stream must not be null", nodes);

        // NOw walk it with the generic tree walker, which does nothing but
        // verify the tree really.
        //
        try {
            if (parser.getNumberOfSyntaxErrors() == 0) {
                SnomedExpressionTree walker = new SnomedExpressionTree(nodes, testTerminologyDAO);
                assertNotNull("Expression tree must not be null", walker);
                logger.info("    AST Walk Start\n");
                pStart = System.currentTimeMillis();
                AbstractExpressionWithFocusConcepts returnedExpression = walker.expression();
                assertNotNull("Returned expression must not be null", returnedExpression);
                logger.info("returnedExpression = " + returnedExpression);
                stop = System.currentTimeMillis();
                logger.info("\n      AST Walked in " + (stop - pStart) + "ms.");
            }

            // output tree to a graphics file using DOT
            if (tokens.size() < 4096) {
                // Use the ANLTR built in dot generator
                //
                DOTTreeGenerator gen = new DOTTreeGenerator();
                assertNotNull("DOT generator must not be null", gen);
                source = source.substring(0, source.length() - 3);
                String outputName = source + "dot";
                logger.info("    Producing AST dot (graphviz) file");

                StringTemplate st = gen.toDOT(t, new CommonTreeAdaptor());
                assertNotNull("String template must not be null", st);
                // Create the output file and write the dot spec to it
                //
                FileWriter outputStream = new FileWriter(outputName);
                outputStream.write(st.toString());
                outputStream.close();

                //                    // Invoke dot to generate a .png file
                //                    //
                //                    logger.info("    Producing png graphic for tree");
                //                    pStart = System.currentTimeMillis();
                //                    Process proc = Runtime.getRuntime().exec("dot -Tpng -o" + source + "png " + outputName);
                //                    proc.waitFor();
                //                    File dotFile = new File(SnomedExpressionParserTest.class.getResource("test-expression.png").toURI());
                //                    assertTrue("File must exist", dotFile.exists());
                //                    stop = System.currentTimeMillis();
                //                    logger.info("      PNG graphic produced in " + (stop - pStart) + "ms.");
            }
        } catch (Exception e) {
            logger.warn("AST Walk caused an error. Nested exception is : " + e.fillInStackTrace());
        }
    } catch (FileNotFoundException ex) {
        // The file we tried to parse does not exist
        //
        logger.warn("\n  !!The file " + source + " does not exist!!\n");
    } catch (Exception ex) {
        // Something went wrong in the parser, report this
        logger.warn("Parser threw an exception. Nested exception is : " + ex.fillInStackTrace());
    }
}

From source file:org.uhp.portlets.news.web.ItemForm.java

public void addExternalAttachment(final String temporaryStoragePath, final String userPrefix) {
    if (getExternal().getTitle().length() > 1) {
        Attachment external = getExternal();

        String postfix = "." + String.valueOf(Calendar.getInstance().getTimeInMillis());
        String prefix = "";
        if (userPrefix != null) {
            prefix = userPrefix;//w ww.  ja v a  2 s.  c om
        } else if (item.getItemId() != null) {
            // Get the item id to prefix the filename
            prefix = String.valueOf(item.getItemId()) + "_";
        }

        File tmp = null;
        FileOutputStream outputStream = null;
        InputStream inputStream = null;
        try {
            File dir = new File(temporaryStoragePath);
            if (!dir.exists()) {
                dir.mkdir();
            }

            tmp = new File(
                    temporaryStoragePath + "/" + prefix + external.getFile().getOriginalFilename() + postfix);

            outputStream = new FileOutputStream(tmp);
            inputStream = external.getFile().getInputStream();
            byte[] buf = new byte[(int) external.getFile().getSize()];
            int len;
            while ((len = inputStream.read(buf)) > 0) {
                outputStream.write(buf, 0, len);
            }

        } catch (Exception e) {
            LOGGER.error(e, e.fillInStackTrace());
        } finally {
            try {
                if (outputStream != null) {
                    outputStream.close();
                }
                if (inputStream != null) {
                    inputStream.close();
                }
            } catch (IOException e) {
                LOGGER.error(e, e.fillInStackTrace());
            }
        }
        if (tmp != null) {
            external.setTempDiskStoredFile(tmp);
            external.setMimeType(external.getFile().getContentType());
            getAttachments().add(external);
        }
        setExternal(new Attachment());
    }
}

From source file:com.uphyca.kitkat.storage.internal.impl.LiveSdkSkyDriveClient.java

@Override
public void login(final Activity activity, final SkyDriveAuthListener listener) {
    mLiveAuthClient.login(activity, SCOPES, new LiveAuthListener() {
        @Override//from  w ww.jav  a 2s.  co m
        public void onAuthComplete(LiveStatus status, LiveConnectSession session, Object userState) {
            if (status == LiveStatus.CONNECTED) {
                mLiveConnectClient = new LiveConnectClient(session);
                listener.onAuthComplete();
                return;
            }
            Exception e = new RuntimeException("Login did not connect. Status is " + status + ".");
            e.fillInStackTrace();
            listener.onAuthError(e);
        }

        @Override
        public void onAuthError(LiveAuthException exception, Object userState) {
            Exception e = new RuntimeException(exception);
            listener.onAuthError(e);
        }
    });
}