Refactor of History module #184
@@ -1,27 +0,0 @@
 | 
				
			|||||||
package com.r11.tools.controller;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import lombok.SneakyThrows;
 | 
					 | 
				
			||||||
import org.springframework.stereotype.Controller;
 | 
					 | 
				
			||||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
					 | 
				
			||||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
					 | 
				
			||||||
import org.springframework.web.servlet.ModelAndView;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Class responsible for returning homepage html
 | 
					 | 
				
			||||||
 * @author Gabriel Modzelewski
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
@Controller
 | 
					 | 
				
			||||||
@RequestMapping("/")
 | 
					 | 
				
			||||||
public class MainController {
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Default path to get the homepage
 | 
					 | 
				
			||||||
     * @return the view of homepage
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @SneakyThrows
 | 
					 | 
				
			||||||
    @GetMapping
 | 
					 | 
				
			||||||
    public ModelAndView showHome(){
 | 
					 | 
				
			||||||
        ModelAndView mov = new ModelAndView();
 | 
					 | 
				
			||||||
        mov.setViewName("html/mock");
 | 
					 | 
				
			||||||
        return mov;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -8,6 +8,9 @@ import com.r11.tools.controller.XPathController;
 | 
				
			|||||||
import com.r11.tools.controller.XsdController;
 | 
					import com.r11.tools.controller.XsdController;
 | 
				
			||||||
import com.r11.tools.controller.XsltController;
 | 
					import com.r11.tools.controller.XsltController;
 | 
				
			||||||
import com.r11.tools.controller.internal.RestControllerRegistry;
 | 
					import com.r11.tools.controller.internal.RestControllerRegistry;
 | 
				
			||||||
 | 
					import com.r11.tools.xml.Saxon;
 | 
				
			||||||
 | 
					import com.r11.tools.xml.Xalan;
 | 
				
			||||||
 | 
					import com.r11.tools.xml.XmlEngine;
 | 
				
			||||||
import org.apache.logging.log4j.LogManager;
 | 
					import org.apache.logging.log4j.LogManager;
 | 
				
			||||||
import org.apache.logging.log4j.Logger;
 | 
					import org.apache.logging.log4j.Logger;
 | 
				
			||||||
import spark.Spark;
 | 
					import spark.Spark;
 | 
				
			||||||
@@ -35,12 +38,15 @@ public class SparkApplication {
 | 
				
			|||||||
        Gson jsongson = new GsonBuilder()
 | 
					        Gson jsongson = new GsonBuilder()
 | 
				
			||||||
            .disableHtmlEscaping()
 | 
					            .disableHtmlEscaping()
 | 
				
			||||||
            .create();
 | 
					            .create();
 | 
				
			||||||
 | 
					        XmlEngine saxon = new Saxon();
 | 
				
			||||||
 | 
					        XmlEngine xalan = new Xalan();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        RestControllerRegistry registry = new RestControllerRegistry();
 | 
					        RestControllerRegistry registry = new RestControllerRegistry();
 | 
				
			||||||
        registry.registerController(new ProcessorInfoController(logger));
 | 
					        registry.registerController(new ProcessorInfoController(logger, saxon, xalan));
 | 
				
			||||||
        registry.registerController(new XsdController(gson, logger));
 | 
					        registry.registerController(new XsdController(gson, logger, saxon, xalan));
 | 
				
			||||||
        registry.registerController(new XPathController(gson, logger));
 | 
					        registry.registerController(new XPathController(gson, logger, saxon, xalan));
 | 
				
			||||||
        registry.registerController(new XsltController(gson, logger));
 | 
					        registry.registerController(new XsltController(gson, logger, saxon, xalan));
 | 
				
			||||||
        registry.registerController(new JsonController(gson, jsongson, logger));
 | 
					        registry.registerController(new JsonController(gson, jsongson, logger));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        registry.register();
 | 
					        registry.register();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ 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.XmlEngine;
 | 
				
			||||||
import org.apache.logging.log4j.Logger;
 | 
					import org.apache.logging.log4j.Logger;
 | 
				
			||||||
import spark.Request;
 | 
					import spark.Request;
 | 
				
			||||||
import spark.Response;
 | 
					import spark.Response;
 | 
				
			||||||
@@ -13,9 +14,13 @@ import spark.Response;
 | 
				
			|||||||
public class ProcessorInfoController implements RestController {
 | 
					public class ProcessorInfoController implements RestController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final Logger logger;
 | 
					    private final Logger logger;
 | 
				
			||||||
 | 
					    private final XmlEngine saxon;
 | 
				
			||||||
 | 
					    private final XmlEngine xalan;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ProcessorInfoController(Logger logger) {
 | 
					    public ProcessorInfoController(Logger logger, XmlEngine saxon, XmlEngine xalan) {
 | 
				
			||||||
        this.logger = logger;
 | 
					        this.logger = logger;
 | 
				
			||||||
 | 
					        this.saxon = saxon;
 | 
				
			||||||
 | 
					        this.xalan = xalan;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -24,8 +29,8 @@ public class ProcessorInfoController implements RestController {
 | 
				
			|||||||
    @ScopedControllerManifest(method = HandlerType.GET, path = "/procinfo")
 | 
					    @ScopedControllerManifest(method = HandlerType.GET, path = "/procinfo")
 | 
				
			||||||
    public void processorInfo(Request request, Response response) {
 | 
					    public void processorInfo(Request request, Response response) {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            response.header("processor", "Saxon " + Saxon.getVersion() + " over s9api");
 | 
					            response.header("processor", "Saxon " + saxon.getVersion() + " over s9api");
 | 
				
			||||||
            response.body(Saxon.getVersion());
 | 
					            response.body(saxon.getVersion());
 | 
				
			||||||
        } catch (Exception ex) {
 | 
					        } catch (Exception ex) {
 | 
				
			||||||
            this.logger.error("Error on retrieving engine version. " + ex);
 | 
					            this.logger.error("Error on retrieving engine version. " + ex);
 | 
				
			||||||
            response.body(ex.getMessage());
 | 
					            response.body(ex.getMessage());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
 | 
				
			|||||||
import com.r11.tools.controller.internal.*;
 | 
					import com.r11.tools.controller.internal.*;
 | 
				
			||||||
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 com.r11.tools.xml.XmlEngine;
 | 
				
			||||||
import org.apache.logging.log4j.Logger;
 | 
					import org.apache.logging.log4j.Logger;
 | 
				
			||||||
import spark.Request;
 | 
					import spark.Request;
 | 
				
			||||||
import spark.Response;
 | 
					import spark.Response;
 | 
				
			||||||
@@ -15,9 +16,14 @@ public class XPathController implements RestController {
 | 
				
			|||||||
    private final Gson gson;
 | 
					    private final Gson gson;
 | 
				
			||||||
    private final Logger logger;
 | 
					    private final Logger logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public XPathController(Gson gson, Logger logger) {
 | 
					    private final XmlEngine saxon;
 | 
				
			||||||
 | 
					    private final XmlEngine xalan;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public XPathController(Gson gson, Logger logger, XmlEngine saxon, XmlEngine xalan) {
 | 
				
			||||||
        this.gson = gson;
 | 
					        this.gson = gson;
 | 
				
			||||||
        this.logger = logger;
 | 
					        this.logger = logger;
 | 
				
			||||||
 | 
					        this.saxon = saxon;
 | 
				
			||||||
 | 
					        this.xalan = xalan;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @ScopedControllerManifest(method = HandlerType.POST, path = "/xpath")
 | 
					    @ScopedControllerManifest(method = HandlerType.POST, path = "/xpath")
 | 
				
			||||||
@@ -56,11 +62,11 @@ public class XPathController implements RestController {
 | 
				
			|||||||
        JsonObject responseJson = new JsonObject();
 | 
					        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).getData().trim();
 | 
					                    tmp = saxon.processXPath(data, query, version).getData().trim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    response.status(200);
 | 
					                    response.status(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -78,18 +84,18 @@ public class XPathController implements RestController {
 | 
				
			|||||||
                duration = System.currentTimeMillis() - timeStart;
 | 
					                duration = System.currentTimeMillis() - timeStart;
 | 
				
			||||||
                this.logger.info("Request (XPath, Saxon) processed in " + duration + " ms.");
 | 
					                this.logger.info("Request (XPath, Saxon) processed in " + duration + " ms.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                responseJson.addProperty("processor", "Saxon " + Saxon.getVersion() + " " + version + " over s9api");
 | 
					                responseJson.addProperty("processor", "Saxon " + saxon.getVersion() + " " + version + " over s9api");
 | 
				
			||||||
                responseJson.addProperty("time", duration);
 | 
					                responseJson.addProperty("time", duration);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                response.body(this.gson.toJson(responseJson));
 | 
					                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 {
 | 
				
			||||||
                    XPathQueryResult xPathQueryResult = Xalan.processXPath(data, query);
 | 
					                    XPathQueryResult xPathQueryResult = xalan.processXPath(data, query, "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    response.status(200);
 | 
					                    response.status(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -108,7 +114,7 @@ public class XPathController implements RestController {
 | 
				
			|||||||
                duration = System.currentTimeMillis() - timeStart;
 | 
					                duration = System.currentTimeMillis() - timeStart;
 | 
				
			||||||
                this.logger.info("Request (XPath, Xalan) processed in " + duration + " ms.");
 | 
					                this.logger.info("Request (XPath, Xalan) processed in " + duration + " ms.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                responseJson.addProperty("processor", Xalan.getVersion());
 | 
					                responseJson.addProperty("processor", xalan.getVersion());
 | 
				
			||||||
                responseJson.addProperty("time", duration);
 | 
					                responseJson.addProperty("time", duration);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                response.body(this.gson.toJson(responseJson));
 | 
					                response.body(this.gson.toJson(responseJson));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@ 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 com.r11.tools.xml.XmlEngine;
 | 
				
			||||||
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,9 +18,14 @@ public class XsdController implements RestController {
 | 
				
			|||||||
    private final Gson gson;
 | 
					    private final Gson gson;
 | 
				
			||||||
    private final Logger logger;
 | 
					    private final Logger logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public XsdController(Gson gson, Logger logger) {
 | 
					    private final XmlEngine saxon;
 | 
				
			||||||
 | 
					    private final XmlEngine xalan;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public XsdController(Gson gson, Logger logger, XmlEngine saxon, XmlEngine xalan) {
 | 
				
			||||||
        this.gson = gson;
 | 
					        this.gson = gson;
 | 
				
			||||||
        this.logger = logger;
 | 
					        this.logger = logger;
 | 
				
			||||||
 | 
					        this.saxon = saxon;
 | 
				
			||||||
 | 
					        this.xalan = xalan;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @ScopedControllerManifest(method = HandlerType.POST, path = "/xsd")
 | 
					    @ScopedControllerManifest(method = HandlerType.POST, path = "/xsd")
 | 
				
			||||||
@@ -44,14 +50,14 @@ public class XsdController implements RestController {
 | 
				
			|||||||
        String data = requestJson.get("data").getAsString();
 | 
					        String data = requestJson.get("data").getAsString();
 | 
				
			||||||
        String xsd = requestJson.get("process").getAsString();
 | 
					        String xsd = requestJson.get("process").getAsString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response.header("processor", Xalan.getVersion());
 | 
					        response.header("processor", xalan.getVersion());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        long timeStart = System.currentTimeMillis();
 | 
					        long timeStart = System.currentTimeMillis();
 | 
				
			||||||
        String tmp;
 | 
					        String tmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        JsonObject responseJson = new JsonObject();
 | 
					        JsonObject responseJson = new JsonObject();
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            tmp = Xalan.validate(data, xsd).trim();
 | 
					            tmp = xalan.validate(data, xsd).trim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            response.status(200);
 | 
					            response.status(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -69,7 +75,7 @@ public class XsdController implements RestController {
 | 
				
			|||||||
        long duration = System.currentTimeMillis() - timeStart;
 | 
					        long duration = System.currentTimeMillis() - timeStart;
 | 
				
			||||||
        this.logger.info("Request (XSD, Xalan) processed in " + duration + " ms.");
 | 
					        this.logger.info("Request (XSD, Xalan) processed in " + duration + " ms.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        responseJson.addProperty("processor", Xalan.getVersion());
 | 
					        responseJson.addProperty("processor", xalan.getVersion());
 | 
				
			||||||
        responseJson.addProperty("time", duration);
 | 
					        responseJson.addProperty("time", duration);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response.body(this.gson.toJson(responseJson));
 | 
					        response.body(this.gson.toJson(responseJson));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@ 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 com.r11.tools.xml.XmlEngine;
 | 
				
			||||||
import org.apache.logging.log4j.Logger;
 | 
					import org.apache.logging.log4j.Logger;
 | 
				
			||||||
import spark.Request;
 | 
					import spark.Request;
 | 
				
			||||||
import spark.Response;
 | 
					import spark.Response;
 | 
				
			||||||
@@ -18,9 +19,14 @@ public class XsltController implements RestController {
 | 
				
			|||||||
    private final Gson gson;
 | 
					    private final Gson gson;
 | 
				
			||||||
    private final Logger logger;
 | 
					    private final Logger logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public XsltController(Gson gson, Logger logger) {
 | 
					    private final XmlEngine saxon;
 | 
				
			||||||
 | 
					    private final XmlEngine xalan;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public XsltController(Gson gson, Logger logger, XmlEngine saxon, XmlEngine xalan) {
 | 
				
			||||||
        this.gson = gson;
 | 
					        this.gson = gson;
 | 
				
			||||||
        this.logger = logger;
 | 
					        this.logger = logger;
 | 
				
			||||||
 | 
					        this.saxon = saxon;
 | 
				
			||||||
 | 
					        this.xalan = xalan;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @ScopedControllerManifest(method = HandlerType.POST, path = "/xslt")
 | 
					    @ScopedControllerManifest(method = HandlerType.POST, path = "/xslt")
 | 
				
			||||||
@@ -61,7 +67,7 @@ public class XsltController implements RestController {
 | 
				
			|||||||
            case "saxon":
 | 
					            case "saxon":
 | 
				
			||||||
                timeStart = System.currentTimeMillis();
 | 
					                timeStart = System.currentTimeMillis();
 | 
				
			||||||
                try {
 | 
					                try {
 | 
				
			||||||
                    tmp = Saxon.processXSLT(data, query);
 | 
					                    tmp = saxon.processXSLT(data, query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    response.status(200);
 | 
					                    response.status(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -79,7 +85,7 @@ public class XsltController implements RestController {
 | 
				
			|||||||
                duration = System.currentTimeMillis() - timeStart;
 | 
					                duration = System.currentTimeMillis() - timeStart;
 | 
				
			||||||
                this.logger.info("Request (XSLT, Saxon) processed in " + duration + " ms.");
 | 
					                this.logger.info("Request (XSLT, Saxon) processed in " + duration + " ms.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                responseJson.addProperty("processor", "Saxon " + Saxon.getVersion() + " " + version);
 | 
					                responseJson.addProperty("processor", "Saxon " + saxon.getVersion() + " " + version);
 | 
				
			||||||
                responseJson.addProperty("time", duration);
 | 
					                responseJson.addProperty("time", duration);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                response.body(this.gson.toJson(responseJson));
 | 
					                response.body(this.gson.toJson(responseJson));
 | 
				
			||||||
@@ -88,7 +94,7 @@ public class XsltController implements RestController {
 | 
				
			|||||||
            case "xalan":
 | 
					            case "xalan":
 | 
				
			||||||
                timeStart = System.currentTimeMillis();
 | 
					                timeStart = System.currentTimeMillis();
 | 
				
			||||||
                try {
 | 
					                try {
 | 
				
			||||||
                    tmp = Xalan.processXSLT(data, query);
 | 
					                    tmp = xalan.processXSLT(data, query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    response.status(200);
 | 
					                    response.status(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -106,7 +112,7 @@ public class XsltController implements RestController {
 | 
				
			|||||||
                duration = System.currentTimeMillis() - timeStart;
 | 
					                duration = System.currentTimeMillis() - timeStart;
 | 
				
			||||||
                this.logger.info("Request (XSLT, Xalan) processed in " + duration + " ms.");
 | 
					                this.logger.info("Request (XSLT, Xalan) processed in " + duration + " ms.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                responseJson.addProperty("processor", Xalan.getVersion());
 | 
					                responseJson.addProperty("processor", xalan.getVersion());
 | 
				
			||||||
                responseJson.addProperty("time", duration);
 | 
					                responseJson.addProperty("time", duration);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                response.body(this.gson.toJson(responseJson));
 | 
					                response.body(this.gson.toJson(responseJson));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ import java.io.StringWriter;
 | 
				
			|||||||
 * Handler for Saxon engine
 | 
					 * Handler for Saxon engine
 | 
				
			||||||
 * @author Wojciech Czop
 | 
					 * @author Wojciech Czop
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class Saxon {
 | 
					public class Saxon implements XmlEngine{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Transforms string containing xml document via xslt
 | 
					     * Transforms string containing xml document via xslt
 | 
				
			||||||
@@ -20,7 +20,7 @@ public class Saxon {
 | 
				
			|||||||
     * @return transformed xml
 | 
					     * @return transformed xml
 | 
				
			||||||
     * @throws SaxonApiException thrown on stylesheet or transformation errors
 | 
					     * @throws SaxonApiException thrown on stylesheet or transformation errors
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static String processXSLT(String data, String transform) throws SaxonApiException {
 | 
					    public String processXSLT(String data, String transform) throws SaxonApiException {
 | 
				
			||||||
        Processor processor = new Processor(false);
 | 
					        Processor processor = new Processor(false);
 | 
				
			||||||
        XsltCompiler compiler = processor.newXsltCompiler();
 | 
					        XsltCompiler compiler = processor.newXsltCompiler();
 | 
				
			||||||
        XsltExecutable stylesheet = compiler.compile(new StreamSource(new StringReader(transform)));
 | 
					        XsltExecutable stylesheet = compiler.compile(new StreamSource(new StringReader(transform)));
 | 
				
			||||||
@@ -34,6 +34,11 @@ public class Saxon {
 | 
				
			|||||||
        return sw.toString();
 | 
					        return sw.toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String validate(String data, String xsd) {
 | 
				
			||||||
 | 
					        throw new UnsupportedOperationException();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Process xpath and return either node or wrapped atomic value
 | 
					     * Process xpath and return either node or wrapped atomic value
 | 
				
			||||||
     * @param data xml to be querried
 | 
					     * @param data xml to be querried
 | 
				
			||||||
@@ -42,7 +47,7 @@ public class Saxon {
 | 
				
			|||||||
     * @return string xml representation of the node
 | 
					     * @return string xml representation of the node
 | 
				
			||||||
     * @throws Exception thrown on node building errors or invalid xpath
 | 
					     * @throws Exception thrown on node building errors or invalid xpath
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static XPathQueryResult processXPath(String data, String query, String version) throws Exception {
 | 
					    public XPathQueryResult processXPath(String data, String query, String version) throws Exception {
 | 
				
			||||||
        Processor p = new Processor(false);
 | 
					        Processor p = new Processor(false);
 | 
				
			||||||
        XPathCompiler compiler = p.newXPathCompiler();
 | 
					        XPathCompiler compiler = p.newXPathCompiler();
 | 
				
			||||||
        DocumentBuilder builder = p.newDocumentBuilder();
 | 
					        DocumentBuilder builder = p.newDocumentBuilder();
 | 
				
			||||||
@@ -70,7 +75,7 @@ public class Saxon {
 | 
				
			|||||||
     * Returns version of the processor
 | 
					     * Returns version of the processor
 | 
				
			||||||
     * @return version of the processor
 | 
					     * @return version of the processor
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static String getVersion() {
 | 
					    public String getVersion() {
 | 
				
			||||||
        return new Processor(false).getSaxonProductVersion();
 | 
					        return new Processor(false).getSaxonProductVersion();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,7 +24,7 @@ import java.io.*;
 | 
				
			|||||||
 * Handler for Xalan engine
 | 
					 * Handler for Xalan engine
 | 
				
			||||||
 * @author Wojciech Czop
 | 
					 * @author Wojciech Czop
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class Xalan {
 | 
					public class Xalan implements XmlEngine{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Transforms string containing xml document via xslt
 | 
					     * Transforms string containing xml document via xslt
 | 
				
			||||||
@@ -33,7 +33,7 @@ public class Xalan {
 | 
				
			|||||||
     * @return transformed xml
 | 
					     * @return transformed xml
 | 
				
			||||||
     * @throws Exception thrown on stylesheet or transformation errors
 | 
					     * @throws Exception thrown on stylesheet or transformation errors
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static String processXSLT(String data, String transform) throws Exception{
 | 
					    public String processXSLT(String data, String transform) throws Exception {
 | 
				
			||||||
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 | 
					        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 | 
				
			||||||
        DocumentBuilder builder = factory.newDocumentBuilder();
 | 
					        DocumentBuilder builder = factory.newDocumentBuilder();
 | 
				
			||||||
        Document document = builder.parse(new InputSource(new StringReader(data)));
 | 
					        Document document = builder.parse(new InputSource(new StringReader(data)));
 | 
				
			||||||
@@ -51,7 +51,7 @@ public class Xalan {
 | 
				
			|||||||
        return sw.toString();
 | 
					        return sw.toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static boolean isTextNode(Node n) {
 | 
					    private boolean isTextNode(Node n) {
 | 
				
			||||||
        if (n == null)
 | 
					        if (n == null)
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        short nodeType = n.getNodeType();
 | 
					        short nodeType = n.getNodeType();
 | 
				
			||||||
@@ -65,7 +65,7 @@ public class Xalan {
 | 
				
			|||||||
     * @return xml processed using given xpath
 | 
					     * @return xml processed using given xpath
 | 
				
			||||||
     * @throws Exception thrown on node building errors or invalid xpath
 | 
					     * @throws Exception thrown on node building errors or invalid xpath
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static XPathQueryResult processXPath(String data, String transform) throws Exception {
 | 
					    public XPathQueryResult processXPath(String data, String transform, String version) throws Exception {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Set up a DOM tree to query.
 | 
					        // Set up a DOM tree to query.
 | 
				
			||||||
        InputSource in = new InputSource(new StringReader(data));
 | 
					        InputSource in = new InputSource(new StringReader(data));
 | 
				
			||||||
@@ -112,7 +112,7 @@ public class Xalan {
 | 
				
			|||||||
     * Returns version of the processor
 | 
					     * Returns version of the processor
 | 
				
			||||||
     * @return version of the processor
 | 
					     * @return version of the processor
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static String getVersion(){
 | 
					    public String getVersion(){
 | 
				
			||||||
        return org.apache.xalan.Version.getVersion();
 | 
					        return org.apache.xalan.Version.getVersion();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -123,7 +123,7 @@ public class Xalan {
 | 
				
			|||||||
     * @return statement of validity
 | 
					     * @return statement of validity
 | 
				
			||||||
     * @throws Exception thrown on invalid xsd schema or xml
 | 
					     * @throws Exception thrown on invalid xsd schema or xml
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static String validate(String data, String xsd) throws Exception{
 | 
					    public String validate(String data, String xsd) throws Exception {
 | 
				
			||||||
        Source dataSource = new StreamSource(new StringReader(data));
 | 
					        Source dataSource = new StreamSource(new StringReader(data));
 | 
				
			||||||
        Source xsdSource = new StreamSource(new StringReader(xsd));
 | 
					        Source xsdSource = new StreamSource(new StringReader(xsd));
 | 
				
			||||||
        SchemaFactory schemaFactory = SchemaFactory
 | 
					        SchemaFactory schemaFactory = SchemaFactory
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					package com.r11.tools.xml;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.r11.tools.controller.internal.XPathQueryResult;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface XmlEngine {
 | 
				
			||||||
 | 
					    XPathQueryResult processXPath(String data, String query, String version) throws Exception;
 | 
				
			||||||
 | 
					    String processXSLT(String data, String transform) throws Exception;
 | 
				
			||||||
 | 
					    String validate(String data, String xsd) throws Exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getVersion();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
		 Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB  | 
@@ -42,7 +42,7 @@ function init() {
 | 
				
			|||||||
    tools.set("xslt", "tools/xslt.html");
 | 
					    tools.set("xslt", "tools/xslt.html");
 | 
				
			||||||
    tools.set("xmlform", "tools/xmlFormatter.html");
 | 
					    tools.set("xmlform", "tools/xmlFormatter.html");
 | 
				
			||||||
    tools.set("jsonform", "tools/jsonFormatter.html");
 | 
					    tools.set("jsonform", "tools/jsonFormatter.html");
 | 
				
			||||||
    tools.set("mock", getMockHost());
 | 
					    tools.set("mock", "tools/mock.html");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    changeActiveTools('XML');
 | 
					    changeActiveTools('XML');
 | 
				
			||||||
    loadLastPage();
 | 
					    loadLastPage();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@ var json = {};
 | 
				
			|||||||
var jsonIndex = 0;
 | 
					var jsonIndex = 0;
 | 
				
			||||||
var lastId = 1;
 | 
					var lastId = 1;
 | 
				
			||||||
var htable_row = 0;
 | 
					var htable_row = 0;
 | 
				
			||||||
var host = getDomain();
 | 
					var host = window.location.protocol + "//" + window.location.hostname + ":8097";
 | 
				
			||||||
var dataModified = false;
 | 
					var dataModified = false;
 | 
				
			||||||
const addMessageName = 'addMessage';
 | 
					const addMessageName = 'addMessage';
 | 
				
			||||||
const loadMessageName = 'changeMessage';
 | 
					const loadMessageName = 'changeMessage';
 | 
				
			||||||
@@ -65,28 +65,6 @@ function clearDataField() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * The `escapeHTML` function is used to escape special characters in an HTML element's innerHTML property.
 | 
					 | 
				
			||||||
 * This is done to prevent these characters from being interpreted as HTML tags or attributes, 
 | 
					 | 
				
			||||||
 * which could potentially cause security vulnerabilities or unintended behavior.
 | 
					 | 
				
			||||||
 * 
 | 
					 | 
				
			||||||
 * @function
 | 
					 | 
				
			||||||
 * @name escapeHTML
 | 
					 | 
				
			||||||
 * @kind function
 | 
					 | 
				
			||||||
 * @param {any} element
 | 
					 | 
				
			||||||
 * @returns {void}
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
function escapeHTML(elementID) {
 | 
					 | 
				
			||||||
    document.getElementById(elementID).innerHTML = document.getElementById(elementID).innerHTML
 | 
					 | 
				
			||||||
        .replace(/&/g, "&")
 | 
					 | 
				
			||||||
        .replace(/</g, "<")
 | 
					 | 
				
			||||||
        .replace(/>/g, ">")
 | 
					 | 
				
			||||||
        .replace(/"/g, """)
 | 
					 | 
				
			||||||
        .replace(/'/g, "'");
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
* It fills the XML area with a sample XML.
 | 
					* It fills the XML area with a sample XML.
 | 
				
			||||||
* 
 | 
					* 
 | 
				
			||||||
@@ -111,6 +89,16 @@ function fillDefaultXML(element) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					* It fills the XSD area with a sample XSD and XML area with matching XML.
 | 
				
			||||||
 | 
					* 
 | 
				
			||||||
 | 
					* @function
 | 
				
			||||||
 | 
					* @name fillDefaultXSD
 | 
				
			||||||
 | 
					* @kind function
 | 
				
			||||||
 | 
					* @param {any} element
 | 
				
			||||||
 | 
					* @returns {void}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
function fillDefaultXSD(){
 | 
					function fillDefaultXSD(){
 | 
				
			||||||
    const serverAddress = window.location.protocol + "//" + window.location.hostname + ":8086";
 | 
					    const serverAddress = window.location.protocol + "//" + window.location.hostname + ":8086";
 | 
				
			||||||
    fetch(serverAddress + "/assets/samples/sampleXSD.xsd")
 | 
					    fetch(serverAddress + "/assets/samples/sampleXSD.xsd")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,6 @@
 | 
				
			|||||||
    <link rel="stylesheet" href="assets/css/frame.css">
 | 
					    <link rel="stylesheet" href="assets/css/frame.css">
 | 
				
			||||||
    <script src="assets/scripts/common/jquery-3.6.0.slim.min.js"></script>
 | 
					    <script src="assets/scripts/common/jquery-3.6.0.slim.min.js"></script>
 | 
				
			||||||
    <script src="assets/scripts/frame.js"></script>
 | 
					    <script src="assets/scripts/frame.js"></script>
 | 
				
			||||||
    <!-- <link rel="stylesheet" href="common.css"> -->
 | 
					 | 
				
			||||||
    <link rel="shortcut icon" href="assets/images/favicon.ico" type="image/x-icon"> 
 | 
					    <link rel="shortcut icon" href="assets/images/favicon.ico" type="image/x-icon"> 
 | 
				
			||||||
    <!-- Meta tags for SEO and SEM -->
 | 
					    <!-- Meta tags for SEO and SEM -->
 | 
				
			||||||
    <title>Release11 Web Tools</title>
 | 
					    <title>Release11 Web Tools</title>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,12 +3,10 @@
 | 
				
			|||||||
<head>
 | 
					<head>
 | 
				
			||||||
    <title>R11 MockedServices</title>
 | 
					    <title>R11 MockedServices</title>
 | 
				
			||||||
    <meta charset="utf-8">
 | 
					    <meta charset="utf-8">
 | 
				
			||||||
    <link rel="stylesheet" href="../css/fontello.css" type="text/css">
 | 
					    <link rel="stylesheet" href="../assets/css/tools/mock/fontello.css" type="text/css">
 | 
				
			||||||
    <link rel="stylesheet" href="../css/main.css" type="text/css">
 | 
					    <link rel="stylesheet" href="../assets/css/tools/mock/main.css" type="text/css">
 | 
				
			||||||
    <!-- <link rel="stylesheet" href="css/common.css" type="text/css"> -->
 | 
					    <link rel="stylesheet" href="../assets/css/tools/mock/common.css" type="text/css">
 | 
				
			||||||
    <link rel="stylesheet" href="../css/common.css" type="text/css">
 | 
					 | 
				
			||||||
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
 | 
					    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
 | 
				
			||||||
    <!-- <script src="../js/dyn_host.js"></script> -->
 | 
					 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
    <div class="container">
 | 
					    <div class="container">
 | 
				
			||||||
@@ -155,14 +153,6 @@
 | 
				
			|||||||
                                                </tr>
 | 
					                                                </tr>
 | 
				
			||||||
                                            </thead>
 | 
					                                            </thead>
 | 
				
			||||||
                                            <tbody>
 | 
					                                            <tbody>
 | 
				
			||||||
                                                <!-- <tr class="even">
 | 
					 | 
				
			||||||
                                                    <td>2021-01-01T10:57:26</td>
 | 
					 | 
				
			||||||
                                                    <td>Client request</td>
 | 
					 | 
				
			||||||
                                                </tr>
 | 
					 | 
				
			||||||
                                                <tr>
 | 
					 | 
				
			||||||
                                                    <td>2021-01-01T10:57:26</td>
 | 
					 | 
				
			||||||
                                                    <td>Client request</td>
 | 
					 | 
				
			||||||
                                                </tr> -->
 | 
					 | 
				
			||||||
                                            </tbody>
 | 
					                                            </tbody>
 | 
				
			||||||
                                        </table>
 | 
					                                        </table>
 | 
				
			||||||
                                    </div>
 | 
					                                    </div>
 | 
				
			||||||
@@ -179,19 +169,6 @@
 | 
				
			|||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <!-- tile list -->
 | 
					                <!-- tile list -->
 | 
				
			||||||
                <div id="listItems">
 | 
					                <div id="listItems">
 | 
				
			||||||
                    <!-- <div class="tile">
 | 
					 | 
				
			||||||
                        <div class="content">
 | 
					 | 
				
			||||||
                            <div class="display-space-between">
 | 
					 | 
				
			||||||
                                <div class="centered-vertically">
 | 
					 | 
				
			||||||
                                    <p>Id: 2</p>
 | 
					 | 
				
			||||||
                                    <p>Status: 200</p>
 | 
					 | 
				
			||||||
                                </div>
 | 
					 | 
				
			||||||
                                <div>
 | 
					 | 
				
			||||||
                                    <button id="test1" class="modification-button btn-tile"><i class="icon-cancel"></i></button>
 | 
					 | 
				
			||||||
                                </div>
 | 
					 | 
				
			||||||
                            </div>
 | 
					 | 
				
			||||||
                        </div>
 | 
					 | 
				
			||||||
                    </div> -->
 | 
					 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <div id="new-tile" class="max-width centered-content small-vertical-margin">
 | 
					                <div id="new-tile" class="max-width centered-content small-vertical-margin">
 | 
				
			||||||
                    <button id="btn-newtile" class="modification-button btn-addtile"><i class="icon-plus"></i></button>
 | 
					                    <button id="btn-newtile" class="modification-button btn-addtile"><i class="icon-plus"></i></button>
 | 
				
			||||||
@@ -302,7 +279,7 @@
 | 
				
			|||||||
            <div>Message saved<i class="r-exclamation"></i></div>
 | 
					            <div>Message saved<i class="r-exclamation"></i></div>
 | 
				
			||||||
            <button>×</button>
 | 
					            <button>×</button>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div class="body">Your message has been successfuly saved.<br>You might view it under the link.</div>
 | 
					        <div class="body">Your message has been successfully saved.<br>You might view it under the link.</div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div id="modal-query" class="modal">
 | 
					    <div id="modal-query" class="modal">
 | 
				
			||||||
        <div class="header">
 | 
					        <div class="header">
 | 
				
			||||||
@@ -317,10 +294,10 @@
 | 
				
			|||||||
            <button>No</button>
 | 
					            <button>No</button>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <script type="text/javascript" src="../js/modal.js"></script>
 | 
					    <script type="text/javascript" src="../assets/scripts/tools/mock/modal.js"></script>
 | 
				
			||||||
    <script type="text/javascript" src="../js/uianimation.js"></script>
 | 
					    <script type="text/javascript" src="../assets/scripts/tools/mock//uianimation.js"></script>
 | 
				
			||||||
    <script type="text/javascript" src="../js/datatransfer.js"></script>
 | 
					    <script type="text/javascript" src="../assets/scripts/tools/mock/datatransfer.js"></script>
 | 
				
			||||||
    <script type="text/javascript" src="../js/historyloader.js"></script>
 | 
					    <script type="text/javascript" src="../assets/scripts/tools/mock/historyloader.js"></script>
 | 
				
			||||||
    <script type="text/javascript" src="../js/fiddle.js"></script>
 | 
					    <script type="text/javascript" src="../assets/scripts/tools/mock/fiddle.js"></script>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user