public static DandelionException wrap(Throwable exception) { if (exception instanceof DandelionException) { DandelionException se = (DandelionException) exception; return se; } else { return new DandelionException(exception.getMessage(), exception); } } }
public static DandelionException wrap(Throwable exception) { if (exception instanceof DandelionException) { DandelionException se = (DandelionException) exception; return se; } else { return new DandelionException(exception.getMessage(), exception); } } }
public URL toStandardUrl(URL url) throws IOException { URL standardUrl = null; try { Object root = VFS_METHOD_GET_ROOT.invoke(null, url); standardUrl = (URL) VFSUTILS_METHOD_GET_REAL_URL.invoke(null, root); } catch (Exception e) { StringBuilder error = new StringBuilder("Unable to resolve the URL \""); error.append(url.getPath()); error.append("\" using JBoss VFS2 classes"); throw new DandelionException(error.toString(), e); } return standardUrl; } }
public URL toStandardUrl(URL url) throws IOException { URL standardUrl = null; try { Object child = VFS_METHOD_GET_CHILD.invoke(null, url); standardUrl = (URL) VIRTUALFILE_METHOD_TO_URL.invoke(child); } catch (Exception e) { StringBuilder error = new StringBuilder("Unable to resolve the URL \""); error.append(url.getPath()); error.append("\" using JBoss VFS2 classes"); throw new DandelionException(error.toString(), e); } return standardUrl; } }
public AbstractColumnAttrProcessor getProcessor() { AttributeNameProcessorMatcher matcher = new AttributeNameProcessorMatcher(attributeName, elementNameFilter, DataTablesDialect.DIALECT_PREFIX + ":data", "internalUse"); try { return processorClass.getDeclaredConstructor(IAttributeNameProcessorMatcher.class).newInstance(matcher); } catch (Exception e) { throw new DandelionException(e); } } }
public AbstractTableAttrProcessor getProcessor() { AttributeNameProcessorMatcher matcher = new AttributeNameProcessorMatcher(attributeName, elementNameFilter, DataTablesDialect.DIALECT_PREFIX + ":table", "true"); try { return processorClass.getDeclaredConstructor(IAttributeNameProcessorMatcher.class).newInstance(matcher); } catch (Exception e) { throw new DandelionException(e); } } }
public static String getFileContentFromClasspath(String pathToFile, boolean neverFail) { try { InputStream in = getFileFromClasspath(pathToFile); return getContentFromInputStream(in); } catch (IOException e) { StringBuilder sb = new StringBuilder("The content pointed by the path "); sb.append(pathToFile); sb.append(" can't be read from an inputStream."); throw new DandelionException(sb.toString(), e); } }
public static AssetLocator getAssetLocator(Asset asset, Context context) { String locationKey = asset.getConfigLocationKey(); Map<String, AssetLocator> locators = context.getAssetLocatorsMap(); if (!locators.containsKey(locationKey)) { StringBuilder msg = new StringBuilder("The location key '"); msg.append(locationKey); msg.append("' is not valid. Please choose a valid one among "); msg.append(locators.keySet()); msg.append("."); throw new DandelionException(msg.toString()); } AssetLocator locator = locators.get(locationKey); return locator; }
public static String getFileContentFromClasspath(String pathToFile, boolean neverFail) { try { InputStream in = getFileFromClasspath(pathToFile); return getContentFromInputStream(in); } catch (IOException e) { StringBuilder sb = new StringBuilder("The content pointed by the path "); sb.append(pathToFile); sb.append(" can't be read from an inputStream."); throw new DandelionException(sb.toString(), e); } }
public static AssetLocator getAssetLocator(Asset asset, Context context) { String locationKey = asset.getConfigLocationKey(); Map<String, AssetLocator> locators = context.getAssetLocatorsMap(); if (!locators.containsKey(locationKey)) { StringBuilder msg = new StringBuilder("The location key '"); msg.append(locationKey); msg.append("' is not valid. Please choose a valid one among "); msg.append(locators.keySet()); msg.append("."); throw new DandelionException(msg.toString()); } AssetLocator locator = locators.get(locationKey); return locator; }
@Override protected Object getProcessedValue(OptionProcessingContext context) { Integer result = null; String valueAsString = context.getValueAsString(); try { result = StringUtils.isNotBlank(valueAsString) ? Integer.parseInt(valueAsString) : null; } catch (NumberFormatException e) { throw new DandelionException("The value '" + valueAsString + "' cannot be parsed to Integer", e); } return result; } }
@Override protected Object getProcessedValue(OptionProcessingContext context) { Integer result = null; String valueAsString = context.getValueAsString(); try { result = StringUtils.isNotBlank(valueAsString) ? Integer.parseInt(valueAsString) : null; } catch (NumberFormatException e) { throw new DandelionException("The value '" + valueAsString + "' cannot be parsed to Integer", e); } return result; } }
public static String md5Digest(String string) { Validate.notBlank(string, "The string to get the hash from cannot be blank"); char[] encodedDigest; try { byte[] digest = digest(MD5_ALGORITHM_NAME, string.getBytes("UTF-8")); encodedDigest = encodeHex(digest); } catch (UnsupportedEncodingException e) { throw new DandelionException("Unable to get a MD5 hash of " + string, e); } return new String(encodedDigest); }
public void addEdge(BundleStorageUnit from, BundleStorageUnit to) { from.addEdgeTo(to); to.addEdgeFrom(from); List<BundleStorageUnit> cycle = BundleCycleDetector.introducesCycle(to); if (cycle != null) { StringBuilder sb = new StringBuilder("A cycle has been detected in the asset graph for the bundle "); sb.append(from.getName()); sb.append("."); throw new DandelionException(sb.toString()); } }
public void addEdge(BundleStorageUnit from, BundleStorageUnit to) { from.addEdgeTo(to); to.addEdgeFrom(from); List<BundleStorageUnit> cycle = BundleCycleDetector.introducesCycle(to); if (cycle != null) { StringBuilder sb = new StringBuilder("A cycle has been detected in the asset graph for the bundle "); sb.append(from.getName()); sb.append("."); throw new DandelionException(sb.toString()); } }
public static String md5Digest(String string) { Validate.notBlank(string, "The string to get the hash from cannot be blank"); char[] encodedDigest; try { byte[] digest = digest(MD5_ALGORITHM_NAME, string.getBytes("UTF-8")); encodedDigest = encodeHex(digest); } catch (UnsupportedEncodingException e) { throw new DandelionException("Unable to get a MD5 hash of " + string, e); } return new String(encodedDigest); }
private void checkMarkupUsage(Element element) { Element parent = (Element) element.getParent(); if (parent == null || !"div".equals(parent.getNormalizedName()) || !parent.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":conf") || StringUtils.isBlank(parent.getAttributeValue(DataTablesDialect.DIALECT_PREFIX + ":conf"))) { throw new DandelionException( "The element 'div dt:confType=\"...\"' must be inside an element 'div dt:conf=\"tableId\"'."); } }
@Override public boolean handle(HandlerContext handlerContext) { byte[] newResponse; String debugPage = handlerContext.getRequest().getParameter(WebConstants.DANDELION_DEBUGGER_PAGE); try { String responseAsString = getView(debugPage, handlerContext); newResponse = responseAsString.getBytes(handlerContext.getContext().getConfiguration().getEncoding()); } catch (Exception e) { throw new DandelionException("An error occured when generating the \"" + debugPage + "\" debug page.", e); } // The response is overriden with a new one containing the debug page handlerContext.setResponseAsBytes(newResponse); return false; }
@Override protected String doGetContent(Asset asset, Map<String, Object> parameters, HttpServletRequest request) { AssetContentGenerator generator = AssetRequestContext.get(request).getGenerator(asset.getGeneratorUid()); if (generator == null) { throw new DandelionException("No asset generator has been found in the request with the uid \"" + asset.getGeneratorUid() + "\". Ensure to call AssetRequestContext.get(request).addGenerator(\"" + asset.getGeneratorUid() + "\", ...);"); } return generator.getAssetContent(request); } }
@Override protected String doGetContent(Asset asset, Map<String, Object> parameters, HttpServletRequest request) { AssetContentGenerator generator = AssetRequestContext.get(request).getGenerator(asset.getGeneratorUid()); if (generator == null) { throw new DandelionException("No asset generator has been found in the request with the uid \"" + asset.getGeneratorUid() + "\". Ensure to call AssetRequestContext.get(request).addGenerator(\"" + asset.getGeneratorUid() + "\", ...);"); } return generator.getAssetContent(request); } }