private void validateCollectionName(String name) throws ArangoDBException { if (name.indexOf('/') != -1) { throw new ArangoDBException("does not allow '/' in name."); } }
private static void validateName(final String type, final String regex, final CharSequence name) throws ArangoDBException { if (!Pattern.matches(regex, name)) { throw new ArangoDBException(String.format("%s %s is not valid.", type, name)); } } }
@Override public Response execute(final Request request, final HostHandle hostHandle) throws ArangoDBException { try { return httpCommunitaction.execute(request, hostHandle); } catch (final ClientProtocolException e) { throw new ArangoDBException(e); } catch (final IOException e) { throw new ArangoDBException(e); } }
public Message get(final long messageId) throws ArangoDBException { final Message result = response.remove(messageId); if (result == null) { final Exception e = error.remove(messageId); if (e != null) { throw new ArangoDBException(e); } } return result; }
private String createIndexId(final String id) { final String index; if (id.matches(DocumentUtil.REGEX_ID)) { index = id; } else if (id.matches(DocumentUtil.REGEX_KEY)) { index = name + "/" + id; } else { throw new ArangoDBException(String.format("index id %s is not valid.", id)); } return index; }
public void disconnect() { try { protocol.close(); } catch (final IOException e) { throw new ArangoDBException(e); } } }
private static String loadHost(final Properties properties, final String currentValue) { final String host = getProperty(properties, PROPERTY_KEY_HOST, currentValue, ArangoDefaults.DEFAULT_HOST); if (host.contains(":")) { throw new ArangoDBException(String.format( "Could not load property-value arangodb.host=%s. Expect only ip. Do you mean arangodb.hosts=ip:port ?", host)); } return host; }
@Override public void closeOnError() { try { connectionPool.close(); } catch (final IOException e) { throw new ArangoDBException(e); } }
public InternalArangoDBBuilder loadProperties(final InputStream in) throws ArangoDBException { if (in != null) { final Properties properties = new Properties(); try { properties.load(in); loadProperties(properties); } catch (final IOException e) { throw new ArangoDBException(e); } } return this; }
@Override protected void authenticate(final VstConnectionAsync connection) { Response response = null; try { response = execute(new AuthenticationRequest(user, password != null ? password : "", ENCRYPTION_PLAIN), connection).get(); } catch (final InterruptedException e) { throw new ArangoDBException(e); } catch (final ExecutionException e) { throw new ArangoDBException(e); } checkError(response); }
public Credentials addCredentials(final HttpRequestBase httpRequest) { Credentials credentials = null; if (user != null) { credentials = new UsernamePasswordCredentials(user, password != null ? password : ""); try { httpRequest.addHeader(new BasicScheme().authenticate(credentials, httpRequest, null)); } catch (final AuthenticationException e) { throw new ArangoDBException(e); } } return credentials; }
@Override public void close(final String id) { try { executor.execute(queryCloseRequest(id, options), Void.class, hostHandle).get(); } catch (InterruptedException | ExecutionException e) { throw new ArangoDBException(e); } } }, type, result);
@Override public CursorEntity next(final String id) { final CompletableFuture<CursorEntity> result = executor.execute(queryNextRequest(id, options), CursorEntity.class, hostHandle); try { return result.get(); } catch (InterruptedException | ExecutionException e) { throw new ArangoDBException(e); } }
@SuppressWarnings("unchecked") @Override public <A extends Annotation> Optional<ReferenceResolver<A>> getReferenceResolver(final A annotation) { ReferenceResolver<A> resolver = null; try { if (annotation instanceof Ref) { resolver = (ReferenceResolver<A>) new RefResolver(arangoTemplate()); } } catch (final Exception e) { throw new ArangoDBException(e); } return Optional.ofNullable(resolver); }
@Override public void close(final String id) { try { executor.execute(queryCloseRequest(id, options), Void.class, hostHandle).get(); } catch (InterruptedException | ExecutionException e) { throw new ArangoDBException(e); } } }, type, result);
@Override public CursorEntity next(final String id) { final CompletableFuture<CursorEntity> result = executor.execute(queryNextRequest(id, options), CursorEntity.class, hostHandle); try { return result.get(); } catch (InterruptedException | ExecutionException e) { throw new ArangoDBException(e); } }
@Override public void shutdown() throws ArangoDBException { try { executor.disconnect(); cp.close(); } catch (final IOException e) { throw new ArangoDBException(e); } }
@Override public void shutdown() throws ArangoDBException { try { executor.disconnect(); cp.close(); } catch (final IOException e) { throw new ArangoDBException(e); } }
public <T> T execute( final Request request, final ResponseDeserializer<T> responseDeserializer, final HostHandle hostHandle) throws ArangoDBException { try { final Response response = protocol.execute(request, hostHandle); return responseDeserializer.deserialize(response); } catch (final VPackException e) { throw new ArangoDBException(e); } }
@Override protected Response execute(final Request request, final VstConnectionSync connection) throws ArangoDBException { try { final Message requestMessage = createMessage(request); final Message responseMessage = send(requestMessage, connection); final Response response = createResponse(responseMessage); checkError(response); return response; } catch (final VPackParserException e) { throw new ArangoDBException(e); } }