refactored org to uk
[vamsas.git] / src / org / vamsas / client / SessionUrn.java
index ee9e980..4eff113 100644 (file)
@@ -3,7 +3,6 @@
  */
 package org.vamsas.client;
 
-import java.io.File;
 import java.net.URI;
 import java.util.Hashtable;
 import java.util.Vector;
@@ -14,7 +13,7 @@ import java.util.Vector;
  * uses java.net.URI internally for construction of URN
  */
 public abstract class SessionUrn {
-  URI urn;
+  protected URI urn;
   /**
    * The types of URI protocols we understand
    */
@@ -23,16 +22,19 @@ public abstract class SessionUrn {
   /**
    * construct urn for a locally stored session file
    * @param type
-   * @param file
+   * @param url
    */
-  protected SessionUrn(String type, File file) {
+  protected SessionUrn(String type, java.net.URL url) {
     if (!TYPES.containsKey(type.toLowerCase()))
-      throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for file '"+file.getAbsolutePath()+"'");
-    urn = URI.create(type+"://"+file.getAbsolutePath());
+      throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for URL '"+url+"'");
+    try {
+      urn = URI.create(type+"://"+url.getPath());
+    } catch (Exception e) {
+      // TODO: something better than throwing an error should be done here.
+      throw new Error(e);
+    }
   }
   public String getSessionUrn() {
     return urn.toString();
   }
-  
-  // TODO: add abstract 'handler' methods for resolving the URN to a particular class
 }