[jboss-cvs] JBossAS SVN: r77000 - projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 13 03:38:07 EDT 2008


Author: alesj
Date: 2008-08-13 03:38:07 -0400 (Wed, 13 Aug 2008)
New Revision: 77000

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java
Log:
Simple refactoring.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java	2008-08-13 03:42:21 UTC (rev 76999)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java	2008-08-13 07:38:07 UTC (rev 77000)
@@ -125,7 +125,7 @@
 
    /**
     * Creates a 'directory' within the context determined by the url host part
-    * @param url The url of the directory we want tot create
+    * @param url The url of the directory we want to create
     * @return The created directory
     * @throws IllegalArgumentException if there is no root matching the host part of the url 
     */
@@ -134,16 +134,14 @@
       String rootName = url.getHost();
       MemoryContext ctx = registry.get(rootName);
       if (ctx == null)
-      {
          throw new IllegalArgumentException("No MemoryContext exists for " + rootName);
-      }
 
       return ctx.createDirectory(url);
    }
    
    /**
     * Creates a 'file' within the context determined by the url host part
-    * @param url The url of the directory we want tot create
+    * @param url The url of the directory we want to create
     * @param contents The contents of the file
     * @return The created file
     * @throws IllegalArgumentException if there is no root matching the host part of the url 
@@ -153,10 +151,8 @@
       String rootName = url.getHost();
       MemoryContext ctx = registry.get(rootName);
       if (ctx == null)
-      {
-         throw new RuntimeException("No MemoryContext exists for " + rootName);
-      }
-      
+         throw new IllegalArgumentException("No MemoryContext exists for " + rootName);
+
       return ctx.putFile(url, contents);
    }
    
@@ -168,10 +164,9 @@
     */
    public boolean deleteRoot(URL url)
    {
-      if (url.getPath() != null && url.getPath().length() > 0)
-      {
-         throw new IllegalArgumentException("Root can not contain '/'");
-      }
+      String path = url.getPath();
+      if (path != null && path.length() > 0)
+         throw new IllegalArgumentException("Root can not contain '/' - " + path);
 
       String rootName = url.getHost();
       return (registry.remove(rootName) != null);
@@ -186,16 +181,15 @@
    {
       try
       {
-         if (url.getPath() == null || url.getPath().length() == 0)
-         {
+         String path = url.getPath();
+         if (path == null || path.length() == 0)
             return deleteRoot(url);
-         }
 
          String rootName = url.getHost();
          MemoryContext ctx = registry.get(rootName);
          if (ctx != null)
          {
-            MemoryContextHandler child = (MemoryContextHandler)ctx.getChild(ctx.getRoot(), url.getPath());
+            MemoryContextHandler child = (MemoryContextHandler)ctx.getChild(ctx.getRoot(), path);
             MemoryContextHandler parent = (MemoryContextHandler)child.getParent();
             return parent.deleteChild(child);
          }




More information about the jboss-cvs-commits mailing list