[Mulgara-svn] r471 - branches/nw-interface/src/jar/query/java/org/mulgara/query/operation

pag at mulgara.org pag at mulgara.org
Thu Oct 11 16:04:59 UTC 2007


Author: pag
Date: 2007-10-11 11:04:58 -0500 (Thu, 11 Oct 2007)
New Revision: 471

Modified:
   branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Backup.java
Log:
Factored out the serverUri calculation into a public static method

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Backup.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Backup.java	2007-10-11 15:35:03 UTC (rev 470)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Backup.java	2007-10-11 16:04:58 UTC (rev 471)
@@ -57,7 +57,7 @@
   public Backup(URI source, URI destination) {
     super(source, destination, false);
     if (!destination.getScheme().equals(FILE)) throw new IllegalArgumentException("Backups must be sent to a file");
-    calcServerUri(source);
+    updateServerUri(source);
   }
 
   /**
@@ -136,7 +136,6 @@
    * @return The number of statements affected, or <code>null</code> if this is not relevant.
    */
   protected Long doTx(Connection conn, InputStream inputStream) throws QueryException {
-    // TODO: Attempt to factor out any common so that this becomes a call to Session.backup.
     return null;
   }
 
@@ -144,21 +143,35 @@
    * Sets the server URI for this server operation.
    * @param uri The URI to determine the server URI from.
    */
-  private URI calcServerUri(URI uri) {
+  private URI updateServerUri(URI uri) {
+    // This should already be set, though we don't really care
     assert serverUri != null;
+    serverUri = calcServerUri(uri);
+    return serverUri;
+  }
+ 
+
+  /**
+   * Determine the URI to be used for a server when processing a backup.
+   * @param uri Can contain the URI of a graph, or of an entire server.
+   * @return The URI for the server containing the uri.
+   */
+  public static URI calcServerUri(URI uri) {
+    URI calcUri = null;
+    
     // check if backing up a graph or a server
     String fragment = uri.getFragment();
     if (fragment == null) {
       if (logger.isDebugEnabled()) logger.debug("Backup for server: " + uri);
-      serverUri = uri;
+      calcUri = uri;
     } else {
       String serverUriString = uri.toString().replaceAll("#" + fragment, "");
       try {
-        serverUri = new URI(serverUriString);
+        calcUri = new URI(serverUriString);
       } catch (URISyntaxException e) {
         throw new Error("Unable to truncate a fragment from a valid URI");
       }
     }
-    return serverUri;
+    return calcUri;
   }
 }




More information about the Mulgara-svn mailing list