View Javadoc

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