View Javadoc
1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util;
17  
18  import java.io.File;
19  import java.util.ArrayList;
20  
21  import org.codehaus.plexus.util.StringUtils;
22  import org.kuali.common.util.scm.ScmRequest;
23  import org.springframework.util.Assert;
24  
25  /**
26   * @deprecated
27   */
28  @Deprecated
29  public class ScmUtils {
30  
31  	/**
32  	 * Use <code>ScmConfig</code> instead
33  	 */
34  	@Deprecated
35  	public static org.kuali.common.util.service.ScmService getScmService(String url) {
36  		Assert.hasText(url, "URL has no text");
37  		// scm:svn:https://svn.kuali.org/repos/student/trunk
38  		String[] tokens = StringUtils.split(url, ":");
39  		String scmType = tokens[1].toUpperCase();
40  		org.kuali.common.util.service.ScmType type = org.kuali.common.util.service.ScmType.valueOf(scmType);
41  		switch (type) {
42  		case SVN:
43  			return new org.kuali.common.util.service.SvnService();
44  		case GIT:
45  			throw new IllegalArgumentException("GIT support is coming soon!");
46  		default:
47  			throw new IllegalArgumentException("SCM type [" + scmType + "] is unknown");
48  		}
49  	}
50  
51  	public static ScmRequest cloneOrNew(ScmRequest request) {
52  		if (request == null) {
53  			return new ScmRequest();
54  		} else {
55  			return clone(request);
56  		}
57  	}
58  
59  	public static ScmRequest clone(ScmRequest request) {
60  		ScmRequest clone = new ScmRequest();
61  		clone.setCommitMessage(request.getCommitMessage());
62  
63  		if (!CollectionUtils.isEmpty(request.getAdds())) {
64  			clone.setAdds(new ArrayList<File>(request.getAdds()));
65  		}
66  
67  		if (!CollectionUtils.isEmpty(request.getDeletes())) {
68  			clone.setDeletes(new ArrayList<File>(request.getDeletes()));
69  		}
70  
71  		if (!CollectionUtils.isEmpty(request.getCommits())) {
72  			clone.setCommits(new ArrayList<File>(request.getCommits()));
73  		}
74  		return clone;
75  	}
76  
77  }