diff --git a/scm-test/src/main/java/sonia/scm/repository/client/api/AddCommandBuilder.java b/scm-test/src/main/java/sonia/scm/repository/client/api/AddCommandBuilder.java new file mode 100644 index 0000000000..93fc60d010 --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/api/AddCommandBuilder.java @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +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; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public final class AddCommandBuilder +{ + + /** + * the logger for AddCommandBuilder + */ + private static final Logger logger = + LoggerFactory.getLogger(AddCommandBuilder.class); + + //~--- constructors --------------------------------------------------------- + + /** + * Constructs ... + * + * + * @param directory + * @param command + */ + AddCommandBuilder(AddCommand command) + { + this.command = command; + } + + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param path + * @param pathes + * + * @return + */ + public AddCommandBuilder add(String path, String... pathes) + { + add(path); + + if (Util.isNotEmpty(pathes)) + { + for (String p : pathes) + { + add(p); + } + } + + return this; + } + + /** + * Method description + * + * + * @param path + */ + private void add(String path) + { + if (Util.isNotEmpty(path)) + { + if (logger.isDebugEnabled()) + { + logger.debug("add path {}", path); + } + + command.add(path); + } + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private AddCommand command; +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/api/ClientCommand.java b/scm-test/src/main/java/sonia/scm/repository/client/api/ClientCommand.java new file mode 100644 index 0000000000..764c2f1563 --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/api/ClientCommand.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ +package sonia.scm.repository.client.api; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public enum ClientCommand +{ + ADD, REMOVE, COMMIT, PUSH +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/api/ClientCommandNotSupportedException.java b/scm-test/src/main/java/sonia/scm/repository/client/api/ClientCommandNotSupportedException.java new file mode 100644 index 0000000000..d31a6d548c --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/api/ClientCommandNotSupportedException.java @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.api; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public class ClientCommandNotSupportedException extends RuntimeException +{ + + /** + * Constructs ... + * + * + * @param clientCommand + */ + public ClientCommandNotSupportedException(ClientCommand clientCommand) + { + super( + "client command ".concat(clientCommand.name()).concat( + " is not supported")); + this.clientCommand = clientCommand; + } + + /** + * Constructs ... + * + * + * @param clientCommand + * @param message + */ + public ClientCommandNotSupportedException(ClientCommand clientCommand, + String message) + { + super(message); + this.clientCommand = clientCommand; + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + public ClientCommand getClientCommand() + { + return clientCommand; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private ClientCommand clientCommand; +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/api/CommitCommandBuilder.java b/scm-test/src/main/java/sonia/scm/repository/client/api/CommitCommandBuilder.java new file mode 100644 index 0000000000..73b42ef6cd --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/api/CommitCommandBuilder.java @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.api; + +//~--- non-JDK imports -------------------------------------------------------- + +import com.google.common.collect.Lists; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import sonia.scm.repository.Changeset; +import sonia.scm.repository.client.spi.CommitCommand; +import sonia.scm.repository.client.spi.CommitRequest; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public final class CommitCommandBuilder +{ + + /** + * the logger for CommitCommandBuilder + */ + private static final Logger logger = + LoggerFactory.getLogger(CommitCommandBuilder.class); + + //~--- constructors --------------------------------------------------------- + + /** + * Constructs ... + * + * + * @param directory + * @param command + */ + CommitCommandBuilder(CommitCommand command) + { + this.command = command; + } + + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param path + * @param pathes + * + * @return + */ + public CommitCommandBuilder add(String path, String... pathes) + { + request.setPaths(Lists.asList(path, pathes)); + + return this; + } + + /** + * Method description + * + * + * @param author + * @param message + * + * @return + */ + public Changeset commit(String author, String message) + { + request.setAuthor(author); + request.setMessage(message); + + if (logger.isDebugEnabled()) + { + logger.debug("commit {}", request); + } + + Changeset changeset = command.commit(request); + + request.reset(); + + return changeset; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private CommitCommand command; + + /** Field description */ + private CommitRequest request = new CommitRequest(); +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/api/PushCommandBuilder.java b/scm-test/src/main/java/sonia/scm/repository/client/api/PushCommandBuilder.java new file mode 100644 index 0000000000..83c9b9ed5c --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/api/PushCommandBuilder.java @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.api; + +//~--- non-JDK imports -------------------------------------------------------- + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import sonia.scm.repository.client.spi.PushCommand; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public final class PushCommandBuilder +{ + + /** + * the logger for PushCommandBuilder + */ + private static final Logger logger = + LoggerFactory.getLogger(PushCommandBuilder.class); + + //~--- constructors --------------------------------------------------------- + + /** + * Constructs ... + * + * + * @param command + */ + PushCommandBuilder(PushCommand command) + { + this.command = command; + } + + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + */ + public void push() + { + if (logger.isDebugEnabled()) + { + logger.debug("push changes back to main repository"); + } + + command.push(); + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private PushCommand command; +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/api/RemoveCommandBuilder.java b/scm-test/src/main/java/sonia/scm/repository/client/api/RemoveCommandBuilder.java new file mode 100644 index 0000000000..eb4ab9db43 --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/api/RemoveCommandBuilder.java @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +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; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public final class RemoveCommandBuilder +{ + + /** + * the logger for RemoveCommandBuilder + */ + private static final Logger logger = + LoggerFactory.getLogger(RemoveCommandBuilder.class); + + //~--- constructors --------------------------------------------------------- + + /** + * Constructs ... + * + * + * @param directory + * @param command + */ + RemoveCommandBuilder(RemoveCommand command) + { + this.command = command; + } + + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param path + * @param pathes + * + * @return + */ + public RemoveCommandBuilder remove(String path, String... pathes) + { + remove(path); + + if (Util.isNotEmpty(pathes)) + { + for (String p : pathes) + { + remove(p); + } + } + + return this; + } + + /** + * Method description + * + * + * @param path + */ + private void remove(String path) + { + if (Util.isNotEmpty(path)) + { + if (logger.isDebugEnabled()) + { + logger.debug("add path {}", path); + } + + command.remove(path); + } + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private RemoveCommand command; +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/api/RepositoryClient.java b/scm-test/src/main/java/sonia/scm/repository/client/api/RepositoryClient.java new file mode 100644 index 0000000000..c83c59a51a --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/api/RepositoryClient.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.api; + +//~--- non-JDK imports -------------------------------------------------------- + +import sonia.scm.repository.client.spi.RepositoryClientProvider; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public final class RepositoryClient +{ + + /** + * Constructs ... + * + * + * @param directory + * @param clientProvider + */ + RepositoryClient(RepositoryClientProvider clientProvider) + { + this.clientProvider = clientProvider; + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + public AddCommandBuilder getAddCommand() + { + return new AddCommandBuilder(clientProvider.getAddCommand()); + } + + /** + * Method description + * + * + * @return + */ + public CommitCommandBuilder getCommitCommand() + { + return new CommitCommandBuilder(clientProvider.getCommitCommand()); + } + + /** + * Method description + * + * + * @return + */ + public PushCommandBuilder getPushCommand() + { + return new PushCommandBuilder(clientProvider.getPushCommand()); + } + + /** + * Method description + * + * + * @return + */ + public RemoveCommandBuilder getRemoveCommand() + { + return new RemoveCommandBuilder(clientProvider.getRemoveCommand()); + } + + /** + * Method description + * + * + * @param command + * + * @return + */ + public boolean isCommandSupported(ClientCommand command) + { + return clientProvider.getSupportedClientCommands().contains(command); + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private RepositoryClientProvider clientProvider; +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/api/RepositoryClientFactory.java b/scm-test/src/main/java/sonia/scm/repository/client/api/RepositoryClientFactory.java new file mode 100644 index 0000000000..8e7bf3b89b --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/api/RepositoryClientFactory.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ +package sonia.scm.repository.client.api; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public final class RepositoryClientFactory +{ + +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/spi/AddCommand.java b/scm-test/src/main/java/sonia/scm/repository/client/spi/AddCommand.java new file mode 100644 index 0000000000..f4c37f38a6 --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/spi/AddCommand.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.spi; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public interface AddCommand +{ + + /** + * Method description + * + * + * @param path + * + * @param file + */ + public void add(String path); +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/spi/CommitCommand.java b/scm-test/src/main/java/sonia/scm/repository/client/spi/CommitCommand.java new file mode 100644 index 0000000000..a4e4fbeb85 --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/spi/CommitCommand.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.spi; + +//~--- non-JDK imports -------------------------------------------------------- + +import sonia.scm.repository.Changeset; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public interface CommitCommand +{ + + /** + * Method description + * + * + * @param request + * + * @return + */ + public Changeset commit(CommitRequest request); +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/spi/CommitRequest.java b/scm-test/src/main/java/sonia/scm/repository/client/spi/CommitRequest.java new file mode 100644 index 0000000000..5713501b3d --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/spi/CommitRequest.java @@ -0,0 +1,202 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.spi; + +//~--- non-JDK imports -------------------------------------------------------- + +import com.google.common.base.Objects; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.List; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public final class CommitRequest +{ + + /** + * Method description + * + * + * @param obj + * + * @return + */ + @Override + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + + if (getClass() != obj.getClass()) + { + return false; + } + + final CommitRequest other = (CommitRequest) obj; + + return Objects.equal(author, other.author) + && Objects.equal(message, other.message) + && Objects.equal(paths, other.paths); + } + + /** + * Method description + * + * + * @return + */ + @Override + public int hashCode() + { + return Objects.hashCode(author, message, paths); + } + + /** + * Method description + * + */ + public void reset() + { + this.author = null; + this.message = null; + + this.paths = null; + } + + /** + * Method description + * + * + * @return + */ + @Override + public String toString() + { + //J- + return Objects.toStringHelper(this) + .add("author", author) + .add("message", message) + .add("paths", paths) + .toString(); + //J+ + } + + //~--- set methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @param author + */ + public void setAuthor(String author) + { + this.author = author; + } + + /** + * Method description + * + * + * @param message + */ + public void setMessage(String message) + { + this.message = message; + } + + /** + * Method description + * + * + * @param files + * + * @param paths + */ + public void setPaths(List paths) + { + this.paths = paths; + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + String getAuthor() + { + return author; + } + + /** + * Method description + * + * + * @return + */ + String getMessage() + { + return message; + } + + /** + * Method description + * + * + * @return + */ + List getPaths() + { + return paths; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private String author; + + /** Field description */ + private String message; + + /** Field description */ + private List paths; +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/spi/PushCommand.java b/scm-test/src/main/java/sonia/scm/repository/client/spi/PushCommand.java new file mode 100644 index 0000000000..0590ab5c68 --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/spi/PushCommand.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.spi; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public interface PushCommand +{ + + /** + * Method description + * + */ + public void push(); +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/spi/RemoveCommand.java b/scm-test/src/main/java/sonia/scm/repository/client/spi/RemoveCommand.java new file mode 100644 index 0000000000..361b14a578 --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/spi/RemoveCommand.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.spi; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public interface RemoveCommand +{ + + /** + * Method description + * + * + * @param file + * + * @param path + */ + public void remove(String path); +} diff --git a/scm-test/src/main/java/sonia/scm/repository/client/spi/RepositoryClientProvider.java b/scm-test/src/main/java/sonia/scm/repository/client/spi/RepositoryClientProvider.java new file mode 100644 index 0000000000..242a8bf530 --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/repository/client/spi/RepositoryClientProvider.java @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. 2. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. 3. Neither the name of SCM-Manager; + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository.client.spi; + +//~--- non-JDK imports -------------------------------------------------------- + +import sonia.scm.repository.client.api.ClientCommand; +import sonia.scm.repository.client.api.ClientCommandNotSupportedException; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.Set; + +/** + * + * @author Sebastian Sdorra + * @since 1.18 + */ +public abstract class RepositoryClientProvider +{ + + /** + * Method description + * + * + * @return + */ + public abstract Set getSupportedClientCommands(); + + /** + * Method description + * + * + * @return + */ + public AddCommand getAddCommand() + { + throw new ClientCommandNotSupportedException(ClientCommand.ADD); + } + + /** + * Method description + * + * + * @return + */ + public CommitCommand getCommitCommand() + { + throw new ClientCommandNotSupportedException(ClientCommand.COMMIT); + } + + /** + * Method description + * + * + * @return + */ + public PushCommand getPushCommand() + { + throw new ClientCommandNotSupportedException(ClientCommand.PUSH); + } + + /** + * Method description + * + * + * @return + */ + public RemoveCommand getRemoveCommand() + { + throw new ClientCommandNotSupportedException(ClientCommand.REMOVE); + } +}