/hg/icedtea-web: Added basic support for javafx desc
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Mon Feb 5 13:34:02 UTC 2018
changeset 7251d3abc7ab in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=7251d3abc7ab
author: Jiri Vanek <jvanek at redhat.com>
date: Mon Feb 05 14:31:51 2018 +0100
Added basic support for javafx desc
* netx/net/sourceforge/jnlp/ApplicationDesc.java: added flag fx to rember what was initiator
* netx/net/sourceforge/jnlp/Node.java: Added abstraction ElementName over string of element name to hold namespace and separate it for name if present
* netx/net/sourceforge/jnlp/Parser.java: for javafx-desc ApplicationDesc is instantiated. Adapted to ElementName
* tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java: ElementName
* tests/netx/unit/net/sourceforge/jnlp/ParserTest.java: ElementName
diffstat:
ChangeLog | 10 +
netx/net/sourceforge/jnlp/ApplicationDesc.java | 6 +-
netx/net/sourceforge/jnlp/Node.java | 55 ++++-
netx/net/sourceforge/jnlp/Parser.java | 44 ++-
tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java | 4 +-
tests/netx/unit/net/sourceforge/jnlp/ParserTest.java | 138 ++++++------
6 files changed, 160 insertions(+), 97 deletions(-)
diffs (truncated from 968 to 500 lines):
diff -r 6639d193e740 -r 7251d3abc7ab ChangeLog
--- a/ChangeLog Sun Feb 04 09:58:58 2018 +0100
+++ b/ChangeLog Mon Feb 05 14:31:51 2018 +0100
@@ -1,3 +1,13 @@
+2018-02-05 Jiri Vanek <jvanek at redhat.com>
+
+ Added basic support for javafx desc
+ * netx/net/sourceforge/jnlp/ApplicationDesc.java: added flag fx to rember what was initiator
+ * netx/net/sourceforge/jnlp/Node.java: Added abstraction ElementName over string of element name to hold namespace
+ and separate it for name if present
+ * netx/net/sourceforge/jnlp/Parser.java: for javafx-desc ApplicationDesc is instantiated. Adapted to ElementName
+ * tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java: ElementName
+ * tests/netx/unit/net/sourceforge/jnlp/ParserTest.java: ElementName
+
2018-02-03 Jiri Vanek <jvanek at redhat.com>
nosecurity switch made extendable also for certificate issues
diff -r 6639d193e740 -r 7251d3abc7ab netx/net/sourceforge/jnlp/ApplicationDesc.java
--- a/netx/net/sourceforge/jnlp/ApplicationDesc.java Sun Feb 04 09:58:58 2018 +0100
+++ b/netx/net/sourceforge/jnlp/ApplicationDesc.java Mon Feb 05 14:31:51 2018 +0100
@@ -30,7 +30,8 @@
private final String mainClass;
/** the arguments */
- private String arguments[];
+ private String arguments[];
+ private final boolean fx;
/**
* Create an Application descriptor.
@@ -38,9 +39,10 @@
* @param mainClass the main class name and package
* @param arguments the arguments
*/
- public ApplicationDesc(String mainClass, String arguments[]) {
+ public ApplicationDesc(String mainClass, String[] arguments, boolean isFX) {
this.mainClass = mainClass;
this.arguments = arguments;
+ this.fx = isFX;
}
/**
diff -r 6639d193e740 -r 7251d3abc7ab netx/net/sourceforge/jnlp/Node.java
--- a/netx/net/sourceforge/jnlp/Node.java Sun Feb 04 09:58:58 2018 +0100
+++ b/netx/net/sourceforge/jnlp/Node.java Mon Feb 05 14:31:51 2018 +0100
@@ -40,6 +40,7 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
+import java.util.Objects;
import net.sourceforge.nanoxml.XMLElement;
@@ -52,7 +53,7 @@
* regular XML Node interface (for the methods used by Parser).
*/
/* NANO */
-class Node {
+public class Node {
private XMLElement xml;
private Node next;
private Node children[];
@@ -124,18 +125,62 @@
return (String) xml.getAttribute(name);
}
- String getNodeName() {
+ public ElementName getNodeName() {
if (xml.getName() == null) {
- return "";
+ return new ElementName("");
}
else {
- return xml.getName();
+ return new ElementName(xml.getName());
}
}
+
@Override
public String toString() {
- return getNodeName();
+ return getNodeName().getOriginal();
+ }
+
+ public static class ElementName {
+
+ private final String base;
+
+ public ElementName(String base) {
+ this.base = base;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ElementName) {
+ return ((ElementName) obj).base.equals(base);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return base.hashCode();
+ }
+
+ public String getName() {
+ if (base.contains(":")) {
+ return base.split(":")[1];
+ } else {
+ return base;
+ }
+ }
+ public String getPrefix() {
+ if (base.contains(":")) {
+ return base.split(":")[0];
+ } else {
+ return "";
+ }
+ }
+
+ private String getOriginal() {
+ return base + "(" + getPrefix() + ":" + getName() + ")";
+ }
+
}
}
diff -r 6639d193e740 -r 7251d3abc7ab netx/net/sourceforge/jnlp/Parser.java
--- a/netx/net/sourceforge/jnlp/Parser.java Sun Feb 04 09:58:58 2018 +0100
+++ b/netx/net/sourceforge/jnlp/Parser.java Mon Feb 05 14:31:51 2018 +0100
@@ -147,14 +147,14 @@
* @param codebase codebase to use if we did not parse one from JNLP file.
* @throws ParseException if the JNLP file is invalid
*/
- Parser(JNLPFile file, URL base, Node root, ParserSettings settings, URL codebase) throws ParseException {
+ public Parser(JNLPFile file, URL base, Node root, ParserSettings settings, URL codebase) throws ParseException {
this.file = file;
this.root = root;
this.strict = settings.isStrict();
this.allowExtensions = settings.isExtensionAllowed();
// ensure it's a JNLP node
- if (root == null || !root.getNodeName().equals("jnlp")) {
+ if (root == null || !root.getNodeName().getName().equals("jnlp")) {
throw new ParseException(R("PInvalidRoot"));
}
@@ -216,7 +216,7 @@
UpdateDesc updateDesc = null;
Node child = parent.getFirstChild();
while (child != null) {
- if (child.getNodeName().equals("update")) {
+ if (child.getNodeName().getName().equals("update")) {
if (strict && updateDesc != null) {
throw new ParseException(R("PTwoUpdates"));
}
@@ -315,7 +315,7 @@
// step through the elements
Node child = node.getFirstChild();
while (child != null) {
- String name = child.getNodeName();
+ String name = child.getNodeName().getName();
// check for nativelib but no trusted environment
if ("nativelib".equals(name)) {
@@ -403,7 +403,7 @@
* @throws ParseException if the JNLP file is invalid
*/
private JARDesc getJAR(Node node) throws ParseException {
- boolean nativeJar = "nativelib".equals(node.getNodeName());
+ boolean nativeJar = "nativelib".equals(node.getNodeName().getName());
URL location = getRequiredURL(node, "href", base);
Version version = getVersion(node, "version", null);
String part = getAttribute(node, "part", null);
@@ -545,7 +545,7 @@
// step through the elements
Node child = node.getFirstChild();
while (child != null) {
- String name = child.getNodeName();
+ String name = child.getNodeName().getName();
if ("title".equals(name)) {
addInfo(info, child, null, getSpanText(child, false));
@@ -610,7 +610,7 @@
return;
}
- info.addItem(node.getNodeName() + modStr, value);
+ info.addItem(node.getNodeName().getName() + modStr, value);
}
/**
@@ -704,23 +704,27 @@
// check for other than one application type
if (1 < getChildNodes(parent, "applet-desc").length
+ getChildNodes(parent, "application-desc").length
+ + getChildNodes(parent, "javafx-desc").length
+ getChildNodes(parent, "installer-desc").length) {
throw new ParseException(R("PTwoDescriptors"));
}
Node child = parent.getFirstChild();
while (child != null) {
- String name = child.getNodeName();
+ String name = child.getNodeName().getName();
if ("applet-desc".equals(name)) {
return getApplet(child);
}
if ("application-desc".equals(name)) {
- return getApplication(child);
+ return getApplication(child, false);
}
if ("installer-desc".equals(name)) {
return getInstaller(child);
}
+ if ("javafx-desc".equals(name)) {
+ return getApplication(child, true);
+ }
child = child.getNextSibling();
}
@@ -728,6 +732,8 @@
// not reached
return null;
}
+
+
/**
* @param node
@@ -768,7 +774,7 @@
* @param node
* @throws ParseException if the JNLP file is invalid
*/
- private ApplicationDesc getApplication(Node node) throws ParseException {
+ private ApplicationDesc getApplication(Node node, boolean isFx) throws ParseException {
String main = getMainClass(node, false);
List<String> argsList = new ArrayList<>();
@@ -784,7 +790,7 @@
String argStrings[] = argsList.toArray(new String[argsList.size()]);
- return new ApplicationDesc(main, argStrings);
+ return new ApplicationDesc(main, argStrings, isFx);
}
/**
@@ -800,7 +806,7 @@
Node child = parent.getFirstChild();
while (child != null) {
- String name = child.getNodeName();
+ String name = child.getNodeName().getName();
if ("component-desc".equals(name)) {
return new ComponentDesc();
@@ -848,7 +854,7 @@
// step through the elements
Node child = node.getFirstChild();
while (child != null) {
- String name = child.getNodeName();
+ String name = child.getNodeName().getName();
if (null != name) {
switch (name) {
@@ -901,7 +907,7 @@
// step through the elements
Node child = node.getFirstChild();
while (child != null) {
- String name = child.getNodeName();
+ String name = child.getNodeName().getName();
if (null != name) {
switch (name) {
@@ -1064,7 +1070,7 @@
if (child == null) {
if (strict)
// not sure if this is an error or whether "" is proper
- throw new ParseException("No text specified (node="+node.getNodeName()+")");
+ throw new ParseException("No text specified (node="+node.getNodeName().getName()+")");
else
return "";
}
@@ -1093,7 +1099,7 @@
Node child = node.getFirstChild();
while (child != null) {
- if (child.getNodeName().equals(name)) {
+ if (child.getNodeName().getName().equals(name)) {
result.add(child);
}
child = child.getNextSibling();
@@ -1148,7 +1154,7 @@
* @param base the base URL
* @throws ParseException if the JNLP file is invalid
*/
- URL getURL(Node node, String name, URL base) throws ParseException {
+ public URL getURL(Node node, String name, URL base) throws ParseException {
String href;
if (CODEBASE.equals(name)) {
href = getCleanAttribute(node, name);
@@ -1160,7 +1166,7 @@
} else {
href = getAttribute(node, name, null);
}
- return getURL(href, node.getNodeName(), base, strict);
+ return getURL(href, node.getNodeName().getName(), base, strict);
}
public static URL getURL(String href, String nodeName, URL base, boolean strict) throws ParseException {
@@ -1334,7 +1340,7 @@
if (result == null || result.length() == 0) {
if (strict || defaultValue == null) {
- throw new ParseException(R("PNeedsAttribute", node.getNodeName(), name));
+ throw new ParseException(R("PNeedsAttribute", node.getNodeName().getName(), name));
}
}
diff -r 6639d193e740 -r 7251d3abc7ab tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java
--- a/tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java Sun Feb 04 09:58:58 2018 +0100
+++ b/tests/netx/unit/net/sourceforge/jnlp/ParserCornerCases.java Mon Feb 05 14:31:51 2018 +0100
@@ -66,7 +66,7 @@
Assert.assertTrue(target.getContent().contains("<entry key=\"key\">value</entry>"));
Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("argument", node.getNodeName());
+ Assert.assertEquals("argument", node.getNodeName().getName());
String contents = node.getNodeValue();
Assert.assertTrue(contents.contains("xml"));
Assert.assertTrue(contents.contains("DOCTYPE"));
@@ -94,7 +94,7 @@
Node node = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
node = node.getFirstChild().getFirstChild();
- Assert.assertEquals("argument", node.getNodeName());
+ Assert.assertEquals("argument", node.getNodeName().getName());
String contents = node.getNodeValue();
Assert.assertTrue(contents.contains("xml"));
Assert.assertTrue(contents.contains("DOCTYPE"));
diff -r 6639d193e740 -r 7251d3abc7ab tests/netx/unit/net/sourceforge/jnlp/ParserTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/ParserTest.java Sun Feb 04 09:58:58 2018 +0100
+++ b/tests/netx/unit/net/sourceforge/jnlp/ParserTest.java Mon Feb 05 14:31:51 2018 +0100
@@ -67,7 +67,7 @@
String data = "<jnlp></jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
@@ -82,7 +82,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
@@ -105,7 +105,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
@@ -135,7 +135,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = parser.getInfo(root);
@@ -162,7 +162,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = parser.getInfo(root);
@@ -185,7 +185,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = parser.getInfo(root);
@@ -216,7 +216,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = parser.getInfo(root);
@@ -247,7 +247,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = parser.getInfo(root);
@@ -277,7 +277,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = parser.getInfo(root);
@@ -306,7 +306,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = parser.getInfo(root);
@@ -334,7 +334,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
@@ -361,7 +361,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
@@ -385,7 +385,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
@@ -409,7 +409,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
List<InformationDesc> infoDescs = new ArrayList<InformationDesc>();
@@ -431,7 +431,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
@@ -454,7 +454,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
@@ -493,7 +493,7 @@
+ "</jnlp>\n";
Node root = Parser.getRootNode(new ByteArrayInputStream(data.getBytes()), defaultParser);
- Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName());
+ Assert.assertEquals("Root name is not jnlp", "jnlp", root.getNodeName().getName());
MockJNLPFile file = new MockJNLPFile(ALL_LOCALE);
Parser parser = new Parser(file, null, root, defaultParser);
More information about the distro-pkg-dev
mailing list