geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r391092 - /geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/Module.java
Date Mon, 03 Apr 2006 17:42:05 GMT
Author: dain
Date: Mon Apr  3 10:42:03 2006
New Revision: 391092

URL: http://svn.apache.org/viewcvs?rev=391092&view=rev
Log:
Fixed bug where directory for generated geronimo classes was being created in the root of
the file system at /META-INF

Modified:
    geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/Module.java

Modified: geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/Module.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/Module.java?rev=391092&r1=391091&r2=391092&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/Module.java
(original)
+++ geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/Module.java
Mon Apr  3 10:42:03 2006
@@ -27,7 +27,6 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.deployment.DeploymentContext;
-import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.gbean.AbstractName;
 
 /**
@@ -151,19 +150,46 @@
         addClass(location, fqcn, bytes, context);
     }
 
-    private URI getUniqueModuleLocation(DeploymentContext context) {
+    private URI getUniqueModuleLocation(DeploymentContext context) throws IOException {
         if (uniqueModuleLocation == null) {
+            URI metainfUri = URI.create("META-INF/");
+            File metainfDir = context.getTargetFile(metainfUri);
+            if (!metainfDir.exists()) {
+                metainfDir.mkdirs();
+            }
+            if (!metainfDir.isDirectory()) {
+                throw new IOException("META-INF directory exists but is not a directory:
" + metainfDir.getAbsolutePath());
+            }
+            if (!metainfDir.canRead()) {
+                throw new IOException("META-INF directory is not readable: " + metainfDir.getAbsolutePath());
+            }
+            if (!metainfDir.canWrite()) {
+                throw new IOException("META-INF directory is not wirtable: " + metainfDir.getAbsolutePath());
+            }
+
             String suffix = "";
-            URI candidateURI;
-            File candidateFile;
-            int i = 1;
+            URI generatedUri;
+            File generatedDir;
+            int i = 0;
             do {
-                candidateURI = URI.create("/META-INF/geronimo-generated" + suffix + "/");
-                candidateFile = context.getTargetFile(candidateURI);
+                generatedUri = metainfUri.resolve("geronimo-generated" + suffix + "/");
+                generatedDir = context.getTargetFile(generatedUri);
                 suffix = "" + i++;
-            } while (candidateFile.exists());
-            candidateFile.mkdirs();
-            uniqueModuleLocation = candidateURI;
+            } while (generatedDir.exists());
+            generatedDir.mkdirs();
+
+            // these shouldn't ever happen, but let's check anyway
+            if (!generatedDir.isDirectory()) {
+                throw new IOException("Geronimo generated classes directory exists but is
not a directory: " + generatedDir.getAbsolutePath());
+            }
+            if (!generatedDir.canRead()) {
+                throw new IOException("Geronimo generated classes directory is not readable:
" + generatedDir.getAbsolutePath());
+            }
+            if (!generatedDir.canWrite()) {
+                throw new IOException("Geronimo generated classes directory is not wirtable:
" + generatedDir.getAbsolutePath());
+            }
+
+            uniqueModuleLocation = generatedUri;
         }
         return uniqueModuleLocation;
     }



Mime
View raw message