use of datawave.webservice.query.exception.QueryException in project datawave by NationalSecurityAgency.
the class RESTExceptionMapperTest method testToResponse_WrappedQueryException.
@Test
public void testToResponse_WrappedQueryException() {
Exception e = new WebApplicationException(new QueryException("top-level", new QueryException("bottom-level", "567-8"), "123-4"));
StackTraceElement[] traceArr = new StackTraceElement[1];
traceArr[0] = new StackTraceElement("dummyClass", "dummyMethod", null, 0);
e.setStackTrace(traceArr);
Response response = rem.toResponse(e);
MultivaluedMap<String, Object> responseMap = response.getHeaders();
Assert.assertEquals(500, response.getStatus());
Assert.assertEquals(6, responseMap.size());
Assert.assertEquals(Lists.newArrayList(true), responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS));
Assert.assertEquals(Lists.newArrayList("*"), responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
Assert.assertEquals(Lists.newArrayList(864000), responseMap.get(HttpHeaders.ACCESS_CONTROL_MAX_AGE));
Assert.assertEquals(Lists.newArrayList("567-8"), responseMap.get(Constants.ERROR_CODE));
Assert.assertEquals(Lists.newArrayList("null/null"), responseMap.get(Constants.RESPONSE_ORIGIN));
Assert.assertEquals(Lists.newArrayList("X-SSL-ClientCert-Subject, X-ProxiedEntitiesChain, X-ProxiedIssuersChain, Accept, Accept-Encoding"), responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS));
}
use of datawave.webservice.query.exception.QueryException in project datawave by NationalSecurityAgency.
the class IteratorBuildingVisitor method buildExceededFromTermFrequency.
/**
* @param data
*/
private NestedIterator<Key> buildExceededFromTermFrequency(String identifier, JexlNode rootNode, JexlNode sourceNode, LiteralRange<?> range, Object data) {
if (limitLookup) {
ChainableEventDataQueryFilter wrapped = createWrappedTermFrequencyFilter(identifier, sourceNode, attrFilter);
NestedIterator<Key> eventFieldIterator = new EventFieldIterator(rangeLimiter, source.deepCopy(env), identifier, new AttributeFactory(this.typeMetadata), getEventFieldAggregator(identifier, wrapped));
TermFrequencyIndexBuilder builder = new TermFrequencyIndexBuilder();
builder.setSource(source.deepCopy(env));
builder.setTypeMetadata(typeMetadata);
builder.setFieldsToAggregate(fieldsToAggregate);
builder.setTimeFilter(timeFilter);
builder.setAttrFilter(attrFilter);
builder.setDatatypeFilter(datatypeFilter);
builder.setEnv(env);
builder.setTermFrequencyAggregator(getTermFrequencyAggregator(identifier, sourceNode, attrFilter, attrFilter != null ? attrFilter.getMaxNextCount() : -1));
builder.setNode(rootNode);
Range fiRange = getFiRangeForTF(range);
builder.setRange(fiRange);
builder.setField(identifier);
NestedIterator<Key> tfIterator = builder.build();
OrIterator tfMerge = new OrIterator(Arrays.asList(tfIterator, eventFieldIterator));
return tfMerge;
} else {
QueryException qe = new QueryException(DatawaveErrorCode.UNEXPECTED_SOURCE_NODE, MessageFormat.format("{0}", "buildExceededFromTermFrequency"));
throw new DatawaveFatalQueryException(qe);
}
}
use of datawave.webservice.query.exception.QueryException in project datawave by NationalSecurityAgency.
the class IteratorBuildingVisitor method visit.
@Override
public Object visit(ASTNENode node, Object data) {
// We have no parent already defined
if (data == null) {
// We don't support querying only on a negation
throw new IllegalStateException("Root node cannot be a negation");
}
IndexIteratorBuilder builder = null;
try {
builder = iteratorBuilderClass.asSubclass(IndexIteratorBuilder.class).newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
builder.setQueryId(queryId);
builder.setSource(source.deepCopy(env));
builder.setTypeMetadata(typeMetadata);
builder.setFieldsToAggregate(fieldsToAggregate);
builder.setTimeFilter(timeFilter);
builder.setDatatypeFilter(datatypeFilter);
builder.setKeyTransform(fiAggregator);
builder.setEnv(env);
builder.setNode(node);
node.childrenAccept(this, builder);
// handle this, so we should just not build an IndexIterator for it.
if (null == builder.getValue()) {
if (this.indexOnlyFields.contains(builder.getField())) {
QueryException qe = new QueryException(DatawaveErrorCode.INDEX_ONLY_FIELDS_RETRIEVAL_ERROR, MessageFormat.format("{0} {1} {2}", "Unable to compare index only field", builder.getField(), "against null"));
throw new DatawaveFatalQueryException(qe);
}
// SatisfactionVisitor should have already initialized this to false
if (isQueryFullySatisfied == true) {
log.warn("Determined that isQueryFullySatisfied should be false, but it was not preset to false in the SatisfactionVisitor");
}
return null;
}
AbstractIteratorBuilder iterators = (AbstractIteratorBuilder) data;
// Add the negated IndexIteratorBuilder to the parent as an *exclude*
if (!iterators.hasSeen(builder.getField(), builder.getValue()) && includeReferences.contains(builder.getField()) && !excludeReferences.contains(builder.getField())) {
iterators.addExclude(builder.build());
} else {
// SatisfactionVisitor should have already initialized this to false
if (isQueryFullySatisfied == true) {
log.warn("Determined that isQueryFullySatisfied should be false, but it was not preset to false in the SatisfactionVisitor");
}
}
return null;
}
use of datawave.webservice.query.exception.QueryException in project datawave by NationalSecurityAgency.
the class IteratorBuildingVisitor method ivarateRange.
/**
* Build the iterator stack using the regex ivarator (field index caching regex iterator)
*
* @param rootNode
* the node that was processed to generated this builder
* @param sourceNode
* the source node derived from the root
* @param data
*/
public void ivarateRange(JexlNode rootNode, JexlNode sourceNode, Object data) throws IOException {
IndexRangeIteratorBuilder builder = new IndexRangeIteratorBuilder();
builder.negateAsNeeded(data);
// hence the "IndexAgnostic" method can be used here
if (sourceNode instanceof ASTAndNode) {
LiteralRange range = JexlASTHelper.findRange().recursively().getRange(sourceNode);
if (range == null) {
QueryException qe = new QueryException(DatawaveErrorCode.MULTIPLE_RANGES_IN_EXPRESSION);
throw new DatawaveFatalQueryException(qe);
}
builder.setRange(range);
} else {
QueryException qe = new QueryException(DatawaveErrorCode.UNEXPECTED_SOURCE_NODE, MessageFormat.format("{0}", "ExceededValueThresholdMarkerJexlNode"));
throw new DatawaveFatalQueryException(qe);
}
builder.forceDocumentBuild(!limitLookup && this.isQueryFullySatisfied);
ivarate(builder, rootNode, sourceNode, data);
}
use of datawave.webservice.query.exception.QueryException in project datawave by NationalSecurityAgency.
the class IteratorBuildingVisitor method ivarateRegex.
/**
* Build the iterator stack using the regex ivarator (field index caching regex iterator)
*
* @param rootNode
* the node that was processed to generated this builder
* @param sourceNode
* the source node derived from the root
* @param data
*/
public void ivarateRegex(JexlNode rootNode, JexlNode sourceNode, Object data) throws IOException {
IndexRegexIteratorBuilder builder = new IndexRegexIteratorBuilder();
if (sourceNode instanceof ASTERNode || sourceNode instanceof ASTNRNode) {
builder.setNegated(sourceNode instanceof ASTNRNode);
builder.setField(JexlASTHelper.getIdentifier(sourceNode));
builder.setValue(String.valueOf(JexlASTHelper.getLiteralValue(sourceNode)));
} else {
QueryException qe = new QueryException(DatawaveErrorCode.UNEXPECTED_SOURCE_NODE, MessageFormat.format("{0}", "ExceededValueThresholdMarkerJexlNode"));
throw new DatawaveFatalQueryException(qe);
}
builder.negateAsNeeded(data);
builder.forceDocumentBuild(!limitLookup && this.isQueryFullySatisfied);
ivarate(builder, rootNode, sourceNode, data);
}
Aggregations