Refactor to reduce warnings
This commit is contained in:
@@ -44,7 +44,7 @@ public class SparkInitializer {
|
||||
/**
|
||||
* Handler that returns processor version
|
||||
*/
|
||||
private static Route procinfoHandler = (Request req, Response resp) -> {
|
||||
private static final Route procinfoHandler = (Request req, Response resp) -> {
|
||||
try {
|
||||
resp.header("processor", "Saxon " + Saxon.getVersion() + " over s9api");
|
||||
return Saxon.getVersion();
|
||||
@@ -58,10 +58,10 @@ public class SparkInitializer {
|
||||
* Handler that returns info if document is valid
|
||||
* Also provides info about request time and processor
|
||||
*/
|
||||
private static Route xsdHandler = (Request req, Response resp) -> {
|
||||
private static final Route xsdHandler = (Request req, Response resp) -> {
|
||||
String body = req.body();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Map<String, String> requestMap = null;
|
||||
Map<String, String> requestMap = new HashMap<>();
|
||||
Map<String, String> responseMap = new HashMap<>();
|
||||
try {
|
||||
requestMap = mapper.readValue(body, Map.class);
|
||||
@@ -71,8 +71,6 @@ public class SparkInitializer {
|
||||
|
||||
String data = requestMap.get("data");
|
||||
String xsd = requestMap.get("process");
|
||||
String processor = requestMap.get("processor");
|
||||
String version = requestMap.get("version");
|
||||
|
||||
resp.header("processor", Xalan.getVersion());
|
||||
long timeStart = System.currentTimeMillis();
|
||||
@@ -98,10 +96,10 @@ public class SparkInitializer {
|
||||
/**
|
||||
* Handler that returns output of xpath query and processor data
|
||||
*/
|
||||
private static Route xpathHandler = (Request req, Response resp) -> {
|
||||
private static final Route xpathHandler = (Request req, Response resp) -> {
|
||||
String body = req.body();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Map<String, String> requestMap = null;
|
||||
Map<String, String> requestMap = new HashMap<>();
|
||||
Map<String, String> responseMap = new HashMap<>();
|
||||
try {
|
||||
requestMap = mapper.readValue(body, Map.class);
|
||||
@@ -173,10 +171,10 @@ public class SparkInitializer {
|
||||
/**
|
||||
* Handler that returns outcome of xslt transformation and processor data
|
||||
*/
|
||||
private static Route xsltHandler = (Request req, Response resp) -> {
|
||||
private static final Route xsltHandler = (Request req, Response resp) -> {
|
||||
String body = req.body();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Map<String, String> jsonMap = null;
|
||||
Map<String, String> jsonMap = new HashMap<>();
|
||||
Map<String, String> responseMap = new HashMap<>();
|
||||
try {
|
||||
jsonMap = mapper.readValue(body, Map.class);
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.r11.tools.xslt.processors;
|
||||
|
||||
import net.sf.saxon.om.NamespaceBinding;
|
||||
import net.sf.saxon.om.NamespaceMap;
|
||||
import net.sf.saxon.s9api.XPathCompiler;
|
||||
import net.sf.saxon.s9api.XdmNode;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Handler for saxon namespace scan engine.
|
||||
* All found namespaces are stored within {@link #namespaceMap}
|
||||
@@ -24,12 +21,13 @@ public class NewNamespaceResolver {
|
||||
* @param doc dom structure object
|
||||
* @return map of namespaces
|
||||
*/
|
||||
|
||||
// TODO: Closer inspection. Return value is never used according to IntelliJ
|
||||
//
|
||||
public NamespaceMap process(XdmNode doc) {
|
||||
namespaceMap = NamespaceMap.emptyMap();
|
||||
Iterator<XdmNode> it = doc.children().iterator();
|
||||
// TODO: remove
|
||||
while (it.hasNext()) {
|
||||
XdmNode tmp = it.next();
|
||||
// TODO: remove
|
||||
for (XdmNode tmp : doc.children()) {
|
||||
extractNamespace(tmp);
|
||||
}
|
||||
// end
|
||||
@@ -41,12 +39,6 @@ public class NewNamespaceResolver {
|
||||
* @param compiler compiler used to compile xpath statements
|
||||
*/
|
||||
public void exportNamespaces(XPathCompiler compiler){
|
||||
Iterator<NamespaceBinding> it = namespaceMap.iterator();
|
||||
// TODO: remove
|
||||
while(it.hasNext()){
|
||||
System.out.println(it.next());
|
||||
}
|
||||
// end
|
||||
namespaceMap.forEach(namespaceBinding -> compiler.declareNamespace(namespaceBinding.getPrefix(), namespaceBinding.getURI()));
|
||||
}
|
||||
|
||||
@@ -61,14 +53,11 @@ public class NewNamespaceResolver {
|
||||
}
|
||||
if (node.children().iterator().hasNext()) {
|
||||
|
||||
Iterator<XdmNode> it = node.children().iterator();
|
||||
while (it.hasNext()) {
|
||||
XdmNode rNode = it.next();
|
||||
// TODO: remove
|
||||
if(rNode.getUnderlyingNode().getPrefix().isEmpty() && !rNode.getParent().getUnderlyingNode().getPrefix().isEmpty()){
|
||||
for (XdmNode rNode : node.children()) {
|
||||
if (rNode.getUnderlyingNode().getPrefix().isEmpty() && !rNode.getParent().getUnderlyingNode().getPrefix().isEmpty()) {
|
||||
LOG.warn("Missing prefix. Parent has " + rNode.getParent().getUnderlyingNode().getPrefix() + ", but child has none");
|
||||
}
|
||||
// end
|
||||
|
||||
extractNamespace(rNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ import java.io.StringWriter;
|
||||
*/
|
||||
public class Saxon {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger("Saxon");
|
||||
|
||||
/**
|
||||
* Transforms string containing xml document via xslt
|
||||
* @param data xml to be transformed
|
||||
|
||||
@@ -28,8 +28,6 @@ import java.io.StringWriter;
|
||||
*/
|
||||
public class Xalan {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger("Xalan");
|
||||
|
||||
/**
|
||||
* Transforms string containing xml document via xslt
|
||||
* @param data xml to be transformed
|
||||
|
||||
Reference in New Issue
Block a user