1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
27
28 @Deprecated
29 public class ScmUtils {
30
31
32
33
34 @Deprecated
35 public static org.kuali.common.util.service.ScmService getScmService(String url) {
36 Assert.hasText(url, "URL has no text");
37
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 }