use of edu.umd.cs.findbugs.annotations.SuppressWarnings in project SearchServices by Alfresco.
the class Solr4QueryParser method getPrefixQuery.
@SuppressWarnings("deprecation")
public Query getPrefixQuery(String field, String termStr, AnalysisMode analysisMode) throws ParseException {
if (field.equals(FIELD_PATH)) {
throw new UnsupportedOperationException("Prefix Queries are not support for " + FIELD_PATH);
} else if (field.equals(FIELD_PATHWITHREPEATS)) {
throw new UnsupportedOperationException("Prefix Queries are not support for " + FIELD_PATHWITHREPEATS);
} else if (field.equals(FIELD_TEXT)) {
return createDefaultTextQuery(textField -> getPrefixQuery(textField, termStr, analysisMode));
} else if (field.equals(FIELD_ID)) {
boolean lowercaseExpandedTerms = getLowercaseExpandedTerms();
try {
setLowercaseExpandedTerms(false);
return super.getPrefixQuery(FIELD_LID, termStr);
} finally {
setLowercaseExpandedTerms(lowercaseExpandedTerms);
}
} else if (field.equals(FIELD_DBID) || field.equals(FIELD_ISROOT) || field.equals(FIELD_ISCONTAINER) || field.equals(FIELD_ISNODE) || field.equals(FIELD_TX) || field.equals(FIELD_PARENT) || field.equals(FIELD_PRIMARYPARENT) || field.equals(FIELD_QNAME) || field.equals(FIELD_PRIMARYASSOCTYPEQNAME) || field.equals(FIELD_ASSOCTYPEQNAME)) {
boolean lowercaseExpandedTerms = getLowercaseExpandedTerms();
try {
setLowercaseExpandedTerms(false);
return super.getPrefixQuery(field, termStr);
} finally {
setLowercaseExpandedTerms(lowercaseExpandedTerms);
}
} else if (field.equals(FIELD_CLASS)) {
return super.getPrefixQuery(field, termStr);
// throw new UnsupportedOperationException("Prefix Queries are not
// support for "+FIELD_CLASS);
} else if (field.equals(FIELD_TYPE)) {
return super.getPrefixQuery(field, termStr);
// throw new UnsupportedOperationException("Prefix Queries are not
// support for "+FIELD_TYPE);
} else if (field.equals(FIELD_EXACTTYPE)) {
return super.getPrefixQuery(field, termStr);
// throw new UnsupportedOperationException("Prefix Queries are not
// support for "+FIELD_EXACTTYPE);
} else if (field.equals(FIELD_ASPECT)) {
return super.getPrefixQuery(field, termStr);
// throw new UnsupportedOperationException("Prefix Queries are not
// support for "+FIELD_ASPECT);
} else if (field.equals(FIELD_EXACTASPECT)) {
return super.getPrefixQuery(field, termStr);
// throw new UnsupportedOperationException("Prefix Queries are not
// support for "+FIELD_EXACTASPECT);
} else if (isPropertyField(field)) {
return attributeQueryBuilder(field, termStr, new PrefixQuery(), analysisMode, LuceneFunction.FIELD);
} else if (field.equals(FIELD_ALL)) {
Set<String> all = searchParameters.getAllAttributes();
if ((all == null) || (all.size() == 0)) {
Collection<QName> contentAttributes = dictionaryService.getAllProperties(null);
BooleanQuery.Builder query = new BooleanQuery.Builder();
for (QName qname : contentAttributes) {
// The super implementation will create phrase queries etc
// if required
Query part = getPrefixQuery(PROPERTY_FIELD_PREFIX + qname.toString(), termStr, analysisMode);
if (part != null) {
query.add(part, Occur.SHOULD);
} else {
query.add(createNoMatchQuery(), Occur.SHOULD);
}
}
return query.build();
} else {
BooleanQuery.Builder query = new BooleanQuery.Builder();
for (String fieldName : all) {
Query part = getPrefixQuery(fieldName, termStr, analysisMode);
if (part != null) {
query.add(part, Occur.SHOULD);
} else {
query.add(createNoMatchQuery(), Occur.SHOULD);
}
}
return query.build();
}
} else if (field.equals(FIELD_ISUNSET)) {
throw new UnsupportedOperationException("Prefix Queries are not support for " + FIELD_ISUNSET);
} else if (field.equals(FIELD_ISNULL)) {
throw new UnsupportedOperationException("Prefix Queries are not support for " + FIELD_ISNULL);
} else if (field.equals(FIELD_ISNOTNULL)) {
throw new UnsupportedOperationException("Prefix Queries are not support for " + FIELD_ISNOTNULL);
} else if (field.equals(FIELD_EXISTS)) {
throw new UnsupportedOperationException("Prefix Queries are not support for " + FIELD_EXISTS);
} else if (QueryParserUtils.matchDataTypeDefinition(searchParameters.getNamespace(), namespacePrefixResolver, dictionaryService, field) != null) {
Collection<QName> contentAttributes = dictionaryService.getAllProperties(QueryParserUtils.matchDataTypeDefinition(searchParameters.getNamespace(), namespacePrefixResolver, dictionaryService, field).getName());
BooleanQuery.Builder query = new BooleanQuery.Builder();
for (QName qname : contentAttributes) {
// The super implementation will create phrase queries etc if
// required
Query part = getPrefixQuery(PROPERTY_FIELD_PREFIX + qname.toString(), termStr, analysisMode);
if (part != null) {
query.add(part, Occur.SHOULD);
} else {
query.add(createNoMatchQuery(), Occur.SHOULD);
}
}
return query.build();
} else if (field.equals(FIELD_FTSSTATUS)) {
throw new UnsupportedOperationException("Prefix Queries are not support for " + FIELD_FTSSTATUS);
} else if (field.equals(FIELD_TAG)) {
return super.getPrefixQuery(field, termStr);
} else if (field.equals(FIELD_SITE)) {
return super.getPrefixQuery(field, termStr);
} else if (field.equals(FIELD_NPATH)) {
return super.getPrefixQuery(field, termStr);
} else if (field.equals(FIELD_PNAME)) {
return super.getPrefixQuery(field, termStr);
} else {
return super.getPrefixQuery(field, termStr);
}
}
use of edu.umd.cs.findbugs.annotations.SuppressWarnings in project SearchServices by Alfresco.
the class Solr4QueryParser method getWildcardQuery.
@SuppressWarnings("deprecation")
public Query getWildcardQuery(String field, String termStr, AnalysisMode analysisMode) throws ParseException {
if (field.equals(FIELD_PATH)) {
throw new UnsupportedOperationException("Wildcard Queries are not support for " + FIELD_PATH);
} else if (field.equals(FIELD_PATHWITHREPEATS)) {
throw new UnsupportedOperationException("Wildcard Queries are not support for " + FIELD_PATHWITHREPEATS);
} else if (field.equals(FIELD_TEXT)) {
return createDefaultTextQuery(textField -> getWildcardQuery(textField, termStr, analysisMode));
} else if (field.equals(FIELD_ID)) {
boolean lowercaseExpandedTerms = getLowercaseExpandedTerms();
try {
setLowercaseExpandedTerms(false);
return super.getWildcardQuery(FIELD_LID, termStr);
} finally {
setLowercaseExpandedTerms(lowercaseExpandedTerms);
}
} else if (field.equals(FIELD_DBID) || field.equals(FIELD_ISROOT) || field.equals(FIELD_ISCONTAINER) || field.equals(FIELD_ISNODE) || field.equals(FIELD_TX) || field.equals(FIELD_PARENT) || field.equals(FIELD_PRIMARYPARENT) || field.equals(FIELD_QNAME) || field.equals(FIELD_PRIMARYASSOCTYPEQNAME) || field.equals(FIELD_ASSOCTYPEQNAME)) {
boolean lowercaseExpandedTerms = getLowercaseExpandedTerms();
try {
setLowercaseExpandedTerms(false);
return super.getWildcardQuery(field, termStr);
} finally {
setLowercaseExpandedTerms(lowercaseExpandedTerms);
}
} else if (field.equals(FIELD_CLASS)) {
return super.getWildcardQuery(field, termStr);
// throw new UnsupportedOperationException("Wildcard Queries are not
// support for "+FIELD_CLASS);
} else if (field.equals(FIELD_TYPE)) {
return super.getWildcardQuery(field, termStr);
// throw new UnsupportedOperationException("Wildcard Queries are not
// support for "+FIELD_TYPE);
} else if (field.equals(FIELD_EXACTTYPE)) {
return super.getWildcardQuery(field, termStr);
// throw new UnsupportedOperationException("Wildcard Queries are not
// support for "+FIELD_EXACTTYPE);
} else if (field.equals(FIELD_ASPECT)) {
return super.getWildcardQuery(field, termStr);
// throw new UnsupportedOperationException("Wildcard Queries are not
// support for "+FIELD_ASPECT);
} else if (field.equals(FIELD_EXACTASPECT)) {
return super.getWildcardQuery(field, termStr);
// throw new UnsupportedOperationException("Wildcard Queries are not
// support for "+FIELD_EXACTASPECT);
} else if (isPropertyField(field)) {
return attributeQueryBuilder(field, termStr, new WildcardQuery(), analysisMode, LuceneFunction.FIELD);
} else if (field.equals(FIELD_ALL)) {
Set<String> all = searchParameters.getAllAttributes();
if ((all == null) || (all.size() == 0)) {
Collection<QName> contentAttributes = dictionaryService.getAllProperties(null);
BooleanQuery.Builder query = new BooleanQuery.Builder();
for (QName qname : contentAttributes) {
// The super implementation will create phrase queries etc
// if required
Query part = getWildcardQuery(PROPERTY_FIELD_PREFIX + qname.toString(), termStr, analysisMode);
if (part != null) {
query.add(part, Occur.SHOULD);
} else {
query.add(createNoMatchQuery(), Occur.SHOULD);
}
}
return query.build();
} else {
BooleanQuery.Builder query = new BooleanQuery.Builder();
for (String fieldName : all) {
Query part = getWildcardQuery(fieldName, termStr, analysisMode);
if (part != null) {
query.add(part, Occur.SHOULD);
} else {
query.add(createNoMatchQuery(), Occur.SHOULD);
}
}
return query.build();
}
} else if (field.equals(FIELD_ISUNSET)) {
throw new UnsupportedOperationException("Wildcard Queries are not support for " + FIELD_ISUNSET);
} else if (field.equals(FIELD_ISNULL)) {
throw new UnsupportedOperationException("Wildcard Queries are not support for " + FIELD_ISNULL);
} else if (field.equals(FIELD_ISNOTNULL)) {
throw new UnsupportedOperationException("Wildcard Queries are not support for " + FIELD_ISNOTNULL);
} else if (field.equals(FIELD_EXISTS)) {
throw new UnsupportedOperationException("Wildcard Queries are not support for " + FIELD_EXISTS);
} else if (QueryParserUtils.matchDataTypeDefinition(searchParameters.getNamespace(), namespacePrefixResolver, dictionaryService, field) != null) {
Collection<QName> contentAttributes = dictionaryService.getAllProperties(QueryParserUtils.matchDataTypeDefinition(searchParameters.getNamespace(), namespacePrefixResolver, dictionaryService, field).getName());
BooleanQuery.Builder query = new BooleanQuery.Builder();
for (QName qname : contentAttributes) {
// The super implementation will create phrase queries etc if
// required
Query part = getWildcardQuery(PROPERTY_FIELD_PREFIX + qname.toString(), termStr, analysisMode);
if (part != null) {
query.add(part, Occur.SHOULD);
} else {
query.add(createNoMatchQuery(), Occur.SHOULD);
}
}
return query.build();
} else if (field.equals(FIELD_FTSSTATUS)) {
throw new UnsupportedOperationException("Wildcard Queries are not support for " + FIELD_FTSSTATUS);
} else if (field.equals(FIELD_TAG)) {
return super.getWildcardQuery(field, termStr);
} else if (field.equals(FIELD_SITE)) {
return super.getWildcardQuery(field, termStr);
} else if (field.equals(FIELD_PNAME)) {
return super.getWildcardQuery(field, termStr);
} else if (field.equals(FIELD_NPATH)) {
return super.getWildcardQuery(field, termStr);
} else {
return super.getWildcardQuery(field, termStr);
}
}
use of edu.umd.cs.findbugs.annotations.SuppressWarnings in project SearchServices by Alfresco.
the class TempFileWarningLogger method checkFiles.
// Avoid FindBugs false positive (https://github.com/spotbugs/spotbugs/issues/756)
@SuppressWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE")
public boolean checkFiles() {
if (log.isDebugEnabled()) {
log.debug("Looking for temp files matching " + glob + " in directory " + dir);
}
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, glob)) {
for (Path file : stream) {
if (log.isDebugEnabled()) {
log.debug("Solr suggester temp file found matching file pattern: " + glob + ", path: " + file);
log.debug("Removing suggester temp files.");
}
return true;
}
return false;
} catch (IOException e) {
throw new RuntimeException("Unable to create directory stream", e);
}
}
use of edu.umd.cs.findbugs.annotations.SuppressWarnings in project incubator-gobblin by apache.
the class Fork method consumeRecordStream.
@SuppressWarnings(value = "RV_RETURN_VALUE_IGNORED", justification = "We actually don't care about the return value of subscribe.")
public void consumeRecordStream(RecordStreamWithMetadata<D, S> stream) throws RecordStreamProcessor.StreamProcessingException {
if (this.converter instanceof MultiConverter) {
// if multiconverter, unpack it
for (Converter cverter : ((MultiConverter) this.converter).getConverters()) {
stream = cverter.processStream(stream, this.taskState);
}
} else {
stream = this.converter.processStream(stream, this.taskState);
}
stream = this.rowLevelPolicyChecker.processStream(stream, this.taskState);
stream = stream.mapStream(s -> s.map(r -> {
onEachRecord();
return r;
}));
stream = stream.mapStream(s -> s.doOnSubscribe(subscription -> onStart()));
stream = stream.mapStream(s -> s.doOnComplete(() -> verifyAndSetForkState(ForkState.RUNNING, ForkState.SUCCEEDED)));
stream = stream.mapStream(s -> s.doOnCancel(() -> {
// Errors don't propagate up from below the fork, but cancel the stream, so use the failed state to indicate that
// the fork failed to complete, which will then fail the task.
verifyAndSetForkState(ForkState.RUNNING, ForkState.FAILED);
}));
stream = stream.mapStream(s -> s.doOnError(exc -> {
verifyAndSetForkState(ForkState.RUNNING, ForkState.FAILED);
this.logger.error(String.format("Fork %d of task %s failed to process data records", this.index, this.taskId), exc);
}));
stream = stream.mapStream(s -> s.doFinally(this::cleanup));
stream.getRecordStream().subscribe(r -> {
if (r instanceof RecordEnvelope) {
this.writer.get().writeEnvelope((RecordEnvelope) r);
} else if (r instanceof ControlMessage) {
// This is to avoid missing an ack/nack in the error path.
try {
this.writer.get().getMessageHandler().handleMessage((ControlMessage) r);
} catch (Throwable error) {
r.nack(error);
throw error;
}
r.ack();
}
}, e -> {
// Handle writer close in error case since onComplete will not call when exception happens
if (this.writer.isPresent()) {
this.writer.get().close();
}
logger.error("Failed to process record.", e);
verifyAndSetForkState(ForkState.RUNNING, ForkState.FAILED);
}, () -> {
if (this.writer.isPresent()) {
this.writer.get().close();
}
});
}
use of edu.umd.cs.findbugs.annotations.SuppressWarnings in project st-js by st-js.
the class NodeJSExecutor method run.
/**
* <p>run.</p>
*
* @param srcFile a {@link java.io.File} object.
* @return a {@link org.stjs.generator.executor.ExecutionResult} object.
*/
@SuppressWarnings(value = "REC_CATCH_EXCEPTION")
public ExecutionResult run(File srcFile) {
try {
Process p = Runtime.getRuntime().exec(new String[] { NODE_JS, srcFile.getAbsolutePath() });
int exitValue = p.waitFor();
return new ExecutionResult(null, readStream(p.getInputStream()), readStream(p.getErrorStream()), exitValue);
} catch (IOException e) {
// TODO : this is not really going to be working on all OS!
if (e.getMessage().contains("Cannot run program")) {
String errMsg = "Please install node.js to use this feature https://github.com/joyent/node/wiki/Installation";
throw new STJSRuntimeException(errMsg, e);
}
throw new STJSRuntimeException(e);
} catch (InterruptedException e) {
throw new STJSRuntimeException(e);
}
}
Aggregations