Skip to content

Commit

Permalink
maybe here
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Oct 8, 2023
1 parent 5000ce4 commit b3e5448
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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(
Expand Down

0 comments on commit b3e5448

Please sign in to comment.