Coverage Report - org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository
 
Classes in this File Line Coverage Branch Coverage Complexity
SynergyScmProviderRepository
0 %
0/41
0 %
0/6
2,111
 
 1  
 package org.apache.maven.scm.provider.synergy.repository;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  * http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.scm.provider.ScmProviderRepository;
 23  
 import org.apache.maven.scm.repository.ScmRepositoryException;
 24  
 
 25  
 import java.net.MalformedURLException;
 26  
 import java.net.URISyntaxException;
 27  
 import java.net.UnknownHostException;
 28  
 import java.util.StringTokenizer;
 29  
 
 30  
 /**
 31  
  * @author <a href="mailto:julien.henry@capgemini.com">Julien Henry</a>
 32  
  * @version $Id: SynergyScmProviderRepository.java 894254 2009-12-28 21:55:32Z olamy $
 33  
  */
 34  
 public class SynergyScmProviderRepository
 35  
     extends ScmProviderRepository
 36  
 {
 37  
 
 38  
     private String projectSpec;
 39  
 
 40  
     private String projectName;
 41  
 
 42  
     private String projectVersion;
 43  
 
 44  
     private String projectRelease;
 45  
 
 46  
     private String projectPurpose;
 47  
 
 48  
     private String delimiter;
 49  
     
 50  
     private String instance;
 51  
 
 52  
     /**
 53  
      * @param url format is
 54  
      *            project_name|delimiter|project_version|Release|Purpose|instance
 55  
      */
 56  
     public SynergyScmProviderRepository( String url )
 57  
         throws ScmRepositoryException
 58  0
     {
 59  
         try
 60  
         {
 61  0
             parseUrl( url );
 62  
         }
 63  0
         catch ( MalformedURLException e )
 64  
         {
 65  0
             throw new ScmRepositoryException( "Illegal URL: " + url + "(" + e.getMessage() + ")" );
 66  
         }
 67  0
         catch ( URISyntaxException e )
 68  
         {
 69  0
             throw new ScmRepositoryException( "Illegal URL: " + url + "(" + e.getMessage() + ")" );
 70  
         }
 71  0
         catch ( UnknownHostException e )
 72  
         {
 73  0
             throw new ScmRepositoryException( "Illegal URL: " + url + "(" + e.getMessage() + ")" );
 74  0
         }
 75  0
     }
 76  
 
 77  
     private void parseUrl( String url )
 78  
         throws MalformedURLException, URISyntaxException, UnknownHostException
 79  
     {
 80  0
         if ( url.indexOf( '|' ) != -1 )
 81  
         {
 82  0
             StringTokenizer tokenizer = new StringTokenizer( url, "|" );
 83  0
             fillInProperties( tokenizer );
 84  0
         }
 85  
         else
 86  
         {
 87  0
             StringTokenizer tokenizer = new StringTokenizer( url, ":" );
 88  0
             fillInProperties( tokenizer );
 89  
         }
 90  0
     }
 91  
 
 92  
     private void fillInProperties( StringTokenizer tokenizer )
 93  
         throws UnknownHostException, URISyntaxException, MalformedURLException
 94  
     {
 95  0
         if ( tokenizer.countTokens() == 5 )
 96  
         {
 97  0
             projectName = tokenizer.nextToken();
 98  0
             delimiter = tokenizer.nextToken();
 99  0
             projectVersion = tokenizer.nextToken();
 100  0
             projectRelease = tokenizer.nextToken();
 101  0
             projectPurpose = tokenizer.nextToken();
 102  0
             instance = "1";
 103  
 
 104  0
             projectSpec = projectName + delimiter + projectVersion + ":project:" + instance;
 105  
 
 106  
         }
 107  0
         else if (tokenizer.countTokens() == 6 )
 108  
         {   //optional prep project instance also
 109  0
             projectName = tokenizer.nextToken();
 110  0
             delimiter = tokenizer.nextToken();
 111  0
             projectVersion = tokenizer.nextToken();
 112  0
             projectRelease = tokenizer.nextToken();
 113  0
             projectPurpose = tokenizer.nextToken();
 114  0
             instance = tokenizer.nextToken();
 115  
 
 116  0
             projectSpec = projectName + delimiter + projectVersion + ":project:" + instance;
 117  
             
 118  
         }
 119  
         else
 120  
         {
 121  0
             throw new MalformedURLException();
 122  
         }
 123  0
     }
 124  
 
 125  
     public String getProjectSpec()
 126  
     {
 127  0
         return projectSpec;
 128  
     }
 129  
 
 130  
     public String getProjectName()
 131  
     {
 132  0
         return projectName;
 133  
     }
 134  
 
 135  
     public String getProjectVersion()
 136  
     {
 137  0
         return projectVersion;
 138  
     }
 139  
 
 140  
     /**
 141  
      * @return the project_purpose
 142  
      */
 143  
     public String getProjectPurpose()
 144  
     {
 145  0
         return projectPurpose;
 146  
     }
 147  
 
 148  
     /**
 149  
      * @return the project_release
 150  
      */
 151  
     public String getProjectRelease()
 152  
     {
 153  0
         return projectRelease;
 154  
     }
 155  
 
 156  
     /**
 157  
      * @return the instance
 158  
      */
 159  
     public String getInstance() {
 160  0
         return instance;
 161  
     }
 162  
     
 163  
 
 164  
 }