mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
Simplify things
This commit is contained in:
@@ -32,97 +32,38 @@
|
||||
|
||||
package sonia.scm.repository.client.api;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.client.spi.AddCommand;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.18
|
||||
*/
|
||||
public final class AddCommandBuilder
|
||||
{
|
||||
public final class AddCommandBuilder {
|
||||
|
||||
/**
|
||||
* the logger for AddCommandBuilder
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(AddCommandBuilder.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(AddCommandBuilder.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private final AddCommand command;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param directory
|
||||
* @param command
|
||||
*/
|
||||
AddCommandBuilder(AddCommand command)
|
||||
{
|
||||
AddCommandBuilder(AddCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
* @param pathes
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public AddCommandBuilder add(String path, String... pathes) throws IOException
|
||||
{
|
||||
add(path);
|
||||
|
||||
if (Util.isNotEmpty(pathes))
|
||||
{
|
||||
for (String p : pathes)
|
||||
{
|
||||
add(p);
|
||||
}
|
||||
public AddCommandBuilder add(String... paths) throws IOException {
|
||||
for (String p : paths) {
|
||||
add(p);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void add(String path) throws IOException
|
||||
{
|
||||
if (Util.isNotEmpty(path))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("add path {}", path);
|
||||
}
|
||||
private void add(String path) throws IOException {
|
||||
if (Util.isNotEmpty(path)) {
|
||||
logger.debug("add path {}", path);
|
||||
|
||||
command.add(path);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private AddCommand command;
|
||||
}
|
||||
|
||||
@@ -32,98 +32,37 @@
|
||||
|
||||
package sonia.scm.repository.client.api;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.client.spi.RemoveCommand;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.18
|
||||
*/
|
||||
public final class RemoveCommandBuilder
|
||||
{
|
||||
public final class RemoveCommandBuilder {
|
||||
|
||||
/**
|
||||
* the logger for RemoveCommandBuilder
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(RemoveCommandBuilder.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(RemoveCommandBuilder.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private final RemoveCommand command;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param directory
|
||||
* @param command
|
||||
*/
|
||||
RemoveCommandBuilder(RemoveCommand command)
|
||||
{
|
||||
RemoveCommandBuilder(RemoveCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
* @param pathes
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public RemoveCommandBuilder remove(String path, String... pathes)
|
||||
throws IOException
|
||||
{
|
||||
remove(path);
|
||||
|
||||
if (Util.isNotEmpty(pathes))
|
||||
{
|
||||
for (String p : pathes)
|
||||
{
|
||||
remove(p);
|
||||
}
|
||||
public RemoveCommandBuilder remove(String... paths) throws IOException {
|
||||
for (String p : paths) {
|
||||
remove(p);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void remove(String path) throws IOException
|
||||
{
|
||||
if (Util.isNotEmpty(path))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("add path {}", path);
|
||||
}
|
||||
|
||||
private void remove(String path) throws IOException {
|
||||
if (Util.isNotEmpty(path)) {
|
||||
logger.debug("add path {}", path);
|
||||
command.remove(path);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private RemoveCommand command;
|
||||
}
|
||||
|
||||
@@ -29,191 +29,75 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository.client.api;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.client.spi.RepositoryClientProvider;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.18
|
||||
*/
|
||||
public final class RepositoryClient implements Closeable
|
||||
{
|
||||
public final class RepositoryClient implements Closeable {
|
||||
|
||||
/**
|
||||
* the logger for RepositoryClient
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(RepositoryClient.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(RepositoryClient.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param directory
|
||||
* @param clientProvider
|
||||
*/
|
||||
RepositoryClient(RepositoryClientProvider clientProvider)
|
||||
{
|
||||
this.clientProvider = clientProvider;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("close client provider");
|
||||
}
|
||||
public void close() {
|
||||
logger.trace("close client provider");
|
||||
|
||||
IOUtil.close(clientProvider);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public AddCommandBuilder getAddCommand()
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("create add command");
|
||||
}
|
||||
public AddCommandBuilder getAddCommand() {
|
||||
logger.trace("create add command");
|
||||
|
||||
return new AddCommandBuilder(clientProvider.getAddCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BranchCommandBuilder getBranchCommand()
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("create branch command");
|
||||
}
|
||||
public BranchCommandBuilder getBranchCommand() {
|
||||
logger.trace("create branch command");
|
||||
|
||||
return new BranchCommandBuilder(clientProvider.getBranchCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CommitCommandBuilder getCommitCommand()
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("create commit command");
|
||||
}
|
||||
public CommitCommandBuilder getCommitCommand() {
|
||||
logger.trace("create commit command");
|
||||
|
||||
return new CommitCommandBuilder(clientProvider.getCommitCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PushCommandBuilder getPushCommand()
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("create push command");
|
||||
}
|
||||
public PushCommandBuilder getPushCommand() {
|
||||
logger.trace("create push command");
|
||||
|
||||
return new PushCommandBuilder(clientProvider.getPushCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RemoveCommandBuilder getRemoveCommand()
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("create remove command");
|
||||
}
|
||||
public RemoveCommandBuilder getRemoveCommand() {
|
||||
logger.trace("create remove command");
|
||||
|
||||
return new RemoveCommandBuilder(clientProvider.getRemoveCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TagCommandBuilder getTagCommand()
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("create tag command");
|
||||
}
|
||||
public TagCommandBuilder getTagCommand() {
|
||||
logger.trace("create tag command");
|
||||
|
||||
return new TagCommandBuilder(clientProvider.getTagCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the working copy of the repository.
|
||||
*
|
||||
* @return working copy
|
||||
* @since 1.51
|
||||
*/
|
||||
public File getWorkingCopy() {
|
||||
return clientProvider.getWorkingCopy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param command
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isCommandSupported(ClientCommand command)
|
||||
{
|
||||
public boolean isCommandSupported(ClientCommand command) {
|
||||
return clientProvider.getSupportedClientCommands().contains(command);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final RepositoryClientProvider clientProvider;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user