Mercurial > hg > release > icedtea-web-1.0
changeset 27:499642ab12a6
Parse jnlps containing <component-desc> as well as <application-desc> elements
2010-10-29 Omair Majid <omajid@redhat.com>
* netx/net/sourceforge/jnlp/JNLPFile.java: Add component.
(getLaunchInfo): Modify javadoc to indicate that it does not return
the ComponentDesc.
(getComponent): Return component instead of launchType.
(isComponent): Check if component is not null.
(parse): Find and set component descriptor.
* netx/net/sourceforge/jnlp/Parser.java
(getLauncher): Remove all checks for component-desc. Allow having
none of application-desc, applet-desc and installer-desc.
(getComponent): Check for more than one component-desc element.
Read and parse the component-desc.
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Fri, 29 Oct 2010 17:40:16 -0400 |
parents | 3571cd24829e |
children | bdab3d4ac170 |
files | ChangeLog netx/net/sourceforge/jnlp/JNLPFile.java netx/net/sourceforge/jnlp/Parser.java |
diffstat | 3 files changed, 40 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Oct 28 16:18:36 2010 -0400 +++ b/ChangeLog Fri Oct 29 17:40:16 2010 -0400 @@ -1,3 +1,17 @@ +2010-10-29 Omair Majid <omajid@redhat.com> + + * netx/net/sourceforge/jnlp/JNLPFile.java: Add component. + (getLaunchInfo): Modify javadoc to indicate that it does not return + the ComponentDesc. + (getComponent): Return component instead of launchType. + (isComponent): Check if component is not null. + (parse): Find and set component descriptor. + * netx/net/sourceforge/jnlp/Parser.java + (getLauncher): Remove all checks for component-desc. Allow having + none of application-desc, applet-desc and installer-desc. + (getComponent): Check for more than one component-desc element. + Read and parse the component-desc. + 2010-10-28 Omair Majid <omajid@redhat.com> * netx/net/sourceforge/jnlp/security/SecurityWarningDialog.java
--- a/netx/net/sourceforge/jnlp/JNLPFile.java Thu Oct 28 16:18:36 2010 -0400 +++ b/netx/net/sourceforge/jnlp/JNLPFile.java Fri Oct 29 17:40:16 2010 -0400 @@ -95,6 +95,9 @@ /** the application description */ protected Object launchType; + /** the component description */ + protected ComponentDesc component; + /** the security descriptor */ protected SecurityDesc security; @@ -402,7 +405,7 @@ /** * Returns an object of one of the following types: AppletDesc, - * ApplicationDesc, InstallerDesc, and ComponentDesc. + * ApplicationDesc and InstallerDesc */ public Object getLaunchInfo() { return launchType; @@ -441,7 +444,7 @@ if (!isComponent()) throw new UnsupportedOperationException(R("JNotComponent")); - return (ComponentDesc) launchType; + return component; } /** @@ -474,7 +477,7 @@ * Returns whether the lauch descriptor describes a Component. */ public boolean isComponent() { - return launchType instanceof ComponentDesc; + return component != null; } /** @@ -574,6 +577,7 @@ update = parser.getUpdate(root); resources = parser.getResources(root, false); // false == not a j2se/java resources section launchType = parser.getLauncher(root); + component = parser.getComponent(root); security = parser.getSecurity(root); } catch (ParseException ex) {
--- a/netx/net/sourceforge/jnlp/Parser.java Thu Oct 28 16:18:36 2010 -0400 +++ b/netx/net/sourceforge/jnlp/Parser.java Fri Oct 29 17:40:16 2010 -0400 @@ -598,16 +598,15 @@ /** * Returns the launch descriptor element, either AppletDesc, - * ApplicationDesc, ComponentDesc, or InstallerDesc. + * ApplicationDesc, or InstallerDesc. * * @param parent the parent node * @throws ParseException if the JNLP file is invalid */ public Object getLauncher(Node parent) throws ParseException { // check for other than one application type - if (1 != getChildNodes(parent, "applet-desc").length + if (1 < getChildNodes(parent, "applet-desc").length + getChildNodes(parent, "application-desc").length - + getChildNodes(parent, "component-desc").length + getChildNodes(parent, "installer-desc").length) throw new ParseException(R("PTwoDescriptors")); @@ -619,8 +618,6 @@ return getApplet(child); if ("application-desc".equals(name)) return getApplication(child); - if ("component-desc".equals(name)) - return getComponent(child); if ("installer-desc".equals(name)) return getInstaller(child); @@ -693,8 +690,23 @@ /** * Returns the component descriptor. */ - public ComponentDesc getComponent(Node node) { - return new ComponentDesc(); + public ComponentDesc getComponent(Node parent) throws ParseException { + + if (1 < getChildNodes(parent, "component-desc").length) { + throw new ParseException(R("PTwoDescriptors")); + } + + Node child = parent.getFirstChild(); + while (child != null) { + String name = child.getNodeName(); + + if ("component-desc".equals(name)) + return new ComponentDesc(); + + child = child.getNextSibling(); + } + + return null; } /**