public BaseProxy(DatabaseClient db, String endpointDir) { if (db == null) { throw new IllegalArgumentException("Cannot connect with null database client"); } else if (db.getDatabase() != null) { throw new IllegalArgumentException("Client cannot specify a database - specified: "+db.getDatabase()); } if (endpointDir == null || endpointDir.length() == 0) { throw new IllegalArgumentException("Cannot make requests with null or empty endpoint directory"); } this.endpointDir = endpointDir; DatabaseClientImpl dbImpl = (DatabaseClientImpl) db; this.services = dbImpl.getServices(); }
public ForestConfigurationImpl readForestConfig() { List<ForestImpl> forests = new ArrayList<>(); JsonNode results = ((DatabaseClientImpl) client).getServices() .getResource(null, "internal/forestinfo", null, null, new JacksonHandle()) .get(); for ( JsonNode forestNode : results ) { String id = forestNode.get("id").asText(); String name = forestNode.get("name").asText(); String database = forestNode.get("database").asText(); String host = forestNode.get("host").asText(); String openReplicaHost = null; if ( forestNode.get("openReplicaHost") != null ) openReplicaHost = forestNode.get("openReplicaHost").asText(); String requestHost = null; if ( forestNode.get("requestHost") != null ) requestHost = forestNode.get("requestHost").asText(); String alternateHost = null; if ( forestNode.get("alternateHost") != null ) alternateHost = forestNode.get("alternateHost").asText(); // Since we added the forestinfo end point to populate both alternateHost and requestHost // in case we have a requestHost so that we don't break the existing API code, we will make the // alternateHost as null if both alternateHost and requestHost is set. if ( requestHost != null && alternateHost != null ) alternateHost = null; boolean isUpdateable = "all".equals(forestNode.get("updatesAllowed").asText()); boolean isDeleteOnly = false; // TODO: get this for real after we start using a REST endpoint forests.add( new ForestImpl(host, openReplicaHost, requestHost, alternateHost, database, name, id, isUpdateable, isDeleteOnly) ); } return new ForestConfigurationImpl(forests.toArray(new ForestImpl[forests.size()])); }
RESTServices services = ((DatabaseClientImpl) batch.getClient()).getServices(); try { RequestParameters params = new RequestParameters();
private Iterable<TypedRow> getTypedRows(QueryBatch batch) throws IOException { StringHandle uris = new StringHandle(String.join("\n", batch.getItems())) .withMimetype("text/uri-list"); RESTServices services = ((DatabaseClientImpl) batch.getClient()).getServices(); RequestParameters params = new RequestParameters(); for ( String templateUri : templateUris ) params.add("template", templateUri);