Get it to build
git-svn-id: https://svn.apache.org/repos/asf/manifoldcf/integration/elasticsearch-2.0/trunk@1758665 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerPlugin.java b/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerPlugin.java
index cad000b..5311ec4 100644
--- a/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerPlugin.java
+++ b/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerPlugin.java
@@ -43,7 +43,7 @@
return "Plugin to connect elasticsearch with ManifoldCF";
}
- @Override
+ //@Override
public void onModule(RestModule module) {
module.addRestAction(MCFAuthorizerRestSearchAction.class);
}
diff --git a/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerRestSearchAction.java b/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerRestSearchAction.java
index d058eae..d03c760 100644
--- a/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerRestSearchAction.java
+++ b/src/main/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerRestSearchAction.java
@@ -66,7 +66,7 @@
protected SearchRequest parseSearchRequestMCF(
final RestRequest request,
- final ParseFieldMatcher parseFieldMatcher) throws IOException {
+ final ParseFieldMatcher parseFieldMatcher) throws MCFAuthorizerException {
final SearchRequest searchRequest;
if(request.param("u")!=null) {
searchRequest = new SearchRequest();
@@ -83,18 +83,22 @@
ObjectNode modifiedJSON, innerJSON;
JsonNode requestJSON;
- requestJSON = objectMapper.readTree(RestActions.getRestContent(request).toBytes());
- if (isTemplateRequest) {
- modifiedJSON = (ObjectNode) requestJSON;
- innerJSON = (ObjectNode)requestJSON.findValue("template");
- filteredQueryBuilder = QueryBuilders.filteredQuery(QueryBuilders.wrapperQuery(innerJSON.findValue("query").toString()), authorizationFilter);
- modifiedJSON.replace("template",innerJSON.set("query", objectMapper.readTree(filteredQueryBuilder.buildAsBytes().toBytes())));
- searchRequest.templateSource(modifiedJSON.toString());
- } else {
- filteredQueryBuilder = QueryBuilders.filteredQuery(QueryBuilders.wrapperQuery(requestJSON.findValue("query").toString()), authorizationFilter);
- modifiedJSON = (ObjectNode) requestJSON;
- modifiedJSON.set("query", objectMapper.readTree(filteredQueryBuilder.buildAsBytes().toBytes()));
- searchRequest.source(modifiedJSON.toString());
+ try {
+ requestJSON = objectMapper.readTree(RestActions.getRestContent(request).toBytes());
+ if (isTemplateRequest) {
+ modifiedJSON = (ObjectNode) requestJSON;
+ innerJSON = (ObjectNode)requestJSON.findValue("template");
+ filteredQueryBuilder = QueryBuilders.filteredQuery(QueryBuilders.wrapperQuery(innerJSON.findValue("query").toString()), authorizationFilter);
+ modifiedJSON.replace("template",innerJSON.set("query", objectMapper.readTree(filteredQueryBuilder.buildAsBytes().toBytes())));
+ searchRequest.templateSource(modifiedJSON.toString());
+ } else {
+ filteredQueryBuilder = QueryBuilders.filteredQuery(QueryBuilders.wrapperQuery(requestJSON.findValue("query").toString()), authorizationFilter);
+ modifiedJSON = (ObjectNode) requestJSON;
+ modifiedJSON.set("query", objectMapper.readTree(filteredQueryBuilder.buildAsBytes().toBytes()));
+ searchRequest.source(modifiedJSON.toString());
+ }
+ } catch (IOException e) {
+ throw new MCFAuthorizerException("JSON parser error: "+e.getMessage(), e);
}
}