Split XSLT process method
This commit is contained in:
		| @@ -57,41 +57,25 @@ public class XsltController implements RestController { | ||||
|             response.body("saxon, xalan"); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         String tmp; | ||||
|         long timeStart; | ||||
|         long duration; | ||||
|  | ||||
|         JsonObject responseJson = new JsonObject(); | ||||
|         switch (processor) { | ||||
|             case "saxon": | ||||
|                 timeStart = System.currentTimeMillis(); | ||||
|                 try { | ||||
|                     tmp = saxon.processXSLT(data, query); | ||||
|  | ||||
|                     response.status(200); | ||||
|  | ||||
|                     responseJson.addProperty("result", tmp); | ||||
|                     responseJson.addProperty("status", "OK"); | ||||
|                 } catch (Exception ex) { | ||||
|                     this.logger.error("Error on processing XSLT using Saxon. " + ex); | ||||
|  | ||||
|                     response.status(400); | ||||
|  | ||||
|                     responseJson.addProperty("result", ex.getMessage()); | ||||
|                     responseJson.addProperty("status", "ERR"); | ||||
|                 } | ||||
|  | ||||
|                 duration = System.currentTimeMillis() - timeStart; | ||||
|                 this.logger.info("Request (XSLT, Saxon) processed in " + duration + " ms."); | ||||
|  | ||||
|                 responseJson.addProperty("processor", "Saxon " + saxon.getVersion() + " " + version); | ||||
|                 responseJson.addProperty("time", duration); | ||||
|  | ||||
|                 response.body(this.gson.toJson(responseJson)); | ||||
|                 processWithSaxon(response, data, query, version, responseJson); | ||||
|                 return; | ||||
|  | ||||
|             case "xalan": | ||||
|                 processWithXalan(response, data, query, responseJson); | ||||
|                 return; | ||||
|  | ||||
|             default: | ||||
|                 response.body("saxon, xalan"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void processWithXalan(Response response, String data, String query, JsonObject responseJson) { | ||||
|         long duration; | ||||
|         long timeStart; | ||||
|         String tmp; | ||||
|         timeStart = System.currentTimeMillis(); | ||||
|         try { | ||||
|             tmp = xalan.processXSLT(data, query); | ||||
| @@ -116,10 +100,35 @@ public class XsltController implements RestController { | ||||
|         responseJson.addProperty("time", duration); | ||||
|  | ||||
|         response.body(this.gson.toJson(responseJson)); | ||||
|                 return; | ||||
|     } | ||||
|  | ||||
|             default: | ||||
|                 response.body("saxon, xalan"); | ||||
|         } | ||||
|     private void processWithSaxon(Response response, String data, String query, String version, JsonObject responseJson) { | ||||
|         long duration; | ||||
|         String tmp; | ||||
|         long timeStart; | ||||
|         timeStart = System.currentTimeMillis(); | ||||
|         try { | ||||
|             tmp = saxon.processXSLT(data, query); | ||||
|  | ||||
|             response.status(200); | ||||
|  | ||||
|             responseJson.addProperty("result", tmp); | ||||
|             responseJson.addProperty("status", "OK"); | ||||
|         } catch (Exception ex) { | ||||
|             this.logger.error("Error on processing XSLT using Saxon. " + ex); | ||||
|  | ||||
|             response.status(400); | ||||
|  | ||||
|             responseJson.addProperty("result", ex.getMessage()); | ||||
|             responseJson.addProperty("status", "ERR"); | ||||
|         } | ||||
|  | ||||
|         duration = System.currentTimeMillis() - timeStart; | ||||
|         this.logger.info("Request (XSLT, Saxon) processed in " + duration + " ms."); | ||||
|  | ||||
|         responseJson.addProperty("processor", "Saxon " + saxon.getVersion() + " " + version); | ||||
|         responseJson.addProperty("time", duration); | ||||
|  | ||||
|         response.body(this.gson.toJson(responseJson)); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user