#90 Gson implementation. #106
@@ -74,16 +74,6 @@
|
|||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>${gson.version}</version>
|
<version>${gson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- XSLT -->
|
<!-- XSLT -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.r11.tools;
|
package com.r11.tools;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import com.r11.tools.controller.JsonController;
|
import com.r11.tools.controller.JsonController;
|
||||||
import com.r11.tools.controller.ProcessorInfoController;
|
import com.r11.tools.controller.ProcessorInfoController;
|
||||||
import com.r11.tools.controller.XPathController;
|
import com.r11.tools.controller.XPathController;
|
||||||
@@ -25,11 +27,16 @@ public class SparkApplication {
|
|||||||
|
|
||||||
Logger logger = LogManager.getLogger(SparkApplication.class);
|
Logger logger = LogManager.getLogger(SparkApplication.class);
|
||||||
|
|
||||||
|
Gson gson = new GsonBuilder()
|
||||||
|
.disableHtmlEscaping()
|
||||||
|
.setPrettyPrinting()
|
||||||
|
.create();
|
||||||
|
|
||||||
RestControllerRegistry registry = new RestControllerRegistry();
|
RestControllerRegistry registry = new RestControllerRegistry();
|
||||||
registry.registerController(new ProcessorInfoController(logger));
|
registry.registerController(new ProcessorInfoController(logger));
|
||||||
registry.registerController(new XsdController(logger));
|
registry.registerController(new XsdController(gson, logger));
|
||||||
registry.registerController(new XPathController(logger));
|
registry.registerController(new XPathController(gson, logger));
|
||||||
registry.registerController(new XsltController(logger));
|
registry.registerController(new XsltController(gson, logger));
|
||||||
registry.registerController(new JsonController());
|
registry.registerController(new JsonController());
|
||||||
|
|
||||||
registry.register();
|
registry.register();
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
package com.r11.tools.controller;
|
package com.r11.tools.controller;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.google.gson.Gson;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.google.gson.JsonObject;
|
||||||
import com.r11.tools.controller.internal.GlobalControllerManifest;
|
import com.r11.tools.controller.internal.GlobalControllerManifest;
|
||||||
import com.r11.tools.controller.internal.HandlerType;
|
import com.r11.tools.controller.internal.HandlerType;
|
||||||
import com.r11.tools.controller.internal.RestController;
|
import com.r11.tools.controller.internal.RestController;
|
||||||
import com.r11.tools.controller.internal.ScopedControllerManifest;
|
import com.r11.tools.controller.internal.ScopedControllerManifest;
|
||||||
import com.r11.tools.xml.Saxon;
|
import com.r11.tools.xml.Saxon;
|
||||||
import com.r11.tools.xml.Xalan;
|
import com.r11.tools.xml.Xalan;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import spark.Request;
|
import spark.Request;
|
||||||
import spark.Response;
|
import spark.Response;
|
||||||
@@ -17,36 +15,37 @@ import spark.Response;
|
|||||||
@GlobalControllerManifest
|
@GlobalControllerManifest
|
||||||
public class XPathController implements RestController {
|
public class XPathController implements RestController {
|
||||||
|
|
||||||
|
private final Gson gson;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
|
||||||
public XPathController(Logger logger) {
|
public XPathController(Gson gson, Logger logger) {
|
||||||
|
this.gson = gson;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ScopedControllerManifest(method = HandlerType.POST, path = "/xpath")
|
@ScopedControllerManifest(method = HandlerType.POST, path = "/xpath")
|
||||||
public void transform(Request request, Response response) throws JsonProcessingException {
|
public void transform(Request request, Response response) {
|
||||||
String body = request.body();
|
String body = request.body();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
Map<String, String> requestMap = new HashMap<>();
|
JsonObject requestJson;
|
||||||
Map<String, String> responseMap = new HashMap<>();
|
|
||||||
try {
|
try {
|
||||||
requestMap = mapper.readValue(body, Map.class);
|
requestJson = this.gson.fromJson(body, JsonObject.class);
|
||||||
} catch (JsonProcessingException ex) {
|
} catch (Exception e) {
|
||||||
this.logger.error("Request JSON error. " + ex);
|
JsonObject responseJson = new JsonObject();
|
||||||
responseMap.put("result", ex.getMessage());
|
responseJson.addProperty("result", e.getMessage());
|
||||||
responseMap.put("processor", "N/A");
|
responseJson.addProperty("processor", "N/A");
|
||||||
responseMap.put("status", "ERR");
|
responseJson.addProperty("status", "ERR");
|
||||||
responseMap.put("time", "N/A");
|
responseJson.addProperty("time", "N/A");
|
||||||
|
|
||||||
response.status(400);
|
response.status(400);
|
||||||
response.body(mapper.writeValueAsString(responseMap));
|
response.body(this.gson.toJson(responseJson));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String data = requestMap.get("data");
|
String data = requestJson.get("data").getAsString();
|
||||||
String query = requestMap.get("process");
|
String query = requestJson.get("process").getAsString();
|
||||||
String processor = requestMap.get("processor");
|
String processor = requestJson.get("processor").getAsString();
|
||||||
String version = requestMap.get("version");
|
String version = requestJson.get("version").getAsString();
|
||||||
|
|
||||||
|
|
||||||
String tmp = "";
|
String tmp = "";
|
||||||
long timeStart;
|
long timeStart;
|
||||||
@@ -57,45 +56,64 @@ public class XPathController implements RestController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JsonObject responseJson = new JsonObject();
|
||||||
switch (processor) {
|
switch (processor) {
|
||||||
case "saxon":
|
case "saxon":
|
||||||
response.header("processor", "Saxon " + Saxon.getVersion() + " " + version + " over s9api");
|
response.header("processor", "Saxon " + Saxon.getVersion() + " " + version + " over s9api");
|
||||||
timeStart = System.currentTimeMillis();
|
timeStart = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tmp = Saxon.processXPath(data, query, version).trim();
|
tmp = Saxon.processXPath(data, query, version).trim();
|
||||||
responseMap.put("result", tmp);
|
|
||||||
responseMap.put("status", "OK");
|
response.status(200);
|
||||||
|
|
||||||
|
responseJson.addProperty("result", tmp);
|
||||||
|
responseJson.addProperty("status", "OK");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.logger.error("Error on processing XPath using Saxon. " + ex);
|
this.logger.error("Error on processing XPath using Saxon. " + ex);
|
||||||
responseMap.put("result", ex.getMessage());
|
|
||||||
responseMap.put("status", "ERR");
|
|
||||||
response.status(400);
|
response.status(400);
|
||||||
|
|
||||||
|
responseJson.addProperty("result", ex.getMessage());
|
||||||
|
responseJson.addProperty("status", "ERR");
|
||||||
}
|
}
|
||||||
|
|
||||||
duration = System.currentTimeMillis() - timeStart;
|
duration = System.currentTimeMillis() - timeStart;
|
||||||
this.logger.info("Request" + body + " processed in " + duration + " ms.");
|
this.logger.info("Request" + body + " processed in " + duration + " ms.");
|
||||||
responseMap.put("processor", "Saxon " + Saxon.getVersion() + " " + version + " over s9api");
|
|
||||||
responseMap.put("time", "" + duration);
|
responseJson.addProperty("processor", "Saxon " + Saxon.getVersion() + " " + version + " over s9api");
|
||||||
response.body(mapper.writeValueAsString(responseMap));
|
responseJson.addProperty("time", duration);
|
||||||
|
|
||||||
|
response.body(this.gson.toJson(responseJson));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case "xalan":
|
case "xalan":
|
||||||
response.header("processor", Xalan.getVersion());
|
response.header("processor", Xalan.getVersion());
|
||||||
timeStart = System.currentTimeMillis();
|
timeStart = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tmp = Xalan.processXPath(data, query).trim();
|
tmp = Xalan.processXPath(data, query).trim();
|
||||||
responseMap.put("result", tmp);
|
|
||||||
responseMap.put("status", "OK");
|
response.status(200);
|
||||||
|
|
||||||
|
responseJson.addProperty("result", tmp);
|
||||||
|
responseJson.addProperty("status", "OK");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.logger.error("Error on processing XPath using Xalan. " + ex);
|
this.logger.error("Error on processing XPath using Xalan. " + ex);
|
||||||
responseMap.put("result", ex.getMessage());
|
|
||||||
responseMap.put("status", "ERR");
|
|
||||||
response.status(400);
|
response.status(400);
|
||||||
|
|
||||||
|
responseJson.addProperty("result", ex.getMessage());
|
||||||
|
responseJson.addProperty("status", "ERR");
|
||||||
}
|
}
|
||||||
|
|
||||||
duration = System.currentTimeMillis() - timeStart;
|
duration = System.currentTimeMillis() - timeStart;
|
||||||
this.logger.info("Request: " + body + " processed in " + duration + " ms.");
|
this.logger.info("Request: " + body + " processed in " + duration + " ms.");
|
||||||
responseMap.put("processor", Xalan.getVersion());
|
|
||||||
responseMap.put("time", Long.toString(duration));
|
responseJson.addProperty("processor", Xalan.getVersion());
|
||||||
response.body(mapper.writeValueAsString(responseMap));
|
responseJson.addProperty("time", duration);
|
||||||
|
|
||||||
|
response.body(this.gson.toJson(responseJson));
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
response.body("saxon, xalan");
|
response.body("saxon, xalan");
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
package com.r11.tools.controller;
|
package com.r11.tools.controller;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.google.gson.Gson;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.google.gson.JsonObject;
|
||||||
import com.r11.tools.controller.internal.GlobalControllerManifest;
|
import com.r11.tools.controller.internal.GlobalControllerManifest;
|
||||||
import com.r11.tools.controller.internal.HandlerType;
|
import com.r11.tools.controller.internal.HandlerType;
|
||||||
import com.r11.tools.controller.internal.RestController;
|
import com.r11.tools.controller.internal.RestController;
|
||||||
import com.r11.tools.controller.internal.ScopedControllerManifest;
|
import com.r11.tools.controller.internal.ScopedControllerManifest;
|
||||||
import com.r11.tools.xml.Xalan;
|
import com.r11.tools.xml.Xalan;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import spark.Request;
|
import spark.Request;
|
||||||
import spark.Response;
|
import spark.Response;
|
||||||
@@ -16,55 +14,65 @@ import spark.Response;
|
|||||||
@GlobalControllerManifest
|
@GlobalControllerManifest
|
||||||
public class XsdController implements RestController {
|
public class XsdController implements RestController {
|
||||||
|
|
||||||
|
private final Gson gson;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
|
||||||
public XsdController(Logger logger) {
|
public XsdController(Gson gson, Logger logger) {
|
||||||
|
this.gson = gson;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ScopedControllerManifest(method = HandlerType.POST, path = "/xsd")
|
@ScopedControllerManifest(method = HandlerType.POST, path = "/xsd")
|
||||||
public Response transform(Request req, Response resp) throws JsonProcessingException {
|
public Response transform(Request request, Response response) {
|
||||||
String body = req.body();
|
String body = request.body();
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
Map<String, String> requestMap = new HashMap<>();
|
|
||||||
Map<String, String> responseMap = new HashMap<>();
|
|
||||||
|
|
||||||
|
JsonObject requestJson;
|
||||||
try {
|
try {
|
||||||
requestMap = mapper.readValue(body, Map.class);
|
requestJson = this.gson.fromJson(body, JsonObject.class);
|
||||||
} catch (JsonProcessingException ex) {
|
} catch (Exception e) {
|
||||||
this.logger.error("Request JSON error. " + ex);
|
JsonObject responseJson = new JsonObject();
|
||||||
responseMap.put("result", ex.getMessage());
|
responseJson.addProperty("result", e.getMessage());
|
||||||
responseMap.put("processor", "N/A");
|
responseJson.addProperty("processor", "N/A");
|
||||||
responseMap.put("status", "ERR");
|
responseJson.addProperty("status", "ERR");
|
||||||
responseMap.put("time", "N/A");
|
responseJson.addProperty("time", "N/A");
|
||||||
resp.status(400);
|
|
||||||
resp.body(mapper.writeValueAsString(responseMap));
|
response.status(400);
|
||||||
return resp;
|
response.body(this.gson.toJson(responseJson));
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
String data = requestMap.get("data");
|
String data = requestJson.get("data").getAsString();
|
||||||
String xsd = requestMap.get("process");
|
String xsd = requestJson.get("process").getAsString();
|
||||||
|
|
||||||
|
response.header("processor", Xalan.getVersion());
|
||||||
|
|
||||||
resp.header("processor", Xalan.getVersion());
|
|
||||||
long timeStart = System.currentTimeMillis();
|
long timeStart = System.currentTimeMillis();
|
||||||
String tmp;
|
String tmp;
|
||||||
|
|
||||||
|
JsonObject responseJson = new JsonObject();
|
||||||
try {
|
try {
|
||||||
tmp = Xalan.validate(data, xsd).trim();
|
tmp = Xalan.validate(data, xsd).trim();
|
||||||
responseMap.put("result", tmp);
|
|
||||||
responseMap.put("status", "OK");
|
response.status(200);
|
||||||
|
|
||||||
|
responseJson.addProperty("result", tmp);
|
||||||
|
responseJson.addProperty("status", "OK");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.logger.error("Error on validation against XSD using Xalan. " + ex);
|
this.logger.error("Error on validation against XSD using Xalan. " + ex);
|
||||||
responseMap.put("result", ex.getMessage());
|
|
||||||
responseMap.put("status", "ERR");
|
response.status(400);
|
||||||
resp.status(400);
|
|
||||||
|
responseJson.addProperty("result", ex.getMessage());
|
||||||
|
responseJson.addProperty("status", "ERR");
|
||||||
}
|
}
|
||||||
|
|
||||||
long duration = System.currentTimeMillis() - timeStart;
|
long duration = System.currentTimeMillis() - timeStart;
|
||||||
this.logger.info("Request: " + body + " processed in " + duration + " ms.");
|
this.logger.info("Request: " + body + " processed in " + duration + " ms.");
|
||||||
responseMap.put("processor", Xalan.getVersion());
|
|
||||||
responseMap.put("time", "" + duration);
|
responseJson.addProperty("processor", Xalan.getVersion());
|
||||||
resp.body(mapper.writeValueAsString(responseMap));
|
responseJson.addProperty("time", duration);
|
||||||
return resp;
|
|
||||||
|
response.body(this.gson.toJson(responseJson));
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package com.r11.tools.controller;
|
package com.r11.tools.controller;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParseException;
|
import com.google.gson.Gson;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.google.gson.JsonObject;
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.r11.tools.controller.internal.GlobalControllerManifest;
|
import com.r11.tools.controller.internal.GlobalControllerManifest;
|
||||||
import com.r11.tools.controller.internal.HandlerType;
|
import com.r11.tools.controller.internal.HandlerType;
|
||||||
import com.r11.tools.controller.internal.RestController;
|
import com.r11.tools.controller.internal.RestController;
|
||||||
import com.r11.tools.controller.internal.ScopedControllerManifest;
|
import com.r11.tools.controller.internal.ScopedControllerManifest;
|
||||||
import com.r11.tools.xml.Saxon;
|
import com.r11.tools.xml.Saxon;
|
||||||
import com.r11.tools.xml.Xalan;
|
import com.r11.tools.xml.Xalan;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import spark.Request;
|
import spark.Request;
|
||||||
import spark.Response;
|
import spark.Response;
|
||||||
@@ -19,35 +15,37 @@ import spark.Response;
|
|||||||
@GlobalControllerManifest
|
@GlobalControllerManifest
|
||||||
public class XsltController implements RestController {
|
public class XsltController implements RestController {
|
||||||
|
|
||||||
|
private final Gson gson;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
|
||||||
public XsltController(Logger logger) {
|
public XsltController(Gson gson, Logger logger) {
|
||||||
|
this.gson = gson;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ScopedControllerManifest(method = HandlerType.POST, path = "/xslt")
|
@ScopedControllerManifest(method = HandlerType.POST, path = "/xslt")
|
||||||
public void transform(Request request, Response response) throws JsonProcessingException {
|
public void transform(Request request, Response response) {
|
||||||
String body = request.body();
|
String body = request.body();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
Map<String, String> requestMap = new HashMap<>();
|
JsonObject requestJson;
|
||||||
Map<String, String> responseMap = new HashMap<>();
|
|
||||||
try {
|
try {
|
||||||
requestMap = mapper.readValue(body, Map.class);
|
requestJson = this.gson.fromJson(body, JsonObject.class);
|
||||||
} catch (JsonMappingException | JsonParseException ex) {
|
} catch (Exception e) {
|
||||||
this.logger.error("Request JSON error. " + ex);
|
JsonObject responseJson = new JsonObject();
|
||||||
responseMap.put("result", ex.getMessage());
|
responseJson.addProperty("result", e.getMessage());
|
||||||
responseMap.put("processor", "N/A");
|
responseJson.addProperty("processor", "N/A");
|
||||||
responseMap.put("status", "ERR");
|
responseJson.addProperty("status", "ERR");
|
||||||
responseMap.put("time", "N/A");
|
responseJson.addProperty("time", "N/A");
|
||||||
|
|
||||||
response.status(400);
|
response.status(400);
|
||||||
response.body(mapper.writeValueAsString(responseMap));
|
response.body(this.gson.toJson(responseJson));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String data = requestMap.get("data");
|
String data = requestJson.get("data").getAsString();
|
||||||
String query = requestMap.get("process");
|
String query = requestJson.get("process").getAsString();
|
||||||
String processor = requestMap.get("processor");
|
String processor = requestJson.get("processor").getAsString();
|
||||||
String version = requestMap.get("version");
|
String version = requestJson.get("version").getAsString();
|
||||||
|
|
||||||
if (processor == null) {
|
if (processor == null) {
|
||||||
response.body("saxon, xalan");
|
response.body("saxon, xalan");
|
||||||
@@ -57,45 +55,61 @@ public class XsltController implements RestController {
|
|||||||
String tmp;
|
String tmp;
|
||||||
long timeStart;
|
long timeStart;
|
||||||
long duration;
|
long duration;
|
||||||
|
|
||||||
|
JsonObject responseJson = new JsonObject();
|
||||||
switch (processor) {
|
switch (processor) {
|
||||||
case "saxon":
|
case "saxon":
|
||||||
timeStart = System.currentTimeMillis();
|
timeStart = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
tmp = Saxon.processXSLT(data, query);
|
tmp = Saxon.processXSLT(data, query);
|
||||||
responseMap.put("result", tmp);
|
|
||||||
responseMap.put("status", "OK");
|
response.status(200);
|
||||||
|
|
||||||
|
responseJson.addProperty("result", tmp);
|
||||||
|
responseJson.addProperty("status", "OK");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.logger.error("Error on processing XSLT using Saxon. " + ex);
|
this.logger.error("Error on processing XSLT using Saxon. " + ex);
|
||||||
responseMap.put("result", ex.getMessage());
|
|
||||||
responseMap.put("status", "ERR");
|
|
||||||
response.status(400);
|
response.status(400);
|
||||||
|
|
||||||
|
responseJson.addProperty("result", ex.getMessage());
|
||||||
|
responseJson.addProperty("status", "ERR");
|
||||||
}
|
}
|
||||||
|
|
||||||
duration = System.currentTimeMillis() - timeStart;
|
duration = System.currentTimeMillis() - timeStart;
|
||||||
this.logger.info("Request: " + body + " processed in " + duration + " ms.");
|
this.logger.info("Request: " + body + " processed in " + duration + " ms.");
|
||||||
responseMap.put("processor", "Saxon " + Saxon.getVersion() + " " + version);
|
|
||||||
responseMap.put("time", Long.toString(duration));
|
responseJson.addProperty("processor", "Saxon " + Saxon.getVersion() + " " + version);
|
||||||
response.body(mapper.writeValueAsString(responseMap));
|
responseJson.addProperty("time", duration);
|
||||||
|
|
||||||
|
response.body(this.gson.toJson(responseJson));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case "xalan":
|
case "xalan":
|
||||||
timeStart = System.currentTimeMillis();
|
timeStart = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
tmp = Xalan.processXSLT(data, query);
|
tmp = Xalan.processXSLT(data, query);
|
||||||
responseMap.put("result", tmp);
|
|
||||||
responseMap.put("status", "OK");
|
response.status(200);
|
||||||
|
|
||||||
|
responseJson.addProperty("result", tmp);
|
||||||
|
responseJson.addProperty("status", "OK");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
this.logger.error("Error on processing XSLT using Xalan. " + ex);
|
this.logger.error("Error on processing XSLT using Xalan. " + ex);
|
||||||
responseMap.put("result", ex.getMessage());
|
|
||||||
responseMap.put("status", "ERR");
|
|
||||||
response.status(400);
|
response.status(400);
|
||||||
|
|
||||||
|
responseJson.addProperty("result", ex.getMessage());
|
||||||
|
responseJson.addProperty("status", "ERR");
|
||||||
}
|
}
|
||||||
|
|
||||||
duration = System.currentTimeMillis() - timeStart;
|
duration = System.currentTimeMillis() - timeStart;
|
||||||
this.logger.info("Request: " + body + " processed in " + duration + " ms.");
|
this.logger.info("Request: " + body + " processed in " + duration + " ms.");
|
||||||
responseMap.put("processor", Xalan.getVersion());
|
|
||||||
responseMap.put("time", Long.toString(duration));
|
responseJson.addProperty("processor", Xalan.getVersion());
|
||||||
response.body(mapper.writeValueAsString(responseMap));
|
responseJson.addProperty("time", duration);
|
||||||
|
|
||||||
|
response.body(this.gson.toJson(responseJson));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user