View Javadoc
1   /**
2    * Copyright 2010-2014 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.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  /**
28   * @deprecated
29   */
30  @Deprecated
31  public class SvnService extends DefaultExecService implements ScmService {
32  
33  	private static final String SVN = "svn";
34  
35  	@Override
36  	public void version() {
37  		executeAndValidate(SVN, Arrays.asList("--version"));
38  	}
39  
40  	@Override
41  	public void add(List<File> paths) {
42  		if (CollectionUtils.isEmpty(paths)) {
43  			// Nothing to do
44  			return;
45  		}
46  		String command = "add";
47  		List<String> cpaths = LocationUtils.getCanonicalPaths(paths);
48  		List<String> options = Arrays.asList("--force", "--parents", "--depth", "infinity");
49  
50  		List<String> arguments = new ArrayList<String>();
51  		arguments.add(command);
52  		arguments.addAll(cpaths);
53  		arguments.addAll(options);
54  
55  		executeAndValidate(SVN, arguments);
56  	}
57  
58  	@Override
59  	public void delete(List<File> paths) {
60  		if (CollectionUtils.isEmpty(paths)) {
61  			// Nothing to do
62  			return;
63  		}
64  		String command = "delete";
65  		List<String> cpaths = LocationUtils.getCanonicalPaths(paths);
66  		List<String> options = Arrays.asList("--force");
67  
68  		List<String> arguments = new ArrayList<String>();
69  		arguments.add(command);
70  		arguments.addAll(cpaths);
71  		arguments.addAll(options);
72  
73  		executeAndValidate(SVN, arguments);
74  	}
75  
76  	@Override
77  	public void commit(List<File> paths, String message) {
78  		if (CollectionUtils.isEmpty(paths)) {
79  			// Nothing to do
80  			return;
81  		}
82  		Assert.notBlank(message, "Commit message is blank");
83  		String command = "commit";
84  		List<String> cpaths = LocationUtils.getCanonicalPaths(paths);
85  		List<String> options = Arrays.asList("--depth", "infinity", "--message", message);
86  
87  		List<String> arguments = new ArrayList<String>();
88  		arguments.add(command);
89  		arguments.addAll(cpaths);
90  		arguments.addAll(options);
91  
92  		executeAndValidate(SVN, arguments);
93  	}
94  
95  }