You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by li...@apache.org on 2008/11/14 16:51:20 UTC

svn commit: r714047 - /geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java

Author: linsun
Date: Fri Nov 14 07:51:19 2008
New Revision: 714047

URL: http://svn.apache.org/viewvc?rev=714047&view=rev
Log:
GERONIMO-4395 EmployeeDatasource and jdbc/EmployeeDatasource create the same files.  Slightly modified patch from Ivan Thanks Ivan

Modified:
    geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java

Modified: geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java?rev=714047&r1=714046&r2=714047&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java (original)
+++ geronimo/server/trunk/plugins/system-database/sysdb-portlets/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java Fri Nov 14 07:51:19 2008
@@ -46,6 +46,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Random;
 import java.util.Set;
 import java.util.SortedSet;
 
@@ -96,6 +97,8 @@
 import org.apache.geronimo.deployment.tools.loader.ConnectorDeployable;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.proxy.GeronimoManagedBean;
 import org.apache.geronimo.kernel.repository.Artifact;
@@ -969,15 +972,22 @@
                 org.apache.geronimo.deployment.service.jsr88.Artifact configId = new org.apache.geronimo.deployment.service.jsr88.Artifact();
                 environment.setConfigId(configId);
                 configId.setGroupId("console.dbpool");
+                configId.setVersion("1.0");
+                configId.setType("rar");
+                
                 String artifactId = data.name;
-                if (artifactId.indexOf('/') != -1) {
-                    // slash in artifact-id results in invalid configuration-id and leads to deployment errors
-                    // use the after / portion as the artifactId
-                    artifactId = artifactId.substring(artifactId.indexOf('/') + 1);
+                // simply replace / with _ if / exists within the artifactId
+                // this is needed because we don't allow / within the artifactId
+                artifactId = artifactId.replace('/', '_');
+
+                // Let's check whether the artifact exists
+                ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(PortletManager.getKernel());
+                if (configurationManager.isInstalled(new Artifact(configId.getGroupId(), artifactId,
+                        configId.getVersion(), configId.getType()))) {
+                    artifactId = artifactId + "_" + new Random(System.currentTimeMillis()).nextInt(99);
                 }
+
                 configId.setArtifactId(artifactId);
-                configId.setVersion("1.0");
-                configId.setType("rar");
 
                 String[] jars = data.getJars();
                 int length = jars[jars.length - 1].length() == 0 ? jars.length - 1 : jars.length;