From b3e5448bd9912320125a90c0e35a8764d437ebeb Mon Sep 17 00:00:00 2001 From: Luke Sikina Date: Sun, 8 Oct 2023 08:06:22 -0400 Subject: [PATCH] maybe here --- .../java/edu/harvard/dbmi/avillach/PicsureRS.java | 14 ++++++++++---- .../resource/passthru/PassThroughResourceRS.java | 4 +--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/PicsureRS.java b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/PicsureRS.java index 55e4f186..b21bebfa 100644 --- a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/PicsureRS.java +++ b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/PicsureRS.java @@ -8,6 +8,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; import edu.harvard.dbmi.avillach.domain.*; import edu.harvard.dbmi.avillach.service.FormatService; @@ -153,11 +154,16 @@ public QueryStatus query( @Parameter @QueryParam("isInstitute") - Boolean isInstitutionQuery + Boolean isInstitutionQuery, + + @Context SecurityContext context ) { - return isInstitutionQuery == null || !isInstitutionQuery ? - queryService.query(dataQueryRequest, headers) : - queryService.institutionalQuery(dataQueryRequest, headers); + if (isInstitutionQuery == null || !isInstitutionQuery) { + return queryService.query(dataQueryRequest, headers); + } else { + dataQueryRequest.setInstitutionOfOrigin(context.getUserPrincipal().getName()); + return queryService.institutionalQuery(dataQueryRequest, headers); + } } @POST diff --git a/pic-sure-resources/pic-sure-passthrough-resource/src/main/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRS.java b/pic-sure-resources/pic-sure-passthrough-resource/src/main/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRS.java index 0071ac89..6c428f25 100644 --- a/pic-sure-resources/pic-sure-passthrough-resource/src/main/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRS.java +++ b/pic-sure-resources/pic-sure-passthrough-resource/src/main/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRS.java @@ -87,7 +87,7 @@ public ResourceInfo info(QueryRequest infoRequest) { @POST @Path("/query") - public QueryStatus query(QueryRequest queryRequest, @Context SecurityContext context) { + public QueryStatus query(QueryRequest queryRequest) { if (queryRequest == null) { throw new ProtocolException(ProtocolException.MISSING_DATA); } @@ -104,8 +104,6 @@ public QueryStatus query(QueryRequest queryRequest, @Context SecurityContext con chainRequest.setResourceCredentials(queryRequest.getResourceCredentials()); chainRequest.setResourceUUID(UUID.fromString(properties.getTargetResourceId())); chainRequest.setCommonAreaUUID(queryRequest.getCommonAreaUUID()); - chainRequest.setInstitutionOfOrigin(context.getUserPrincipal().getName()); - logger.info("Context: {}", context.getUserPrincipal()); String payload = objectMapper.writeValueAsString(chainRequest); HttpResponse response = httpClient.retrievePostResponse(