Skip to content

Commit

Permalink
Passing query parameters and headers to patch extension request scope (
Browse files Browse the repository at this point in the history
…#1781)

* Passing query parameters and headers to patch extension request scope

* Added javadocs

Co-authored-by: Aaron Klish <[email protected]>
  • Loading branch information
aklish and Aaron Klish authored Jan 22, 2021
1 parent acb9e30 commit 9ce5414
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion elide-core/src/main/java/com/yahoo/elide/Elide.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public ElideResponse patch(String baseUrlEndPoint, String contentType, String ac
if (JsonApiPatch.isPatchExtension(contentType) && JsonApiPatch.isPatchExtension(accept)) {
handler = (tx, user) -> {
PatchRequestScope requestScope = new PatchRequestScope(baseUrlEndPoint, path, apiVersion, tx,
user, requestId, elideSettings);
user, requestId, queryParams, requestHeaders, elideSettings);
try {
Supplier<Pair<Integer, JsonNode>> responder =
JsonApiPatch.processJsonPatch(dataStore, path, jsonApiDocument, requestScope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import com.yahoo.elide.jsonapi.EntityProjectionMaker;
import com.yahoo.elide.jsonapi.models.JsonApiDocument;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.ws.rs.core.MultivaluedMap;

Expand All @@ -30,6 +31,8 @@ public class PatchRequestScope extends RequestScope {
* @param transaction current database transaction
* @param user request user
* @param requestId request ID
* @param queryParams request query parameters
* @param requestHeaders request headers
* @param elideSettings Elide settings object
*/
public PatchRequestScope(
Expand All @@ -39,6 +42,8 @@ public PatchRequestScope(
DataStoreTransaction transaction,
User user,
UUID requestId,
MultivaluedMap<String, String> queryParams,
Map<String, List<String>> requestHeaders,
ElideSettings elideSettings) {
super(
baseUrlEndPoint,
Expand All @@ -47,8 +52,8 @@ public PatchRequestScope(
(JsonApiDocument) null,
transaction,
user,
(MultivaluedMap<String, String>) null,
Collections.emptyMap(),
queryParams,
requestHeaders,
requestId,
elideSettings
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ public void testRelationChangeSpecType() {
@Test
public void testPatchRequestScope() {
DataStoreTransaction tx = mock(DataStoreTransaction.class);
PatchRequestScope parentScope = new PatchRequestScope(null, "/book", NO_VERSION, tx, new TestUser("1"), UUID.randomUUID(), elideSettings);
PatchRequestScope parentScope = new PatchRequestScope(null, "/book", NO_VERSION, tx, new TestUser("1"), UUID.randomUUID(), null, Collections.emptyMap(), elideSettings);
PatchRequestScope scope = new PatchRequestScope(
parentScope.getPath(), parentScope.getJsonApiDocument(), parentScope);
// verify wrap works
Expand Down

0 comments on commit 9ce5414

Please sign in to comment.