From f2c632b26529d1c16ff8195dc2b997ba7d00c8b3 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 8 May 2011 16:50:46 +0200 Subject: [PATCH] added scm-client-api --- pom.xml | 1 + scm-clients/pom.xml | 32 +++++++ scm-clients/scm-client-api/pom.xml | 18 ++++ .../java/sonia/scm/client/ClientHandler.java | 94 +++++++++++++++++++ .../main/java/sonia/scm/client/ScmClient.java | 70 ++++++++++++++ .../sonia/scm/client/ScmClientException.java | 43 +++++++++ .../sonia/scm/client/ScmClientSession.java | 76 +++++++++++++++ 7 files changed, 334 insertions(+) create mode 100644 scm-clients/pom.xml create mode 100644 scm-clients/scm-client-api/pom.xml create mode 100644 scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientHandler.java create mode 100644 scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClient.java create mode 100644 scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientException.java create mode 100644 scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientSession.java diff --git a/pom.xml b/pom.xml index e3a1643824..fa7b8f6d27 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,7 @@ scm-core scm-test maven + scm-clients plugins samples scm-webapp diff --git a/scm-clients/pom.xml b/scm-clients/pom.xml new file mode 100644 index 0000000000..77cb958925 --- /dev/null +++ b/scm-clients/pom.xml @@ -0,0 +1,32 @@ + + + + 4.0.0 + + + sonia.scm + scm + 1.3-SNAPSHOT + + + sonia.scm.clients + scm-clients + pom + 1.3-SNAPSHOT + scm-clients + + + scm-client-api + + + + + + sonia.scm + scm-core + 1.3-SNAPSHOT + + + + + \ No newline at end of file diff --git a/scm-clients/scm-client-api/pom.xml b/scm-clients/scm-client-api/pom.xml new file mode 100644 index 0000000000..772c76db2b --- /dev/null +++ b/scm-clients/scm-client-api/pom.xml @@ -0,0 +1,18 @@ + + + + 4.0.0 + + + sonia.scm.clients + scm-clients + 1.3-SNAPSHOT + + + sonia.scm.clients + scm-client-api + jar + 1.3-SNAPSHOT + scm-client-api + + \ No newline at end of file diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientHandler.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientHandler.java new file mode 100644 index 0000000000..4aa9482b31 --- /dev/null +++ b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientHandler.java @@ -0,0 +1,94 @@ +/** + * 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.client; + +import java.util.List; + +/** + * + * @author Sebastian Sdorra + */ +public interface ClientHandler +{ + + + /** + * Method description + * + * + * @param repository + */ + public void create(T item); + + /** + * Method description + * + * + * @param id + */ + public void delete(String id); + + /** + * Method description + * + * + * @param repository + */ + public void delete(T item); + + /** + * Method description + * + * + * @param repository + */ + public void modify(T item); + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + public List getAll(); + + /** + * Method description + * + * + * @param id + * + * @return + */ + public T get(String id); +} diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClient.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClient.java new file mode 100644 index 0000000000..0ec776d5f4 --- /dev/null +++ b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClient.java @@ -0,0 +1,70 @@ +/** + * 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.client; + +/** + * + * @author Sebastian Sdorra + */ +public interface ScmClient +{ + + /** + * Creates an ScmClientSession for the given user + * + * + * @param url + * @param username + * @param password + * + * @return + * + * @throws ScmClientException + */ + public ScmClientSession createSession(String url, String username, + String password) + throws ScmClientException; + + /** + * Creates an anonymous ScmClientSession + * + * + * @param url + * + * @return + * + * @throws ScmClientException + */ + public ScmClientSession createSession(String url) throws ScmClientException; +} diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientException.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientException.java new file mode 100644 index 0000000000..a5522969a4 --- /dev/null +++ b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientException.java @@ -0,0 +1,43 @@ +/** + * 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.client; + +/** + * + * @author Sebastian Sdorra + */ +public class ScmClientException extends Exception +{ + + + + +} diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientSession.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientSession.java new file mode 100644 index 0000000000..65481243d4 --- /dev/null +++ b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientSession.java @@ -0,0 +1,76 @@ +/** + * 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.client; + +//~--- non-JDK imports -------------------------------------------------------- + +import sonia.scm.group.Group; +import sonia.scm.repository.Repository; +import sonia.scm.user.User; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.Closeable; + +/** + * + * @author Sebastian Sdorra + */ +public interface ScmClientSession extends Closeable +{ + + /** + * Method description + * + * + * @return + */ + public ClientHandler getGroupHandler(); + + /** + * Method description + * + * + * @return + */ + public ClientHandler getRepositoryHandler(); + + /** + * Method description + * + * + * @return + */ + public ClientHandler getUserHandler(); +}