private HttpResponse doRequest(DatasetId datasetInstanceId, String opName, @Nullable String body) throws IOException, ConflictException { String path = String.format("namespaces/%s/data/datasets/%s/admin/%s", datasetInstanceId.getNamespace(), datasetInstanceId.getEntityName(), opName); LOG.trace("executing POST on {} with body {}", path, body); try { HttpRequest.Builder builder = remoteClient.requestBuilder(HttpMethod.POST, path); if (body != null) { builder.withBody(body); } String userId = authenticationContext.getPrincipal().getName(); if (userId != null) { builder.addHeader(Constants.Security.Headers.USER_ID, userId); } HttpResponse httpResponse = remoteClient.execute(builder.build()); LOG.trace("executed POST on {} with body {}: {}", path, body, httpResponse.getResponseCode()); verifyResponse(httpResponse); return httpResponse; } catch (Exception e) { LOG.trace("Caught exception for POST on {} with body {}", path, body, e); throw e; } }
private HttpResponse doRequest(DatasetId datasetInstanceId, String opName, @Nullable String body) throws IOException, ConflictException { String path = String.format("namespaces/%s/data/datasets/%s/admin/%s", datasetInstanceId.getNamespace(), datasetInstanceId.getEntityName(), opName); LOG.trace("executing POST on {} with body {}", path, body); try { HttpRequest.Builder builder = remoteClient.requestBuilder(HttpMethod.POST, path); if (body != null) { builder.withBody(body); } String userId = authenticationContext.getPrincipal().getName(); if (userId != null) { builder.addHeader(Constants.Security.Headers.USER_ID, userId); } HttpResponse httpResponse = remoteClient.execute(builder.build()); LOG.trace("executed POST on {} with body {}: {}", path, body, httpResponse.getResponseCode()); verifyResponse(httpResponse); return httpResponse; } catch (Exception e) { LOG.trace("Caught exception for POST on {} with body {}", path, body, e); throw e; } }