@@ -262,6 +262,17 @@ public RemoteTransactionExplicitLock acquireLock() {
262262 return explicitLock ;
263263 }
264264
265+ /**
266+ * Returns a builder for configuring a remote batch graph import.
267+ * The builder mirrors the server-side GraphBatch.Builder parameters.
268+ *
269+ * @return a new {@link RemoteGraphBatch.Builder}
270+ */
271+ public RemoteGraphBatch .Builder batch () {
272+ checkDatabaseIsOpen ();
273+ return new RemoteGraphBatch .Builder (this );
274+ }
275+
265276 @ Override
266277 public void begin () {
267278 begin (transactionIsolationLevel );
@@ -572,6 +583,42 @@ private String getUrl(final String command, final String databaseName) {
572583 return getUrl (command ) + "/" + databaseName ;
573584 }
574585
586+ JSONObject sendBatch (final String content , final Map <String , String > queryParams ) {
587+ checkDatabaseIsOpen ();
588+
589+ final StringBuilder urlBuilder = new StringBuilder (getUrl ("batch" , databaseName ));
590+ if (queryParams != null && !queryParams .isEmpty ()) {
591+ urlBuilder .append ('?' );
592+ boolean first = true ;
593+ for (final Map .Entry <String , String > entry : queryParams .entrySet ()) {
594+ if (!first )
595+ urlBuilder .append ('&' );
596+ urlBuilder .append (entry .getKey ()).append ('=' ).append (entry .getValue ());
597+ first = false ;
598+ }
599+ }
600+
601+ try {
602+ final HttpRequest request = createRequestBuilder ("POST" , urlBuilder .toString ())
603+ .POST (HttpRequest .BodyPublishers .ofString (content ))
604+ .header ("Content-Type" , "application/x-ndjson" )
605+ .build ();
606+
607+ final HttpResponse <String > response = httpClient .send (request , HttpResponse .BodyHandlers .ofString ());
608+
609+ if (response .statusCode () != 200 ) {
610+ final Exception detail = manageException (response , "batch import" );
611+ throw new DatabaseOperationException ("Error on batch import" , detail );
612+ }
613+
614+ return new JSONObject (response .body ());
615+ } catch (final DatabaseOperationException e ) {
616+ throw e ;
617+ } catch (final Exception e ) {
618+ throw new DatabaseOperationException ("Error on batch import" , e );
619+ }
620+ }
621+
575622 protected ResultSet createResultSet (final JSONObject response ) {
576623 final ResultSet resultSet = new InternalResultSet ();
577624
0 commit comments