Search in sources :

Example 1 with PostUUIDCriteria

use of datawave.webservice.query.util.PostUUIDCriteria in project datawave by NationalSecurityAgency.

the class QueryExecutorBean method lookupContentByUUIDBatch.

/**
 * @param queryParameters
 * @param httpHeaders
 * @return content results, either as a paged BaseQueryResponse or StreamingOutput
 * @RequestHeader X-ProxiedEntitiesChain use when proxying request for user, by specifying a chain of DNs of the identities to proxy
 * @RequestHeader X-ProxiedIssuersChain required when using X-ProxiedEntitiesChain, specify one issuer DN per subject DN listed in X-ProxiedEntitiesChain
 * @ResponseHeader query-session-id this header and value will be in the Set-Cookie header, subsequent calls for this session will need to supply the
 *                 query-session-id header in the request in a Cookie header or as a query parameter
 * @ResponseHeader X-OperationTimeInMS time spent on the server performing the operation, does not account for network or result serialization
 * @ResponseHeader X-Partial-Results true if the page contains less than the requested number of results
 *
 * @HTTP 200 success
 * @HTTP 204 success and no results
 * @HTTP 400 invalid or missing parameter
 * @HTTP 500 internal server error
 */
@POST
@Path("/lookupContentUUID")
@Produces({ "application/xml", "text/xml", "application/json", "text/yaml", "text/x-yaml", "application/x-yaml", "application/x-protobuf", "application/x-protostuff" })
@GZIP
@GenerateQuerySessionId(cookieBasePath = "/DataWave/Query/")
@Interceptors({ ResponseInterceptor.class, RequiredInterceptor.class })
@Override
@Timed(name = "dw.query.lookupContentUUIDBatch", absolute = true)
public <T> T lookupContentByUUIDBatch(MultivaluedMap<String, String> queryParameters, @Required("httpHeaders") @Context HttpHeaders httpHeaders) {
    if (!queryParameters.containsKey("uuidPairs")) {
        throw new BadRequestException(new IllegalArgumentException("uuidPairs missing from query parameters"), new VoidResponse());
    }
    T response = null;
    String queryId = null;
    try {
        String uuidPairs = queryParameters.getFirst("uuidPairs");
        String streaming = queryParameters.getFirst("streaming");
        boolean streamingOutput = false;
        if (!StringUtils.isEmpty(streaming)) {
            streamingOutput = Boolean.parseBoolean(streaming);
        }
        // Create the criteria for looking up the respective events, which we need to get the shard IDs and column families
        // required for the content lookup
        final PostUUIDCriteria criteria = new PostUUIDCriteria(uuidPairs, queryParameters);
        // Set the HTTP headers if a streamed response is required
        if (streamingOutput) {
            criteria.setStreamingOutputHeaders(httpHeaders);
        }
        response = this.lookupUUIDUtil.lookupContentByUUIDs(criteria);
        if (response instanceof BaseQueryResponse) {
            queryId = ((BaseQueryResponse) response).getQueryId();
        }
        return response;
    } finally {
        if (null != queryId) {
            asyncClose(queryId);
        }
    }
}
Also used : GET(javax.ws.rs.GET) POST(javax.ws.rs.POST) PUT(javax.ws.rs.PUT) VoidResponse(datawave.webservice.result.VoidResponse) BaseQueryResponse(datawave.webservice.result.BaseQueryResponse) BadRequestException(datawave.webservice.common.exception.BadRequestException) PostUUIDCriteria(datawave.webservice.query.util.PostUUIDCriteria) Path(javax.ws.rs.Path) GenerateQuerySessionId(datawave.annotation.GenerateQuerySessionId) Interceptors(javax.interceptor.Interceptors) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GZIP(org.jboss.resteasy.annotations.GZIP)

Example 2 with PostUUIDCriteria

use of datawave.webservice.query.util.PostUUIDCriteria in project datawave by NationalSecurityAgency.

