svn commit: r13987 - trunk/src_new/org/argouml/configuration/ConfigurationProperties.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: penyaskito
Date: 2007-12-23 04:50:19-0800
New Revision: 13987

Modified:
   trunk/src_new/org/argouml/configuration/ConfigurationProperties.java

Log:
The argo.user.properties is moved into .argouml. If a previous config file exists, it will be moved to the new location. (See issue 3766)

Modified: trunk/src_new/org/argouml/configuration/ConfigurationProperties.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/configuration/ConfigurationProperties.java?view=diff&rev=13987&p1=trunk/src_new/org/argouml/configuration/ConfigurationProperties.java&p2=trunk/src_new/org/argouml/configuration/ConfigurationProperties.java&r1=13986&r2=13987
==============================================================================
--- trunk/src_new/org/argouml/configuration/ConfigurationProperties.java	(original)
+++ trunk/src_new/org/argouml/configuration/ConfigurationProperties.java	2007-12-23 04:50:19-0800
@@ -86,9 +86,18 @@
      * @return a generic path string.
      */
     public String getDefaultPath() {
-        return System.getProperty("user.home") + "/argo.user.properties";
+        return System.getProperty("user.home") + "/.argouml/argo.user.properties";
     }
 
+    /**
+     * Returns the default path for user properties (before 0.25.4)
+     * @return a generic path string
+     * @deprecated This should be removed on the next version after 0.26
+     */
+    @Deprecated
+    public String getOldDefaultPath() {
+        return System.getProperty("user.home") + "/argo.user.properties";
+    }
 
     /**
      * Load the configuration from a specified location.
@@ -108,7 +117,26 @@
             }
             // Try to create an empty file.
             try {
-                file.createNewFile();
+                File parent = file.getParentFile();
+                // create the argouml dir if it doesn't exist
+                if (!parent.exists()) {
+                    parent.mkdir();
+                    LOG.info("New argouml home dir created as " + parent);
+                }
+                // This is done for compatibility with previous version: 
+                // Move the argo.user.properties
+                // written before 0.25.4 to the new location, if it exists.
+                // TODO: Remove this when the next major release is done.
+                File oldFile = new File(getOldDefaultPath());
+                if (oldFile.exists()) {
+                    oldFile.renameTo(file);
+                    propertyBundle.load(new FileInputStream(file));
+                    LOG.info("Configuration moved from " 
+                            + oldFile + " to " + file);
+                }
+                else {
+                    file.createNewFile();
+                }
                 if (file.exists() && file.isFile()) {
                     LOG.info("New configuration created as " + file);
                     // Pretend we loaded the file correctly
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.