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