svn commit: r15563 - branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: maurelio1234
Date: 2008-08-14 05:27:15-0700
New Revision: 15563

Modified:
   branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java

Log:

issue 5318



Modified: branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java?view=diff&rev=15563&p1=branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java&p2=branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java&r1=15562&r2=15563
==============================================================================
--- branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java	(original)
+++ branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java	2008-08-14 05:27:15-0700
@@ -25,6 +25,8 @@
 package org.argouml.profile.internal;
 
 import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -110,34 +112,54 @@
         loadDefaultProfilesfromConfiguration();
     }
 
-    private void loadDefaultProfilesfromConfiguration() {    
-        disableConfigurationUpdate = true;
-        
-        String defaultProfilesList = Configuration
-                        .getString(KEY_DEFAULT_PROFILES);
-        if (defaultProfilesList.equals("")) {
-            // if the list does not exist
-            // add the Java profile as default
-            
-            addToDefaultProfiles(profileJava);
-        } else {
-            StringTokenizer tokenizer = new StringTokenizer(
-                    defaultProfilesList, DIRECTORY_SEPARATOR, false);
-
-            while (tokenizer.hasMoreTokens()) {
-                String desc = tokenizer.nextToken();
-                Profile p = null;
-
-                if (desc.charAt(0) == 'U') {
-                    String fileName = desc.substring(1);
-                    p = findUserDefinedProfile(new File(fileName));
-                } else if (desc.charAt(0) == 'C') {
-                    String className = desc.substring(1);
-                    p = getProfileForClass(className);
-                }
+    private void loadDefaultProfilesfromConfiguration() {
+        if (!disableConfigurationUpdate) {
+            disableConfigurationUpdate = true;
+
+            String defaultProfilesList = Configuration
+                    .getString(KEY_DEFAULT_PROFILES);
+            if (defaultProfilesList.equals("")) {
+                // if the list does not exist
+                // add the Java profile as default
+
+                addToDefaultProfiles(profileJava);
+            } else {
+                StringTokenizer tokenizer = new StringTokenizer(
+                        defaultProfilesList, DIRECTORY_SEPARATOR, false);
+
+                while (tokenizer.hasMoreTokens()) {
+                    String desc = tokenizer.nextToken();
+                    Profile p = null;
+
+                    if (desc.charAt(0) == 'U') {
+                        String fileName = desc.substring(1);
+                        File file;
+                        try {
+                            file = new File(new URI(fileName));
+
+                            p = findUserDefinedProfile(file);
+
+                            if (p == null) {
+                                try {
+                                    p = new UserDefinedProfile(file);
+                                    registerProfile(p);
+                                } catch (ProfileException e) {
+                                    LOG.error("Error loading profile: " + file,
+                                            e);
+                                }
+                            }
+                        } catch (URISyntaxException e1) {
+                            LOG.error("Invalid path for Profile: " + fileName,
+                                    e1);
+                        }
+                    } else if (desc.charAt(0) == 'C') {
+                        String className = desc.substring(1);
+                        p = getProfileForClass(className);
+                    }
 
-                if (p != null) {
-                    addToDefaultProfiles(p);
+                    if (p != null) {
+                        addToDefaultProfiles(p);
+                    }
                 }
             }
         }
@@ -152,7 +174,7 @@
                 if (p instanceof UserDefinedProfile) {
                     buf.append("U"
                             + ((UserDefinedProfile) p).getModelFile()
-                                    .getAbsolutePath());
+                                    .toURI().toASCIIString());
                 } else {
                     buf.append("C" + p.getClass().getName());
                 }
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.