From d0ce9b118b00ec4f6c8d513e7ebe39f7ad30d8c7 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Mon, 28 Apr 2014 17:57:02 +0200 Subject: [PATCH 01/36] escape backslash in checkout url to fix issue #570 --- .../resources/js/repository/sonia.repository.infopanel.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.infopanel.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.infopanel.js index c6f469ead8..32a03dae2d 100644 --- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.infopanel.js +++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.infopanel.js @@ -125,7 +125,11 @@ Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, { var index = uri.indexOf("://"); if ( index > 0 ){ index += 3; - uri = uri.substring(0, index) + state.user.name + "@" + uri.substring(index); + var username = state.user.name; + // escape backslash for active directory users + // see https://bitbucket.org/sdorra/scm-manager/issue/570/incorrect-git-checkout-url-generated-for + username = username.replace('\\', '\\\\'); + uri = uri.substring(0, index) + username + "@" + uri.substring(index); } } return uri; From b6fb38edff015c0b4620635df27af03ae0f0aa4c Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Mon, 28 Apr 2014 18:25:50 +0200 Subject: [PATCH 02/36] avoid creation of .cipherkey during unit tests --- .../scm/security/DefaultCipherHandler.java | 25 ++++++-- .../scm/security/InMemoryCipherHandler.java | 58 +++++++++++++++++++ .../services/sonia.scm.security.CipherHandler | 1 + 3 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 scm-test/src/main/java/sonia/scm/security/InMemoryCipherHandler.java create mode 100644 scm-test/src/main/resources/META-INF/services/sonia.scm.security.CipherHandler diff --git a/scm-core/src/main/java/sonia/scm/security/DefaultCipherHandler.java b/scm-core/src/main/java/sonia/scm/security/DefaultCipherHandler.java index 64f81be6fd..4b82563687 100644 --- a/scm-core/src/main/java/sonia/scm/security/DefaultCipherHandler.java +++ b/scm-core/src/main/java/sonia/scm/security/DefaultCipherHandler.java @@ -35,6 +35,8 @@ package sonia.scm.security; //~--- non-JDK imports -------------------------------------------------------- +import com.google.common.annotations.VisibleForTesting; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -106,6 +108,21 @@ public class DefaultCipherHandler implements CipherHandler //~--- constructors --------------------------------------------------------- + /** + * Constructs a new DefaultCipherHandler. Note this constructor is only for + * unit tests. + * + * + * @param key + * + * @since 1.38 + */ + @VisibleForTesting + protected DefaultCipherHandler(String key) + { + this.key = key.toCharArray(); + } + /** * Constructs ... * @@ -116,7 +133,7 @@ public class DefaultCipherHandler implements CipherHandler * */ public DefaultCipherHandler(SCMContextProvider context, - KeyGenerator keyGenerator) + KeyGenerator keyGenerator) { File configDirectory = new File(context.getBaseDirectory(), "config"); @@ -178,7 +195,7 @@ public class DefaultCipherHandler implements CipherHandler System.arraycopy(encodedInput, 0, salt, 0, SALT_LENGTH); System.arraycopy(encodedInput, SALT_LENGTH, encoded, 0, - encodedInput.length - SALT_LENGTH); + encodedInput.length - SALT_LENGTH); IvParameterSpec iv = new IvParameterSpec(salt); SecretKey secretKey = buildSecretKey(plainKey); @@ -245,7 +262,7 @@ public class DefaultCipherHandler implements CipherHandler System.arraycopy(salt, 0, result, 0, SALT_LENGTH); System.arraycopy(encodedInput, 0, result, SALT_LENGTH, - result.length - SALT_LENGTH); + result.length - SALT_LENGTH); res = new String(Base64.encode(result), ENCODING); } catch (Exception ex) @@ -270,7 +287,7 @@ public class DefaultCipherHandler implements CipherHandler * @throws UnsupportedEncodingException */ private SecretKey buildSecretKey(char[] plainKey) - throws UnsupportedEncodingException, NoSuchAlgorithmException + throws UnsupportedEncodingException, NoSuchAlgorithmException { byte[] raw = new String(plainKey).getBytes(ENCODING); MessageDigest digest = MessageDigest.getInstance(DIGEST_TYPE); diff --git a/scm-test/src/main/java/sonia/scm/security/InMemoryCipherHandler.java b/scm-test/src/main/java/sonia/scm/security/InMemoryCipherHandler.java new file mode 100644 index 0000000000..18c965fc50 --- /dev/null +++ b/scm-test/src/main/java/sonia/scm/security/InMemoryCipherHandler.java @@ -0,0 +1,58 @@ +/** + * 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.security; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.UUID; + +/** + * @author Sebastian Sdorra + * @since 1.38 + */ +public class InMemoryCipherHandler extends DefaultCipherHandler +{ + + /** Field description */ + private static final String KEY = UUID.randomUUID().toString(); + + //~--- constructors --------------------------------------------------------- + + /** + * Constructs ... + * + */ + public InMemoryCipherHandler() + { + super(KEY); + } +} diff --git a/scm-test/src/main/resources/META-INF/services/sonia.scm.security.CipherHandler b/scm-test/src/main/resources/META-INF/services/sonia.scm.security.CipherHandler new file mode 100644 index 0000000000..d480cb88a1 --- /dev/null +++ b/scm-test/src/main/resources/META-INF/services/sonia.scm.security.CipherHandler @@ -0,0 +1 @@ +sonia.scm.security.InMemoryCipherHandler \ No newline at end of file From 2fb341ec6798ac8a635738ccff52310756ba2a46 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 4 May 2014 14:17:09 +0200 Subject: [PATCH 03/36] fix NoClassDefFoundError, see issue #576 --- scm-clients/scm-cli-client/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/scm-clients/scm-cli-client/pom.xml b/scm-clients/scm-cli-client/pom.xml index 7e911579a1..4840737e6b 100644 --- a/scm-clients/scm-cli-client/pom.xml +++ b/scm-clients/scm-cli-client/pom.xml @@ -22,7 +22,6 @@ javax.servlet servlet-api ${servlet.version} - provided From 0ce1bb1f447acc2458b3f9b5798a319f1f99285a Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 4 May 2014 15:06:45 +0200 Subject: [PATCH 04/36] added some simple integration tests for the scm-cli-client --- scm-clients/scm-cli-client/pom.xml | 118 ++++++++++++++++ .../sonia/scm/cli/AbstractITCaseBase.java | 129 ++++++++++++++++++ .../sonia/scm/cli/RepositoriesITCase.java | 86 ++++++++++++ .../sonia/scm/cli/ServerVersionITCase.java | 70 ++++++++++ .../test/java/sonia/scm/cli/UsersITCase.java | 72 ++++++++++ .../java/sonia/scm/cli/VersionITCase.java | 65 +++++++++ 6 files changed, 540 insertions(+) create mode 100644 scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/AbstractITCaseBase.java create mode 100644 scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/RepositoriesITCase.java create mode 100644 scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/ServerVersionITCase.java create mode 100644 scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/UsersITCase.java create mode 100644 scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/VersionITCase.java diff --git a/scm-clients/scm-cli-client/pom.xml b/scm-clients/scm-cli-client/pom.xml index 4840737e6b..13a618e0b4 100644 --- a/scm-clients/scm-cli-client/pom.xml +++ b/scm-clients/scm-cli-client/pom.xml @@ -106,6 +106,124 @@ + + + + it + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.4 + + + package + + copy + + + + + sonia.scm + scm-webapp + ${project.version} + war + ${project.build.directory}/webapp + scm-webapp.war + + + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.12 + + + ${project.version} + + + + + integration-test + + integration-test + + + + verify + + verify + + + + + + + org.mortbay.jetty + jetty-maven-plugin + ${jetty.version} + + 8085 + STOP + + + scm.home + target/scm-it + + + file.encoding + UTF-8 + + + + + 8081 + 60000 + 16384 + + + + /scm + + ${project.build.directory}/webapp/scm-webapp.war + ${project.build.javaLevel} + ${project.build.javaLevel} + ${project.build.sourceEncoding} + 0 + true + + + + start-jetty + pre-integration-test + + deploy-war + + + + stop-jetty + post-integration-test + + stop + + + + + + + + + + + + diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/AbstractITCaseBase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/AbstractITCaseBase.java new file mode 100644 index 0000000000..5184ea37ed --- /dev/null +++ b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/AbstractITCaseBase.java @@ -0,0 +1,129 @@ +/** + * 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.cli; + +//~--- non-JDK imports -------------------------------------------------------- + +import com.google.common.collect.Lists; +import com.google.common.io.Closeables; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import java.util.Arrays; +import java.util.List; + +/** + * + * @author Sebastian Sdorra + */ +public abstract class AbstractITCaseBase +{ + + /** + * Method description + * + * + * @param cmd + * + * @return + * + * @throws IOException + */ + protected String execute(String... cmd) throws IOException + { + String result = null; + ByteArrayInputStream inputStream = null; + ByteArrayOutputStream outputStream = null; + + try + { + inputStream = new ByteArrayInputStream(new byte[0]); + outputStream = new ByteArrayOutputStream(); + + App app = new App(inputStream, outputStream); + + app.run(cmd); + + outputStream.flush(); + result = outputStream.toString().trim(); + } + finally + { + Closeables.close(inputStream, true); + Closeables.close(outputStream, true); + } + + return result; + } + + /** + * Method description + * + * + * @param cmd + * + * @return + * + * @throws IOException + */ + protected String executeServer(String... cmd) throws IOException + { + List cmdList = Lists.newArrayList(); + + cmdList.add("--server"); + cmdList.add("http://localhost:8081/scm"); + cmdList.add("--user"); + cmdList.add("scmadmin"); + cmdList.add("--password"); + cmdList.add("scmadmin"); + cmdList.addAll(Arrays.asList(cmd)); + + return execute(cmdList.toArray(new String[cmdList.size()])); + } + + /** + * Method description + * + * + * @param values + * + * @return + */ + protected String prepareForTest(String values) + { + return values.replaceAll("\\n", ";").replaceAll("\\s+", ""); + } +} diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/RepositoriesITCase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/RepositoriesITCase.java new file mode 100644 index 0000000000..d09e912157 --- /dev/null +++ b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/RepositoriesITCase.java @@ -0,0 +1,86 @@ +/** + * 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.cli; + +//~--- non-JDK imports -------------------------------------------------------- + +import org.junit.Test; + +import static org.hamcrest.Matchers.*; + +import static org.junit.Assert.*; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.IOException; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * @author Sebastian Sdorra + */ +public class RepositoriesITCase extends AbstractITCaseBase +{ + + /** + * Method description + * + * + * @throws IOException + */ + @Test + public void listRepositoriesTest() throws IOException + { + executeServer("create-repository", "--type", "git", "--name", "hobbo", + "--description", "Test Repo"); + + String repositories = prepareForTest(executeServer("list-repositories")); + + assertThat(repositories, containsString("Name:hobbo;")); + assertThat(repositories, containsString("Description:TestRepo;")); + assertThat(repositories, containsString("Type:git;")); + + Pattern pattern = Pattern.compile("ID:([^;]+);"); + Matcher matcher = pattern.matcher(repositories); + + if (!matcher.find()) + { + fail("could not extract id of repository"); + } + + String id = matcher.group(1); + + executeServer("delete-repository", id); + } +} diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/ServerVersionITCase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/ServerVersionITCase.java new file mode 100644 index 0000000000..7e424587fb --- /dev/null +++ b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/ServerVersionITCase.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.cli; + +//~--- non-JDK imports -------------------------------------------------------- + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assume.assumeTrue; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.IOException; + +/** + * + * @author Sebastian Sdorra + */ +public class ServerVersionITCase extends AbstractITCaseBase +{ + + /** + * Method description + * + * + * @throws IOException + */ + @Test + public void testServerVersion() throws IOException + { + String systemVersion = System.getProperty("scm.version"); + + assumeTrue("skip test, because system property scm.version is not set", + systemVersion != null); + + String version = executeServer("server-version"); + + assertEquals("scm-manager version: ".concat(systemVersion), version); + } +} diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/UsersITCase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/UsersITCase.java new file mode 100644 index 0000000000..e5b29457a9 --- /dev/null +++ b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/UsersITCase.java @@ -0,0 +1,72 @@ +/** + * 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.cli; + +//~--- non-JDK imports -------------------------------------------------------- + +import org.junit.Test; + +import static org.hamcrest.Matchers.*; + +import static org.junit.Assert.*; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.IOException; + +/** + * + * @author Sebastian Sdorra + */ +public class UsersITCase extends AbstractITCaseBase +{ + + /** + * Method description + * + * + * @throws IOException + */ + @Test + public void listUsersTest() throws IOException + { + String users = prepareForTest(executeServer("list-users")); + + assertThat(users, containsString("Name:scmadmin;")); + assertThat(users, containsString("DisplayName:SCMAdministrator;")); + assertThat(users, containsString("Type:xml;")); + assertThat(users, containsString("E-Mail:scm-admin@scm-manager.org;")); + assertThat(users, containsString("Active:true;")); + assertThat(users, containsString("Administrator:true;")); + System.out.println(users); + } +} diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/VersionITCase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/VersionITCase.java new file mode 100644 index 0000000000..3d9563c34e --- /dev/null +++ b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/VersionITCase.java @@ -0,0 +1,65 @@ +/** + * 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.cli; + +//~--- non-JDK imports -------------------------------------------------------- + +import org.junit.Test; + +import static org.junit.Assert.*; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.IOException; + +/** + * + * @author Sebastian Sdorra + */ +public class VersionITCase extends AbstractITCaseBase +{ + + /** + * Method description + * + * + * @throws IOException + */ + @Test + public void testVersion() throws IOException + { + // maven properties are not available during it tests + String version = execute("version"); + + assertEquals("scm-cli-client version: unknown", version); + } +} From 3d87b61fcf3378894fb6f04cb271cd409cc917fd Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 4 May 2014 15:31:53 +0200 Subject: [PATCH 05/36] use autoVersionSubmodules option for release plugin --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 3cd3374357..09bde3089f 100644 --- a/pom.xml +++ b/pom.xml @@ -261,6 +261,7 @@ true release,APIviz,doc @{project.version} + true From 97ea990c76d66213cdc7008a83525dba0ebbfff6 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 4 May 2014 15:33:40 +0200 Subject: [PATCH 06/36] [maven-release-plugin] prepare release 1.38 --- maven/pom.xml | 4 ++-- maven/scm-maven-plugin/pom.xml | 4 ++-- maven/scm-plugin-archetype/pom.xml | 4 ++-- pom.xml | 4 ++-- scm-clients/pom.xml | 6 +++--- scm-clients/scm-cli-client/pom.xml | 6 +++--- scm-clients/scm-client-api/pom.xml | 4 ++-- scm-clients/scm-client-impl/pom.xml | 8 ++++---- scm-core/pom.xml | 4 ++-- scm-dao-orientdb/pom.xml | 8 ++++---- scm-dao-xml/pom.xml | 8 ++++---- scm-plugin-backend/pom.xml | 6 +++--- scm-plugins/pom.xml | 8 ++++---- scm-plugins/scm-git-plugin/pom.xml | 6 +++--- scm-plugins/scm-hg-plugin/pom.xml | 6 +++--- scm-plugins/scm-svn-plugin/pom.xml | 6 +++--- scm-samples/pom.xml | 4 ++-- scm-samples/scm-sample-auth/pom.xml | 6 +++--- scm-samples/scm-sample-hello/pom.xml | 6 +++--- scm-server/pom.xml | 4 ++-- scm-test/pom.xml | 6 +++--- scm-webapp/pom.xml | 24 ++++++++++++------------ support/pom.xml | 4 ++-- support/scm-support-btrace/pom.xml | 6 +++--- 24 files changed, 76 insertions(+), 76 deletions(-) diff --git a/maven/pom.xml b/maven/pom.xml index 8f537bfac0..3fe5615d54 100644 --- a/maven/pom.xml +++ b/maven/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38-SNAPSHOT + 1.38 sonia.scm.maven scm-maven-plugins pom - 1.38-SNAPSHOT + 1.38 scm-maven-plugins diff --git a/maven/scm-maven-plugin/pom.xml b/maven/scm-maven-plugin/pom.xml index 7a0db4a82b..c98afbae1c 100644 --- a/maven/scm-maven-plugin/pom.xml +++ b/maven/scm-maven-plugin/pom.xml @@ -6,12 +6,12 @@ scm-maven-plugins sonia.scm.maven - 1.38-SNAPSHOT + 1.38 sonia.scm.maven scm-maven-plugin - 1.38-SNAPSHOT + 1.38 maven-plugin scm-maven-plugin diff --git a/maven/scm-plugin-archetype/pom.xml b/maven/scm-plugin-archetype/pom.xml index 439dcb6005..1f541b69e5 100644 --- a/maven/scm-plugin-archetype/pom.xml +++ b/maven/scm-plugin-archetype/pom.xml @@ -6,12 +6,12 @@ scm-maven-plugins sonia.scm.maven - 1.38-SNAPSHOT + 1.38 sonia.scm.maven scm-plugin-archetype - 1.38-SNAPSHOT + 1.38 scm-plugin-archetype diff --git a/pom.xml b/pom.xml index 09bde3089f..d79d6fde55 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ sonia.scm scm pom - 1.38-SNAPSHOT + 1.38 The easiest way to share your Git, Mercurial and Subversion repositories over http. @@ -36,7 +36,7 @@ scm:hg:http://bitbucket.org/sdorra/scm-manager scm:hg:https://bitbucket.org/sdorra/scm-manager http://bitbucket.org/sdorra/scm-manager - HEAD + 1.38 diff --git a/scm-clients/pom.xml b/scm-clients/pom.xml index 8a9504dec7..e2875b0b44 100644 --- a/scm-clients/pom.xml +++ b/scm-clients/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38-SNAPSHOT + 1.38 sonia.scm.clients scm-clients pom - 1.38-SNAPSHOT + 1.38 scm-clients @@ -32,7 +32,7 @@ scm-core sonia.scm jar - 1.38-SNAPSHOT + 1.38 shiro-core diff --git a/scm-clients/scm-cli-client/pom.xml b/scm-clients/scm-cli-client/pom.xml index 13a618e0b4..8cde9b906b 100644 --- a/scm-clients/scm-cli-client/pom.xml +++ b/scm-clients/scm-cli-client/pom.xml @@ -6,12 +6,12 @@ scm-clients sonia.scm.clients - 1.38-SNAPSHOT + 1.38 sonia.scm.clients scm-cli-client - 1.38-SNAPSHOT + 1.38 scm-cli-client @@ -34,7 +34,7 @@ sonia.scm.clients scm-client-impl - 1.38-SNAPSHOT + 1.38 diff --git a/scm-clients/scm-client-api/pom.xml b/scm-clients/scm-client-api/pom.xml index 581f395a72..1185de13a6 100644 --- a/scm-clients/scm-client-api/pom.xml +++ b/scm-clients/scm-client-api/pom.xml @@ -6,13 +6,13 @@ sonia.scm.clients scm-clients - 1.38-SNAPSHOT + 1.38 sonia.scm.clients scm-client-api jar - 1.38-SNAPSHOT + 1.38 scm-client-api diff --git a/scm-clients/scm-client-impl/pom.xml b/scm-clients/scm-client-impl/pom.xml index 06fb7edfe5..cbae7bb0b5 100644 --- a/scm-clients/scm-client-impl/pom.xml +++ b/scm-clients/scm-client-impl/pom.xml @@ -6,13 +6,13 @@ sonia.scm.clients scm-clients - 1.38-SNAPSHOT + 1.38 sonia.scm.clients scm-client-impl jar - 1.38-SNAPSHOT + 1.38 scm-client-impl @@ -36,7 +36,7 @@ sonia.scm.clients scm-client-api - 1.38-SNAPSHOT + 1.38 @@ -88,7 +88,7 @@ sonia.scm scm-test - 1.38-SNAPSHOT + 1.38 test diff --git a/scm-core/pom.xml b/scm-core/pom.xml index 3d500f978f..ea21fc819f 100644 --- a/scm-core/pom.xml +++ b/scm-core/pom.xml @@ -6,12 +6,12 @@ scm sonia.scm - 1.38-SNAPSHOT + 1.38 sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 scm-core diff --git a/scm-dao-orientdb/pom.xml b/scm-dao-orientdb/pom.xml index 0957811fd0..fb908e8112 100644 --- a/scm-dao-orientdb/pom.xml +++ b/scm-dao-orientdb/pom.xml @@ -6,12 +6,12 @@ sonia.scm scm - 1.38-SNAPSHOT + 1.38 sonia.scm scm-dao-orientdb - 1.38-SNAPSHOT + 1.38 scm-dao-orientdb @@ -26,7 +26,7 @@ sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 @@ -52,7 +52,7 @@ sonia.scm scm-test - 1.38-SNAPSHOT + 1.38 test diff --git a/scm-dao-xml/pom.xml b/scm-dao-xml/pom.xml index a0ae5ad1ea..ab068c6550 100644 --- a/scm-dao-xml/pom.xml +++ b/scm-dao-xml/pom.xml @@ -6,12 +6,12 @@ sonia.scm scm - 1.38-SNAPSHOT + 1.38 sonia.scm scm-dao-xml - 1.38-SNAPSHOT + 1.38 scm-dao-xml @@ -26,7 +26,7 @@ sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 @@ -34,7 +34,7 @@ sonia.scm scm-test - 1.38-SNAPSHOT + 1.38 test diff --git a/scm-plugin-backend/pom.xml b/scm-plugin-backend/pom.xml index 2ab2520932..3785815666 100644 --- a/scm-plugin-backend/pom.xml +++ b/scm-plugin-backend/pom.xml @@ -6,13 +6,13 @@ scm sonia.scm - 1.38-SNAPSHOT + 1.38 sonia.scm scm-plugin-backend war - 1.38-SNAPSHOT + 1.38 ${project.artifactId} @@ -62,7 +62,7 @@ sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 diff --git a/scm-plugins/pom.xml b/scm-plugins/pom.xml index 0015d947b6..3e468017c7 100644 --- a/scm-plugins/pom.xml +++ b/scm-plugins/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38-SNAPSHOT + 1.38 sonia.scm.plugins scm-plugins pom - 1.38-SNAPSHOT + 1.38 scm-plugins @@ -26,7 +26,7 @@ sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 @@ -59,7 +59,7 @@ sonia.scm.maven scm-maven-plugin - 1.38-SNAPSHOT + 1.38 process-resources diff --git a/scm-plugins/scm-git-plugin/pom.xml b/scm-plugins/scm-git-plugin/pom.xml index dee7eb34b1..33ae5ede6c 100644 --- a/scm-plugins/scm-git-plugin/pom.xml +++ b/scm-plugins/scm-git-plugin/pom.xml @@ -6,12 +6,12 @@ scm-plugins sonia.scm.plugins - 1.38-SNAPSHOT + 1.38 sonia.scm.plugins scm-git-plugin - 1.38-SNAPSHOT + 1.38 scm-git-plugin https://bitbucket.org/sdorra/scm-manager Plugin for the version control system Git @@ -48,7 +48,7 @@ sonia.scm scm-test - 1.38-SNAPSHOT + 1.38 test diff --git a/scm-plugins/scm-hg-plugin/pom.xml b/scm-plugins/scm-hg-plugin/pom.xml index ba8b7dec19..b15ab28106 100644 --- a/scm-plugins/scm-hg-plugin/pom.xml +++ b/scm-plugins/scm-hg-plugin/pom.xml @@ -6,12 +6,12 @@ sonia.scm.plugins scm-plugins - 1.38-SNAPSHOT + 1.38 sonia.scm.plugins scm-hg-plugin - 1.38-SNAPSHOT + 1.38 scm-hg-plugin https://bitbucket.org/sdorra/scm-manager Plugin for the version control system Mercurial @@ -36,7 +36,7 @@ sonia.scm scm-test - 1.38-SNAPSHOT + 1.38 test diff --git a/scm-plugins/scm-svn-plugin/pom.xml b/scm-plugins/scm-svn-plugin/pom.xml index 410b75c819..b338a955cf 100644 --- a/scm-plugins/scm-svn-plugin/pom.xml +++ b/scm-plugins/scm-svn-plugin/pom.xml @@ -6,12 +6,12 @@ scm-plugins sonia.scm.plugins - 1.38-SNAPSHOT + 1.38 sonia.scm.plugins scm-svn-plugin - 1.38-SNAPSHOT + 1.38 scm-svn-plugin https://bitbucket.org/sdorra/scm-manager Plugin for the version control system Subversion @@ -48,7 +48,7 @@ sonia.scm scm-test - 1.38-SNAPSHOT + 1.38 test diff --git a/scm-samples/pom.xml b/scm-samples/pom.xml index 56d054dead..6bd520ade5 100644 --- a/scm-samples/pom.xml +++ b/scm-samples/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38-SNAPSHOT + 1.38 sonia.scm.samples scm-samples pom - 1.38-SNAPSHOT + 1.38 scm-samples diff --git a/scm-samples/scm-sample-auth/pom.xml b/scm-samples/scm-sample-auth/pom.xml index 8710fed90c..ec07b05cc7 100644 --- a/scm-samples/scm-sample-auth/pom.xml +++ b/scm-samples/scm-sample-auth/pom.xml @@ -6,12 +6,12 @@ scm-samples sonia.scm.samples - 1.38-SNAPSHOT + 1.38 sonia.scm.sample scm-sample-auth - 1.38-SNAPSHOT + 1.38 scm-sample-auth Sample Authentication Plugin https://bitbucket.org/sdorra/scm-manager @@ -28,7 +28,7 @@ sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 diff --git a/scm-samples/scm-sample-hello/pom.xml b/scm-samples/scm-sample-hello/pom.xml index 24c6fc2d2a..08f0dd4278 100644 --- a/scm-samples/scm-sample-hello/pom.xml +++ b/scm-samples/scm-sample-hello/pom.xml @@ -6,12 +6,12 @@ scm-samples sonia.scm.samples - 1.38-SNAPSHOT + 1.38 sonia.scm.sample scm-sample-hello - 1.38-SNAPSHOT + 1.38 scm-sample-hello A simple hello world plugin https://bitbucket.org/sdorra/scm-manager @@ -28,7 +28,7 @@ sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 diff --git a/scm-server/pom.xml b/scm-server/pom.xml index 5a7d6c761a..f192380f93 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -6,12 +6,12 @@ scm sonia.scm - 1.38-SNAPSHOT + 1.38 sonia.scm scm-server - 1.38-SNAPSHOT + 1.38 scm-server jar diff --git a/scm-test/pom.xml b/scm-test/pom.xml index 3b9d144b29..49bdd747e9 100644 --- a/scm-test/pom.xml +++ b/scm-test/pom.xml @@ -6,12 +6,12 @@ scm sonia.scm - 1.38-SNAPSHOT + 1.38 sonia.scm scm-test - 1.38-SNAPSHOT + 1.38 scm-test @@ -25,7 +25,7 @@ sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml index 1493965741..49954487d9 100644 --- a/scm-webapp/pom.xml +++ b/scm-webapp/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38-SNAPSHOT + 1.38 sonia.scm scm-webapp war - 1.38-SNAPSHOT + 1.38 scm-webapp @@ -38,31 +38,31 @@ sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 sonia.scm scm-dao-xml - 1.38-SNAPSHOT + 1.38 sonia.scm.plugins scm-hg-plugin - 1.38-SNAPSHOT + 1.38 sonia.scm.plugins scm-svn-plugin - 1.38-SNAPSHOT + 1.38 sonia.scm.plugins scm-git-plugin - 1.38-SNAPSHOT + 1.38 @@ -280,7 +280,7 @@ sonia.scm scm-test - 1.38-SNAPSHOT + 1.38 test @@ -293,7 +293,7 @@ sonia.scm.plugins scm-git-plugin - 1.38-SNAPSHOT + 1.38 tests test @@ -301,7 +301,7 @@ sonia.scm.plugins scm-hg-plugin - 1.38-SNAPSHOT + 1.38 tests test @@ -309,7 +309,7 @@ sonia.scm.plugins scm-svn-plugin - 1.38-SNAPSHOT + 1.38 tests test @@ -534,7 +534,7 @@ sonia.scm scm-dao-orientdb - 1.38-SNAPSHOT + 1.38 diff --git a/support/pom.xml b/support/pom.xml index 63d17840f3..774929cd4f 100644 --- a/support/pom.xml +++ b/support/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38-SNAPSHOT + 1.38 sonia.scm.support scm-support pom - 1.38-SNAPSHOT + 1.38 scm-support diff --git a/support/scm-support-btrace/pom.xml b/support/scm-support-btrace/pom.xml index 226201307e..0c7e02548b 100644 --- a/support/scm-support-btrace/pom.xml +++ b/support/scm-support-btrace/pom.xml @@ -4,12 +4,12 @@ sonia.scm.support scm-support - 1.38-SNAPSHOT + 1.38 sonia.scm scm-support-btrace - 1.38-SNAPSHOT + 1.38 jar scm-support-btrace @@ -18,7 +18,7 @@ sonia.scm scm-core - 1.38-SNAPSHOT + 1.38 From 28e423ae495685f57110ab8a965487ff9ff550ce Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 4 May 2014 15:33:40 +0200 Subject: [PATCH 07/36] [maven-release-plugin] copy for tag 1.38 From 62fe0366d7de6e2a9501e9686c162d32f64aedc4 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 4 May 2014 15:33:41 +0200 Subject: [PATCH 08/36] [maven-release-plugin] prepare for next development iteration --- maven/pom.xml | 4 ++-- maven/scm-maven-plugin/pom.xml | 4 ++-- maven/scm-plugin-archetype/pom.xml | 4 ++-- pom.xml | 4 ++-- scm-clients/pom.xml | 6 +++--- scm-clients/scm-cli-client/pom.xml | 6 +++--- scm-clients/scm-client-api/pom.xml | 4 ++-- scm-clients/scm-client-impl/pom.xml | 8 ++++---- scm-core/pom.xml | 4 ++-- scm-dao-orientdb/pom.xml | 8 ++++---- scm-dao-xml/pom.xml | 8 ++++---- scm-plugin-backend/pom.xml | 6 +++--- scm-plugins/pom.xml | 8 ++++---- scm-plugins/scm-git-plugin/pom.xml | 6 +++--- scm-plugins/scm-hg-plugin/pom.xml | 6 +++--- scm-plugins/scm-svn-plugin/pom.xml | 6 +++--- scm-samples/pom.xml | 4 ++-- scm-samples/scm-sample-auth/pom.xml | 6 +++--- scm-samples/scm-sample-hello/pom.xml | 6 +++--- scm-server/pom.xml | 4 ++-- scm-test/pom.xml | 6 +++--- scm-webapp/pom.xml | 24 ++++++++++++------------ support/pom.xml | 4 ++-- support/scm-support-btrace/pom.xml | 6 +++--- 24 files changed, 76 insertions(+), 76 deletions(-) diff --git a/maven/pom.xml b/maven/pom.xml index 3fe5615d54..2273c9a88c 100644 --- a/maven/pom.xml +++ b/maven/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38 + 1.39-SNAPSHOT sonia.scm.maven scm-maven-plugins pom - 1.38 + 1.39-SNAPSHOT scm-maven-plugins diff --git a/maven/scm-maven-plugin/pom.xml b/maven/scm-maven-plugin/pom.xml index c98afbae1c..77eab0bb74 100644 --- a/maven/scm-maven-plugin/pom.xml +++ b/maven/scm-maven-plugin/pom.xml @@ -6,12 +6,12 @@ scm-maven-plugins sonia.scm.maven - 1.38 + 1.39-SNAPSHOT sonia.scm.maven scm-maven-plugin - 1.38 + 1.39-SNAPSHOT maven-plugin scm-maven-plugin diff --git a/maven/scm-plugin-archetype/pom.xml b/maven/scm-plugin-archetype/pom.xml index 1f541b69e5..f2d787bb62 100644 --- a/maven/scm-plugin-archetype/pom.xml +++ b/maven/scm-plugin-archetype/pom.xml @@ -6,12 +6,12 @@ scm-maven-plugins sonia.scm.maven - 1.38 + 1.39-SNAPSHOT sonia.scm.maven scm-plugin-archetype - 1.38 + 1.39-SNAPSHOT scm-plugin-archetype diff --git a/pom.xml b/pom.xml index d79d6fde55..524b304255 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ sonia.scm scm pom - 1.38 + 1.39-SNAPSHOT The easiest way to share your Git, Mercurial and Subversion repositories over http. @@ -36,7 +36,7 @@ scm:hg:http://bitbucket.org/sdorra/scm-manager scm:hg:https://bitbucket.org/sdorra/scm-manager http://bitbucket.org/sdorra/scm-manager - 1.38 + HEAD diff --git a/scm-clients/pom.xml b/scm-clients/pom.xml index e2875b0b44..53cedc1ceb 100644 --- a/scm-clients/pom.xml +++ b/scm-clients/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38 + 1.39-SNAPSHOT sonia.scm.clients scm-clients pom - 1.38 + 1.39-SNAPSHOT scm-clients @@ -32,7 +32,7 @@ scm-core sonia.scm jar - 1.38 + 1.39-SNAPSHOT shiro-core diff --git a/scm-clients/scm-cli-client/pom.xml b/scm-clients/scm-cli-client/pom.xml index 8cde9b906b..678ffee8a0 100644 --- a/scm-clients/scm-cli-client/pom.xml +++ b/scm-clients/scm-cli-client/pom.xml @@ -6,12 +6,12 @@ scm-clients sonia.scm.clients - 1.38 + 1.39-SNAPSHOT sonia.scm.clients scm-cli-client - 1.38 + 1.39-SNAPSHOT scm-cli-client @@ -34,7 +34,7 @@ sonia.scm.clients scm-client-impl - 1.38 + 1.39-SNAPSHOT diff --git a/scm-clients/scm-client-api/pom.xml b/scm-clients/scm-client-api/pom.xml index 1185de13a6..6357e5f647 100644 --- a/scm-clients/scm-client-api/pom.xml +++ b/scm-clients/scm-client-api/pom.xml @@ -6,13 +6,13 @@ sonia.scm.clients scm-clients - 1.38 + 1.39-SNAPSHOT sonia.scm.clients scm-client-api jar - 1.38 + 1.39-SNAPSHOT scm-client-api diff --git a/scm-clients/scm-client-impl/pom.xml b/scm-clients/scm-client-impl/pom.xml index cbae7bb0b5..af3e99d539 100644 --- a/scm-clients/scm-client-impl/pom.xml +++ b/scm-clients/scm-client-impl/pom.xml @@ -6,13 +6,13 @@ sonia.scm.clients scm-clients - 1.38 + 1.39-SNAPSHOT sonia.scm.clients scm-client-impl jar - 1.38 + 1.39-SNAPSHOT scm-client-impl @@ -36,7 +36,7 @@ sonia.scm.clients scm-client-api - 1.38 + 1.39-SNAPSHOT @@ -88,7 +88,7 @@ sonia.scm scm-test - 1.38 + 1.39-SNAPSHOT test diff --git a/scm-core/pom.xml b/scm-core/pom.xml index ea21fc819f..6478cb65fe 100644 --- a/scm-core/pom.xml +++ b/scm-core/pom.xml @@ -6,12 +6,12 @@ scm sonia.scm - 1.38 + 1.39-SNAPSHOT sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT scm-core diff --git a/scm-dao-orientdb/pom.xml b/scm-dao-orientdb/pom.xml index fb908e8112..923d7cbe2f 100644 --- a/scm-dao-orientdb/pom.xml +++ b/scm-dao-orientdb/pom.xml @@ -6,12 +6,12 @@ sonia.scm scm - 1.38 + 1.39-SNAPSHOT sonia.scm scm-dao-orientdb - 1.38 + 1.39-SNAPSHOT scm-dao-orientdb @@ -26,7 +26,7 @@ sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT @@ -52,7 +52,7 @@ sonia.scm scm-test - 1.38 + 1.39-SNAPSHOT test diff --git a/scm-dao-xml/pom.xml b/scm-dao-xml/pom.xml index ab068c6550..4957a33533 100644 --- a/scm-dao-xml/pom.xml +++ b/scm-dao-xml/pom.xml @@ -6,12 +6,12 @@ sonia.scm scm - 1.38 + 1.39-SNAPSHOT sonia.scm scm-dao-xml - 1.38 + 1.39-SNAPSHOT scm-dao-xml @@ -26,7 +26,7 @@ sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT @@ -34,7 +34,7 @@ sonia.scm scm-test - 1.38 + 1.39-SNAPSHOT test diff --git a/scm-plugin-backend/pom.xml b/scm-plugin-backend/pom.xml index 3785815666..f51cc9249d 100644 --- a/scm-plugin-backend/pom.xml +++ b/scm-plugin-backend/pom.xml @@ -6,13 +6,13 @@ scm sonia.scm - 1.38 + 1.39-SNAPSHOT sonia.scm scm-plugin-backend war - 1.38 + 1.39-SNAPSHOT ${project.artifactId} @@ -62,7 +62,7 @@ sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT diff --git a/scm-plugins/pom.xml b/scm-plugins/pom.xml index 3e468017c7..3b4341b78b 100644 --- a/scm-plugins/pom.xml +++ b/scm-plugins/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38 + 1.39-SNAPSHOT sonia.scm.plugins scm-plugins pom - 1.38 + 1.39-SNAPSHOT scm-plugins @@ -26,7 +26,7 @@ sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT @@ -59,7 +59,7 @@ sonia.scm.maven scm-maven-plugin - 1.38 + 1.39-SNAPSHOT process-resources diff --git a/scm-plugins/scm-git-plugin/pom.xml b/scm-plugins/scm-git-plugin/pom.xml index 33ae5ede6c..cc5eb8bc7d 100644 --- a/scm-plugins/scm-git-plugin/pom.xml +++ b/scm-plugins/scm-git-plugin/pom.xml @@ -6,12 +6,12 @@ scm-plugins sonia.scm.plugins - 1.38 + 1.39-SNAPSHOT sonia.scm.plugins scm-git-plugin - 1.38 + 1.39-SNAPSHOT scm-git-plugin https://bitbucket.org/sdorra/scm-manager Plugin for the version control system Git @@ -48,7 +48,7 @@ sonia.scm scm-test - 1.38 + 1.39-SNAPSHOT test diff --git a/scm-plugins/scm-hg-plugin/pom.xml b/scm-plugins/scm-hg-plugin/pom.xml index b15ab28106..0dd4e228ee 100644 --- a/scm-plugins/scm-hg-plugin/pom.xml +++ b/scm-plugins/scm-hg-plugin/pom.xml @@ -6,12 +6,12 @@ sonia.scm.plugins scm-plugins - 1.38 + 1.39-SNAPSHOT sonia.scm.plugins scm-hg-plugin - 1.38 + 1.39-SNAPSHOT scm-hg-plugin https://bitbucket.org/sdorra/scm-manager Plugin for the version control system Mercurial @@ -36,7 +36,7 @@ sonia.scm scm-test - 1.38 + 1.39-SNAPSHOT test diff --git a/scm-plugins/scm-svn-plugin/pom.xml b/scm-plugins/scm-svn-plugin/pom.xml index b338a955cf..c2ccbc890e 100644 --- a/scm-plugins/scm-svn-plugin/pom.xml +++ b/scm-plugins/scm-svn-plugin/pom.xml @@ -6,12 +6,12 @@ scm-plugins sonia.scm.plugins - 1.38 + 1.39-SNAPSHOT sonia.scm.plugins scm-svn-plugin - 1.38 + 1.39-SNAPSHOT scm-svn-plugin https://bitbucket.org/sdorra/scm-manager Plugin for the version control system Subversion @@ -48,7 +48,7 @@ sonia.scm scm-test - 1.38 + 1.39-SNAPSHOT test diff --git a/scm-samples/pom.xml b/scm-samples/pom.xml index 6bd520ade5..b88019f883 100644 --- a/scm-samples/pom.xml +++ b/scm-samples/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38 + 1.39-SNAPSHOT sonia.scm.samples scm-samples pom - 1.38 + 1.39-SNAPSHOT scm-samples diff --git a/scm-samples/scm-sample-auth/pom.xml b/scm-samples/scm-sample-auth/pom.xml index ec07b05cc7..543ed7fc7a 100644 --- a/scm-samples/scm-sample-auth/pom.xml +++ b/scm-samples/scm-sample-auth/pom.xml @@ -6,12 +6,12 @@ scm-samples sonia.scm.samples - 1.38 + 1.39-SNAPSHOT sonia.scm.sample scm-sample-auth - 1.38 + 1.39-SNAPSHOT scm-sample-auth Sample Authentication Plugin https://bitbucket.org/sdorra/scm-manager @@ -28,7 +28,7 @@ sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT diff --git a/scm-samples/scm-sample-hello/pom.xml b/scm-samples/scm-sample-hello/pom.xml index 08f0dd4278..23f86e5d97 100644 --- a/scm-samples/scm-sample-hello/pom.xml +++ b/scm-samples/scm-sample-hello/pom.xml @@ -6,12 +6,12 @@ scm-samples sonia.scm.samples - 1.38 + 1.39-SNAPSHOT sonia.scm.sample scm-sample-hello - 1.38 + 1.39-SNAPSHOT scm-sample-hello A simple hello world plugin https://bitbucket.org/sdorra/scm-manager @@ -28,7 +28,7 @@ sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT diff --git a/scm-server/pom.xml b/scm-server/pom.xml index f192380f93..593f3ecd26 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -6,12 +6,12 @@ scm sonia.scm - 1.38 + 1.39-SNAPSHOT sonia.scm scm-server - 1.38 + 1.39-SNAPSHOT scm-server jar diff --git a/scm-test/pom.xml b/scm-test/pom.xml index 49bdd747e9..85aab24199 100644 --- a/scm-test/pom.xml +++ b/scm-test/pom.xml @@ -6,12 +6,12 @@ scm sonia.scm - 1.38 + 1.39-SNAPSHOT sonia.scm scm-test - 1.38 + 1.39-SNAPSHOT scm-test @@ -25,7 +25,7 @@ sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml index 49954487d9..15f718f672 100644 --- a/scm-webapp/pom.xml +++ b/scm-webapp/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38 + 1.39-SNAPSHOT sonia.scm scm-webapp war - 1.38 + 1.39-SNAPSHOT scm-webapp @@ -38,31 +38,31 @@ sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT sonia.scm scm-dao-xml - 1.38 + 1.39-SNAPSHOT sonia.scm.plugins scm-hg-plugin - 1.38 + 1.39-SNAPSHOT sonia.scm.plugins scm-svn-plugin - 1.38 + 1.39-SNAPSHOT sonia.scm.plugins scm-git-plugin - 1.38 + 1.39-SNAPSHOT @@ -280,7 +280,7 @@ sonia.scm scm-test - 1.38 + 1.39-SNAPSHOT test @@ -293,7 +293,7 @@ sonia.scm.plugins scm-git-plugin - 1.38 + 1.39-SNAPSHOT tests test @@ -301,7 +301,7 @@ sonia.scm.plugins scm-hg-plugin - 1.38 + 1.39-SNAPSHOT tests test @@ -309,7 +309,7 @@ sonia.scm.plugins scm-svn-plugin - 1.38 + 1.39-SNAPSHOT tests test @@ -534,7 +534,7 @@ sonia.scm scm-dao-orientdb - 1.38 + 1.39-SNAPSHOT diff --git a/support/pom.xml b/support/pom.xml index 774929cd4f..fbfaa5fff4 100644 --- a/support/pom.xml +++ b/support/pom.xml @@ -6,13 +6,13 @@ sonia.scm scm - 1.38 + 1.39-SNAPSHOT sonia.scm.support scm-support pom - 1.38 + 1.39-SNAPSHOT scm-support diff --git a/support/scm-support-btrace/pom.xml b/support/scm-support-btrace/pom.xml index 0c7e02548b..8c6621da56 100644 --- a/support/scm-support-btrace/pom.xml +++ b/support/scm-support-btrace/pom.xml @@ -4,12 +4,12 @@ sonia.scm.support scm-support - 1.38 + 1.39-SNAPSHOT sonia.scm scm-support-btrace - 1.38 + 1.39-SNAPSHOT jar scm-support-btrace @@ -18,7 +18,7 @@ sonia.scm scm-core - 1.38 + 1.39-SNAPSHOT From 22d3aefeb5e8a4e4ea4b625e4fe8a7f195ff767f Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Tue, 6 May 2014 07:44:15 +0200 Subject: [PATCH 09/36] fix marshalling exception, see issue #578 --- .../sonia/scm/api/rest/RestActionUploadResult.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scm-webapp/src/main/java/sonia/scm/api/rest/RestActionUploadResult.java b/scm-webapp/src/main/java/sonia/scm/api/rest/RestActionUploadResult.java index 4778e0ff1d..6428a7dffd 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/rest/RestActionUploadResult.java +++ b/scm-webapp/src/main/java/sonia/scm/api/rest/RestActionUploadResult.java @@ -30,18 +30,30 @@ */ + package sonia.scm.api.rest; +//~--- JDK imports ------------------------------------------------------------ + import javax.xml.bind.annotation.XmlRootElement; /** * * @author Sebastian Sdorra */ -@XmlRootElement(name="result") +@XmlRootElement(name = "result") public class RestActionUploadResult extends RestActionResult { + /** + * Constructs ... + * + */ + public RestActionUploadResult() + { + this(true); + } + /** * Constructs ... * From 24b424f4830af9b89125393b5f4be501cb6718ee Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 7 May 2014 08:45:07 +0200 Subject: [PATCH 10/36] fix IndentXMLStreamWriterTest on windows --- .../sonia/scm/xml/IndentXMLStreamWriter.java | 4 +++- .../scm/xml/IndentXMLStreamWriterTest.java | 17 ++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scm-core/src/main/java/sonia/scm/xml/IndentXMLStreamWriter.java b/scm-core/src/main/java/sonia/scm/xml/IndentXMLStreamWriter.java index 55c6928d80..81e973f379 100644 --- a/scm-core/src/main/java/sonia/scm/xml/IndentXMLStreamWriter.java +++ b/scm-core/src/main/java/sonia/scm/xml/IndentXMLStreamWriter.java @@ -34,6 +34,7 @@ package sonia.scm.xml; //~--- JDK imports ------------------------------------------------------------ +import com.google.common.annotations.VisibleForTesting; import javax.xml.namespace.NamespaceContext; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; @@ -48,7 +49,8 @@ public final class IndentXMLStreamWriter implements XMLStreamWriter { /** line separator */ - private static final String LINE_SEPARATOR = + @VisibleForTesting + static final String LINE_SEPARATOR = System.getProperty("line.separator"); //~--- constructors --------------------------------------------------------- diff --git a/scm-core/src/test/java/sonia/scm/xml/IndentXMLStreamWriterTest.java b/scm-core/src/test/java/sonia/scm/xml/IndentXMLStreamWriterTest.java index 070a949ca4..ecfdd06a0f 100644 --- a/scm-core/src/test/java/sonia/scm/xml/IndentXMLStreamWriterTest.java +++ b/scm-core/src/test/java/sonia/scm/xml/IndentXMLStreamWriterTest.java @@ -86,15 +86,14 @@ public class IndentXMLStreamWriterTest String content = baos.toString(); - //J- - Assert.assertEquals( - "\n" + - "\n" + - " Hello\n" + - "\n", - content - ); - //J + StringBuilder buffer = new StringBuilder(""); + buffer.append(IndentXMLStreamWriter.LINE_SEPARATOR); + buffer.append("").append(IndentXMLStreamWriter.LINE_SEPARATOR); + buffer.append(" Hello"); + buffer.append(IndentXMLStreamWriter.LINE_SEPARATOR); + buffer.append("").append(IndentXMLStreamWriter.LINE_SEPARATOR); + + Assert.assertEquals(buffer.toString(), content); } From 5d3456ff6e578c57e3b7086671d196abe1fafad9 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 7 May 2014 08:50:50 +0200 Subject: [PATCH 11/36] close branch issue-578 From b1a3f7d5c9093297badb8258f231125e3cb5a00d Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 8 May 2014 19:50:15 +0200 Subject: [PATCH 12/36] implement marker interface for plugin class loaders to make it easier to find class loader leaks --- .../java/sonia/scm/boot/BootstrapUtil.java | 8 +- .../plugin/ChildFirstPluginClassLoader.java | 73 +++++++++++++++++++ .../scm/plugin/DefaultPluginClassLoader.java | 71 ++++++++++++++++++ .../sonia/scm/plugin/PluginClassLoader.java | 44 +++++++++++ 4 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 scm-webapp/src/main/java/sonia/scm/plugin/ChildFirstPluginClassLoader.java create mode 100644 scm-webapp/src/main/java/sonia/scm/plugin/DefaultPluginClassLoader.java create mode 100644 scm-webapp/src/main/java/sonia/scm/plugin/PluginClassLoader.java diff --git a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapUtil.java b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapUtil.java index 5944afda51..cb2f842595 100644 --- a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapUtil.java +++ b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapUtil.java @@ -40,12 +40,12 @@ import com.google.common.base.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import sonia.scm.net.ChildFirstURLClassLoader; +import sonia.scm.plugin.ChildFirstPluginClassLoader; +import sonia.scm.plugin.DefaultPluginClassLoader; //~--- JDK imports ------------------------------------------------------------ import java.net.URL; -import java.net.URLClassLoader; import java.util.List; @@ -107,7 +107,7 @@ public final class BootstrapUtil { logger.info("using {} as plugin classloading strategy", STRATEGY_CHILDFIRST); - classLoader = new ChildFirstURLClassLoader(urls, parent); + classLoader = new ChildFirstPluginClassLoader(urls, parent); } else if (!STRATEGY_PARENTFIRST.equals(strategy)) { @@ -119,7 +119,7 @@ public final class BootstrapUtil { logger.info("using {} as plugin classloading strategy", STRATEGY_PARENTFIRST); - classLoader = new URLClassLoader(urls, parent); + classLoader = new DefaultPluginClassLoader(urls, parent); } return classLoader; diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/ChildFirstPluginClassLoader.java b/scm-webapp/src/main/java/sonia/scm/plugin/ChildFirstPluginClassLoader.java new file mode 100644 index 0000000000..5e57825401 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/plugin/ChildFirstPluginClassLoader.java @@ -0,0 +1,73 @@ +/** + * 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.plugin; + +//~--- non-JDK imports -------------------------------------------------------- + +import sonia.scm.net.ChildFirstURLClassLoader; + +//~--- JDK imports ------------------------------------------------------------ + +import java.net.URL; + +/** + * Child first {@link ClassLoader} for SCM-Manager plugins. + * + * @author Sebastian Sdorra + */ +public class ChildFirstPluginClassLoader extends ChildFirstURLClassLoader + implements PluginClassLoader +{ + + /** + * Constructs ... + * + * + * @param urls + */ + public ChildFirstPluginClassLoader(URL[] urls) + { + super(urls); + } + + /** + * Constructs ... + * + * + * @param urls + * @param parent + */ + public ChildFirstPluginClassLoader(URL[] urls, ClassLoader parent) + { + super(urls, parent); + } +} diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/DefaultPluginClassLoader.java b/scm-webapp/src/main/java/sonia/scm/plugin/DefaultPluginClassLoader.java new file mode 100644 index 0000000000..532fb1dbff --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/plugin/DefaultPluginClassLoader.java @@ -0,0 +1,71 @@ +/** + * 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.plugin; + +//~--- JDK imports ------------------------------------------------------------ + +import java.net.URL; +import java.net.URLClassLoader; + +/** + * Default {@link ClassLoader} for SCM-Manager plugins. This {@link ClassLoader} + * uses the default parent first strategy. + * + * @author Sebastian Sdorra + */ +public class DefaultPluginClassLoader extends URLClassLoader + implements PluginClassLoader +{ + + /** + * Constructs ... + * + * + * @param urls + */ + public DefaultPluginClassLoader(URL[] urls) + { + super(urls); + } + + /** + * Constructs ... + * + * + * @param urls + * @param parent + */ + public DefaultPluginClassLoader(URL[] urls, ClassLoader parent) + { + super(urls, parent); + } +} diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/PluginClassLoader.java b/scm-webapp/src/main/java/sonia/scm/plugin/PluginClassLoader.java new file mode 100644 index 0000000000..e9e87ebaa3 --- /dev/null +++ b/scm-webapp/src/main/java/sonia/scm/plugin/PluginClassLoader.java @@ -0,0 +1,44 @@ +/** + * 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.plugin; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.Closeable; + +/** + * The PluginClassLoader interface is mainly a marker to find the class loader + * in a memory dump. This should make it easier to find class loader leaks. + * + * @author Sebastian Sdorra + */ +public interface PluginClassLoader {} From 0f88d1e30a3b43235779ddb3600261e904f1f136 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 8 May 2014 21:03:38 +0200 Subject: [PATCH 13/36] fix possible class loader leak --- .../java/sonia/scm/boot/BootstrapFilter.java | 44 +++++-- .../sonia/scm/boot/BootstrapListener.java | 120 ++++++++++++------ .../java/sonia/scm/boot/BootstrapUtil.java | 13 ++ 3 files changed, 127 insertions(+), 50 deletions(-) diff --git a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapFilter.java b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapFilter.java index 7ece6b4954..d68552db94 100644 --- a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapFilter.java +++ b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapFilter.java @@ -72,12 +72,23 @@ public class BootstrapFilter implements Filter @Override public void destroy() { - if (classLoader != null) - { - Thread.currentThread().setContextClassLoader(classLoader); - } + ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - guiceFilter.destroy(); + try + { + if (classLoader != null) + { + Thread.currentThread().setContextClassLoader(classLoader); + } + + logger.debug("destroy guice filter"); + + guiceFilter.destroy(); + } + finally + { + Thread.currentThread().setContextClassLoader(oldClassLoader); + } } /** @@ -93,15 +104,24 @@ public class BootstrapFilter implements Filter */ @Override public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) - throws IOException, ServletException + FilterChain chain) + throws IOException, ServletException { - if (classLoader != null) - { - Thread.currentThread().setContextClassLoader(classLoader); - } + ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - guiceFilter.doFilter(request, response, chain); + try + { + if (classLoader != null) + { + Thread.currentThread().setContextClassLoader(classLoader); + } + + guiceFilter.doFilter(request, response, chain); + } + finally + { + Thread.currentThread().setContextClassLoader(oldClassLoader); + } } /** diff --git a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapListener.java b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapListener.java index cf922b02a2..24814e88c2 100644 --- a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapListener.java +++ b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapListener.java @@ -35,14 +35,19 @@ package sonia.scm.boot; //~--- non-JDK imports -------------------------------------------------------- +import com.google.common.collect.Lists; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import sonia.scm.SCMContext; import sonia.scm.SCMContextProvider; +import sonia.scm.util.ClassLoaders; +import sonia.scm.util.IOUtil; //~--- JDK imports ------------------------------------------------------------ +import java.io.Closeable; import java.io.File; import java.net.MalformedURLException; @@ -51,6 +56,7 @@ import java.net.URL; import java.util.LinkedList; import java.util.List; +import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; @@ -89,8 +95,28 @@ public class BootstrapListener implements ServletContextListener { if (scmContextListener != null) { + logger.info("destroy scm context listener"); scmContextListener.contextDestroyed(sce); } + + ServletContext servletContext = sce.getServletContext(); + ClassLoader classLoader = BootstrapUtil.getClassLoader(servletContext); + + if (classLoader != null) + { + if (classLoader instanceof Closeable) + { + logger.info("close plugin class loader"); + IOUtil.close((Closeable) classLoader); + } + + logger.debug("remove plugin class loader from servlet context"); + BootstrapUtil.removeClassLoader(servletContext); + } + else + { + logger.debug("plugin class loader is not available"); + } } /** @@ -110,6 +136,44 @@ public class BootstrapListener implements ServletContextListener context.getStage()); } + ClassLoader classLoader = createClassLoader(context); + + if (classLoader != null) + { + if (logger.isInfoEnabled()) + { + logger.info("try to use ScmBootstrapClassLoader"); + } + + scmContextListener = BootstrapUtil.loadClass(classLoader, + ServletContextListener.class, LISTENER); + BootstrapUtil.setClassLoader(sce.getServletContext(), classLoader); + } + + if (scmContextListener == null) + { + if (logger.isWarnEnabled()) + { + logger.warn("fallback to default classloader"); + } + + scmContextListener = + BootstrapUtil.loadClass(ServletContextListener.class, LISTENER); + } + + initializeContext(classLoader, scmContextListener, sce); + } + + /** + * Method description + * + * + * @param context + * + * @return + */ + private ClassLoader createClassLoader(SCMContextProvider context) + { ClassLoader classLoader = null; File pluginDirectory = new File(context.getBaseDirectory(), PLUGIN_DIRECTORY); @@ -144,31 +208,7 @@ public class BootstrapListener implements ServletContextListener logger.debug("no plugin directory found"); } - if (classLoader != null) - { - if (logger.isInfoEnabled()) - { - logger.info("try to use ScmBootstrapClassLoader"); - } - - scmContextListener = BootstrapUtil.loadClass(classLoader, - ServletContextListener.class, LISTENER); - Thread.currentThread().setContextClassLoader(classLoader); - BootstrapUtil.setClassLoader(sce.getServletContext(), classLoader); - } - - if (scmContextListener == null) - { - if (logger.isWarnEnabled()) - { - logger.warn("fallback to default classloader"); - } - - scmContextListener = - BootstrapUtil.loadClass(ServletContextListener.class, LISTENER); - } - - scmContextListener.contextInitialized(sce); + return classLoader; } /** @@ -188,7 +228,7 @@ public class BootstrapListener implements ServletContextListener logger.debug("create classloader from plugin classpath"); } - List classpathURLs = new LinkedList(); + List classpathURLs = Lists.newLinkedList(); for (String path : classpath) { @@ -224,32 +264,36 @@ public class BootstrapListener implements ServletContextListener } return BootstrapUtil.createClassLoader(classpathURLs, - getParentClassLoader()); + ClassLoaders.getContextClassLoader(BootstrapListener.class)); } - //~--- get methods ---------------------------------------------------------- - /** * Method description * * - * @return + * @param classLoader + * @param listener + * @param sce */ - private ClassLoader getParentClassLoader() + private void initializeContext(ClassLoader classLoader, + ServletContextListener listener, ServletContextEvent sce) { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); - if (classLoader == null) + try { - if (logger.isWarnEnabled()) + if (classLoader != null) { - logger.warn("could not use context classloader, try to use default"); + Thread.currentThread().setContextClassLoader(classLoader); } - classLoader = BootstrapListener.class.getClassLoader(); + logger.info("initialize scm context listener"); + listener.contextInitialized(sce); + } + finally + { + Thread.currentThread().setContextClassLoader(oldClassLoader); } - - return classLoader; } //~--- fields --------------------------------------------------------------- diff --git a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapUtil.java b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapUtil.java index cb2f842595..87db199d7a 100644 --- a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapUtil.java +++ b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapUtil.java @@ -235,4 +235,17 @@ public final class BootstrapUtil { context.setAttribute(CLASSLOADER, classLoader); } + + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param context + */ + public static void removeClassLoader(ServletContext context) + { + context.removeAttribute(CLASSLOADER); + } } From 018e37874224638ab27c5d52b8b0520e3567607f Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 8 May 2014 21:04:17 +0200 Subject: [PATCH 14/36] fix typo --- .../main/java/sonia/scm/repository/DirectoryHealthCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scm-core/src/main/java/sonia/scm/repository/DirectoryHealthCheck.java b/scm-core/src/main/java/sonia/scm/repository/DirectoryHealthCheck.java index 382857b30f..0f329d89b2 100644 --- a/scm-core/src/main/java/sonia/scm/repository/DirectoryHealthCheck.java +++ b/scm-core/src/main/java/sonia/scm/repository/DirectoryHealthCheck.java @@ -70,7 +70,7 @@ public abstract class DirectoryHealthCheck implements HealthCheck private static final HealthCheckFailure DIRECTORY_DOES_NOT_EXISTS = new HealthCheckFailure("1oOTx803F1", "repository directory does not exists", - "The repository does not exists. Perhaps it was deleted outside of scm-manafer."); + "The repository does not exists. Perhaps it was deleted outside of scm-manager."); /** * the logger for DirectoryHealthCheck From ac5b2ddd0e2389c7c0bb1d1496936f51498be9f2 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 8 May 2014 21:09:45 +0200 Subject: [PATCH 15/36] implement simple health check for mercurial repositories --- .../sonia/scm/repository/HgHealthCheck.java | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgHealthCheck.java diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgHealthCheck.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgHealthCheck.java new file mode 100644 index 0000000000..53a9c242b4 --- /dev/null +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgHealthCheck.java @@ -0,0 +1,100 @@ +/** + * 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; + +//~--- non-JDK imports -------------------------------------------------------- + +import com.google.inject.Inject; + +import sonia.scm.plugin.ext.Extension; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.File; + +/** + * Simple {@link HealthCheck} for mercurial repositories. + * + * @author Sebastian Sdorra + * @since 1.39 + */ +@Extension +public final class HgHealthCheck extends DirectoryHealthCheck +{ + + /** Field description */ + private static final HealthCheckFailure COULD_NOT_FIND_DOT_HG_DIRECTORY = + new HealthCheckFailure("6bOdhOXpB1", "Could not find .hg directory", + "The mercurial repository does not contain .hg directory."); + + /** Field description */ + private static final String DOT_HG = ".hg"; + + //~--- constructors --------------------------------------------------------- + + /** + * Constructs ... + * + * + * @param repositoryManager + */ + @Inject + public HgHealthCheck(RepositoryManager repositoryManager) + { + super(repositoryManager); + } + + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param repository + * @param directory + * + * @return + */ + @Override + protected HealthCheckResult check(Repository repository, File directory) + { + HealthCheckResult result = HealthCheckResult.healthy(); + File dotHgDirectory = new File(directory, DOT_HG); + + if (!dotHgDirectory.exists()) + { + result = HealthCheckResult.unhealthy(COULD_NOT_FIND_DOT_HG_DIRECTORY); + } + + return result; + } +} From 9f654293a04e2631f2615b5d85dfdf8490a27843 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 8 May 2014 21:11:51 +0200 Subject: [PATCH 16/36] execute HgHealthCheck only for mercurial repositories --- .../java/sonia/scm/repository/HgHealthCheck.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgHealthCheck.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgHealthCheck.java index 53a9c242b4..ed9710578d 100644 --- a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgHealthCheck.java +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgHealthCheck.java @@ -97,4 +97,20 @@ public final class HgHealthCheck extends DirectoryHealthCheck return result; } + + //~--- get methods ---------------------------------------------------------- + + /** + * Returns {@code true} if the repository is from type mercurial. + * + * + * @param repository repository for the health check + * + * @return {@code true} for a mercurial repository + */ + @Override + protected boolean isCheckResponsible(Repository repository) + { + return HgRepositoryHandler.TYPE_NAME.equalsIgnoreCase(repository.getType()); + } } From e5e9ab5c0c11ffbe6ebbadbdf6df6f17d4a6ec87 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 8 May 2014 21:21:56 +0200 Subject: [PATCH 17/36] implemented simple health check for git repositories --- .../sonia/scm/repository/GitHealthCheck.java | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitHealthCheck.java diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitHealthCheck.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitHealthCheck.java new file mode 100644 index 0000000000..935eb7c259 --- /dev/null +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitHealthCheck.java @@ -0,0 +1,135 @@ +/** + * 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; + +//~--- non-JDK imports -------------------------------------------------------- + +import com.google.inject.Inject; + +import sonia.scm.plugin.ext.Extension; + +//~--- JDK imports ------------------------------------------------------------ + +import java.io.File; + +/** + * Simple {@link HealthCheck} for git repositories. + * + * @author Sebastian Sdorra + * @since 1.39 + */ +@Extension +public class GitHealthCheck extends DirectoryHealthCheck +{ + + /** Field description */ + private static final HealthCheckFailure COULD_NOT_FIND_GIT_DIRECTORIES = + new HealthCheckFailure("AKOdhQ0pw1", + "Could not find .git or refs directory", + "The git repository does not contain a .git or a refs directory."); + + /** Field description */ + private static final String DIRECTORY_DOT_GIT = ".git"; + + /** Field description */ + private static final String DIRECTORY_REFS = "refs"; + + //~--- constructors --------------------------------------------------------- + + /** + * Constructs ... + * + * + * @param repositoryManager + */ + @Inject + public GitHealthCheck(RepositoryManager repositoryManager) + { + super(repositoryManager); + } + + //~--- methods -------------------------------------------------------------- + + /** + * Method description + * + * + * @param repository + * @param directory + * + * @return + */ + @Override + protected HealthCheckResult check(Repository repository, File directory) + { + HealthCheckResult result = HealthCheckResult.healthy(); + + if (!isGitRepository(directory)) + { + result = HealthCheckResult.unhealthy(COULD_NOT_FIND_GIT_DIRECTORIES); + } + + return result; + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Returns {@code true} if the repository is from type git. + * + * + * @param repository repository for the health check + * + * @return {@code true} for a mercurial git + */ + @Override + protected boolean isCheckResponsible(Repository repository) + { + return GitRepositoryHandler.TYPE_NAME.equalsIgnoreCase( + repository.getType()); + } + + /** + * Returns {@code true} if the directory contains a .git directory or a refs + * directory (bare git repository). + * + * + * @param directory git repository directory + * + * @return {@code true} if the directory contains a git repository + */ + private boolean isGitRepository(File directory) + { + return new File(directory, DIRECTORY_DOT_GIT).exists() + || new File(directory, DIRECTORY_REFS).exists(); + } +} From aa2ba0a1b6c4558b0b360c1cd0e43e1a387d5ffa Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 8 May 2014 21:23:07 +0200 Subject: [PATCH 18/36] git health check should be final --- .../src/main/java/sonia/scm/repository/GitHealthCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitHealthCheck.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitHealthCheck.java index 935eb7c259..6997a02626 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitHealthCheck.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitHealthCheck.java @@ -48,7 +48,7 @@ import java.io.File; * @since 1.39 */ @Extension -public class GitHealthCheck extends DirectoryHealthCheck +public final class GitHealthCheck extends DirectoryHealthCheck { /** Field description */ From 72978a05afa5905bec2eff626b870c5ca8ef05b8 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 8 May 2014 21:27:15 +0200 Subject: [PATCH 19/36] remove unused imports --- .../sonia/scm/repository/RepositoryManagerDecorator.java | 1 - scm-core/src/main/java/sonia/scm/util/HttpUtil.java | 1 - .../src/main/java/sonia/scm/repository/GitUtil.java | 7 ------- .../main/java/sonia/scm/installer/MacOSHgInstaller.java | 2 -- .../src/main/java/sonia/scm/web/HgServletModule.java | 1 - .../scm/repository/spi/SvnRepositoryServiceProvider.java | 1 - .../src/main/java/sonia/scm/web/SvnServletModule.java | 3 +-- .../src/main/java/sonia/scm/boot/BootstrapListener.java | 1 - .../src/main/java/sonia/scm/plugin/PluginClassLoader.java | 4 ---- .../src/main/java/sonia/scm/template/TemplateServlet.java | 2 -- 10 files changed, 1 insertion(+), 22 deletions(-) diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java index 5493783c0b..c148b487b6 100644 --- a/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java +++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java @@ -37,7 +37,6 @@ package sonia.scm.repository; import sonia.scm.ManagerDecorator; import sonia.scm.Type; -import sonia.scm.group.GroupManager; //~--- JDK imports ------------------------------------------------------------ diff --git a/scm-core/src/main/java/sonia/scm/util/HttpUtil.java b/scm-core/src/main/java/sonia/scm/util/HttpUtil.java index 244ac98719..7e4c410aa4 100644 --- a/scm-core/src/main/java/sonia/scm/util/HttpUtil.java +++ b/scm-core/src/main/java/sonia/scm/util/HttpUtil.java @@ -37,7 +37,6 @@ package sonia.scm.util; import com.google.common.base.CharMatcher; import com.google.common.base.Strings; -import com.google.common.io.ByteStreams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitUtil.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitUtil.java index 8bd530d5e9..6fe3211ca8 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitUtil.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitUtil.java @@ -36,7 +36,6 @@ package sonia.scm.repository; //~--- non-JDK imports -------------------------------------------------------- import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Strings; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; @@ -44,8 +43,6 @@ import org.eclipse.jgit.api.FetchCommand; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.diff.DiffFormatter; -import org.eclipse.jgit.errors.IncorrectObjectTypeException; -import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; @@ -68,7 +65,6 @@ import sonia.scm.util.Util; import java.io.File; import java.io.IOException; -import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -471,9 +467,6 @@ public final class GitUtil * * @return * - * @throws IncorrectObjectTypeException - * @throws MissingObjectException - * * @throws IOException */ public static Ref getRefForCommit(org.eclipse.jgit.lib.Repository repository, diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/installer/MacOSHgInstaller.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/installer/MacOSHgInstaller.java index 1e8b19ceba..3ceb1abb63 100644 --- a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/installer/MacOSHgInstaller.java +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/installer/MacOSHgInstaller.java @@ -35,8 +35,6 @@ package sonia.scm.installer; //~--- non-JDK imports -------------------------------------------------------- -import com.google.common.base.Strings; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/web/HgServletModule.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/web/HgServletModule.java index 5bf080860a..4634cb8d93 100644 --- a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/web/HgServletModule.java +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/web/HgServletModule.java @@ -42,7 +42,6 @@ import sonia.scm.plugin.ext.Extension; import sonia.scm.repository.HgContext; import sonia.scm.repository.HgContextProvider; import sonia.scm.repository.HgHookManager; -import sonia.scm.web.filter.BasicAuthenticationFilter; /** * diff --git a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/spi/SvnRepositoryServiceProvider.java b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/spi/SvnRepositoryServiceProvider.java index 7626bdd32a..5c1907da7b 100644 --- a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/spi/SvnRepositoryServiceProvider.java +++ b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/spi/SvnRepositoryServiceProvider.java @@ -40,7 +40,6 @@ import com.google.common.io.Closeables; import sonia.scm.repository.Repository; import sonia.scm.repository.SvnRepositoryHandler; -import sonia.scm.repository.SvnUtil; import sonia.scm.repository.api.Command; //~--- JDK imports ------------------------------------------------------------ diff --git a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnServletModule.java b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnServletModule.java index 9eda6fe7dd..dc84f4964a 100644 --- a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnServletModule.java +++ b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnServletModule.java @@ -38,7 +38,6 @@ package sonia.scm.web; import com.google.inject.servlet.ServletModule; import sonia.scm.plugin.ext.Extension; -import sonia.scm.web.filter.BasicAuthenticationFilter; //~--- JDK imports ------------------------------------------------------------ @@ -75,7 +74,7 @@ public class SvnServletModule extends ServletModule Map parameters = new HashMap(); parameters.put(PARAMETER_SVN_PARENTPATH, - System.getProperty("java.io.tmpdir")); + System.getProperty("java.io.tmpdir")); serve(PATTERN_SVN).with(SvnDAVServlet.class, parameters); } } diff --git a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapListener.java b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapListener.java index 24814e88c2..6658c25b05 100644 --- a/scm-webapp/src/main/java/sonia/scm/boot/BootstrapListener.java +++ b/scm-webapp/src/main/java/sonia/scm/boot/BootstrapListener.java @@ -53,7 +53,6 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; -import java.util.LinkedList; import java.util.List; import javax.servlet.ServletContext; diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/PluginClassLoader.java b/scm-webapp/src/main/java/sonia/scm/plugin/PluginClassLoader.java index e9e87ebaa3..20a7a0bfb9 100644 --- a/scm-webapp/src/main/java/sonia/scm/plugin/PluginClassLoader.java +++ b/scm-webapp/src/main/java/sonia/scm/plugin/PluginClassLoader.java @@ -31,10 +31,6 @@ package sonia.scm.plugin; -//~--- JDK imports ------------------------------------------------------------ - -import java.io.Closeable; - /** * The PluginClassLoader interface is mainly a marker to find the class loader * in a memory dump. This should make it easier to find class loader leaks. diff --git a/scm-webapp/src/main/java/sonia/scm/template/TemplateServlet.java b/scm-webapp/src/main/java/sonia/scm/template/TemplateServlet.java index 9ecec82463..89e6baa685 100644 --- a/scm-webapp/src/main/java/sonia/scm/template/TemplateServlet.java +++ b/scm-webapp/src/main/java/sonia/scm/template/TemplateServlet.java @@ -39,8 +39,6 @@ import com.google.common.collect.ImmutableSet; import com.google.inject.Inject; import com.google.inject.Singleton; -import freemarker.template.Configuration; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; From c4db25b072706f60af66978da770cc270320cf34 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sat, 10 May 2014 12:02:40 +0200 Subject: [PATCH 20/36] remove antiJARLocking attribute from context.xml, because it is no longer supported by tomcat 8 --- scm-webapp/src/main/webapp/META-INF/context.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scm-webapp/src/main/webapp/META-INF/context.xml b/scm-webapp/src/main/webapp/META-INF/context.xml index b1f2c9aba6..6572785af2 100644 --- a/scm-webapp/src/main/webapp/META-INF/context.xml +++ b/scm-webapp/src/main/webapp/META-INF/context.xml @@ -31,4 +31,4 @@ --> - + From 4ad6d4b696038c07290fe104d773baaeaac6adf3 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 14 May 2014 16:30:58 +0200 Subject: [PATCH 21/36] update commons-daemon to version 1.0.15 --- scm-server/pom.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scm-server/pom.xml b/scm-server/pom.xml index 593f3ecd26..70487249c7 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -20,7 +20,7 @@ commons-daemon commons-daemon - 1.0.10 + ${commons.daemon.version} @@ -75,7 +75,7 @@ scm-server - 1.0.10 + ${commons.daemon.version} sonia.scm.server.ScmServerDaemon commons-daemon @@ -163,5 +163,9 @@ scm-server + + + 1.0.15 + From 3a4e51b9a81acf38dee93e0d354064061381b996 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 14 May 2014 16:33:31 +0200 Subject: [PATCH 22/36] added profile to build an rpm package for scm-server --- scm-server/pom.xml | 125 +++++++++++++++++- scm-server/src/main/nativepkg/default | 54 ++++++++ scm-server/src/main/nativepkg/logging.xml | 101 ++++++++++++++ scm-server/src/main/nativepkg/rpm-init-script | 118 +++++++++++++++++ 4 files changed, 395 insertions(+), 3 deletions(-) create mode 100644 scm-server/src/main/nativepkg/default create mode 100644 scm-server/src/main/nativepkg/logging.xml create mode 100644 scm-server/src/main/nativepkg/rpm-init-script diff --git a/scm-server/pom.xml b/scm-server/pom.xml index 70487249c7..2256557213 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -56,7 +56,7 @@ sonia.maven appassembler-maven-plugin - 1.2.0.3 + 1.2.1.1-SNAPSHOT scm-app @@ -67,7 +67,7 @@ ${project.build.directory}/appassembler - ${project.build.directory}/appassembler/commons-daemon/scm-server + ${exploded.directory} lib flat true @@ -131,7 +131,7 @@ scm-webapp ${project.version} war - ${project.build.directory}/appassembler/commons-daemon/scm-server/var/webapp + ${exploded.directory}/var/webapp scm-webapp.war @@ -164,8 +164,127 @@ scm-server + + + nativepkg + + + + + + com.github.sdorra + nativepkg-maven-plugin + 1.0.0-SNAPSHOT + + + + rpm + + package + + + + true + ${maven.build.timestamp} +
devel
+ Development/Tools + SCM-Manager + BSD 3-Clause + www.scm-manager.org + ${project.description} + Sebastian Sdorra <s.sdorra@gmail.com> + + noarch + linux + + + + + /opt/scm-server/bin/scm-server + ${exploded.directory}/bin/scm-server + 0744 + + + /opt/scm-server/conf/server-config.xml + ${project.basedir}/src/main/conf/server-config.xml + true + + + /opt/scm-server/conf/logging.xml + ${project.basedir}/src/main/nativepkg/logging.xml + true + + + /opt/scm-server/libexec/jsvc-linux-i686 + ${exploded.directory}/libexec/jsvc-linux-i686 + 0744 + + + /opt/scm-server/libexec/jsvc-linux-x86_64 + ${exploded.directory}/libexec/jsvc-linux-x86_64 + 0744 + + + /opt/scm-server/var/webapp/scm-webapp.war + ${exploded.directory}/var/webapp/scm-webapp.war + + + /opt/scm-server/var/webapp/docroot/index.html + ${basedir}/src/main/docroot/index.html + + + /etc/default/scm-server + ${project.basedir}/src/main/nativepkg/default + 0744 + true + + + /etc/init.d/scm-server + ${project.basedir}/src/main/nativepkg/rpm-init-script + 0744 + + + + + /usr/sbin/scm-server + /opt/scm-server/bin/scm-server + + + /opt/scm-server/var/log + /var/log/scm + + + /opt/scm-server/work + /var/cache/scm/work + + + + + /opt/scm-server/lib + ${exploded.directory}/lib + + + /var/cache/scm/work + + + /var/log/scm + + + /var/lib/scm + + + +
+
+ +
+
+
+
+ 1.0.15 + ${project.build.directory}/appassembler/commons-daemon/scm-server diff --git a/scm-server/src/main/nativepkg/default b/scm-server/src/main/nativepkg/default new file mode 100644 index 0000000000..2df2561404 --- /dev/null +++ b/scm-server/src/main/nativepkg/default @@ -0,0 +1,54 @@ +#!/bin/sh +# +# 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 +# + +# scm-server port +PORT=8080 + +# change user +# USER=scm + +# home of scm-manager +SCM_HOME=/var/lib/scm + +# alternative jvm path +JAVA_HOME="/usr/lib/jvm/jre" + +# path to pid +PIDFILE=/var/run/scm.pid + +# path to log directory +LOGDIR=/var/log/scm + +# increase memory +# EXTRA_JVM_ARGUMENTS="$EXTRA_JVM_ARGUMENTS -Xms1g -Xmx1g" + +# pass extra jvm arguments +EXTRA_JVM_ARGUMENTS="$EXTRA_JVM_ARGUMENTS -Djetty.port=$PORT" diff --git a/scm-server/src/main/nativepkg/logging.xml b/scm-server/src/main/nativepkg/logging.xml new file mode 100644 index 0000000000..c5ddb0f5f3 --- /dev/null +++ b/scm-server/src/main/nativepkg/logging.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + /var/log/scm/scm-manager.log + + + /var/log/scm/scm-manager-%i.log + 1 + 10 + + + + 10MB + + + true + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scm-server/src/main/nativepkg/rpm-init-script b/scm-server/src/main/nativepkg/rpm-init-script new file mode 100644 index 0000000000..5e6cac53f3 --- /dev/null +++ b/scm-server/src/main/nativepkg/rpm-init-script @@ -0,0 +1,118 @@ +#!/bin/sh + +# +# SCM-Server start script +# + +# +# 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 +# + +# chkconfig: 35 35 65 +# description: SCM-Server +# +### BEGIN INIT INFO +# Provides: scm-server +# Required-Start: $local_fs $remote_fs $network $time $named +# Required-Stop: $local_fs $remote_fs $network $time $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Description: SCM-Server +### END INIT INFO + +# start script is based on the one posted from JavaNode to SCM-Manager mailing +# list: https://groups.google.com/d/msg/scmmanager/-wNjenUbl0Q/CkELJ6fLMHsJ + + +# Source function library. +if [ -x /etc/rc.d/init.d/functions ]; then +. /etc/rc.d/init.d/functions +fi + +# Check for and source configuration file otherwise set defaults +RETVAL=0 + +appname=ScmServerDaemon + +# See how we were called. +start() { + /opt/scm-server/bin/scm-server start +} + +stop() { + if [ ! status = 0 ] + then + /opt/scm-server/bin/scm-server stop + else + echo "SCM-Server is not running" + fi +} + +status() { + ps auxwww | grep java | grep ${appname} || echo "SCM-Server is not running" +} + +restart() { + stop + SECONDS=0 + STAT=$( ps auxwww | grep java | grep ${appname} | wc -l ) + while [ $STAT -ne 0 ] + do + sleep 3 + if [ $SECONDS -gt 300 ] + then + SCM_PID=$( ps auxwww | grep java | grep ${appname} | awk '{ print $2 }' ) + kill -9 $SCM_PID + fi + STAT=$( ps auxwww | grep java | grep ${appname} | wc -l ) + done + start +} + +# See how we were called. + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + status) + status + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $RETVAL \ No newline at end of file From a5355cfefb2cc84849c8b84265992505020bf50c Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 16 May 2014 12:39:08 +0200 Subject: [PATCH 23/36] use user scm to run scm-server for rpm package installations --- scm-server/pom.xml | 15 +++++++++++---- scm-server/src/main/nativepkg/default | 4 ++-- scm-server/src/main/nativepkg/rpm-create-user | 5 +++++ 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 scm-server/src/main/nativepkg/rpm-create-user diff --git a/scm-server/pom.xml b/scm-server/pom.xml index 2256557213..0aac5b430e 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -178,6 +178,7 @@ + deb rpm package @@ -197,6 +198,7 @@ noarch linux + ${project.basedir}/src/main/nativepkg/rpm-create-user @@ -245,10 +247,6 @@ - - /usr/sbin/scm-server - /opt/scm-server/bin/scm-server - /opt/scm-server/var/log /var/log/scm @@ -265,12 +263,21 @@ /var/cache/scm/work + scm + scm + 0700 /var/log/scm + root + scm + 0770 /var/lib/scm + scm + scm + 0700 diff --git a/scm-server/src/main/nativepkg/default b/scm-server/src/main/nativepkg/default index 2df2561404..0699a2e50a 100644 --- a/scm-server/src/main/nativepkg/default +++ b/scm-server/src/main/nativepkg/default @@ -33,10 +33,10 @@ PORT=8080 # change user -# USER=scm +USER=scm # home of scm-manager -SCM_HOME=/var/lib/scm +export SCM_HOME=/var/lib/scm # alternative jvm path JAVA_HOME="/usr/lib/jvm/jre" diff --git a/scm-server/src/main/nativepkg/rpm-create-user b/scm-server/src/main/nativepkg/rpm-create-user new file mode 100644 index 0000000000..82398c513c --- /dev/null +++ b/scm-server/src/main/nativepkg/rpm-create-user @@ -0,0 +1,5 @@ +getent group scm >/dev/null || groupadd -r scm +getent passwd scm >/dev/null || \ + useradd -r -g scm -M -s /sbin/nologin \ + -c "user for the scm-server process" scm +exit 0 \ No newline at end of file From e71477e301f7825a591707ac4722ad38b2958ede Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 16 May 2014 13:14:26 +0200 Subject: [PATCH 24/36] fix open webserver port < 1024 as non privileged user --- .../main/java/sonia/scm/server/ScmServer.java | 36 +++++++++++++++++-- .../sonia/scm/server/ScmServerDaemon.java | 3 ++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/scm-server/src/main/java/sonia/scm/server/ScmServer.java b/scm-server/src/main/java/sonia/scm/server/ScmServer.java index 6cb36415a6..13da881679 100644 --- a/scm-server/src/main/java/sonia/scm/server/ScmServer.java +++ b/scm-server/src/main/java/sonia/scm/server/ScmServer.java @@ -92,12 +92,23 @@ public class ScmServer extends Thread { try { + if (!initialized) + { + server.join(); + } + server.start(); - server.join(); } catch (Exception ex) { - throw new RuntimeException(ex); + if (ex instanceof ScmServerException) + { + throw(ScmServerException) ex; + } + else + { + throw new ScmServerException("could not start scm-server", ex); + } } } @@ -110,6 +121,7 @@ public class ScmServer extends Thread try { server.setStopAtShutdown(true); + initialized = false; } catch (Exception ex) { @@ -117,8 +129,28 @@ public class ScmServer extends Thread } } + /** + * Method description + * + */ + void init() + { + try + { + server.start(); + initialized = true; + } + catch (Exception ex) + { + throw new ScmServerException("could not initialize server", ex); + } + } + //~--- fields --------------------------------------------------------------- + /** Field description */ + private boolean initialized = false; + /** Field description */ private Server server = new Server(); } diff --git a/scm-server/src/main/java/sonia/scm/server/ScmServerDaemon.java b/scm-server/src/main/java/sonia/scm/server/ScmServerDaemon.java index 93fd7d77bd..0799f7e69e 100644 --- a/scm-server/src/main/java/sonia/scm/server/ScmServerDaemon.java +++ b/scm-server/src/main/java/sonia/scm/server/ScmServerDaemon.java @@ -113,6 +113,9 @@ public class ScmServerDaemon implements Daemon public void init(DaemonContext context) throws DaemonInitException, Exception { daemonArgs = context.getArguments(); + // initialize web server and open port. We have to do this in the init + // method, because this method is started by jsvc with super user privileges. + webserver.init(); } /** From 6d3fe8e9d0da69bfbc9508a37ff7e0f92600d001 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 18 May 2014 10:20:54 +0200 Subject: [PATCH 25/36] fix npe on non daemon start --- scm-server/src/main/java/sonia/scm/server/ScmServer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scm-server/src/main/java/sonia/scm/server/ScmServer.java b/scm-server/src/main/java/sonia/scm/server/ScmServer.java index 13da881679..507e12a37f 100644 --- a/scm-server/src/main/java/sonia/scm/server/ScmServer.java +++ b/scm-server/src/main/java/sonia/scm/server/ScmServer.java @@ -94,10 +94,10 @@ public class ScmServer extends Thread { if (!initialized) { - server.join(); + init(); } - server.start(); + server.join(); } catch (Exception ex) { From 37de8d9c71fbbe79cb1a39f6c4a77953499c40d0 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 18 May 2014 10:48:26 +0200 Subject: [PATCH 26/36] improve deb generation --- scm-server/pom.xml | 8 +++++--- .../src/main/nativepkg/{rpm-create-user => create-user} | 0 .../src/main/nativepkg/{rpm-init-script => init-script} | 0 3 files changed, 5 insertions(+), 3 deletions(-) rename scm-server/src/main/nativepkg/{rpm-create-user => create-user} (100%) rename scm-server/src/main/nativepkg/{rpm-init-script => init-script} (100%) diff --git a/scm-server/pom.xml b/scm-server/pom.xml index 0aac5b430e..31aecdebe7 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -198,7 +198,9 @@ noarch linux - ${project.basedir}/src/main/nativepkg/rpm-create-user + + ${project.basedir}/src/main/nativepkg/create-user + @@ -242,7 +244,7 @@ /etc/init.d/scm-server - ${project.basedir}/src/main/nativepkg/rpm-init-script + ${project.basedir}/src/main/nativepkg/init-script 0744 @@ -269,7 +271,7 @@ /var/log/scm - root + scm scm 0770 diff --git a/scm-server/src/main/nativepkg/rpm-create-user b/scm-server/src/main/nativepkg/create-user similarity index 100% rename from scm-server/src/main/nativepkg/rpm-create-user rename to scm-server/src/main/nativepkg/create-user diff --git a/scm-server/src/main/nativepkg/rpm-init-script b/scm-server/src/main/nativepkg/init-script similarity index 100% rename from scm-server/src/main/nativepkg/rpm-init-script rename to scm-server/src/main/nativepkg/init-script From 6a508b53d1dc99925bd662a35456849e401d3bd1 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 18 May 2014 11:23:40 +0200 Subject: [PATCH 27/36] do not force a java home --- scm-server/src/main/nativepkg/default | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scm-server/src/main/nativepkg/default b/scm-server/src/main/nativepkg/default index 0699a2e50a..f2675e1673 100644 --- a/scm-server/src/main/nativepkg/default +++ b/scm-server/src/main/nativepkg/default @@ -38,8 +38,8 @@ USER=scm # home of scm-manager export SCM_HOME=/var/lib/scm -# alternative jvm path -JAVA_HOME="/usr/lib/jvm/jre" +# force jvm path +# JAVA_HOME="/usr/lib/jvm/jre" # path to pid PIDFILE=/var/run/scm.pid From 68090719d732ebedd5fe6d7e82923c7d27800f35 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 18 May 2014 11:25:39 +0200 Subject: [PATCH 28/36] disable wadl --- .../src/main/java/sonia/scm/ScmServletModule.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scm-webapp/src/main/java/sonia/scm/ScmServletModule.java b/scm-webapp/src/main/java/sonia/scm/ScmServletModule.java index 25f96cd563..0f7fbbf822 100644 --- a/scm-webapp/src/main/java/sonia/scm/ScmServletModule.java +++ b/scm-webapp/src/main/java/sonia/scm/ScmServletModule.java @@ -43,6 +43,7 @@ import com.google.inject.servlet.ServletModule; import com.google.inject.throwingproviders.ThrowingProviderBinder; import org.apache.shiro.authz.permission.PermissionResolver; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,6 +73,8 @@ import sonia.scm.plugin.PluginManager; import sonia.scm.repository.ChangesetViewerUtil; import sonia.scm.repository.DefaultRepositoryManager; import sonia.scm.repository.DefaultRepositoryProvider; +import sonia.scm.repository.HealthCheckContextListener; +import sonia.scm.repository.LastModifiedUpdateListener; import sonia.scm.repository.Repository; import sonia.scm.repository.RepositoryBrowserUtil; import sonia.scm.repository.RepositoryDAO; @@ -141,7 +144,6 @@ import sonia.scm.web.security.WebSecurityContext; //~--- JDK imports ------------------------------------------------------------ - import com.sun.jersey.api.core.PackagesResourceConfig; import com.sun.jersey.api.core.ResourceConfig; import com.sun.jersey.api.json.JSONConfiguration; @@ -154,8 +156,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; -import sonia.scm.repository.HealthCheckContextListener; -import sonia.scm.repository.LastModifiedUpdateListener; /** * @@ -277,7 +277,7 @@ public class ScmServletModule extends ServletModule bind(CipherHandler.class).toInstance(cu.getCipherHandler()); bind(EncryptionHandler.class, MessageDigestEncryptionHandler.class); bind(FileSystem.class, DefaultFileSystem.class); - + // bind health check stuff bind(HealthCheckContextListener.class); @@ -378,7 +378,7 @@ public class ScmServletModule extends ServletModule bind(TemplateEngine.class).annotatedWith(DefaultEngine.class).to( MustacheTemplateEngine.class); bind(TemplateEngineFactory.class); - + // bind events bind(LastModifiedUpdateListener.class); @@ -395,6 +395,7 @@ public class ScmServletModule extends ServletModule */ params.put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE.toString()); params.put(ResourceConfig.FEATURE_REDIRECT, Boolean.TRUE.toString()); + params.put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.TRUE.toString()); params.put(ServletContainer.RESOURCE_CONFIG_CLASS, UriExtensionsConfig.class.getName()); From e6ffe578d2da88f956357701907e05cb363982aa Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 18 May 2014 11:34:33 +0200 Subject: [PATCH 29/36] use version 1.2.2.0 of appassembler-maven-plugin --- scm-server/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scm-server/pom.xml b/scm-server/pom.xml index 31aecdebe7..af887145a2 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -56,7 +56,7 @@ sonia.maven appassembler-maven-plugin - 1.2.1.1-SNAPSHOT + 1.2.2.0 scm-app From d42307e8b090ed5a73fb5ee7d7288e02b60790aa Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 22 May 2014 16:39:33 +0200 Subject: [PATCH 30/36] fix log messages --- .../sonia/scm/api/rest/resources/AbstractManagerResource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/AbstractManagerResource.java b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/AbstractManagerResource.java index 375776472f..bb9c626053 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/AbstractManagerResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/AbstractManagerResource.java @@ -196,7 +196,7 @@ public abstract class AbstractManagerResource Date: Fri, 23 May 2014 11:48:19 +0200 Subject: [PATCH 31/36] fixed wrong resource paths --- .../src/main/java/sonia/scm/web/GitRepositoryViewer.java | 2 +- .../src/main/java/sonia/scm/web/SvnCollectionRenderer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryViewer.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryViewer.java index 49b98f1047..aff932350d 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryViewer.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryViewer.java @@ -84,7 +84,7 @@ public class GitRepositoryViewer public static final String MIMETYPE_HTML = "text/html"; /** Field description */ - public static final String RESOURCE_GITINDEX = "sonia/scm/git.index.mustache"; + public static final String RESOURCE_GITINDEX = "/sonia/scm/git.index.mustache"; /** Field description */ private static final int CHANGESET_PER_BRANCH = 10; diff --git a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnCollectionRenderer.java b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnCollectionRenderer.java index 34f6a75cb8..7370dabadb 100644 --- a/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnCollectionRenderer.java +++ b/scm-plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnCollectionRenderer.java @@ -78,7 +78,7 @@ public class SvnCollectionRenderer implements CollectionRenderer /** Field description */ private static final String RESOURCE_SVNINDEX = - "sonia/scm/svn.index.mustache"; + "/sonia/scm/svn.index.mustache"; /** * the logger for SvnCollectionRenderer From 0a95e1694201e06ce5a2647a725bac56fe9095c9 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 23 May 2014 15:24:26 +0200 Subject: [PATCH 32/36] added classifier to native packages --- scm-server/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/scm-server/pom.xml b/scm-server/pom.xml index af887145a2..314b47b7bf 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -186,6 +186,7 @@ true + all ${maven.build.timestamp}
devel
Development/Tools From 2467356f9a30d45958b470c01a8562da2b23a09e Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Mon, 26 May 2014 09:14:26 +0200 Subject: [PATCH 33/36] use pre install script instead of post for user creation --- scm-server/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scm-server/pom.xml b/scm-server/pom.xml index 314b47b7bf..974f1d3320 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -200,7 +200,7 @@ linux - ${project.basedir}/src/main/nativepkg/create-user + ${project.basedir}/src/main/nativepkg/create-user From db003d46245f551fd0f8127c7233ab4827bc6171 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 1 Jun 2014 09:57:07 +0200 Subject: [PATCH 34/36] added tcpip dependency for windows services --- scm-server/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scm-server/pom.xml b/scm-server/pom.xml index 974f1d3320..e31d5173e9 100644 --- a/scm-server/pom.xml +++ b/scm-server/pom.xml @@ -101,6 +101,10 @@ darwin.arch.enable false + + windows.service.dependencies + Tcpip +
From fb93e86ec3d69acad6b759551fc93def65a6c3e9 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 4 Jun 2014 13:57:39 +0200 Subject: [PATCH 35/36] update commons-beanutils to version 1.9.2 --- scm-webapp/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml index 15f718f672..db4781fe28 100644 --- a/scm-webapp/pom.xml +++ b/scm-webapp/pom.xml @@ -164,7 +164,7 @@ commons-beanutils commons-beanutils - 1.9.1 + 1.9.2 From abf871fa8877ac9319fef8a418597cce3baa3a2f Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 4 Jun 2014 13:59:13 +0200 Subject: [PATCH 36/36] update mustache to version 0.8.15 --- scm-webapp/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml index db4781fe28..c93aae12a3 100644 --- a/scm-webapp/pom.xml +++ b/scm-webapp/pom.xml @@ -520,7 +520,7 @@ 1.13.1 1.0 3.0.5 - 0.8.14 + 0.8.15 Tomcat