private void ensureFrom() { if (StringUtils.isBlank(from)) { throw new PaxmlRuntimeException("No 'from' parameter given in sftp command"); } }
private void ensureTo() { if (StringUtils.isBlank(to)) { throw new PaxmlRuntimeException("No 'to' parameter given in sftp command"); } }
public static String getHostIp() { try { InetAddress addr = InetAddress.getLocalHost(); return addr.getHostAddress(); } catch (UnknownHostException e) { throw new PaxmlRuntimeException("Cannot get this machine's ip", e); } }
public static String getHostName() { try { InetAddress addr = InetAddress.getLocalHost(); return addr.getHostName(); } catch (UnknownHostException e) { throw new PaxmlRuntimeException("Cannot get this machine's name", e); } }
public static String readStreamToString(InputStream in, String encoding) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { IOUtils.copy(in, out); return out.toString(encoding == null ? "UTF-8" : encoding); } catch (IOException e) { throw new PaxmlRuntimeException(e); } }
private static void saveKeyStore(final File file, final String password, final KeyStore ks) { file.delete(); FileOutputStream fos = null; try { fos = new FileOutputStream(file); ks.store(fos, password.toCharArray()); } catch (Exception e) { throw new PaxmlRuntimeException("Cannot write to key store file: " + file.getAbsolutePath(), e); } finally { IOUtils.closeQuietly(fos); } }
private void checkHeaderless() { if (headers == null) { throw new PaxmlRuntimeException("Cannot add column to headerless csv: " + getResourceIdentifier()); } }
private File getContainerFile() { if (StringUtils.isEmpty(dir)) { throw new PaxmlRuntimeException("No 'dir' property specified!"); } try { return ResourceUtils.getFile(dir); } catch (FileNotFoundException e) { return new File(dir); } }
/** * {@inheritDoc} */ public void registerTag(Class<? extends ITag> clazz) { String tagName = getTagName(clazz); if (StringUtils.isBlank(tagName)) { throw new PaxmlRuntimeException("Class " + clazz.getName() + " has no 'name' property given in its own nor its super classes/interfaces' @" + Tag.class.getSimpleName() + " annotation"); } tags.put(tagName, clazz); }
public Map<String, Object> next() { final Map<String, Object> result = next; if (next == null) { throw new PaxmlRuntimeException("No more elements!"); } fetch(); return result; }
@Override public String getName() { try { return meta.getTableName(0); } catch (SQLException e) { throw new PaxmlRuntimeException("Cannot get table name with query: " + query); } }
public void setMethod(String method) { this.method = method; try { _method = HttpMethod.valueOf(method.toUpperCase()); } catch (Exception e) { throw new PaxmlRuntimeException("Unsupported rest method: " + method); } }
public Map<String, Object> next() { final Map<String, Object> result = next; if (next == null) { throw new PaxmlRuntimeException("No more elements!"); } fetch(); return result; }
public void assertWritable() { if (readonly) { throw new PaxmlRuntimeException("Resource is readonly: " + getResourceIdentifier()); } }
private void println(String line) { OutputStream out = streams.getOutputStream(false); try { out.write(line.getBytes("UTF-8")); out.write("\r\n".getBytes("UTF-8")); out.flush(); } catch (IOException e) { throw new PaxmlRuntimeException(e.getMessage()); } } }
public void save() { try { workbook.write(new FileOutputStream(file)); } catch (Exception e) { throw new PaxmlRuntimeException("Cannot save excel to file: " + file.getAbsolutePath(), e); } }
public void visit(OMElement ele, String attrName, String attrValue) { if (!set.contains(attrName)) { throw new PaxmlRuntimeException("No attribute '" + attrName + "' should exist in tag: " + ele.getLocalName()); } } });
private void registerClassTag(Class clazz) { List<String> names = getTagNames(clazz); if (names == null || names.isEmpty()) { throw new PaxmlRuntimeException("Class " + clazz.getName() + " has no 'name' property given in its own nor its super classes/interfaces' @" + Tag.class.getSimpleName() + " annotation"); } for (String tagName : names) { tags.put(tagName, clazz); } }
public boolean has(String name) { if (!context.hasConstId(name, true)) { if(strict){ throw new PaxmlRuntimeException("Unknown const name: " + name); } return true; } return true; }
public static File getPaxmlHome(boolean assert_PAXML_HOME) { String paxmlHome = getSystemProperty(PAXML_HOME_ENV_KEY); if (paxmlHome == null) { if (assert_PAXML_HOME) { throw new PaxmlRuntimeException("System environment variable 'PAXML_HOME' not set!"); } else { return null; } } return new File(paxmlHome); }