Example usage for org.apache.commons.lang3.exception ExceptionUtils getRootCauseMessage

List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getRootCauseMessage

Introduction

In this page you can find the example usage for org.apache.commons.lang3.exception ExceptionUtils getRootCauseMessage.

Prototype

public static String getRootCauseMessage(final Throwable th) 

Source Link

Document

Gets a short message summarising the root cause exception.

Usage

From source file:org.mrobson.example.hibernates2i.cxfhibernate.service.PersonRestService.java

@SuppressWarnings("deprecation")
@POST//from  w  w  w  .ja va2 s  .  c om
@Path("/addPerson/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Adding a new Person")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The person has been saved"),
        @ApiResponse(code = 400, message = "Persistence exception"),
        @ApiResponse(code = 500, message = "Invalid Person") })
public Response savePerson(Person ps) throws ApplicationException {
    LOG.info("Invoking savePerson, Person name is: {}", ps.getFirstName());
    Person savedPs = null;
    try {
        savedPs = personService.savePersonWS(ps);
    } catch (Exception e) {
        throw new ApplicationException("Could not save person: " + ps.toString() + " Cause: "
                + ExceptionUtils.getCause(e) + " Error: " + ExceptionUtils.getRootCauseMessage(e));
    }
    return Response.ok().entity(savedPs).build();
}

From source file:org.neo4art.importer.wikipedia.transformer.WikipediaElementTransformer.java

public static WikipediaElement toWikipediaElement(WikiArticle article) {

    WikipediaElement wikipediaElement = null;

    WikiPatternMatcher articleTextParser = null;

    try {//from   w  w  w.jav  a  2 s.  c o  m

        if (StringUtils.isNotEmpty(article.getText())) {
            articleTextParser = new WikiPatternMatcher(article.getText());
        }

        if ((wikipediaElement = from(article, articleTextParser)) != null) {

            wikipediaElement.setId(Long.parseLong(article.getId()));
            wikipediaElement.setTitle(article.getTitle());
            wikipediaElement.setRevision(Long.parseLong(article.getRevisionId()));
            wikipediaElement
                    .setTimestamp(DatatypeConverter.parseDateTime(article.getTimeStamp()).getTimeInMillis());

            if (articleTextParser != null) {

                // ----- LINKS -----
                List<String> links = articleTextParser.getLinks();
                if (CollectionUtils.isNotEmpty(links)) {
                    for (String link : links) {
                        WikipediaPage page = new WikipediaPage();
                        page.setTitle(link);
                        wikipediaElement.addLink(page);
                    }
                }

                // ----- CATEGORIES -----
                List<String> categorieNames = articleTextParser.getCategories();
                if (CollectionUtils.isNotEmpty(categorieNames)) {
                    for (String categoryName : categorieNames) {
                        WikipediaCategory category = new WikipediaCategory();
                        category.setTitle(categoryName);
                        wikipediaElement.addCategory(category);
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        logger.error(
                "Error parsing article " + article.getTitle() + " : " + ExceptionUtils.getRootCauseMessage(e));
    }

    return wikipediaElement;
}

From source file:org.opentestsystem.ap.iat.filter.AppendSessionZuulPreFilter.java

private String getAccessToken() {
    try {/*from   www .j a  v a 2  s. c o m*/
        return retrieveAccessTokenFromProvider();
    } catch (Exception e) {
        log.info("Retry access token retrieval, {}", ExceptionUtils.getRootCauseMessage(e));
        resetRestTemplate();
        return retrieveAccessTokenFromProvider();
    }
}

From source file:org.rm3l.ddwrt.DDWRTMainActivity.java

@Override
public void onRouterActionFailure(@NotNull RouterAction routerAction, @NotNull Router router,
        @Nullable Exception exception) {
    Utils.displayMessage(this, String.format("Error on action '%s': %s", routerAction.toString().toLowerCase(),
            ExceptionUtils.getRootCauseMessage(exception)), Style.ALERT);
}

From source file:org.rm3l.ddwrt.tiles.services.vpn.OpenVPNClientTile.java

@Override
public void onRouterActionFailure(@NotNull RouterAction routerAction, @NotNull Router router,
        @Nullable Exception exception) {
    Utils.displayMessage(mParentFragmentActivity,
            String.format("Error: %s", ExceptionUtils.getRootCauseMessage(exception)), Style.ALERT);
}

From source file:org.thelq.stackexchange.dbimport.gui.GUI.java

protected void showErrorDialog(Exception ex, String title, String messageRaw) {
    String root = "";
    if (ex.getCause() != null)
        root = "\n" + ExceptionUtils.getRootCauseMessage(ex);
    String message = "";
    if (!StringUtils.isBlank(messageRaw))
        message = "\n" + messageRaw.trim();
    JOptionPane.showMessageDialog(frame, title + message + "\n\nError: " + ex.getLocalizedMessage() + root
            + "\nSee Log for more information", title, JOptionPane.ERROR_MESSAGE);
}

From source file:org.waastad.tomeedsvalidation.entity.CustomerTest.java

@Test
public void test10() throws Exception {
    Customer c = new Customer("name");
    try {/*from  w ww . j a va2s  .  c  o m*/
        customerRepository.save(c);
        fail("Should fail on missing transaction....");
    } catch (Exception e) {
        System.out.println(ExceptionUtils.getRootCauseMessage(e));
    }
}

From source file:org.xwiki.component.internal.ContextComponentManagerProvider.java

@Override
public ComponentManager get() {
    ComponentManager componentManagerToUse;

    // Look for the Context Component Manager so that Macros can be registered for a specific user, for a
    // specific wiki, etc. If it's not found use the Root Component Manager. This allows the Rendering module
    // to work outside of XWiki when there's no notion of Execution Context and Wiki Model for example.
    try {/*from  www.  j  a  va 2s .c o  m*/
        componentManagerToUse = this.rootComponentManager.getInstance(ComponentManager.class, "context");
    } catch (ComponentLookupException e) {
        // This means the Context CM doesn't exist, use the Root CM.
        componentManagerToUse = this.rootComponentManager;
        this.logger
                .debug("Failed to find the [context] Component Manager. Cause: [{}]. Using the Root Component "
                        + "Manager", ExceptionUtils.getRootCauseMessage(e));
    }

    return componentManagerToUse;
}

From source file:org.xwiki.component.wiki.internal.bridge.WikiObjectComponentManagerEventListenerProxy.java

/**
 * This method uses the given objectReference and a XWikiDocument that is the source of every
 * {@link com.xpn.xwiki.internal.event.XObjectEvent} to build and register the component(s) contained in
 * this entity reference.//from   w ww . j ava 2 s.  co m
 *
 * @param objectReference the reference containing the parameters needed to instanciate the new component(s)
 * @param baseObject the base object corresponding to the XObject
 * @param componentBuilder the builder that should be used in order to build the component
 */
public void registerObjectComponents(ObjectReference objectReference, BaseObject baseObject,
        WikiObjectComponentBuilder componentBuilder) {
    // Unregister all wiki components registered under the given entity. We do this as otherwise we would need to
    // handle the specific cases of elements added, elements updated and elements deleted, etc.
    // Instead we unregister all wiki components and re-register them all.
    this.wikiComponentManagerEventListenerHelper.unregisterComponents(objectReference);

    try {
        /* If we are dealing with a WikiBaseObjectComponentBuilder, we directly get the base object corresponding to
         * the current event and build the components from it. */
        List<WikiComponent> wikiComponents;
        if (componentBuilder instanceof WikiBaseObjectComponentBuilder) {
            wikiComponents = ((WikiBaseObjectComponentBuilder) componentBuilder).buildComponents(baseObject);
        } else {
            wikiComponents = componentBuilder.buildComponents(objectReference);
        }

        this.wikiComponentManagerEventListenerHelper.registerComponentList(wikiComponents);
    } catch (WikiComponentException e) {
        logger.warn(String.format("Unable to register the component associated to [%s]: %s", objectReference,
                ExceptionUtils.getRootCauseMessage(e)));
    }
}

From source file:org.xwiki.component.wiki.internal.DefaultWikiComponentManagerEventListener.java

/**
 * Register wiki components from a given document.
 * //from www  . j  ava  2s  .c  o m
 * @param document the document to register the components for
 */
private void registerComponents(DocumentModelBridge document) {
    DocumentReference documentReference = document.getDocumentReference();

    // Unregister all wiki components registered under this document. We do this as otherwise we would need to
    // handle the specific cases of xobject added, xobject updated, xobject deleted, etc. Instead we unregister
    // all wiki components and re-register them all.
    unregisterComponents(documentReference);

    // Re-register all wiki components in the passed document
    for (WikiComponentBuilder provider : this.wikiComponentProviders) {
        // Check whether the given document has a wiki component defined in it.
        if (provider.getDocumentReferences().contains(documentReference)) {
            try {
                List<WikiComponent> components = provider.buildComponents(documentReference);
                for (WikiComponent component : components) {
                    // Register the component.
                    try {
                        this.wikiComponentManager.registerWikiComponent(component);
                    } catch (WikiComponentException e) {
                        this.logger.warn("Unable to register component(s) from document [{}]: {}",
                                component.getDocumentReference(), ExceptionUtils.getRootCauseMessage(e));
                    }
                }
            } catch (WikiComponentException e) {
                this.logger.warn("Failed to create wiki component(s) for document [{}]: {}", documentReference,
                        ExceptionUtils.getRootCauseMessage(e));
            }
            break;
        }
    }
}