maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r374508 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase: command/changelog/ command/checkout/ util/
Date Thu, 02 Feb 2006 21:21:52 GMT
Author: evenisse
Date: Thu Feb  2 13:21:47 2006
New Revision: 374508

URL: http://svn.apache.org/viewcvs?rev=374508&view=rev
Log:
[SCM-140] Remove duplicate code for clearcase-setting.xml loading

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/util/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/util/ClearCaseUtil.java
  (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java?rev=374508&r1=374507&r2=374508&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java
Thu Feb  2 13:21:47 2006
@@ -23,17 +23,13 @@
 import org.apache.maven.scm.command.changelog.ChangeLogSet;
 import org.apache.maven.scm.provider.ScmProviderRepository;
 import org.apache.maven.scm.provider.clearcase.command.ClearCaseCommand;
+import org.apache.maven.scm.provider.clearcase.util.ClearCaseUtil;
 import org.apache.maven.scm.providers.clearcase.settings.Settings;
-import org.apache.maven.scm.providers.clearcase.settings.io.xpp3.ClearcaseXpp3Reader;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
@@ -48,33 +44,7 @@
     extends AbstractChangeLogCommand
     implements ClearCaseCommand
 {
-    private static Settings settings;
-
-    static
-    {
-        File scmUserDir = new File( System.getProperty( "user.dir" ), ".scm" );
-        File settingsFile = new File( scmUserDir, "clearcase-settings.xml" );
-        if ( settingsFile.exists() )
-        {
-            ClearcaseXpp3Reader reader = new ClearcaseXpp3Reader();
-            try
-            {
-                settings = reader.read( new FileReader( settingsFile ) );
-            }
-            catch ( FileNotFoundException e )
-            {
-            }
-            catch ( IOException e )
-            {
-            }
-            catch ( XmlPullParserException e )
-            {
-                String message = settingsFile.getAbsolutePath() + " isn't well formed. SKIPPED."
+ e.getMessage();
-
-                System.out.println( message );
-            }
-        }
-    }
+    private static Settings settings = ClearCaseUtil.getSettings();
 
     // ----------------------------------------------------------------------
     // AbstractChangeLogCommand Implementation
@@ -175,13 +145,7 @@
      */
     protected static boolean isClearCaseLT()
     {
-        boolean result = false;
-
-        if ( settings != null )
-        {
-            result = settings.isClearcaseLT();
-        }
-        return result;
+        return settings.isClearcaseLT();
     }
 
     /**
@@ -193,10 +157,6 @@
      */
     protected static void setIsClearCaseLT( boolean isClearCaseLT )
     {
-        if ( settings == null )
-        {
-            settings = new Settings();
-        }
         settings.setClearcaseLT( isClearCaseLT );
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java?rev=374508&r1=374507&r2=374508&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java
Thu Feb  2 13:21:47 2006
@@ -23,6 +23,7 @@
 import org.apache.maven.scm.provider.ScmProviderRepository;
 import org.apache.maven.scm.provider.clearcase.command.ClearCaseCommand;
 import org.apache.maven.scm.provider.clearcase.repository.ClearCaseScmProviderRepository;
+import org.apache.maven.scm.provider.clearcase.util.ClearCaseUtil;
 import org.apache.maven.scm.providers.clearcase.settings.Settings;
 import org.apache.maven.scm.providers.clearcase.settings.io.xpp3.ClearcaseXpp3Reader;
 import org.codehaus.plexus.util.FileUtils;
@@ -47,33 +48,7 @@
     implements ClearCaseCommand
 {
 
-    private static Settings settings;
-
-    static
-    {
-        File scmUserHome = new File( System.getProperty( "user.home" ), ".scm" );
-        File settingsFile = new File( scmUserHome, "clearcase-settings.xml" );
-        if ( settingsFile.exists() )
-        {
-            ClearcaseXpp3Reader reader = new ClearcaseXpp3Reader();
-            try
-            {
-                settings = reader.read( new FileReader( settingsFile ) );
-            }
-            catch ( FileNotFoundException e )
-            {
-            }
-            catch ( IOException e )
-            {
-            }
-            catch ( XmlPullParserException e )
-            {
-                String message = settingsFile.getAbsolutePath() + " isn't well formed. SKIPPED."
+ e.getMessage();
-
-                System.out.println( message);
-            }
-        }
-    }
+    private static Settings settings = ClearCaseUtil.getSettings();
 
     // ----------------------------------------------------------------------
     // AbstractCheckOutCommand Implementation
@@ -253,10 +228,11 @@
     {
         String result = null;
 
-        if ( settings != null )
+        if ( settings.getViewstore() != null )
         {
             result = settings.getViewstore();
         }
+
         if ( result == null )
         {
             result = "\\\\" + getHostName() + "\\viewstore\\";
@@ -278,14 +254,7 @@
      */
     protected static boolean isClearCaseLT()
     {
-        boolean result = false;
-
-        if ( settings != null )
-        {
-            result = settings.isClearcaseLT();
-        }
-
-        return result;
+            return settings.isClearcaseLT();
     }
 
     /**
@@ -295,10 +264,6 @@
      */
     protected static void setIsClearCaseLT( boolean isClearCaseLT )
     {
-        if ( settings == null )
-        {
-            settings = new Settings();
-        }
         settings.setClearcaseLT( isClearCaseLT );
     }
 
@@ -307,14 +272,7 @@
      */
     protected static boolean useVWS()
     {
-        boolean result = false;
-
-        if ( settings != null )
-        {
-            result = settings.isUseVWSParameter();
-        }
-
-        return result;
+            return settings.isUseVWSParameter();
     }
 
     /**
@@ -324,10 +282,6 @@
      */
     protected static void setUseVWS( boolean useVWS )
     {
-        if ( settings == null )
-        {
-            settings = new Settings();
-        }
         settings.setUseVWSParameter( useVWS );
     }
 

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/util/ClearCaseUtil.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/util/ClearCaseUtil.java?rev=374508&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/util/ClearCaseUtil.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/util/ClearCaseUtil.java
Thu Feb  2 13:21:47 2006
@@ -0,0 +1,66 @@
+package org.apache.maven.scm.provider.clearcase.util;
+
+import org.apache.maven.scm.providers.clearcase.settings.Settings;
+import org.apache.maven.scm.providers.clearcase.settings.io.xpp3.ClearcaseXpp3Reader;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class ClearCaseUtil
+{
+    private ClearCaseUtil()
+    {
+    }
+
+    public static Settings getSettings()
+    {
+        File scmUserDir = new File( System.getProperty( "user.dir" ), ".scm" );
+        File settingsFile = new File( scmUserDir, "clearcase-settings.xml" );
+
+        if ( settingsFile.exists() )
+        {
+            ClearcaseXpp3Reader reader = new ClearcaseXpp3Reader();
+            try
+            {
+                return reader.read( new FileReader( settingsFile ) );
+            }
+            catch ( FileNotFoundException e )
+            {
+            }
+            catch ( IOException e )
+            {
+            }
+            catch ( XmlPullParserException e )
+            {
+                String message = settingsFile.getAbsolutePath() + " isn't well formed. SKIPPED."
+ e.getMessage();
+
+                System.out.println( message );
+            }
+        }
+
+        return new Settings();
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/util/ClearCaseUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/util/ClearCaseUtil.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message