All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kuali.common.util.service.SubversionService Maven / Gradle / Ivy

package org.kuali.common.util.service;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.kuali.common.util.Assert;
import org.kuali.common.util.CollectionUtils;
import org.kuali.common.util.LocationUtils;

public class SubversionService extends DefaultExecService implements ScmService {

	private static final String SVN = "svn";

	@Override
	public void add(List paths) {
		if (CollectionUtils.isEmpty(paths)) {
			// Nothing to do
			return;
		}
		String command = "add";
		List cpaths = LocationUtils.getCanonicalPaths(paths);
		List options = Arrays.asList("--force", "--parents", "--depth", "infinity");

		List arguments = new ArrayList();
		arguments.add(command);
		arguments.addAll(cpaths);
		arguments.addAll(options);

		executeAndValidate(SVN, arguments);
	}

	@Override
	public void delete(List paths) {
		if (CollectionUtils.isEmpty(paths)) {
			// Nothing to do
			return;
		}
		String command = "delete";
		List cpaths = LocationUtils.getCanonicalPaths(paths);
		List options = Arrays.asList("--force");

		List arguments = new ArrayList();
		arguments.add(command);
		arguments.addAll(cpaths);
		arguments.addAll(options);

		executeAndValidate(SVN, arguments);
	}

	@Override
	public void commit(List paths, String message) {
		if (CollectionUtils.isEmpty(paths)) {
			// Nothing to do
			return;
		}
		Assert.notBlank(message, "Commit message is blank");
		String command = "commit";
		List cpaths = LocationUtils.getCanonicalPaths(paths);
		List options = Arrays.asList("--depth", "infinity", "--message", message);

		List arguments = new ArrayList();
		arguments.add(command);
		arguments.addAll(cpaths);
		arguments.addAll(options);

		executeAndValidate(SVN, arguments);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy