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.xwiki.index.tree.internal.nestedpages.FarmTreeNode.java

private Collection<String> getWikiIds() {
    try {/*from   w  ww . j  a  v  a  2  s  .c om*/
        return this.wikiDescriptorManager.getAllIds();
    } catch (WikiManagerException e) {
        this.logger.warn("Failed to retrieve the list of wikis. Root cause [{}].",
                ExceptionUtils.getRootCauseMessage(e));
        return Collections.emptyList();
    }
}

From source file:org.xwiki.index.tree.internal.nestedpages.ObjectsOfTypeTreeNode.java

@Override
public List<String> getChildren(String nodeId, int offset, int limit) {
    DocumentReference[] parts = resolve(nodeId);
    if (parts != null) {
        try {//from w w w  .j  a va2 s.  c o  m
            List<String> children = new ArrayList<String>();
            for (ObjectReference objectReference : subList(getXObjectReferences(parts[0], parts[1]), offset,
                    limit)) {
                children.add("object:" + this.defaultEntityReferenceSerializer.serialize(objectReference));
            }
            return children;
        } catch (Exception e) {
            this.logger.warn("Failed to retrieve the children of [{}]. Root cause is [{}].", nodeId,
                    ExceptionUtils.getRootCauseMessage(e));
        }
    }
    return Collections.emptyList();
}

From source file:org.xwiki.index.tree.internal.nestedpages.ObjectsOfTypeTreeNode.java

@Override
public int getChildCount(String nodeId) {
    DocumentReference[] parts = resolve(nodeId);
    if (parts != null) {
        try {// w w  w.j a v  a2 s. c o  m
            return getXObjectReferences(parts[0], parts[1]).size();
        } catch (Exception e) {
            this.logger.warn("Failed to count the children of [{}]. Root cause is [{}].", nodeId,
                    ExceptionUtils.getRootCauseMessage(e));
        }
    }
    return 0;
}

From source file:org.xwiki.index.tree.internal.nestedpages.ObjectTreeNode.java

@Override
public List<String> getChildren(String nodeId, int offset, int limit) {
    EntityReference objectReference = resolve(nodeId);
    if (objectReference != null && objectReference.getType() == EntityType.OBJECT) {
        try {/*from  ww w  .  j  av a2  s  .  c om*/
            return serialize(getChildren(new BaseObjectReference(objectReference), offset, limit));
        } catch (Exception e) {
            this.logger.warn("Failed to retrieve the children of [{}]. Root cause is [{}].", nodeId,
                    ExceptionUtils.getRootCauseMessage(e));
        }
    }
    return Collections.emptyList();
}

From source file:org.xwiki.index.tree.internal.nestedpages.ObjectTreeNode.java

@Override
public int getChildCount(String nodeId) {
    EntityReference objectReference = resolve(nodeId);
    if (objectReference != null && objectReference.getType() == EntityType.OBJECT) {
        try {// ww  w.j av  a2  s.c  om
            return getChildCount(new BaseObjectReference(objectReference));
        } catch (Exception e) {
            this.logger.warn("Failed to count the children of [{}]. Root cause is [{}].", nodeId,
                    ExceptionUtils.getRootCauseMessage(e));
        }
    }
    return 0;
}

From source file:org.xwiki.index.tree.internal.nestedpages.WikiTreeNode.java

@Override
public List<String> getChildren(String nodeId, int offset, int limit) {
    EntityReference wikiReference = resolve(nodeId);
    if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) {
        try {/*from   w w  w  . java2s.  c o m*/
            return serialize(getChildren(new WikiReference(wikiReference), offset, limit));
        } catch (QueryException e) {
            this.logger.warn("Failed to retrieve the children of [{}]. Root cause [{}].", nodeId,
                    ExceptionUtils.getRootCauseMessage(e));
        }
    }
    return Collections.emptyList();
}

From source file:org.xwiki.index.tree.internal.nestedpages.WikiTreeNode.java

@Override
public int getChildCount(String nodeId) {
    EntityReference wikiReference = resolve(nodeId);
    if (wikiReference != null && wikiReference.getType() == EntityType.WIKI) {
        try {/*from w  w w.  j a  v a 2 s .co  m*/
            return getChildCount(new WikiReference(wikiReference));
        } catch (QueryException e) {
            this.logger.warn("Failed to count the children of [{}]. Root cause [{}].", nodeId,
                    ExceptionUtils.getRootCauseMessage(e));
        }
    }
    return 0;
}

From source file:org.xwiki.index.tree.internal.nestedspaces.SpaceTreeNode.java

@Override
public List<String> getChildren(String nodeId, int offset, int limit) {
    EntityReference spaceReference = resolve(nodeId);
    if (spaceReference != null && spaceReference.getType() == EntityType.SPACE) {
        try {/*from   w  w w .  ja  va  2 s  . c o m*/
            return serialize(getChildren(new SpaceReference(spaceReference), offset, limit));
        } catch (QueryException e) {
            this.logger.warn("Failed to retrieve the children of [{}]. Root cause [{}].", nodeId,
                    ExceptionUtils.getRootCauseMessage(e));
        }
    }
    return Collections.emptyList();
}

From source file:org.xwiki.index.tree.internal.nestedspaces.SpaceTreeNode.java

@Override
public int getChildCount(String nodeId) {
    EntityReference spaceReference = resolve(nodeId);
    if (spaceReference != null && spaceReference.getType() == EntityType.SPACE) {
        try {/*w w  w. ja  v  a 2s. com*/
            return getChildCount(new SpaceReference(spaceReference));
        } catch (QueryException e) {
            this.logger.warn("Failed to count the children of [{}]. Root cause [{}].", nodeId,
                    ExceptionUtils.getRootCauseMessage(e));
        }
    }
    return 0;
}

From source file:org.xwiki.instance.internal.DefaultInstanceIdManager.java

@Override
public void initialize() {
    // Load it from the database
    XWikiContext context = getXWikiContext();
    XWikiHibernateBaseStore store = (XWikiHibernateBaseStore) this.hibernateStoreProvider.get();

    // Try retrieving the UUID from the database

    // First ensure that we're on the main wiki since we store the unique id only on the main wiki
    String originalDatabase = context.getWikiId();
    context.setWikiId(context.getMainXWiki());

    try {//from  w ww  .java 2 s.  c  o m
        InstanceId id = store.failSafeExecuteRead(context,
                new XWikiHibernateBaseStore.HibernateCallback<InstanceId>() {
                    @Override
                    public InstanceId doInHibernate(Session session) throws HibernateException {
                        // Retrieve the version from the database
                        return (InstanceId) session.createCriteria(InstanceId.class).uniqueResult();
                    }
                });

        // If the database doesn't hold the UUID then compute one and save it
        if (id == null) {
            // Compute UUID
            final InstanceId newId = new InstanceId(UUID.randomUUID().toString());
            // Store it. Note that this can fail in which case no UUID is saved in the DB and the operation
            // will be retried again next time the wiki is restarted.
            try {
                store.executeWrite(context, new XWikiHibernateBaseStore.HibernateCallback<Object>() {
                    @Override
                    public Object doInHibernate(Session session) throws HibernateException {
                        session.createQuery("delete from " + InstanceId.class.getName()).executeUpdate();
                        session.save(newId);
                        return null;
                    }
                });
            } catch (XWikiException e) {
                this.logger.warn("Failed to save Instance id to database. Reason: [{}]",
                        ExceptionUtils.getRootCauseMessage(e));
            }
            id = newId;
        }

        this.instanceId = id;
    } finally {
        // Restore original database
        context.setWikiId(originalDatabase);
    }
}