svn commit: r593003 - in /xml/xindice/trunk/java/src/org/apache/xindice/tools: XMLTools.java command/Shutdown.java

[email protected]
Newsgroups gmane.text.xml.xindice.devel
Message-ID <[email protected]>
Author: natalia
Date: Wed Nov  7 19:12:23 2007
New Revision: 593003

URL: http://svn.apache.org/viewvc?rev=593003&view=rev
Log:
Fix URL handling for local database shutdown

Modified:
    xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java
    xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java

Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java?rev=593003&r1=593002&r2=593003&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java Wed Nov  7 19:12:23 2007
@@ -205,6 +205,10 @@
                 if (!colname.startsWith("/") && !colname.startsWith("xmldb:xindice")) {
                     throw new IllegalArgumentException("The name of a collection must start with '/'");
                 }
+
+                if (colname.startsWith("xmldb:xindice-embed://")) {
+                    config.setBoolean(LOCAL, true);
+                }
                 config.setString(COLLECTION, colname);
             } else if (token.equalsIgnoreCase("--filer")) {
                 config.setString(FILER, at.nextSwitchToken());

Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java?rev=593003&r1=593002&r2=593003&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java Wed Nov  7 19:12:23 2007
@@ -45,13 +45,7 @@
         try {
             // Collection name can be incorrect, use database name instead
             String context = table.getString(XMLTools.COLLECTION);
-            int i = context.indexOf('/', 1);
-            String db;
-            if (i >= 0) {
-                db = context.substring(0, i);
-            } else {
-                db = context;
-            }
+            String db = getDbName(context);
 
             // Get a Collection reference to pass on to individual commands
             String colstring = normalizeCollectionURI(db, table.getBoolean(XMLTools.LOCAL));
@@ -71,6 +65,19 @@
         }
 
         return true;
+    }
+
+    private String getDbName(String context) {
+        int i = context.indexOf("://");
+        i = i < 0 ? 0 : i + 3;
+
+        int start = context.indexOf('/', i);
+        int end = context.indexOf('/', start + 1);
+        if (end == -1) {
+            end = context.length();
+        }
+
+        return context.substring(0, end);
     }
 
     public void usage() {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.