View Javadoc

1   package org.apache.maven.vsslib;
2   
3   /*
4    * ====================================================================
5    * Copyright 2001-2004 The Apache Software Foundation.
6    *
7    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8    * use this file except in compliance with the License. You may obtain a copy of
9    * the License at
10   *
11   * http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16   * License for the specific language governing permissions and limitations under
17   * the License.
18   * ====================================================================
19   */
20  
21  import org.apache.commons.logging.Log;
22  import org.apache.commons.logging.LogFactory;
23  
24  
25  /**
26   * Bean representation of the vss connection string
27   *
28   * @author Freddy Mallet
29   */
30  public class VssConnection
31  {
32      /** Log */
33      private static final Log LOG =
34          LogFactory.getLog( VssChangeLogGenerator.class );
35  
36      /**
37       * VSS repository path
38       */
39      private String vssDir;
40  
41      /**
42       * VSS user information
43       */
44      private String vssUserInf;
45  
46      /**
47       * VSS project
48       */
49      private String vssProject;
50  
51      /**
52       * Create a new VssConnection objet according to the provided vss connection
53       * string. Here is an example:
54       * scm:vss:\\lancelot\Vss_EApplications\:guest,password:/Security/LOSCProduction
55       * the password is not madatory
56       *
57       * @param connection
58       *            the vss connection string
59       */
60      public VssConnection( String connection )
61      {
62          if ( !connection.startsWith( "scm:vss" ) )
63          {
64              throw new IllegalArgumentException( 
65                  "repositoy connection string does not specify 'vss' as the scm" );
66          }
67  
68          try
69          {
70              String[] splitedConnection = connection.split( ":" );
71  
72              vssDir = splitedConnection[2];
73  
74              if ( !splitedConnection[3].equals( "" ) )
75              {
76                  vssUserInf = splitedConnection[3];
77              }
78  
79              vssProject = splitedConnection[4];
80          }
81          catch ( Exception e )
82          {
83              String message =
84                  "Unable to parse VSS connection string :" + connection;
85  
86              LOG.error( message, e );
87              throw new IllegalArgumentException( message );
88          }
89      }
90  
91      /**
92       * Get the vss directory
93       *
94       * @return vss directory
95       */
96      public String getVssDir()
97      {
98          return vssDir;
99      }
100 
101     /**
102      * Get the vss project
103      *
104      * @return vss project
105      */
106     public String getVssProject()
107     {
108         return vssProject;
109     }
110 
111     /**
112      * Get the vss user information
113      *
114      * @return vss user information
115      */
116     public String getVssUserInf()
117     {
118         return vssUserInf;
119     }
120 }