Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 46940 invoked from network); 13 Dec 2006 16:55:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Dec 2006 16:55:02 -0000 Received: (qmail 11829 invoked by uid 500); 13 Dec 2006 16:55:10 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 11804 invoked by uid 500); 13 Dec 2006 16:55:09 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 11793 invoked by uid 99); 13 Dec 2006 16:55:09 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Dec 2006 08:55:09 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Dec 2006 08:55:01 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 26BFE1A981A; Wed, 13 Dec 2006 08:54:16 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r486734 - in /geronimo/server: branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/ branches/2.0-M1/modules/geronimo-syst... Date: Wed, 13 Dec 2006 16:54:15 -0000 To: scm@geronimo.apache.org From: vamsic007@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061213165416.26BFE1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: vamsic007 Date: Wed Dec 13 08:54:14 2006 New Revision: 486734 URL: http://svn.apache.org/viewvc?view=rev&rev=486734 Log: GERONIMO-2437 Empty dirs and config.xml entries left behind after undeploy o Removes the uninstalled configurations from PersistentConfigurationList o Checks for parent directories upto 3 levels and deletes empty directories o FIXME: Repository is assumed to be Maven2Repository (thus checking 3 levels up). May need a mechanism to determine the repository type and the number of directory levels to check for empty dirs. Modified: geronimo/server/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java geronimo/server/branches/2.0-M1/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Modified: geronimo/server/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?view=diff&rev=486734&r1=486733&r2=486734 ============================================================================== --- geronimo/server/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original) +++ geronimo/server/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Wed Dec 13 08:54:14 2006 @@ -46,6 +46,7 @@ import org.apache.geronimo.kernel.config.InvalidConfigException; import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.apache.geronimo.kernel.config.IOUtil; +import org.apache.geronimo.kernel.config.PersistentConfigurationList; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.FileWriteMonitor; import org.apache.geronimo.kernel.repository.WritableListableRepository; @@ -338,7 +339,37 @@ } File location = repository.getLocation(configId); IOUtil.recursiveDelete(location); - //todo: for Maven 2 repo, delete the version directory if there's nothing left in it (probably the case) + // Number of directory levels up, to check and delete empty parent directories in the repo + int dirDepth = 0; + + // FIXME: Determine the repository type + // For now assume the repo is a Maven2Repository. This should not cause any harm even if it is an + // Maven1Repository, for it would be deleting the 'repository' directory if it happens to be empty. + boolean m2repo = true; + + if(m2repo) { + // Check version, artifact and group directories, i.e. 3 levels up + dirDepth = 3; + } + + File temp = location; + for(int i = 0; i < dirDepth; ++i) { + if((temp = temp.getParentFile()).listFiles().length == 0) { + // Directory is empty. Remove it. + temp.delete(); + } else { + // Directory is not empty. No need to check any more parent directories + break; + } + } + + try { + // Is this the right way to get hold of PersistentConfigurationList? + PersistentConfigurationList configList = (PersistentConfigurationList) kernel.getGBean(PersistentConfigurationList.class); + configList.removeConfiguration(configId); + } catch (Exception e) { + log.warn("Unable to remove configuration from persistent configurations. id = "+configId, e); + } if (configurationInfo != null) { IOException ioException = null; Modified: geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java URL: http://svn.apache.org/viewvc/geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?view=diff&rev=486734&r1=486733&r2=486734 ============================================================================== --- geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original) +++ geronimo/server/branches/1.2/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Wed Dec 13 08:54:14 2006 @@ -45,6 +45,7 @@ import org.apache.geronimo.kernel.config.InvalidConfigException; import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.apache.geronimo.kernel.config.IOUtil; +import org.apache.geronimo.kernel.config.PersistentConfigurationList; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.FileWriteMonitor; import org.apache.geronimo.kernel.repository.WritableListableRepository; @@ -333,7 +334,36 @@ } File location = repository.getLocation(configId); IOUtil.recursiveDelete(location); - //todo: for Maven 2 repo, delete the version directory if there's nothing left in it (probably the case) + // Number of directory levels up, to check and delete empty parent directories in the repo + int dirDepth = 0; + + // FIXME: Determine the repository type + // For now assume the repo is a Maven2Repository. This should not cause any harm even if it is an + // Maven1Repository, for it would be deleting the 'repository' directory if it happens to be empty. + boolean m2repo = true; + if(m2repo) { + // Check version, artifact and group directories, i.e. 3 levels up + dirDepth = 3; + } + + File temp = location; + for(int i = 0; i < dirDepth; ++i) { + if((temp = temp.getParentFile()).listFiles().length == 0) { + // Directory is empty. Remove it. + temp.delete(); + } else { + // Directory is not empty. No need to check any more parent directories + break; + } + } + + try { + // Is this the right way to get hold of PersistentConfigurationList? + PersistentConfigurationList configList = (PersistentConfigurationList) kernel.getGBean(PersistentConfigurationList.class); + configList.removeConfiguration(configId); + } catch (Exception e) { + log.warn("Unable to remove configuration from persistent configurations. id = "+configId, e); + } if (configurationInfo != null) { IOException ioException = null; Modified: geronimo/server/branches/2.0-M1/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0-M1/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?view=diff&rev=486734&r1=486733&r2=486734 ============================================================================== --- geronimo/server/branches/2.0-M1/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original) +++ geronimo/server/branches/2.0-M1/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Wed Dec 13 08:54:14 2006 @@ -45,6 +45,7 @@ import org.apache.geronimo.kernel.config.InvalidConfigException; import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.apache.geronimo.kernel.config.IOUtil; +import org.apache.geronimo.kernel.config.PersistentConfigurationList; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.FileWriteMonitor; import org.apache.geronimo.kernel.repository.WritableListableRepository; @@ -333,7 +334,37 @@ } File location = repository.getLocation(configId); IOUtil.recursiveDelete(location); - //todo: for Maven 2 repo, delete the version directory if there's nothing left in it (probably the case) + // Number of directory levels up, to check and delete empty parent directories in the repo + int dirDepth = 0; + + // FIXME: Determine the repository type + // For now assume the repo is a Maven2Repository. This should not cause any harm even if it is an + // Maven1Repository, for it would be deleting the 'repository' directory if it happens to be empty. + boolean m2repo = true; + + if(m2repo) { + // Check version, artifact and group directories, i.e. 3 levels up + dirDepth = 3; + } + + File temp = location; + for(int i = 0; i < dirDepth; ++i) { + if((temp = temp.getParentFile()).listFiles().length == 0) { + // Directory is empty. Remove it. + temp.delete(); + } else { + // Directory is not empty. No need to check any more parent directories + break; + } + } + + try { + // Is this the right way to get hold of PersistentConfigurationList? + PersistentConfigurationList configList = (PersistentConfigurationList) kernel.getGBean(PersistentConfigurationList.class); + configList.removeConfiguration(configId); + } catch (Exception e) { + log.warn("Unable to remove configuration from persistent configurations. id = "+configId, e); + } if (configurationInfo != null) { IOException ioException = null; Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?view=diff&rev=486734&r1=486733&r2=486734 ============================================================================== --- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original) +++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Wed Dec 13 08:54:14 2006 @@ -45,6 +45,7 @@ import org.apache.geronimo.kernel.config.InvalidConfigException; import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.apache.geronimo.kernel.config.IOUtil; +import org.apache.geronimo.kernel.config.PersistentConfigurationList; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.FileWriteMonitor; import org.apache.geronimo.kernel.repository.WritableListableRepository; @@ -333,7 +334,37 @@ } File location = repository.getLocation(configId); IOUtil.recursiveDelete(location); - //todo: for Maven 2 repo, delete the version directory if there's nothing left in it (probably the case) + // Number of directory levels up, to check and delete empty parent directories in the repo + int dirDepth = 0; + + // FIXME: Determine the repository type + // For now assume the repo is a Maven2Repository. This should not cause any harm even if it is an + // Maven1Repository, for it would be deleting the 'repository' directory if it happens to be empty. + boolean m2repo = true; + + if(m2repo) { + // Check version, artifact and group directories, i.e. 3 levels up + dirDepth = 3; + } + + File temp = location; + for(int i = 0; i < dirDepth; ++i) { + if((temp = temp.getParentFile()).listFiles().length == 0) { + // Directory is empty. Remove it. + temp.delete(); + } else { + // Directory is not empty. No need to check any more parent directories + break; + } + } + + try { + // Is this the right way to get hold of PersistentConfigurationList? + PersistentConfigurationList configList = (PersistentConfigurationList) kernel.getGBean(PersistentConfigurationList.class); + configList.removeConfiguration(configId); + } catch (Exception e) { + log.warn("Unable to remove configuration from persistent configurations. id = "+configId, e); + } if (configurationInfo != null) { IOException ioException = null;