private void ensureFrom() { if (StringUtils.isBlank(from)) { throw new PaxmlRuntimeException("No 'from' 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); } }
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 static void deleteKey(KeyStore keyStore, String keyName) { try { if (keyStore.containsAlias(keyName)) { keyStore.deleteEntry(keyName); } } catch (KeyStoreException e) { throw new PaxmlRuntimeException(e); } }
private static JexlExpression createJexlExpression(String exp, boolean strict) { exp = trimExp(exp); try { return new JexlExpression(exp, strict); } catch (Exception e) { throw new PaxmlRuntimeException("Cannot parse jexl expression: " + exp, e); } }
private static JexlExpression createJexlExpression(String exp, boolean strict) { exp = trimExp(exp); try { return new JexlExpression(exp, strict); } catch (Exception e) { throw new PaxmlRuntimeException("Cannot parse jexl expression: " + exp, e); } }
/** * Assert an xml element has no child elements. * * @param ele * the element */ public static void assertNoSubElements(OMElement ele) { if (ele.getFirstElement() != null) { throw new PaxmlRuntimeException("Tag <" + ele.getLocalName() + "> should not have children tags"); } }
public static Secret getSecret(String name) { String pwd = SecretRepository.getCurrentUserMasterKey(); if (pwd == null) { throw new PaxmlRuntimeException("No secret store password given!"); } String clear = CryptoUtils.getKey(null, pwd, name, null); if (clear == null) { return null; } return new Secret(name, clear); }
public static Secret setSecret(String name, String value) { String pwd = SecretRepository.getCurrentUserMasterKey(); if (pwd == null) { throw new PaxmlRuntimeException("No secret store password given!"); } CryptoUtils.setKey(null, pwd, name, null, value); return new Secret(name, value); }
/** * {@inheritDoc} */ @Override protected boolean populate(final T tag, IParserContext context) { super.populate(tag, context); if (tag.getScope() != Scope.LOCAL) { throw new PaxmlRuntimeException("A <" + DefaultConstTag.TAG_NAME + "> tag must be a local data tag, but its scope: " + tag.getScope()); } return false; }
/** * Get the current tag being executed. * * @return the current tag, never null. */ public ITag getCurrentTag() { Stack stack = getStack(); if (stack.isEmpty()) { throw new PaxmlRuntimeException("No current tag!"); } return stack.getFirst(); }
/** * {@inheritDoc} */ @Override protected boolean populate(final T tag, IParserContext context) { super.populate(tag, context); if (tag.getScope() != Scope.LOCAL) { throw new PaxmlRuntimeException("A <" + DefaultConstTag.TAG_NAME + "> tag must be a local data tag, but its scope: " + tag.getScope()); } return false; }