List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getRootCauseMessage
public static String getRootCauseMessage(final Throwable th)
From source file:org.xwiki.notifications.filters.internal.migrators.ScopeNotificationFilterClassMigrator.java
@Override protected void hibernateMigrate() throws DataMigrationException, XWikiException { XWikiContext xWikiContext = xcontextProvider.get(); try {//from ww w .jav a 2 s. c om // Get every document having at least one NotificationPreferenceScopeClass XObject attached Query query = queryManager.createQuery( "select distinct doc.fullName from Document doc, " + "doc.object(XWiki.Notifications.Code.NotificationPreferenceScopeClass) as document", Query.XWQL); List<String> results = query.execute(); // Migrate each document to use the new XObject DocumentReference currentDocumentReference; for (String result : results) { currentDocumentReference = documentReferenceResolver.resolve(result); XWikiDocument document = xWikiContext.getWiki().getDocument(currentDocumentReference, xWikiContext); logger.debug("Migrating document [{}]...", result); try { migrateDocument(document); } catch (XWikiException e) { logger.warn("Failed to migrate document [{}] : [{}]", result, ExceptionUtils.getRootCauseMessage(e)); } } // When every document has been migrated, we can then delete the old XClass xWikiContext.getWiki().deleteDocument( xWikiContext.getWiki().getDocument(OLD_XCLASS_REFERENCE, xWikiContext), xWikiContext); } catch (QueryException e) { logger.error("Failed to perform a query on the current wiki.", e); } }
From source file:org.xwiki.notifications.notifiers.internal.email.live.DefaultLiveMimeMessageIterator.java
/** * Test if the given user has enabled the notification preference corresponding to the given composite event. * * @param user the user from which we have to extract * @param compositeEvent// www. j av a2 s .c o m * @return */ private boolean hasCorrespondingNotificationPreference(DocumentReference user, CompositeEvent compositeEvent) { try { for (NotificationPreference notificationPreference : notificationPreferenceManager .getAllPreferences(user)) { if (notificationPreference.getFormat().equals(NotificationFormat.EMAIL) && notificationPreference.getProperties() .containsKey(NotificationPreferenceProperty.EVENT_TYPE) && notificationPreference.getProperties().get(NotificationPreferenceProperty.EVENT_TYPE) .equals(compositeEvent.getType())) { return notificationPreference.isNotificationEnabled(); } } } catch (NotificationException e) { this.logger.warn("Unable to retrieve the notifications preferences of [{}]: [{}]", user, ExceptionUtils.getRootCauseMessage(e)); } return false; }
From source file:org.xwiki.notifications.notifiers.internal.rss.DefaultNotificationRSSManager.java
@Override public SyndFeed renderFeed(List<CompositeEvent> events) { SyndFeed feed = new SyndFeedImpl(); // Define the general properties of the rss feed.setFeedType("rss_2.0"); feed.setTitle(this.contextualLocalizationManager.getTranslationPlain("notifications.rss.feedTitle")); // Set the RSS feed link to the service generating the feed feed.setLink(this.modelBridge.getDocumentURL( new DocumentReference(wikiDescriptorManager.getCurrentWikiId(), Arrays.asList("XWiki", "Notifications", "Code"), "NotificationRSSService"), "get", "outputSyntax=plain")); // Set the feed description feed.setDescription(/*from w w w.j av a 2 s. com*/ this.contextualLocalizationManager.getTranslationPlain("notifications.rss.feedDescription")); // Add every given CompositeEvent entry to the rss List<SyndEntry> entries = new ArrayList<>(); for (CompositeEvent event : events) { try { NotificationRSSRenderer renderer = this.getRenderer(event); if (renderer != null) { entries.add(renderer.renderNotification(event)); } else { entries.add(defaultNotificationRSSRenderer.renderNotification(event)); } } catch (NotificationException e) { this.logger.warn("Unable to render RSS entry for CompositeEvent [{}] : [{}]", event, ExceptionUtils.getRootCauseMessage(e)); } } feed.setEntries(entries); return feed; }
From source file:org.xwiki.platform.svg.internal.BatikSVGRasterizer.java
private boolean rasterize(TranscoderInput input, TranscoderOutput output, int width, int height) { PNGTranscoder transcoder = new PNGTranscoder(); if (width > 0) { transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, Float.valueOf(width)); }/*from ww w . j a v a 2 s.com*/ if (height > 0) { transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, Float.valueOf(height)); } // Set maximum width and height to 8k to avoid DoS attacks transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_WIDTH, Float.valueOf(8192)); transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_HEIGHT, Float.valueOf(8192)); try { transcoder.transcode(input, output); return true; } catch (TranscoderException ex) { this.logger.warn("Failed to rasterize SVG image: {}", ExceptionUtils.getRootCauseMessage(ex)); } return false; }
From source file:org.xwiki.platform.svg.script.SVGScriptService.java
/** * Rasterize an image as PNG into a temporary resource belonging to the current document, accessible through the * "tmp" resource URL handler./*from www .j a va2s . com*/ * * @param content the SVG image * @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size * is used * @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native * size is used * @return URL pointing to the temporary resource where the PNG is stored */ public ExtendedURL rasterizeToTemporaryResource(String content, int width, int height) { try { return this.serializer.serialize(this.component.rasterizeToTemporaryResource(content, width, height)); } catch (Exception ex) { this.logger.warn("Failed to rasterize SVG image to temporary resource: {}", ExceptionUtils.getRootCauseMessage(ex)); } return null; }
From source file:org.xwiki.platform.svg.script.SVGScriptService.java
/** * Rasterize an image as PNG as into temporary resource belonging to the current document, accessible through the * "tmp" resource URL handler.//from w ww. j a v a 2 s. c o m * * @param content the SVG image * @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size * is used * @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native * size is used * @param targetContext the document which will "own" the new temporary resource * @return URL pointing to the temporary resource where the PNG is stored */ public ExtendedURL rasterizeToTemporaryResource(String content, int width, int height, DocumentReference targetContext) { try { ExtendedURL result = this.serializer .serialize(this.component.rasterizeToTemporaryResource(content, width, height, targetContext)); return result; } catch (Exception ex) { this.logger.warn("Failed to rasterize SVG image to temporary resource in context [{}]: {}", targetContext, ExceptionUtils.getRootCauseMessage(ex)); } return null; }
From source file:org.xwiki.platform.svg.script.SVGScriptService.java
/** * Rasterize an image as PNG into the current response. * * @param content the SVG image/*from www. j a v a2 s . c om*/ * @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size * is used * @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native * size is used * @return {@code true} if the image was successfully rasterized and written to the response, {@code false} in case * of exceptions */ public boolean rasterizeToResponse(String content, int width, int height) { try { this.component.rasterizeToResponse(content, width, height); return true; } catch (Exception ex) { this.logger.warn("Failed to rasterize SVG image to response: {}", ExceptionUtils.getRootCauseMessage(ex)); } return false; }
From source file:org.xwiki.rendering.internal.transformation.DefaultTransformationManager.java
/** * @return the ordered list of Transformations to execute *///from w ww.j av a2 s . com public List<Transformation> getTransformations() { List<Transformation> transformations = new ArrayList<Transformation>(); for (String hint : this.configuration.getTransformationNames()) { try { transformations.add(this.componentManagerProvider.get() .<Transformation>getInstance(Transformation.class, hint)); } catch (ComponentLookupException e) { this.logger.warn( "Failed to locate transformation with hint [{}], ignoring it. " + "Root reason [{}]", hint, ExceptionUtils.getRootCauseMessage(e)); } } Collections.sort(transformations); return transformations; }
From source file:org.xwiki.repository.internal.XWikiRepositoryModel.java
/** * @since 8.4/*w ww. jav a 2 s.c o m*/ */ public static List<ExtensionRepositoryDescriptor> toRepositoryDescriptors(Collection<String> stringRepositories, ExtensionFactory factory) { if (stringRepositories == null) { return Collections.emptyList(); } List<ExtensionRepositoryDescriptor> reposiories = new ArrayList<>(stringRepositories.size()); for (String stringRepository : stringRepositories) { try { reposiories.add(toRepositoryDescriptor(stringRepository, factory)); } catch (URISyntaxException e) { LOGGER.warn("Failed to parse repository descriptor [{}]", stringRepository, ExceptionUtils.getRootCauseMessage(e)); } } return reposiories; }
From source file:org.xwiki.resource.internal.AbstractResourceReferenceHandlerManager.java
@Override public boolean canHandle(T resourceReferenceQualifier) { boolean result; try {//from ww w. j a v a2s. co m result = !getMatchingHandlers(resourceReferenceQualifier).isEmpty(); } catch (ResourceReferenceHandlerException e) { this.logger.warn("Failed to list Resource Reference Handers. Error [{}]", ExceptionUtils.getRootCauseMessage(e)); result = false; } return result; }