geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r563589 - in /geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin: PluginInstallerGBean.java PluginMetadata.java
Date Tue, 07 Aug 2007 17:41:49 GMT
Author: djencks
Date: Tue Aug  7 10:41:48 2007
New Revision: 563589

URL: http://svn.apache.org/viewvc?view=rev&rev=563589
Log:
GERONIMO-3385 dont prepend 'var/' and do trim source path in copy-file element

Modified:
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginMetadata.java

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?view=diff&rev=563589&r1=563588&r2=563589
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
Tue Aug  7 10:41:48 2007
@@ -802,17 +802,20 @@
             monitor.getResults().setCurrentFile(data.getSourceFile());
             monitor.getResults().setCurrentMessage("Copying "+data.getSourceFile()+" from
plugin to Geronimo installation");
             Set set;
+            String sourceFile = data.getSourceFile().trim();
             try {
-                set = configStore.resolve(configID, null, data.getSourceFile());
+                set = configStore.resolve(configID, null, sourceFile);
             } catch (NoSuchConfigException e) {
                 log.error("Unable to identify module "+configID+" to copy files from");
                 throw new IllegalStateException("Unable to identify module "+configID+" to
copy files from", e);
             }
             if(set.size() == 0) {
-                log.error("Installed configuration into repository but cannot locate file
to copy "+data.getSourceFile());
+                log.error("Installed configuration into repository but cannot locate file
to copy "+sourceFile);
                 continue;
             }
-            File targetDir = data.isRelativeToVar() ? serverInfo.resolveServer("var/"+data.getDestDir())
: serverInfo.resolve(data.getDestDir());
+            File targetDir = data.isRelativeToServer() ? serverInfo.resolveServer(data.getDestDir())
: serverInfo.resolve(data.getDestDir());
+
+            createDirectory(targetDir);
             if(!targetDir.isDirectory()) {
                 log.error("Plugin install cannot write file "+data.getSourceFile()+" to "+data.getDestDir()+"
because "+targetDir.getAbsolutePath()+" is not a directory");
                 continue;
@@ -843,6 +846,15 @@
         }
     }
 
+    private static void createDirectory(File dir) throws IOException {
+        if (dir != null && !dir.exists()) {
+            boolean success = dir.mkdirs();
+            if (!success) {
+                throw new IOException("Cannot create directory " + dir.getAbsolutePath());
+            }
+        }
+    }
+
     private void copyFile(InputStream in, FileOutputStream out) throws IOException {
         byte[] buf = new byte[4096];
         int count;
@@ -1919,7 +1931,7 @@
         for (int i = 0; i < data.getFilesToCopy().length; i++) {
             PluginMetadata.CopyFile file = data.getFilesToCopy()[i];
             Element copy = doc.createElement("copy-file");
-            copy.setAttribute("relative-to", file.isRelativeToVar() ? "server" : "geronimo");
+            copy.setAttribute("relative-to", file.isRelativeToServer() ? "server" : "geronimo");
             copy.setAttribute("dest-dir", file.getDestDir());
             copy.appendChild(doc.createTextNode(file.getSourceFile()));
             config.appendChild(copy);

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginMetadata.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginMetadata.java?view=diff&rev=563589&r1=563588&r2=563589
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginMetadata.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginMetadata.java
Tue Aug  7 10:41:48 2007
@@ -278,18 +278,18 @@
     }
 
     public static class CopyFile implements Serializable {
-        private final boolean relativeToVar;  // if not, relative to the Geronimo install
directory
+        private final boolean relativeToServer;  // if not, relative to the Geronimo install
directory
         private final String sourceFile;
         private final String destDir;
 
-        public CopyFile(boolean relativeToVar, String sourceFile, String destDir) {
-            this.relativeToVar = relativeToVar;
+        public CopyFile(boolean relativeToServer, String sourceFile, String destDir) {
+            this.relativeToServer = relativeToServer;
             this.sourceFile = sourceFile;
             this.destDir = destDir;
         }
 
-        public boolean isRelativeToVar() {
-            return relativeToVar;
+        public boolean isRelativeToServer() {
+            return relativeToServer;
         }
 
         public String getSourceFile() {



Mime
View raw message