the class QueryExecutorBean method lookupUUIDBatch.

/**
 * @param queryParameters
 * @param httpHeaders
 * @return event results, either as a paged BaseQueryResponse or StreamingOutput
 * @RequestHeader X-ProxiedEntitiesChain use when proxying request for user, by specifying a chain of DNs of the identities to proxy
 * @RequestHeader X-ProxiedIssuersChain required when using X-ProxiedEntitiesChain, specify one issuer DN per subject DN listed in X-ProxiedEntitiesChain
 * @ResponseHeader query-session-id this header and value will be in the Set-Cookie header, subsequent calls for this session will need to supply the
 *                 query-session-id header in the request in a Cookie header or as a query parameter
 * @ResponseHeader X-OperationTimeInMS time spent on the server performing the operation, does not account for network or result serialization
 * @ResponseHeader X-Partial-Results true if the page contains less than the requested number of results
 *
 * @HTTP 200 success
 * @HTTP 204 success and no results
 * @HTTP 400 invalid or missing parameter
 * @HTTP 500 internal server error
 */
@POST
@Path("/lookupUUID")
@Produces({ "application/xml", "text/xml", "application/json", "text/yaml", "text/x-yaml", "application/x-yaml", "application/x-protobuf", "application/x-protostuff" })
@GZIP
@GenerateQuerySessionId(cookieBasePath = "/DataWave/Query/")
@Interceptors({ ResponseInterceptor.class, RequiredInterceptor.class })
@Override
@Timed(name = "dw.query.lookupUUIDBatch", absolute = true)
public <T> T lookupUUIDBatch(MultivaluedMap<String, String> queryParameters, @Required("httpHeaders") @Context HttpHeaders httpHeaders) {
    if (!queryParameters.containsKey("uuidPairs")) {
        throw new BadRequestException(new IllegalArgumentException("uuidPairs missing from query parameters"), new VoidResponse());
    }
    T response;
    String queryId = null;
    try {
        String uuidPairs = queryParameters.getFirst("uuidPairs");
        String streaming = queryParameters.getFirst("streaming");
        boolean streamingOutput = false;
        if (!StringUtils.isEmpty(streaming)) {
            streamingOutput = Boolean.parseBoolean(streaming);
        }
        final PostUUIDCriteria criteria = new PostUUIDCriteria(uuidPairs, queryParameters);
        if (streamingOutput) {
            criteria.setStreamingOutputHeaders(httpHeaders);
        }
        response = this.lookupUUIDUtil.createUUIDQueryAndNext(criteria);
        if (response instanceof BaseQueryResponse) {
            queryId = ((BaseQueryResponse) response).getQueryId();
        }
        return response;
    } finally {
        if (null != queryId) {
            asyncClose(queryId);
        }
    }
}
Also used : GET(javax.ws.rs.GET) POST(javax.ws.rs.POST) PUT(javax.ws.rs.PUT) VoidResponse(datawave.webservice.result.VoidResponse) BaseQueryResponse(datawave.webservice.result.BaseQueryResponse) BadRequestException(datawave.webservice.common.exception.BadRequestException) PostUUIDCriteria(datawave.webservice.query.util.PostUUIDCriteria) Path(javax.ws.rs.Path) GenerateQuerySessionId(datawave.annotation.GenerateQuerySessionId) Interceptors(javax.interceptor.Interceptors) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GZIP(org.jboss.resteasy.annotations.GZIP)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)2 GenerateQuerySessionId (datawave.annotation.GenerateQuerySessionId)2 BadRequestException (datawave.webservice.common.exception.BadRequestException)2 PostUUIDCriteria (datawave.webservice.query.util.PostUUIDCriteria)2 BaseQueryResponse (datawave.webservice.result.BaseQueryResponse)2 VoidResponse (datawave.webservice.result.VoidResponse)2 Interceptors (javax.interceptor.Interceptors)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 GZIP (org.jboss.resteasy.annotations.GZIP)2