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 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 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 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); } } }
/** * <p> * Compresses the provided byte array in the GZIP file format. * </p> * * @param response * A byte array holding the data to compress. * @return the data compressed in the GZIP file format. */ private byte[] getGzippedContent(byte[] response) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = new GZIPOutputStream(new BufferedOutputStream(baos)); IOUtils.copy(new ByteArrayInputStream(response), os); os.close(); return baos.toByteArray(); } catch (IOException e) { throw new DandelionException("Problem while computing gzipped content", e); } }
/** * <p> * Compresses the provided byte array in the GZIP file format. * </p> * * @param response * A byte array holding the data to compress. * @return the data compressed in the GZIP file format. */ private byte[] getGzippedContent(byte[] response) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = new GZIPOutputStream(new BufferedOutputStream(baos)); IOUtils.copy(new ByteArrayInputStream(response), os); os.close(); return baos.toByteArray(); } catch (IOException e) { throw new DandelionException("Problem while computing gzipped content", 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; }
throw new DandelionException("JBoss VFS v3 call failed", e);
throw new DandelionException("JBoss VFS v3 call failed", e);
@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); }