1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.service;
17
18 import java.io.File;
19 import java.util.ArrayList;
20 import java.util.Arrays;
21 import java.util.List;
22
23 import org.kuali.common.util.Assert;
24 import org.kuali.common.util.CollectionUtils;
25 import org.kuali.common.util.LocationUtils;
26
27 public class SvnService extends DefaultExecService implements ScmService {
28
29 private static final String SVN = "svn";
30
31 @Override
32 public void version() {
33 executeAndValidate(SVN, Arrays.asList("--version"));
34 }
35
36 @Override
37 public void add(List<File> paths) {
38 if (CollectionUtils.isEmpty(paths)) {
39
40 return;
41 }
42 String command = "add";
43 List<String> cpaths = LocationUtils.getCanonicalPaths(paths);
44 List<String> options = Arrays.asList("--force", "--parents", "--depth", "infinity");
45
46 List<String> arguments = new ArrayList<String>();
47 arguments.add(command);
48 arguments.addAll(cpaths);
49 arguments.addAll(options);
50
51 executeAndValidate(SVN, arguments);
52 }
53
54 @Override
55 public void delete(List<File> paths) {
56 if (CollectionUtils.isEmpty(paths)) {
57
58 return;
59 }
60 String command = "delete";
61 List<String> cpaths = LocationUtils.getCanonicalPaths(paths);
62 List<String> options = Arrays.asList("--force");
63
64 List<String> arguments = new ArrayList<String>();
65 arguments.add(command);
66 arguments.addAll(cpaths);
67 arguments.addAll(options);
68
69 executeAndValidate(SVN, arguments);
70 }
71
72 @Override
73 public void commit(List<File> paths, String message) {
74 if (CollectionUtils.isEmpty(paths)) {
75
76 return;
77 }
78 Assert.notBlank(message, "Commit message is blank");
79 String command = "commit";
80 List<String> cpaths = LocationUtils.getCanonicalPaths(paths);
81 List<String> options = Arrays.asList("--depth", "infinity", "--message", message);
82
83 List<String> arguments = new ArrayList<String>();
84 arguments.add(command);
85 arguments.addAll(cpaths);
86 arguments.addAll(options);
87
88 executeAndValidate(SVN, arguments);
89 }
90
91 }