Coverage Report - org.apache.maven.shared.release.scm.JazzScmTranslator
 
Classes in this File Line Coverage Branch Coverage Complexity
JazzScmTranslator
88%
16/18
66%
8/12
2,5
 
 1  
 package org.apache.maven.shared.release.scm;
 2  
 
 3  
 import java.io.File;
 4  
 
 5  
 /*
 6  
  * Licensed to the Apache Software Foundation (ASF) under one
 7  
  * or more contributor license agreements.  See the NOTICE file
 8  
  * distributed with this work for additional information
 9  
  * regarding copyright ownership.  The ASF licenses this file
 10  
  * to you under the Apache License, Version 2.0 (the
 11  
  * "License"); you may not use this file except in compliance
 12  
  * with the License.  You may obtain a copy of the License at
 13  
  *
 14  
  *   http://www.apache.org/licenses/LICENSE-2.0
 15  
  *
 16  
  * Unless required by applicable law or agreed to in writing,
 17  
  * software distributed under the License is distributed on an
 18  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 19  
  * KIND, either express or implied.  See the License for the
 20  
  * specific language governing permissions and limitations
 21  
  * under the License.
 22  
  */
 23  
 
 24  
 /**
 25  
  * Jazz tag translator.
 26  
  *
 27  
  * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
 28  
  * @plexus.component role="org.apache.maven.shared.release.scm.ScmTranslator" role-hint="jazz"
 29  
  */
 30  408
 public class JazzScmTranslator
 31  
     implements ScmTranslator
 32  
 {
 33  
     /**
 34  
      * {@inheritDoc}
 35  
      */
 36  
     public String translateBranchUrl( String url, String branchName, String branchBase )
 37  
     {
 38  
         // Jazz URL's (currently) take the form:
 39  
         // "scm:jazz:[username[;password]@]http[s]://server_name[:port]/jazzPath:repositoryWorkspace"
 40  
         // Eg:
 41  
         // scm:jazz:Deb;Deb@https://rtc:9444/jazz:BogusRepositoryWorkspace
 42  4
         int i = url.lastIndexOf( ':' );
 43  4
         url = url.substring( 0, i + 1 );
 44  4
         if ( branchName != null && branchName.endsWith( "/" ) )
 45  
         {
 46  
             // Remove the trailing "/", if present.
 47  0
             branchName = branchName.substring( 0, branchName.length() - 1 );
 48  
         }
 49  4
         url = url + branchName;
 50  4
         return url;
 51  
     }
 52  
 
 53  
     /**
 54  
      * {@inheritDoc}
 55  
      */
 56  
     public String translateTagUrl( String url, String tag, String tagBase )
 57  
     {
 58  
         // Jazz URL's (currently) take the form:
 59  
         // "scm:jazz:[username[;password]@]http[s]://server_name[:port]/jazzPath:repositoryWorkspace"
 60  
         // Eg:
 61  
         // scm:jazz:Deb;Deb@https://rtc:9444/jazz:BogusRepositoryWorkspace
 62  4
         int i = url.lastIndexOf( ':' );
 63  4
         url = url.substring( 0, i + 1 );
 64  4
         if ( tag != null && tag.endsWith( "/" ) )
 65  
         {
 66  
             // Remove the trailing "/", if present.
 67  0
             tag = tag.substring( 0, tag.length() - 1 );
 68  
         }
 69  4
         url = url + tag;
 70  4
         return url;
 71  
     }
 72  
 
 73  
     /**
 74  
      * {@inheritDoc}
 75  
      */
 76  
     public String resolveTag( String tag )
 77  
     {
 78  
         // project.scm.tag is not required, so return null.
 79  4
         return null;
 80  
     }
 81  
 
 82  
     /**
 83  
      * {@inheritDoc}
 84  
      */
 85  
     public String toRelativePath( String path )
 86  
     {
 87  
         String relativePath;
 88  8
         if ( path.startsWith( "\\" ) || path.startsWith( "/" ) )
 89  
         {
 90  4
             relativePath = path.substring( 1 );
 91  
         }
 92  
         else
 93  
         {
 94  4
             relativePath = path;
 95  
         }
 96  8
         return relativePath.replace( "\\", File.separator ).replace( "/", File.separator );
 97  
     }
 98  
 }