You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2011/04/28 16:21:48 UTC
svn commit: r1097475 -
/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateDescriptionDocument.java
Author: scottbw
Date: Thu Apr 28 14:21:48 2011
New Revision: 1097475
URL: http://svn.apache.org/viewvc?rev=1097475&view=rev
Log:
Added support for relative URLs for widget update locations
Modified:
incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateDescriptionDocument.java
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateDescriptionDocument.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateDescriptionDocument.java?rev=1097475&r1=1097474&r2=1097475&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateDescriptionDocument.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/updates/UpdateDescriptionDocument.java Thu Apr 28 14:21:48 2011
@@ -36,6 +36,7 @@ public class UpdateDescriptionDocument{
private URL updateSource;
private String versionTag;
private ArrayList<Details> details;
+ private URL baseUrl;
/**
* Get the details of the update, typically a short description of any new features.
@@ -85,10 +86,10 @@ public class UpdateDescriptionDocument{
*/
public UpdateDescriptionDocument(String href) throws InvalidUDDException{
try {
- URL url = new URL(href);
+ baseUrl = new URL(href);
HttpClient client = new HttpClient();
- GetMethod method = new GetMethod(url.toString());
+ GetMethod method = new GetMethod(baseUrl.toString());
method.setFollowRedirects(true);
client.executeMethod(method);
String type = method.getResponseHeader("Content-Type").getValue();
@@ -127,10 +128,18 @@ public class UpdateDescriptionDocument{
if (root.getAttribute("version") == null) throw new InvalidUDDException("no version attribute");
if (root.getAttribute("src") == null) throw new InvalidUDDException("no src attribute");
versionTag = root.getAttributeValue("version");
+
+ // Determine the update source URL.
try {
updateSource = new URL(root.getAttributeValue("src"));
} catch (MalformedURLException e) {
- throw new InvalidUDDException("src attribute is not a valid URL");
+ // If the URL is relative, try to make it absolute by using the URL where the UDD is obtained from as the base
+ try {
+ System.out.println(root.getAttributeValue("src"));
+ updateSource = new URL(baseUrl, root.getAttributeValue("src"));
+ } catch (MalformedURLException e1) {
+ throw new InvalidUDDException("src attribute is not a valid URL");
+ }
}
List<?> detailsElements = root.getChildren("details", Namespace.getNamespace(IW3CXMLConfiguration.MANIFEST_NAMESPACE));
this.details = new ArrayList<Details>();