Merged 2.0.0-m3 into feature/global_config_v2_endpoint

This commit is contained in:
Johannes Schnatterer
2018-08-01 10:30:38 +02:00
358 changed files with 24149 additions and 21316 deletions

View File

@@ -29,3 +29,8 @@ Desktop DF$
# jrebel
rebel.xml
\.pyc
# ui
scm-ui/build
scm-ui/coverage
/?node_modules/

20
Jenkinsfile vendored
View File

@@ -1,7 +1,7 @@
#!groovy
// Keep the version in sync with the one used in pom.xml in order to get correct syntax completion.
@Library('github.com/cloudogu/ces-build-lib@9aadeeb')
@Library('github.com/cloudogu/ces-build-lib@59d3e94')
import com.cloudogu.ces.cesbuildlib.*
node() { // No specific label
@@ -31,16 +31,14 @@ node() { // No specific label
}
stage('Unit Test') {
mvn 'test -Dsonia.scm.test.skip.hg=true'
mvn 'test -Dsonia.scm.test.skip.hg=true -Dmaven.test.failure.ignore=true'
}
stage('SonarQube') {
def sonarQube = new SonarQube(this, 'sonarcloud.io')
analyzeWith(mvn)
if (!sonarQube.waitForQualityGateWebhookToBeCalled()) {
if (!waitForQualityGateWebhookToBeCalled()) {
currentBuild.result = 'UNSTABLE'
}
}
@@ -97,6 +95,18 @@ void analyzeWith(Maven mvn) {
}
}
boolean waitForQualityGateWebhookToBeCalled() {
boolean isQualityGateSucceeded = true
timeout(time: 2, unit: 'MINUTES') { // Needed when there is no webhook for example
def qGate = waitForQualityGate()
echo "SonarQube Quality Gate status: ${qGate.status}"
if (qGate.status != 'OK') {
isQualityGateSucceeded = false
}
}
return isQualityGateSucceeded
}
String getCommitAuthorComplete() {
new Sh(this).returnStdOut 'hg log --branch . --limit 1 --template "{author}"'
}

55
pom.xml
View File

@@ -70,9 +70,9 @@
<module>scm-test</module>
<module>scm-plugins</module>
<module>scm-dao-xml</module>
<module>scm-ui</module>
<module>scm-webapp</module>
<module>scm-server</module>
<module>scm-clients</module>
</modules>
<repositories>
@@ -92,7 +92,6 @@
</snapshots>
</repository>
<!-- TODO remove jitpack after edison hal bugfix -->
<repository>
<id>jitpack</id>
<url>https://jitpack.io</url>
@@ -158,6 +157,33 @@
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.sdorra</groupId>
<artifactId>shiro-unit</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
<!-- TODO replace by proper version from maven central (group: com.github.sdorra) once its there. -->
<dependency>
<groupId>com.github.sdorra.shiro-static-permissions</groupId>
<artifactId>ssp-lib</artifactId>
<version>${ssp.version}</version>
</dependency>
<dependency>
<groupId>com.github.sdorra.shiro-static-permissions</groupId>
<artifactId>ssp-processor</artifactId>
<version>${ssp.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
@@ -225,6 +251,25 @@
</executions>
</plugin>
<plugin>
<groupId>com.github.legman</groupId>
<artifactId>legman-maven-plugin</artifactId>
<version>${legman.version}</version>
<configuration>
<fail>true</fail>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<!-- Prevent usage of guava annotations that would be silently ignored -> hard to find.
We use legman annotations instead, that provide additional features such as weak references. -->
<goal>guava-migration-check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -508,20 +553,20 @@
<servlet.version>3.0.1</servlet.version>
<jaxrs.version>2.0.1</jaxrs.version>
<resteasy.version>3.1.3.Final</resteasy.version>
<jersey-client.version>1.19.4</jersey-client.version>
<jackson.version>2.8.6</jackson.version>
<guice.version>4.0</guice.version>
<resteasy.version>3.1.3.Final</resteasy.version>
<!-- event bus -->
<legman.version>1.2.0</legman.version>
<legman.version>1.3.0</legman.version>
<!-- webserver -->
<jetty.version>9.2.10.v20150310</jetty.version>
<jetty.maven.version>9.2.10.v20150310</jetty.maven.version>
<!-- security libraries -->
<ssp.version>1.0.0-SNAPSHOT</ssp.version>
<ssp.version>967c8fd521</ssp.version>
<shiro.version>1.4.0</shiro.version>
<!-- repostitory libraries -->

View File

@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>sonia.scm</groupId>
<artifactId>scm</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>sonia.scm.clients</groupId>
<artifactId>scm-clients</artifactId>
<packaging>pom</packaging>
<version>2.0.0-SNAPSHOT</version>
<name>scm-clients</name>
<modules>
<module>scm-client-api</module>
<module>scm-client-impl</module>
<module>scm-cli-client</module>
</modules>
<dependencies>
<!--
scm-core with excludes.
TODO: create a module only for data objects.
-->
<dependency>
<artifactId>scm-core</artifactId>
<groupId>sonia.scm</groupId>
<type>jar</type>
<version>2.0.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>shiro-core</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
<exclusion>
<artifactId>aopalliance</artifactId>
<groupId>aopalliance</groupId>
</exclusion>
<exclusion>
<artifactId>guice</artifactId>
<groupId>com.google.inject</groupId>
</exclusion>
<exclusion>
<artifactId>guice-multibindings</artifactId>
<groupId>com.google.inject.extensions</groupId>
</exclusion>
<exclusion>
<artifactId>guice-servlet</artifactId>
<groupId>com.google.inject.extensions</groupId>
</exclusion>
<exclusion>
<artifactId>jersey-core</artifactId>
<groupId>com.sun.jersey</groupId>
</exclusion>
<exclusion>
<artifactId>guice-throwingproviders</artifactId>
<groupId>com.google.inject.extensions</groupId>
</exclusion>
<exclusion>
<artifactId>commons-lang</artifactId>
<groupId>commons-lang</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@@ -1,219 +0,0 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>scm-clients</artifactId>
<groupId>sonia.scm.clients</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>sonia.scm.clients</groupId>
<artifactId>scm-cli-client</artifactId>
<version>2.0.0-SNAPSHOT</version>
<name>scm-cli-client</name>
<dependencies>
<!-- fix javadoc -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>sonia.scm.clients</groupId>
<artifactId>scm-client-impl</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
<version>2.0.29</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.21</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.9.0</version>
<configuration>
<header>http://download.scm-manager.org/licenses/mvn-license.txt</header>
<includes>
<include>src/**</include>
<include>**/test/**</include>
</includes>
<excludes>
<exclude>target/**</exclude>
<exclude>.hg/**</exclude>
<exclude>**/*.ftl</exclude>
</excludes>
<strictCheck>true</strictCheck>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<mainClass>sonia.scm.cli.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>it</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>sonia.scm</groupId>
<artifactId>scm-webapp</artifactId>
<version>${project.version}</version>
<type>war</type>
<outputDirectory>${project.build.directory}/webapp</outputDirectory>
<destFileName>scm-webapp.war</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemPropertyVariables>
<scm.version>${project.version}</scm.version>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.maven.version}</version>
<configuration>
<stopPort>8085</stopPort>
<stopKey>STOP</stopKey>
<systemProperties>
<systemProperty>
<name>scm.home</name>
<value>target/scm-it</value>
</systemProperty>
<systemProperty>
<name>file.encoding</name>
<value>UTF-8</value>
</systemProperty>
</systemProperties>
<httpConnector>
<port>8081</port>
</httpConnector>
<webApp>
<contextPath>/scm</contextPath>
</webApp>
<war>${project.build.directory}/webapp/scm-webapp.war</war>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy-war</goal>
</goals>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -1,339 +0,0 @@
/**
* 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 ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.cli.cmd.CommandDescriptor;
import sonia.scm.cli.cmd.SubCommand;
import sonia.scm.cli.cmd.SubCommandHandler;
import sonia.scm.cli.cmd.SubCommandOptionHandler;
import sonia.scm.cli.config.ConfigOptionHandler;
import sonia.scm.cli.config.ScmClientConfig;
import sonia.scm.cli.config.ServerConfig;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Sebastian Sdorra
*/
public class App
{
/** the logger for App */
private static final Logger logger = LoggerFactory.getLogger(App.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public App()
{
this(System.in, System.out);
}
/**
* Constructs ...
*
*
* @param input
* @param output
*/
public App(BufferedReader input, PrintWriter output)
{
this.input = input;
this.output = output;
}
/**
* Constructs ...
*
*
* @param input
* @param output
*/
public App(InputStream input, OutputStream output)
{
this.input = new BufferedReader(new InputStreamReader(input));
this.output = new PrintWriter(output);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param args
*/
public static void main(String[] args)
{
new App().run(args);
}
/**
* Method description
*
*
* @param args
*/
protected void run(String[] args)
{
CmdLineParser parser = new CmdLineParser(this);
try
{
parser.parseArgument(args);
}
catch (CmdLineException ex)
{
// todo error handling
logger.warn("could not parse commandline", ex);
System.exit(1);
}
configureLogger();
loadConfig();
I18n i18n = new I18n();
if ((args.length == 0) || (subcommand == null) || help)
{
printHelp(parser, i18n);
}
else
{
subcommand.init(input, output, i18n, config);
subcommand.run(arguments);
}
IOUtil.close(input);
IOUtil.close(output);
}
/**
* Method description
*
*/
private void configureLogger()
{
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
lc.getLogger(Logger.ROOT_LOGGER_NAME).setLevel(loggingLevel);
}
/**
* Method description
*
*/
private void loadConfig()
{
if (config == null)
{
config = ScmClientConfig.getInstance().getDefaultConfig();
}
if (Util.isNotEmpty(serverUrl))
{
config.setServerUrl(serverUrl);
}
if (Util.isNotEmpty(username))
{
config.setUsername(username);
}
if (Util.isNotEmpty(password))
{
config.setPassword(password);
}
}
/**
* Method description
*
*
* @param parser
* @param i18n
*/
private void printHelp(CmdLineParser parser, I18n i18n)
{
output.println(i18n.getMessage(I18n.USAGE));
output.println();
output.append(i18n.getMessage(I18n.OPTIONS)).println(":");
output.println();
parser.printUsage(output, i18n.getBundle());
output.println();
output.append(i18n.getMessage(I18n.SUBCOMMANDS_TITLE)).println(":");
output.println();
String group = null;
List<CommandDescriptor> descList =
SubCommandHandler.getInstance().getDescriptors();
int length = 0;
for (CommandDescriptor desc : descList)
{
int l = desc.getName().length();
if (l > length)
{
length = l;
}
}
length += 5;
for (CommandDescriptor desc :
SubCommandHandler.getInstance().getDescriptors())
{
if ((group == null) ||!group.equals(desc.getGroup()))
{
output.println();
group = desc.getGroup();
output.append(i18n.getMessage(group)).println(":");
output.println();
}
int l = desc.getName().length();
output.append(" ").append(desc.getName());
l = length - l;
for (int i = 0; i < l; i++)
{
output.append(" ");
}
output.println(i18n.getMessage(desc.getUsage()));
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--config",
usage = "optionConfig",
metaVar = "config",
handler = ConfigOptionHandler.class,
aliases = { "-c" }
)
private ServerConfig config;
/** Field description */
@Option(
name = "--help",
usage = "optionHelpText",
aliases = { "-h" }
)
private boolean help = false;
/** Field description */
@Argument(index = 1, metaVar = "arg")
private List<String> arguments = new ArrayList<String>();
/** Field description */
private BufferedReader input;
/** Field description */
@Option(
name = "--logging-level",
usage = "optionLoggingLevel",
handler = LoggingLevelOptionHandler.class,
aliases = { "-l" }
)
private Level loggingLevel = Level.ERROR;
/** Field description */
private PrintWriter output;
/** Field description */
@Option(
name = "--password",
usage = "optionPassword",
aliases = { "-p" }
)
private String password;
/** Field description */
@Option(
name = "--server",
usage = "optionServerUrl",
aliases = { "-s" }
)
private String serverUrl;
/** Field description */
@Argument(
index = 0,
metaVar = "metaVar_command",
handler = SubCommandOptionHandler.class
)
private SubCommand subcommand;
/** Field description */
@Option(
name = "--user",
usage = "optionUsername",
aliases = { "-u" }
)
private String username;
}

View File

@@ -1,100 +0,0 @@
/**
* 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.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.OptionDef;
import org.kohsuke.args4j.spi.OptionHandler;
import org.kohsuke.args4j.spi.Parameters;
import org.kohsuke.args4j.spi.Setter;
/**
*
* @author Sebastian Sdorra
*/
public class BooleanModifyOptionHandler extends OptionHandler<Boolean>
{
/**
* Constructs ...
*
*
* @param parser
* @param option
* @param setter
*/
public BooleanModifyOptionHandler(CmdLineParser parser, OptionDef option,
Setter<? super Boolean> setter)
{
super(parser, option, setter);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param params
*
* @return
*
* @throws CmdLineException
*/
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
Boolean bool = Boolean.valueOf(params.getParameter(0));
setter.addValue(bool);
return 1;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getDefaultMetaVariable()
{
return I18n.BOOLEAN;
}
}

View File

@@ -1,138 +0,0 @@
/**
* 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.slf4j.Logger;
import org.slf4j.LoggerFactory;
//~--- JDK imports ------------------------------------------------------------
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
*
* @author Sebastian Sdorra
*/
public class I18n
{
/** Field description */
public static final String ERROR = "error";
/** Field description */
public static final String GROUP_NOT_FOUND = "groupNotFound";
/** Field description */
public static final String LEVEL = "level";
public static final String BOOLEAN = "boolean";
/** Field description */
public static final String OPTIONS = "options";
/** Field description */
public static final String REPOSITORY_NOT_FOUND = "repositoryNotFound";
/** Field description */
public static final String RESOURCE_BUNDLE = "sonia.resources.i18n";
/** Field description */
public static final String SUBCOMMANDS_TITLE = "subCommandsTitle";
/** Field description */
public static final String USAGE = "usage";
/** Field description */
public static final String USER_NOT_FOUND = "userNotFound";
/** the logger for I18n */
private static final Logger logger = LoggerFactory.getLogger(I18n.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public I18n()
{
bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public ResourceBundle getBundle()
{
return bundle;
}
/**
* Method description
*
*
* @param key
*
* @return
*/
public String getMessage(String key)
{
String value = key;
try
{
value = bundle.getString(key);
}
catch (MissingResourceException ex)
{
logger.warn("could not find resource for key {}", key);
}
return value;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private ResourceBundle bundle;
}

View File

@@ -1,104 +0,0 @@
/**
* 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 ch.qos.logback.classic.Level;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.OptionDef;
import org.kohsuke.args4j.spi.OptionHandler;
import org.kohsuke.args4j.spi.Parameters;
import org.kohsuke.args4j.spi.Setter;
/**
*
* @author Sebastian Sdorra
*/
public class LoggingLevelOptionHandler extends OptionHandler<Level>
{
/**
* Constructs ...
*
*
* @param parser
* @param option
* @param setter
*/
public LoggingLevelOptionHandler(CmdLineParser parser, OptionDef option,
Setter<? super Level> setter)
{
super(parser, option, setter);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param params
*
* @return
*
* @throws CmdLineException
*/
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
String value = params.getParameter(0);
Level l = Level.toLevel(value);
setter.addValue(l);
return 1;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getDefaultMetaVariable()
{
return I18n.LEVEL;
}
}

View File

@@ -1,96 +0,0 @@
/**
* Copyright (c) 2014, 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.kohsuke.args4j.Localizable;
//~--- JDK imports ------------------------------------------------------------
import java.util.Locale;
/**
* TODO create real implementation
*
* @author Sebastian Sdorra
*/
public class SimpleLocalizable implements Localizable
{
/**
* Constructs ...
*
*
* @param message
*/
public SimpleLocalizable(String message)
{
this.message = message;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param args
*
* @return
*/
@Override
public String format(Object... args)
{
return message;
}
/**
* Method description
*
*
* @param locale
* @param args
*
* @return
*/
@Override
public String formatWithLocale(Locale locale, Object... args)
{
return message;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private final String message;
}

View File

@@ -1,68 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.group.Group;
//~--- JDK imports ------------------------------------------------------------
import java.util.List;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "add-members",
usage = "usageAddMember",
group = "group"
)
public class AddMembersSubCommand extends MembersSubCommand
{
/**
* Method description
*
*
* @param group
* @param members
*/
@Override
protected void modifyMembers(Group group, List<String> members)
{
group.getMembers().addAll(members);
}
}

View File

@@ -1,147 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Option;
import sonia.scm.repository.Permission;
import sonia.scm.repository.PermissionType;
//~--- JDK imports ------------------------------------------------------------
import java.util.List;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "add-permission",
usage = "usageAddPermission",
group = "repository"
)
public class AddPermissionSubCommand extends PermissionSubCommand
{
/**
* Method description
*
*
* @return
*/
public PermissionType getType()
{
return type;
}
/**
* Method description
*
*
* @return
*/
public boolean isGroup()
{
return group;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param group
*/
public void setGroup(boolean group)
{
this.group = group;
}
/**
* Method description
*
*
* @param type
*/
public void setType(PermissionType type)
{
this.type = type;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param permissions
*/
@Override
protected void modifyPermissions(List<Permission> permissions)
{
permissions.add(new Permission(name, type, group));
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--group",
usage = "optionPermissionGroup",
aliases = { "-g" }
)
private boolean group = false;
/** Field description */
@Option(
name = "--name",
usage = "optionPermissionName",
required = true,
aliases = { "-n" }
)
private String name;
/** Field description */
@Option(
name = "--type",
usage = "optionPermissionType",
required = true,
metaVar = "permissiontype",
aliases = { "-t" }
)
private PermissionType type;
}

View File

@@ -1,53 +0,0 @@
/**
* 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.cmd;
//~--- JDK imports ------------------------------------------------------------
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
*
* @author Sebastian Sdorra
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Command
{
String name() default "";
String usage() default "";
String group() default "misc";
}

View File

@@ -1,204 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.AssertUtil;
import sonia.scm.util.Util;
/**
*
* @author Sebastian Sdorra
*/
public class CommandDescriptor implements Comparable<CommandDescriptor>
{
/** the logger for CommandDescriptor */
private static final Logger logger =
LoggerFactory.getLogger(CommandDescriptor.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param commandClass
*/
public CommandDescriptor(Class<? extends SubCommand> commandClass)
{
AssertUtil.assertIsNotNull(commandClass);
this.commandClass = commandClass;
Command cmd = commandClass.getAnnotation(Command.class);
if (cmd != null)
{
this.name = cmd.name();
this.group = cmd.group();
this.usage = cmd.usage();
}
if (Util.isEmpty(name))
{
name = commandClass.getSimpleName();
}
}
/**
* Constructs ...
*
*
* @param name
* @param usage
* @param commandClass
*/
public CommandDescriptor(String name, String usage,
Class<? extends SubCommand> commandClass)
{
this.name = name;
this.usage = usage;
this.commandClass = commandClass;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param desc
*
* @return
*/
@Override
public int compareTo(CommandDescriptor desc)
{
int result = group.compareTo(desc.group);
if (result == 0)
{
result = name.compareTo(desc.name);
}
return result;
}
/**
* Method description
*
*
* @return
*/
public SubCommand createSubCommand()
{
SubCommand command = null;
try
{
command = commandClass.newInstance();
command.setCommandName(name);
}
catch (Exception ex)
{
logger.error("could not create SubCommand {}", commandClass.getName());
}
return command;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public Class<? extends SubCommand> getCommandClass()
{
return commandClass;
}
/**
* Method description
*
*
* @return
*/
public String getGroup()
{
return group;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public String getUsage()
{
return usage;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Class<? extends SubCommand> commandClass;
/** Field description */
private String group = "misc";
/** Field description */
private String name;
/** Field description */
private String usage = "";
}

View File

@@ -1,212 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Option;
import sonia.scm.cli.wrapper.GroupWrapper;
import sonia.scm.client.ScmClientSession;
import sonia.scm.group.Group;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "create-group",
usage = "usageCreateGroup",
group = "group"
)
public class CreateGroupSubCommand extends TemplateSubCommand
{
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return description;
}
/**
* Method description
*
*
* @return
*/
public List<String> getMembers()
{
return members;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return type;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param description
*/
public void setDescription(String description)
{
this.description = description;
}
/**
* Method description
*
*
* @param members
*/
public void setMembers(List<String> members)
{
this.members = members;
}
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
/**
* Method description
*
*
* @param type
*/
public void setType(String type)
{
this.type = type;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
Group group = new Group();
group.setName(name);
group.setDescription(description);
group.setType(type);
group.setMembers(members);
ScmClientSession session = createSession();
session.getGroupHandler().create(group);
Map<String, Object> env = new HashMap<String, Object>();
env.put("group", new GroupWrapper(group));
renderTemplate(env, GetGroupSubCommand.TEMPLATE);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--description",
usage = "optionGroupDescription",
aliases = { "-d" }
)
private String description;
/** Field description */
@Option(
name = "--member",
usage = "optionGroupMember",
aliases = { "-m" }
)
private List<String> members;
/** Field description */
@Option(
name = "--name",
usage = "optionGroupName",
required = true,
aliases = { "-n" }
)
private String name;
/** Field description */
@Option(
name = "--type",
usage = "optionGroupType",
aliases = { "-t" }
)
private String type = "xml";
}

View File

@@ -1,220 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Option;
import sonia.scm.cli.wrapper.RepositoryWrapper;
import sonia.scm.client.ScmClientSession;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "create-repository",
usage = "usageCreateRepository",
group = "repository"
)
public class CreateRepositorySubCommand extends TemplateSubCommand
{
/**
* Method description
*
*
* @return
*/
public String getContact()
{
return contact;
}
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return description;
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return type;
}
/**
* Method description
*
*
* @return
*/
public boolean isPublicReadable()
{
return publicReadable;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param contact
*/
public void setContact(String contact)
{
this.contact = contact;
}
/**
* Method description
*
*
* @param description
*/
public void setDescription(String description)
{
this.description = description;
}
/**
* Method description
*
*
* @param publicReadable
*/
public void setPublicReadable(boolean publicReadable)
{
this.publicReadable = publicReadable;
}
/**
* Method description
*
*
* @param type
*/
public void setType(String type)
{
this.type = type;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
Repository repository = new Repository();
repository.setName(name);
repository.setType(type);
repository.setContact(contact);
repository.setDescription(description);
ScmClientSession session = createSession();
session.getRepositoryHandler().create(repository);
Map<String, Object> env = new HashMap<String, Object>();
env.put("repository", new RepositoryWrapper(config, repository));
renderTemplate(env, GetRepositorySubCommand.TEMPLATE);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--contact",
usage = "optionRepositoryContact",
aliases = { "-c" }
)
private String contact;
/** Field description */
@Option(
name = "--description",
usage = "optionRepositoryDescription",
aliases = { "-d" }
)
private String description;
/** Field description */
@Option(
name = "--name",
required = true,
usage = "optionRepositoryName",
aliases = { "-n" }
)
private String name;
/** Field description */
@Option(
name = "--public",
usage = "optionRepositoryPublic",
aliases = { "-p" }
)
private boolean publicReadable;
/** Field description */
@Option(
name = "--type",
required = true,
usage = "optionRepositoryType",
aliases = { "-t" }
)
private String type;
}

View File

@@ -1,274 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Option;
import sonia.scm.cli.wrapper.UserWrapper;
import sonia.scm.client.ScmClientSession;
import sonia.scm.user.User;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "create-user",
usage = "usageCreateUser",
group = "user"
)
public class CreateUserSubCommand extends TemplateSubCommand
{
/**
* Method description
*
*
* @return
*/
public String getDisplayName()
{
return displayName;
}
/**
* Method description
*
*
* @return
*/
public String getMail()
{
return mail;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public String getPassword()
{
return password;
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return type;
}
/**
* Method description
*
*
* @return
*/
public boolean isAdmin()
{
return admin;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param admin
*/
public void setAdmin(boolean admin)
{
this.admin = admin;
}
/**
* Method description
*
*
* @param displayName
*/
public void setDisplayName(String displayName)
{
this.displayName = displayName;
}
/**
* Method description
*
*
* @param mail
*/
public void setMail(String mail)
{
this.mail = mail;
}
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
/**
* Method description
*
*
* @param password
*/
public void setPassword(String password)
{
this.password = password;
}
/**
* Method description
*
*
* @param type
*/
public void setType(String type)
{
this.type = type;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
User user = new User();
user.setName(name);
user.setAdmin(admin);
user.setDisplayName(displayName);
user.setPassword(password);
user.setMail(mail);
user.setType(type);
ScmClientSession session = createSession();
session.getUserHandler().create(user);
Map<String, Object> env = new HashMap<String, Object>();
env.put("user", new UserWrapper(user));
renderTemplate(env, GetUserSubCommand.TEMPLATE);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--admin",
usage = "optionUserAdmin",
aliases = { "-a" }
)
private boolean admin = false;
/** Field description */
@Option(
name = "--display-name",
usage = "optionUserDisplayName",
required = true,
aliases = { "-d" }
)
private String displayName;
/** Field description */
@Option(
name = "--mail",
usage = "optionUserMail",
aliases = { "-m" }
)
private String mail;
/** Field description */
@Option(
name = "--name",
usage = "optionUserName",
required = true,
aliases = { "-n" }
)
private String name;
/** Field description */
@Option(
name = "--password",
usage = "optionUserPassword",
aliases = { "-p" }
)
private String password;
/** Field description */
@Option(
name = "--type",
usage = "optionUserType",
aliases = { "-t" }
)
private String type = "xml";
}

View File

@@ -1,61 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cli.config.ScmClientConfig;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "delete-config",
usage = "usageDeleteConfig",
group = "config"
)
public class DeleteConfigSubCommand extends SubCommand
{
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientConfig.getInstance().delete();
}
}

View File

@@ -1,101 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import sonia.scm.client.ScmClientSession;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "delete-group",
usage = "usageDeleteGroup",
group = "group"
)
public class DeleteGroupSubCommand extends SubCommand
{
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
session.getGroupHandler().delete(name);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Argument(
usage = "optionGroupName",
metaVar = "groupname",
required = true
)
private String name;
}

View File

@@ -1,68 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.group.Group;
//~--- JDK imports ------------------------------------------------------------
import java.util.List;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "delete-members",
usage = "usageDeleteMembers",
group = "group"
)
public class DeleteMembersSubCommand extends MembersSubCommand
{
/**
* Method description
*
*
* @param group
* @param members
*/
@Override
protected void modifyMembers(Group group, List<String> members)
{
group.getMembers().removeAll(members);
}
}

View File

@@ -1,117 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Option;
import sonia.scm.repository.Permission;
//~--- JDK imports ------------------------------------------------------------
import java.util.Iterator;
import java.util.List;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "delete-permission",
usage = "usageDeletePermission",
group = "repository"
)
public class DeletePermissionSubCommand extends PermissionSubCommand
{
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param permissions
*/
@Override
protected void modifyPermissions(List<Permission> permissions)
{
Iterator<Permission> it = permissions.iterator();
while (it.hasNext())
{
Permission p = it.next();
if (name.equals(p.getName()))
{
it.remove();
}
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--name",
usage = "optionPermissionName",
required = true,
aliases = { "-n" }
)
private String name;
}

View File

@@ -1,101 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import sonia.scm.client.ScmClientSession;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "delete-repository",
usage = "usageDeleteRepository",
group = "repository"
)
public class DeleteRepositorySubCommand extends SubCommand
{
/**
* Method description
*
*
* @return
*/
public String getId()
{
return id;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param id
*/
public void setId(String id)
{
this.id = id;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
session.getRepositoryHandler().delete(id);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Argument(
usage = "optionRepositoryId",
metaVar = "repositoryid",
required = true
)
private String id;
}

View File

@@ -1,101 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import sonia.scm.client.ScmClientSession;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "delete-user",
usage = "usageDeleteUser",
group = "user"
)
public class DeleteUserSubCommand extends SubCommand
{
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
session.getUserHandler().delete(name);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Argument(
usage = "optionUserName",
metaVar = "username",
required = true
)
private String name;
}

View File

@@ -1,98 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
/**
*
* @author Sebastian Sdorra
* @since 1.41
*/
@Command(
name = "encrypt",
usage = "usageEncrypt",
group = "security"
)
public class EncryptSubCommand extends SubCommand
{
/**
* Method description
*
*
* @return
*/
public String getValue()
{
return value;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param value
*/
public void setValue(String value)
{
this.value = value;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
String enc = createSession().getSecurityHandler().encrypt(value);
output.println(enc);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Argument(
usage = "optionEncryptValue",
metaVar = "value",
required = true
)
private String value;
}

View File

@@ -1,55 +0,0 @@
/**
* 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.cmd;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "generate-key",
usage = "usageGenerateKey",
group = "security"
)
public class GenerateKeySubCommand extends SubCommand
{
/**
* Method description
*
*/
@Override
protected void run()
{
output.println(createSession().getSecurityHandler().generateKey());
}
}

View File

@@ -1,125 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import sonia.scm.cli.I18n;
import sonia.scm.cli.wrapper.GroupWrapper;
import sonia.scm.client.ScmClientSession;
import sonia.scm.group.Group;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "get-group",
usage = "usageGetGroup",
group = "group"
)
public class GetGroupSubCommand extends TemplateSubCommand
{
/** Field description */
public static final String TEMPLATE = "/sonia/resources/get-group.ftl";
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
Group group = session.getGroupHandler().get(name);
if (group != null)
{
Map<String, Object> env = new HashMap<String, Object>();
env.put("group", new GroupWrapper(group));
renderTemplate(env, TEMPLATE);
}
else
{
output.println(i18n.getMessage(I18n.GROUP_NOT_FOUND));
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Argument(
usage = "optionGroupName",
metaVar = "groupname",
required = true
)
private String name;
}

View File

@@ -1,140 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import sonia.scm.cli.I18n;
import sonia.scm.cli.wrapper.RepositoryWrapper;
import sonia.scm.client.ScmClientSession;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "get-repository",
usage = "usageGetRepository",
group = "repository"
)
public class GetRepositorySubCommand extends TemplateSubCommand
{
/** Field description */
public static final String TEMPLATE = "/sonia/resources/get-repository.ftl";
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getId()
{
return id;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param id
*/
public void setId(String id)
{
this.id = id;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
Repository repository;
int index = id.indexOf("/");
if (index > 0)
{
String type = id.substring(0, index);
String name = id.substring(index + 1);
repository = session.getRepositoryHandler().get(type, name);
}
else
{
repository = session.getRepositoryHandler().get(id);
}
if (repository != null)
{
Map<String, Object> env = new HashMap<String, Object>();
env.put("repository", new RepositoryWrapper(config, repository));
renderTemplate(env, TEMPLATE);
}
else
{
output.println(i18n.getMessage(I18n.REPOSITORY_NOT_FOUND));
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Argument(
usage = "optionRepositoryIdOrTypeAndName",
metaVar = "repositoryid",
required = true
)
private String id;
}

View File

@@ -1,125 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import sonia.scm.cli.I18n;
import sonia.scm.cli.wrapper.UserWrapper;
import sonia.scm.client.ScmClientSession;
import sonia.scm.user.User;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "get-user",
usage = "usageGetUser",
group = "user"
)
public class GetUserSubCommand extends TemplateSubCommand
{
/** Field description */
public static final String TEMPLATE = "/sonia/resources/get-user.ftl";
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
User user = session.getUserHandler().get(name);
if (user != null)
{
Map<String, Object> env = new HashMap<String, Object>();
env.put("user", new UserWrapper(user));
renderTemplate(env, TEMPLATE);
}
else
{
output.println(i18n.getMessage(I18n.USER_NOT_FOUND));
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Argument(
usage = "optionUserName",
metaVar = "username",
required = true
)
private String name;
}

View File

@@ -1,186 +0,0 @@
/**
* Copyright (c) 2014, 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.io.Files;
import org.kohsuke.args4j.Option;
import sonia.scm.ConfigurationException;
import sonia.scm.client.ImportBundleRequest;
import sonia.scm.client.ScmClientSession;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
/**
*
* @author Sebastian Sdorra
* @since 1.43
*/
@Command(
name = "import-from-bundle",
usage = "usageImportBundle",
group = "repository"
)
public class ImportBundleSubCommand extends ImportSubCommand
{
/**
* Method description
*
*
* @return
*/
public File getBundle()
{
return bundle;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public boolean isCompressed()
{
return compressed;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param bundle
*/
public void setBundle(File bundle)
{
this.bundle = bundle;
}
/**
* Method description
*
*
* @param compressed
*/
public void setCompressed(boolean compressed)
{
this.compressed = compressed;
}
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
if (!bundle.exists())
{
throw new ConfigurationException("could not find bundle");
}
else
{
ScmClientSession session = createSession();
ImportBundleRequest req = new ImportBundleRequest(getType(), name,
Files.asByteSource(bundle));
req.setCompressed(compressed);
Repository repository =
session.getRepositoryHandler().importFromBundle(req);
printImportedRepository(repository);
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--bundle",
required = true,
usage = "optionRepositoryBundle",
aliases = { "-b" }
)
private File bundle;
/** Field description */
@Option(
name = "--compressed",
usage = "optionRepositoryBundleCompressed",
aliases = { "-c" }
)
private boolean compressed = false;
/** Field description */
@Option(
name = "--name",
required = true,
usage = "optionRepositoryName",
aliases = { "-n" }
)
private String name;
}

View File

@@ -1,82 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.Maps;
import sonia.scm.client.ImportResultWrapper;
import sonia.scm.client.ScmClientSession;
//~--- JDK imports ------------------------------------------------------------
import java.util.Map;
/**
*
* @author Sebastian Sdorra
* @since 1.43
*/
@Command(
name = "import-from-directory",
usage = "usageImportDirectory",
group = "repository"
)
public class ImportDirectorySubCommand extends ImportSubCommand
{
/** Field description */
public static final String TEMPLATE =
"/sonia/resources/import-from-directory.ftl";
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
ImportResultWrapper wrapper =
session.getRepositoryHandler().importFromDirectory(getType());
Map<String, Object> env = Maps.newHashMap();
env.put("importedDirectories", wrapper.getImportedDirectories());
env.put("failedDirectories", wrapper.getFailedDirectories());
renderTemplate(env, TEMPLATE);
}
}

View File

@@ -1,104 +0,0 @@
/**
* Copyright (c) 2014, 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.Maps;
import org.kohsuke.args4j.Argument;
import sonia.scm.cli.wrapper.RepositoryWrapper;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import java.util.Map;
/**
*
* @author Sebastian Sdorra
* @since 1.43
*/
public abstract class ImportSubCommand extends TemplateSubCommand
{
/**
* Method description
*
*
* @return
*/
public String getType()
{
return type;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param type
*/
public void setType(String type)
{
this.type = type;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param repository
*/
protected void printImportedRepository(Repository repository)
{
Map<String, Object> env = Maps.newHashMap();
env.put("repository", new RepositoryWrapper(config, repository));
renderTemplate(env, GetRepositorySubCommand.TEMPLATE);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Argument(
usage = "optionRepositoryType",
metaVar = "repositorytype",
required = true
)
private String type;
}

View File

@@ -1,146 +0,0 @@
/**
* Copyright (c) 2014, 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.Maps;
import org.kohsuke.args4j.Option;
import sonia.scm.client.ImportUrlRequest;
import sonia.scm.client.ScmClientSession;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import java.net.URL;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "import-from-url",
usage = "usageImportUrl",
group = "repository"
)
public class ImportUrlSubCommand extends ImportSubCommand
{
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public URL getUrl()
{
return url;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
/**
* Method description
*
*
* @param url
*/
public void setUrl(URL url)
{
this.url = url;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
ImportUrlRequest request = new ImportUrlRequest(getType(), name,
url.toExternalForm());
Repository repository =
session.getRepositoryHandler().importFromUrl(request);
printImportedRepository(repository);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--name",
required = true,
usage = "optionRepositoryName",
aliases = { "-n" }
)
private String name;
/** Field description */
@Option(
name = "--url",
required = true,
usage = "optionRemoteRepositoryUrl",
aliases = { "-r" }
)
private URL url;
}

View File

@@ -1,79 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cli.wrapper.WrapperUtil;
import sonia.scm.client.ScmClientSession;
import sonia.scm.group.Group;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "list-groups",
usage = "usageListGroups",
group = "group"
)
public class ListGroupsSubCommand extends TemplateSubCommand
{
/** Field description */
public static final String TEMPLATE = "/sonia/resources/list-groups.ftl";
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
List<Group> groups = session.getGroupHandler().getAll();
Map<String, Object> env = new HashMap<String, Object>();
env.put("groups", WrapperUtil.wrapGroups(groups));
renderTemplate(env, TEMPLATE);
}
}

View File

@@ -1,80 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cli.wrapper.WrapperUtil;
import sonia.scm.client.ScmClientSession;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "list-repositories",
usage = "usageListRepositories",
group = "repository"
)
public class ListRepositoriesSubCommand extends TemplateSubCommand
{
/** Field description */
public static final String TEMPLATE =
"/sonia/resources/list-repositories.ftl";
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
List<Repository> repositories = session.getRepositoryHandler().getAll();
Map<String, Object> env = new HashMap<String, Object>();
env.put("repositories", WrapperUtil.wrapRepositories(config, repositories));
renderTemplate(env, TEMPLATE);
}
}

View File

@@ -1,79 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cli.wrapper.WrapperUtil;
import sonia.scm.client.ScmClientSession;
import sonia.scm.user.User;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "list-users",
usage = "usageListUsers",
group = "user"
)
public class ListUsersSubCommand extends TemplateSubCommand
{
/** Field description */
public static final String TEMPLATE = "/sonia/resources/list-users.ftl";
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
List<User> users = session.getUserHandler().getAll();
Map<String, Object> env = new HashMap<String, Object>();
env.put("users", WrapperUtil.wrapUsers(users));
renderTemplate(env, TEMPLATE);
}
}

View File

@@ -1,164 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import sonia.scm.cli.I18n;
import sonia.scm.cli.wrapper.GroupWrapper;
import sonia.scm.client.GroupClientHandler;
import sonia.scm.client.ScmClientSession;
import sonia.scm.group.Group;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
public abstract class MembersSubCommand extends TemplateSubCommand
{
/**
* Method description
*
*
* @param group
* @param members
*/
protected abstract void modifyMembers(Group group, List<String> members);
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public List<String> getMembers()
{
return members;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param members
*/
public void setMembers(List<String> members)
{
this.members = members;
}
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
GroupClientHandler handler = session.getGroupHandler();
Group group = handler.get(name);
if (group != null)
{
modifyMembers(group, members);
handler.modify(group);
Map<String, Object> env = new HashMap<String, Object>();
env.put("group", new GroupWrapper(group));
renderTemplate(env, GetGroupSubCommand.TEMPLATE);
}
else
{
output.println(i18n.getMessage(I18n.GROUP_NOT_FOUND));
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--member",
usage = "optionGroupMember",
required = true,
aliases = { "-m" }
)
private List<String> members;
/** Field description */
@Argument(
usage = "optionGroupName",
metaVar = "groupname",
required = true
)
private String name;
}

View File

@@ -1,139 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import sonia.scm.cli.I18n;
import sonia.scm.cli.wrapper.GroupWrapper;
import sonia.scm.client.GroupClientHandler;
import sonia.scm.client.ScmClientSession;
import sonia.scm.group.Group;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "modify-group",
usage = "usageModifyGroup",
group = "group"
)
public class ModifyGroupSubCommand extends TemplateSubCommand
{
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return description;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param description
*/
public void setDescription(String description)
{
this.description = description;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
GroupClientHandler handler = session.getGroupHandler();
Group group = handler.get(name);
if (group != null)
{
if (Util.isNotEmpty(description))
{
group.setDescription(description);
}
handler.modify(group);
Map<String, Object> env = new HashMap<String, Object>();
env.put("group", new GroupWrapper(group));
renderTemplate(env, GetGroupSubCommand.TEMPLATE);
}
else
{
output.println(i18n.getMessage(I18n.GROUP_NOT_FOUND));
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--description",
usage = "optionGroupDescription",
aliases = { "-d" }
)
private String description;
/** Field description */
@Argument(
usage = "optionGroupName",
metaVar = "groupname",
required = true
)
private String name;
}

View File

@@ -1,269 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import sonia.scm.cli.BooleanModifyOptionHandler;
import sonia.scm.cli.I18n;
import sonia.scm.cli.wrapper.RepositoryWrapper;
import sonia.scm.client.RepositoryClientHandler;
import sonia.scm.client.ScmClientSession;
import sonia.scm.repository.Repository;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "modify-repository",
usage = "usageModifyRepository",
group = "repository"
)
public class ModifyRepositorySubCommand extends TemplateSubCommand
{
/**
* Method description
*
*
* @return
*/
public Boolean getArchvied()
{
return archvied;
}
/**
* Method description
*
*
* @return
*/
public String getContact()
{
return contact;
}
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return description;
}
/**
* Method description
*
*
* @return
*/
public String getId()
{
return id;
}
/**
* Method description
*
*
* @return
*/
public Boolean getPublicReadable()
{
return publicReadable;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param archvied
*/
public void setArchvied(Boolean archvied)
{
this.archvied = archvied;
}
/**
* Method description
*
*
* @param contact
*/
public void setContact(String contact)
{
this.contact = contact;
}
/**
* Method description
*
*
* @param description
*/
public void setDescription(String description)
{
this.description = description;
}
/**
* Method description
*
*
* @param id
*/
public void setId(String id)
{
this.id = id;
}
/**
* Method description
*
*
* @param publicReadable
*/
public void setPublicReadable(Boolean publicReadable)
{
this.publicReadable = publicReadable;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
RepositoryClientHandler handler = session.getRepositoryHandler();
Repository repository = handler.get(id);
if (repository != null)
{
if (Util.isNotEmpty(contact))
{
repository.setContact(contact);
}
if (Util.isNotEmpty(description))
{
repository.setDescription(description);
}
if (archvied != null)
{
repository.setArchived(archvied);
}
if (publicReadable != null)
{
repository.setPublicReadable(publicReadable);
}
handler.modify(repository);
Map<String, Object> env = new HashMap<String, Object>();
env.put("repository", new RepositoryWrapper(config, repository));
renderTemplate(env, GetRepositorySubCommand.TEMPLATE);
}
else
{
output.println(i18n.getMessage(I18n.REPOSITORY_NOT_FOUND));
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--archived",
usage = "optionRepositoryArchive",
aliases = { "-a" },
handler = BooleanModifyOptionHandler.class
)
private Boolean archvied;
/** Field description */
@Option(
name = "--contact",
usage = "optionRepositoryContact",
aliases = { "-c" }
)
private String contact;
/** Field description */
@Option(
name = "--description",
usage = "optionRepositoryDescription",
aliases = { "-d" }
)
private String description;
/** Field description */
@Argument(
usage = "optionRepositoryId",
metaVar = "repositoryid",
required = true
)
private String id;
/** Field description */
@Option(
name = "--public",
usage = "optionRepositoryPublic",
aliases = { "-p" },
handler = BooleanModifyOptionHandler.class
)
private Boolean publicReadable;
}

View File

@@ -1,231 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import sonia.scm.cli.I18n;
import sonia.scm.cli.wrapper.UserWrapper;
import sonia.scm.client.ScmClientSession;
import sonia.scm.client.UserClientHandler;
import sonia.scm.user.User;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "modify-user",
usage = "usageModifyUser",
group = "user"
)
public class ModifyUserSubCommand extends TemplateSubCommand
{
/**
* Method description
*
*
* @return
*/
public String getDisplayName()
{
return displayName;
}
/**
* Method description
*
*
* @return
*/
public String getMail()
{
return mail;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public String getPassword()
{
return password;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param displayName
*/
public void setDisplayName(String displayName)
{
this.displayName = displayName;
}
/**
* Method description
*
*
* @param mail
*/
public void setMail(String mail)
{
this.mail = mail;
}
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
/**
* Method description
*
*
* @param password
*/
public void setPassword(String password)
{
this.password = password;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
UserClientHandler handler = session.getUserHandler();
User user = handler.get(name);
if (user != null)
{
if (Util.isNotEmpty(displayName))
{
user.setDisplayName(displayName);
}
if (Util.isNotEmpty(mail))
{
user.setMail(mail);
}
if (Util.isNotEmpty(password))
{
user.setPassword(password);
}
handler.modify(user);
Map<String, Object> env = new HashMap<String, Object>();
env.put("user", new UserWrapper(user));
renderTemplate(env, GetUserSubCommand.TEMPLATE);
}
else
{
output.println(i18n.getMessage(I18n.USER_NOT_FOUND));
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(
name = "--display-name",
usage = "optionUserDisplayName",
aliases = { "-d" }
)
private String displayName;
/** Field description */
@Option(
name = "--mail",
usage = "optionUserMail",
aliases = { "-m" }
)
private String mail;
/** Field description */
@Argument(
usage = "optionUserName",
metaVar = "username",
required = true
)
private String name;
/** Field description */
@Option(
name = "--password",
usage = "optionUserPassword",
aliases = { "-p" }
)
private String password;
}

View File

@@ -1,141 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.Argument;
import sonia.scm.cli.I18n;
import sonia.scm.cli.wrapper.RepositoryWrapper;
import sonia.scm.client.RepositoryClientHandler;
import sonia.scm.client.ScmClientSession;
import sonia.scm.repository.Permission;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
public abstract class PermissionSubCommand extends TemplateSubCommand
{
/**
* Method description
*
*
* @param permissions
*/
protected abstract void modifyPermissions(List<Permission> permissions);
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getId()
{
return id;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param id
*/
public void setId(String id)
{
this.id = id;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
ScmClientSession session = createSession();
RepositoryClientHandler handler = session.getRepositoryHandler();
Repository repository = handler.get(id);
if (repository != null)
{
List<Permission> permissions = repository.getPermissions();
if (permissions == null)
{
permissions = new ArrayList<Permission>();
}
modifyPermissions(permissions);
repository.setPermissions(permissions);
handler.modify(repository);
Map<String, Object> env = new HashMap<String, Object>();
env.put("repository", new RepositoryWrapper(config, repository));
renderTemplate(env, GetRepositorySubCommand.TEMPLATE);
}
else
{
output.println(i18n.getMessage(I18n.REPOSITORY_NOT_FOUND));
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Argument(
usage = "optionRepositoryId",
metaVar = "repositoryid",
required = true
)
private String id;
}

View File

@@ -1,67 +0,0 @@
/**
* 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.cmd;
import sonia.scm.ScmState;
import sonia.scm.client.ScmClientSession;
import sonia.scm.util.Util;
/**
*
* @author Sebastian Sdorra
* @version 1.9
*/
@Command(
name = "server-version",
usage = "usageServerVersion",
group = "misc"
)
public class ServerVersionSubCommand extends SubCommand
{
@Override
protected void run()
{
ScmClientSession session = createSession();
ScmState state = session.getState();
String version = null;
if ( state != null ){
version = state.getVersion();
}
if ( Util.isEmpty(version) ){
version = VersionSubCommand.DEFAULT_VERSION;
}
output.append("scm-manager version: ").println( version );
}
}

View File

@@ -1,62 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cli.config.ScmClientConfig;
/**
*
* @author Sebastian Sdorra
*/
@Command(
name = "store-config",
usage = "usageStoreConfig",
group = "config"
)
public class StoreConfigSubCommand extends SubCommand
{
/**
* Method description
*
*/
@Override
protected void run()
{
output.println("store config");
ScmClientConfig.getInstance().store();
}
}

View File

@@ -1,235 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.cli.I18n;
import sonia.scm.cli.config.ServerConfig;
import sonia.scm.client.ScmClient;
import sonia.scm.client.ScmClientSession;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Collection;
/**
*
* @author Sebastian Sdorra
*/
public abstract class SubCommand
{
/** the logger for SubCommand */
private static final Logger logger =
LoggerFactory.getLogger(SubCommand.class);
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
protected abstract void run();
/**
* Method description
*
*
* @param input
* @param output
* @param i18n
* @param config
*/
public void init(BufferedReader input, PrintWriter output, I18n i18n,
ServerConfig config)
{
this.input = input;
this.output = output;
this.i18n = i18n;
this.config = config;
}
/**
* Method description
*
*
* @param args
*/
public void run(Collection<String> args)
{
CmdLineParser parser = new CmdLineParser(this);
try
{
parser.parseArgument(args);
if (help)
{
parser.printUsage(output, i18n.getBundle());
System.exit(1);
}
else
{
try
{
run();
}
finally
{
IOUtil.close(session);
}
}
}
catch (CmdLineException ex)
{
if (logger.isWarnEnabled())
{
logger.warn("could not parse comannd line", ex);
}
if (!help)
{
output.append(i18n.getMessage(I18n.ERROR)).append(": ");
output.println(ex.getMessage());
output.println();
}
printHelp(parser);
}
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getCommandName()
{
return commandName;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*/
public void setCommandName(String name)
{
this.commandName = name;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @return
*/
protected ScmClientSession createSession()
{
if (Util.isNotEmpty(config.getUsername())
&& Util.isNotEmpty(config.getPassword()))
{
session = ScmClient.createSession(config.getServerUrl(),
config.getUsername(),
config.getPassword());
}
else
{
session = ScmClient.createSession(config.getServerUrl());
}
return session;
}
/**
* Method description
*
*
* @param parser
*/
protected void printHelp(CmdLineParser parser)
{
parser.printUsage(output, i18n.getBundle());
System.exit(1);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
protected ServerConfig config;
/** Field description */
protected I18n i18n;
/** Field description */
protected BufferedReader input;
/** Field description */
protected PrintWriter output;
/** Field description */
private String commandName;
/** Field description */
@Option(
name = "--help",
usage = "optionHelpText",
aliases = { "-h" }
)
private boolean help = false;
/** Field description */
private ScmClientSession session;
}

View File

@@ -1,234 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.ConfigurationException;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
public class SubCommandHandler
{
/** Field description */
public static final String RESOURCE_SERVICES =
"META-INF/services/".concat(SubCommand.class.getName());
/** Field description */
private static volatile SubCommandHandler instance;
/** the logger for SubCommandOptionHandler */
private static final Logger logger =
LoggerFactory.getLogger(SubCommandOptionHandler.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private SubCommandHandler()
{
subCommands = new HashMap<String, CommandDescriptor>();
loadSubCommands();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public static SubCommandHandler getInstance()
{
if (instance == null)
{
synchronized (SubCommandHandler.class)
{
if (instance == null)
{
instance = new SubCommandHandler();
}
}
}
return instance;
}
/**
* Method description
*
*
* @param name
*
* @return
*/
public CommandDescriptor getDescriptor(String name)
{
return subCommands.get(name);
}
/**
* Method description
*
*
* @return
*/
public List<CommandDescriptor> getDescriptors()
{
List<CommandDescriptor> descs =
new ArrayList<CommandDescriptor>(subCommands.values());
Collections.sort(descs);
return descs;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param url
*/
private void loadSubCommand(URL url)
{
BufferedReader reader = null;
try
{
reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line = reader.readLine();
while (line != null)
{
parseLine(line);
line = reader.readLine();
}
}
catch (IOException ex)
{
logger.error("could not load commands");
}
finally
{
IOUtil.close(reader);
}
}
/**
* Method description
*
*/
private void loadSubCommands()
{
try
{
Enumeration<URL> enm =
SubCommandHandler.class.getClassLoader().getResources(
RESOURCE_SERVICES);
while (enm.hasMoreElements())
{
URL url = enm.nextElement();
loadSubCommand(url);
}
}
catch (IOException ex)
{
throw new ConfigurationException("could not load SubComamnds", ex);
}
}
/**
* Method description
*
*
* @param line
*/
@SuppressWarnings("unchecked")
private void parseLine(String line)
{
line = line.trim();
if (Util.isNotEmpty(line) &&!line.startsWith("#"))
{
try
{
Class<? extends SubCommand> clazz =
(Class<? extends SubCommand>) Class.forName(line);
CommandDescriptor desc = new CommandDescriptor(clazz);
subCommands.put(desc.getName(), desc);
}
catch (ClassNotFoundException ex)
{
logger.warn("could not found command class {}", line);
}
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Map<String, CommandDescriptor> subCommands;
}

View File

@@ -1,118 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Localizable;
import org.kohsuke.args4j.OptionDef;
import org.kohsuke.args4j.spi.Messages;
import org.kohsuke.args4j.spi.OptionHandler;
import org.kohsuke.args4j.spi.Parameters;
import org.kohsuke.args4j.spi.Setter;
import sonia.scm.cli.SimpleLocalizable;
/**
*
* @author Sebastian Sdorra
*/
public class SubCommandOptionHandler extends OptionHandler<SubCommand>
{
/**
* Constructs ...
*
*
* @param parser
* @param option
* @param setter
*/
public SubCommandOptionHandler(CmdLineParser parser, OptionDef option,
Setter<? super SubCommand> setter)
{
super(parser, option, setter);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
*
* @param parameters
*
* @return
*
* @throws CmdLineException
*/
@Override
public int parseArguments(Parameters parameters) throws CmdLineException
{
String name = parameters.getParameter(0);
CommandDescriptor desc =
SubCommandHandler.getInstance().getDescriptor(name);
if (desc != null)
{
owner.stopOptionParsing();
setter.addValue(desc.createSubCommand());
}
else
{
String msg = "command ".concat(name).concat(" not found");
throw new CmdLineException(owner, new SimpleLocalizable(msg));
}
return 1;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getDefaultMetaVariable()
{
return "command";
}
}

View File

@@ -1,165 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.kohsuke.args4j.Option;
import sonia.scm.ConfigurationException;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
public abstract class TemplateSubCommand extends SubCommand
{
/**
* Method description
*
*
* @return
*/
public String getTemplate()
{
return template;
}
/**
* Method description
*
*
* @return
*/
public File getTemplateFile()
{
return templateFile;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param template
*/
public void setTemplate(String template)
{
this.template = template;
}
/**
* Method description
*
*
* @param templateFile
*/
public void setTemplateFile(File templateFile)
{
this.templateFile = templateFile;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param env
* @param defaultTemplate
*/
protected void renderTemplate(Map<String, Object> env, String defaultTemplate)
{
Configuration configuration = new Configuration(Configuration.VERSION_2_3_20);
Reader reader = null;
try
{
if ((templateFile != null) && templateFile.exists())
{
reader = new FileReader(templateFile);
}
else if (Util.isNotEmpty(template))
{
reader = new StringReader(template);
}
else
{
reader = new InputStreamReader(
TemplateSubCommand.class.getResourceAsStream(defaultTemplate));
}
Template tpl = new Template("default-template", reader, configuration);
tpl.process(env, output);
}
catch (TemplateException | IOException ex)
{
throw new ConfigurationException("could not render template", ex);
}
finally
{
IOUtil.close(reader);
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@Option(name = "--template", usage = "optionTemplate")
private String template;
/** Field description */
@Option(name = "--template-file", usage = "optionTemplateFile")
private File templateFile;
}

View File

@@ -1,133 +0,0 @@
/**
* 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.cmd;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
*
* @author Sebastian Sdorra
* @since 1.9
*/
@Command(
name = "version",
usage = "usageVersion",
group = "misc"
)
public class VersionSubCommand extends SubCommand
{
/** Default version {@link String} */
public static final String DEFAULT_VERSION = "unknown";
/** Path to the maven properties file of the scm-core artifact */
public static final String MAVEN_PROPERTIES =
"/META-INF/maven/sonia.scm.clients/scm-cli-client/pom.properties";
/** Maven property for the version of the artifact */
public static final String MAVEN_PROPERTY_VERSION = "version";
/** the logger for VersionSubCommand */
private static final Logger logger =
LoggerFactory.getLogger(VersionSubCommand.class);
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Override
protected void run()
{
String version = getVersion();
output.append("scm-cli-client version: ").println(version);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
private String getVersion()
{
String version = null;
InputStream stream = null;
try
{
stream = VersionSubCommand.class.getResourceAsStream(MAVEN_PROPERTIES);
if (stream != null)
{
Properties properties = new Properties();
properties.load(stream);
version = properties.getProperty(MAVEN_PROPERTY_VERSION);
}
}
catch (IOException ex)
{
logger.warn("could not parse maven.properties", ex);
}
finally
{
IOUtil.close(stream);
}
if (Util.isEmpty(version))
{
version = DEFAULT_VERSION;
}
return version;
}
}

View File

@@ -1,102 +0,0 @@
/**
* 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.config;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.OptionDef;
import org.kohsuke.args4j.spi.OptionHandler;
import org.kohsuke.args4j.spi.Parameters;
import org.kohsuke.args4j.spi.Setter;
/**
*
* @author Sebastian Sdorra
*/
public class ConfigOptionHandler extends OptionHandler<ServerConfig>
{
/**
* Constructs ...
*
*
* @param parser
* @param option
* @param setter
*/
public ConfigOptionHandler(CmdLineParser parser, OptionDef option,
Setter<? super ServerConfig> setter)
{
super(parser, option, setter);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param parameters
*
* @return
*
* @throws CmdLineException
*/
@Override
public int parseArguments(Parameters parameters) throws CmdLineException
{
String name = parameters.getParameter(0);
ServerConfig config = ScmClientConfig.getInstance().getConfig(name);
setter.addValue(config);
return 1;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getDefaultMetaVariable()
{
return "metaVar_config";
}
}

View File

@@ -1,196 +0,0 @@
/**
* 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.config;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
*
* @author Sebastian Sdorra
*/
@XmlRootElement(name = "client-config")
@XmlAccessorType(XmlAccessType.FIELD)
public class ScmClientConfig
{
/** Field description */
public static final String DEFAULT_NAME = "default";
/** Field description */
private static volatile ScmClientConfig instance;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private ScmClientConfig()
{
this.serverConfigMap = new HashMap<String, ServerConfig>();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public static ScmClientConfig getInstance()
{
if (instance == null)
{
synchronized (ScmClientConfig.class)
{
if (instance == null)
{
instance = load();
}
}
}
return instance;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @return
*/
private static ScmClientConfig load()
{
ScmClientConfigFileHandler fileHandler = new ScmClientConfigFileHandler();
ScmClientConfig config = fileHandler.read();
if (config == null)
{
config = new ScmClientConfig();
}
config.setFileHandler(fileHandler);
return config;
}
/**
* Method description
*
*/
public void delete()
{
fileHandler.delete();
}
/**
* Method description
*
*/
public void store()
{
fileHandler.write(this);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*
* @return
*/
public ServerConfig getConfig(String name)
{
ServerConfig config = serverConfigMap.get(name);
if (config == null)
{
config = new ServerConfig();
serverConfigMap.put(name, config);
}
return config;
}
/**
* Method description
*
*
* @return
*/
public ServerConfig getDefaultConfig()
{
return getConfig(DEFAULT_NAME);
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param fileHandler
*/
private void setFileHandler(ScmClientConfigFileHandler fileHandler)
{
this.fileHandler = fileHandler;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@XmlTransient
private ScmClientConfigFileHandler fileHandler;
/** Field description */
@XmlElement(name = "server-config")
@XmlJavaTypeAdapter(XmlConfigAdapter.class)
private Map<String, ServerConfig> serverConfigMap;
}

View File

@@ -1,306 +0,0 @@
/**
* 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.config;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.UUID;
import java.util.prefs.Preferences;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
/**
*
* @author Sebastian Sdorra
*/
public class ScmClientConfigFileHandler
{
/** Field description */
public static final String DEFAULT_CONFIG_NAME = ".scm-cli-config.enc.xml";
/** Field description */
public static final String ENV_CONFIG_FILE = "SCM_CLI_CONFIG";
/** Field description */
public static final String PREF_SECRET_KEY = "scm.client.key";
/** Field description */
public static final String SALT = "AE16347F";
/** Field description */
public static final int SPEC_ITERATION = 12;
/** Field description */
private static final String CIPHER_NAME = "PBEWithMD5AndDES";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public ScmClientConfigFileHandler()
{
prefs = Preferences.userNodeForPackage(ScmClientConfigFileHandler.class);
key = prefs.get(PREF_SECRET_KEY, null);
if (Util.isEmpty(key))
{
key = createNewKey();
prefs.put(PREF_SECRET_KEY, key);
}
try
{
context = JAXBContext.newInstance(ScmClientConfig.class);
}
catch (JAXBException ex)
{
throw new ScmConfigException(
"could not create JAXBContext for ScmClientConfig", ex);
}
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
public void delete()
{
File configFile = getConfigFile();
if (configFile.exists() &&!configFile.delete())
{
throw new ScmConfigException("could not delete config file");
}
prefs.remove(PREF_SECRET_KEY);
}
/**
* Method description
*
*
* @return
*/
public ScmClientConfig read()
{
ScmClientConfig config = null;
File configFile = getConfigFile();
if (configFile.exists())
{
InputStream input = null;
try
{
Cipher c = createCipher(Cipher.DECRYPT_MODE);
input = new CipherInputStream(new FileInputStream(configFile), c);
Unmarshaller um = context.createUnmarshaller();
config = (ScmClientConfig) um.unmarshal(input);
}
catch (Exception ex)
{
throw new ScmConfigException("could not read config file", ex);
}
finally
{
IOUtil.close(input);
}
}
return config;
}
/**
* Method description
*
*
* @param config
*/
public void write(ScmClientConfig config)
{
File configFile = getConfigFile();
OutputStream output = null;
try
{
Cipher c = createCipher(Cipher.ENCRYPT_MODE);
output = new CipherOutputStream(new FileOutputStream(configFile), c);
Marshaller m = context.createMarshaller();
m.marshal(config, output);
}
catch (Exception ex)
{
throw new ScmConfigException("could not write config file", ex);
}
finally
{
IOUtil.close(output);
}
}
/**
* Method description
*
*
* @param mode
*
* @return
*
*
* @throws InvalidAlgorithmParameterException
* @throws InvalidKeyException
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
* @throws NoSuchPaddingException
*/
private Cipher createCipher(int mode)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeySpecException, InvalidKeyException,
InvalidAlgorithmParameterException
{
SecretKey sk = createSecretKey();
Cipher cipher = Cipher.getInstance(CIPHER_NAME);
PBEParameterSpec spec = new PBEParameterSpec(SALT.getBytes(),
SPEC_ITERATION);
cipher.init(mode, sk, spec);
return cipher;
}
/**
* Method description
*
*
* @return
*/
private String createNewKey()
{
return UUID.randomUUID().toString();
}
/**
* Method description
*
*
* @return
*
* @throws InvalidKeySpecException
* @throws NoSuchAlgorithmException
*/
private SecretKey createSecretKey()
throws NoSuchAlgorithmException, InvalidKeySpecException
{
PBEKeySpec keySpec = new PBEKeySpec(key.toCharArray());
SecretKeyFactory factory = SecretKeyFactory.getInstance(CIPHER_NAME);
return factory.generateSecret(keySpec);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
private File getConfigFile()
{
File configFile = null;
String configPath = System.getenv(ENV_CONFIG_FILE);
if (Util.isEmpty(configPath))
{
configFile = new File(System.getProperty("user.home"),
DEFAULT_CONFIG_NAME);
}
else
{
configFile = new File(configPath);
}
return configFile;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private JAXBContext context;
/** Field description */
private String key;
/** Field description */
private Preferences prefs;
}

View File

@@ -1,90 +0,0 @@
/**
* 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.config;
/**
*
* @author Sebastian Sdorra
*/
public class ScmConfigException extends RuntimeException
{
/** Field description */
private static final long serialVersionUID = -4226165375815233654L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public ScmConfigException()
{
super();
}
/**
* Constructs ...
*
*
* @param message
*/
public ScmConfigException(String message)
{
super(message);
}
/**
* Constructs ...
*
*
* @param cause
*/
public ScmConfigException(Throwable cause)
{
super(cause);
}
/**
* Constructs ...
*
*
* @param message
* @param cause
*/
public ScmConfigException(String message, Throwable cause)
{
super(message, cause);
}
}

View File

@@ -1,162 +0,0 @@
/**
* 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.config;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.Validateable;
/**
*
* @author Sebastian Sdorra
*/
public class ServerConfig implements Validateable
{
/**
* Constructs ...
*
*/
public ServerConfig() {}
/**
* Constructs ...
*
*
* @param serverUrl
* @param username
* @param password
*/
public ServerConfig(String serverUrl, String username, String password)
{
this.serverUrl = serverUrl;
this.username = username;
this.password = password;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getPassword()
{
return password;
}
/**
* Method description
*
*
* @return
*/
public String getServerUrl()
{
return serverUrl;
}
/**
* Method description
*
*
* @return
*/
public String getUsername()
{
return username;
}
/**
* Method description
*
*
* @return
*/
@Override
public boolean isValid()
{
// TODO
return true;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param password
*/
public void setPassword(String password)
{
this.password = password;
}
/**
* Method description
*
*
* @param serverUrl
*/
public void setServerUrl(String serverUrl)
{
this.serverUrl = serverUrl;
}
/**
* Method description
*
*
* @param username
*/
public void setUsername(String username)
{
this.username = username;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String password;
/** Field description */
private String serverUrl;
/** Field description */
private String username;
}

View File

@@ -1,98 +0,0 @@
/**
* 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.config;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
*
* @author Sebastian Sdorra
*/
public class XmlConfigAdapter
extends XmlAdapter<XmlConfigSet, Map<String, ServerConfig>>
{
/**
* Method description
*
*
* @param map
*
* @return
*
* @throws Exception
*/
@Override
public XmlConfigSet marshal(Map<String, ServerConfig> map) throws Exception
{
Set<XmlConfigElement> set = new HashSet<XmlConfigElement>();
for (Map.Entry<String, ServerConfig> e : map.entrySet())
{
set.add(new XmlConfigElement(e.getKey(), e.getValue()));
}
return new XmlConfigSet(set);
}
/**
* Method description
*
*
* @param set
*
* @return
*
* @throws Exception
*/
@Override
public Map<String, ServerConfig> unmarshal(XmlConfigSet set) throws Exception
{
Map<String, ServerConfig> map = new HashMap<String, ServerConfig>();
for (XmlConfigElement e : set)
{
map.put(e.getName(), e.getConfig());
}
return map;
}
}

View File

@@ -1,127 +0,0 @@
/**
* 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.config;
//~--- JDK imports ------------------------------------------------------------
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Sebastian Sdorra
*/
@XmlRootElement(name = "server")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlConfigElement
{
/**
* Constructs ...
*
*/
public XmlConfigElement() {}
/**
* Constructs ...
*
*
* @param name
* @param config
*/
public XmlConfigElement(String name, ServerConfig config)
{
this.name = name;
this.config = config;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public ServerConfig getConfig()
{
return config;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param config
*/
public void setConfig(ServerConfig config)
{
this.config = config;
}
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@XmlElement(name = "server-config")
private ServerConfig config;
/** Field description */
private String name;
}

View File

@@ -1,117 +0,0 @@
/**
* 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.config;
//~--- JDK imports ------------------------------------------------------------
import java.util.Iterator;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Sebastian Sdorra
*/
@XmlRootElement(name = "server-config")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlConfigSet implements Iterable<XmlConfigElement>
{
/**
* Constructs ...
*
*/
public XmlConfigSet() {}
/**
* Constructs ...
*
*
* @param configSet
*/
public XmlConfigSet(Set<XmlConfigElement> configSet)
{
this.configSet = configSet;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public Iterator<XmlConfigElement> iterator()
{
return configSet.iterator();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public Set<XmlConfigElement> getConfigSet()
{
return configSet;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param configSet
*/
public void setConfigSet(Set<XmlConfigElement> configSet)
{
this.configSet = configSet;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@XmlElement(name = "server")
private Set<XmlConfigElement> configSet;
}

View File

@@ -1,66 +0,0 @@
/**
* 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.wrapper;
//~--- JDK imports ------------------------------------------------------------
import java.util.Date;
/**
*
* @author Sebastian Sdorra
*/
public class AbstractWrapper
{
/**
* Method description
*
*
* @param value
*
* @return
*/
protected Date getDate(Long value)
{
Date date = null;
if (value != null)
{
date = new Date(value);
}
return date;
}
}

View File

@@ -1,146 +0,0 @@
/**
* 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.wrapper;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.group.Group;
//~--- JDK imports ------------------------------------------------------------
import java.util.Date;
import java.util.List;
/**
*
* @author Sebastian Sdorra
*/
public class GroupWrapper extends AbstractWrapper
{
/**
* Constructs ...
*
*
* @param group
*/
public GroupWrapper(Group group)
{
this.group = group;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public Date getCreationDate()
{
return getDate(group.getCreationDate());
}
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return group.getDescription();
}
/**
* Method description
*
*
* @return
*/
public String getId()
{
return group.getId();
}
/**
* Method description
*
*
* @return
*/
public Date getLastModified()
{
return getDate(group.getLastModified());
}
/**
* Method description
*
*
* @return
*/
public List<String> getMembers()
{
return group.getMembers();
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return group.getName();
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return group.getType();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Group group;
}

View File

@@ -1,210 +0,0 @@
/**
* 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.wrapper;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cli.config.ServerConfig;
import sonia.scm.repository.Permission;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import java.util.Date;
import java.util.List;
/**
*
* @author Sebastian Sdorra
*/
public class RepositoryWrapper extends AbstractWrapper
{
/**
* Constructs ...
*
*
* @param config
* @param repository
*/
public RepositoryWrapper(ServerConfig config, Repository repository)
{
this(config.getServerUrl(), repository);
}
/**
* Constructs ...
*
*
*
* @param baseUrl
* @param repository
*/
public RepositoryWrapper(String baseUrl, Repository repository)
{
this.baseUrl = baseUrl;
this.repository = repository;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getContact()
{
return repository.getContact();
}
/**
* Method description
*
*
* @return
*/
public Date getCreationDate()
{
return getDate(repository.getCreationDate());
}
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return repository.getDescription();
}
/**
* Method description
*
*
* @return
*/
public String getId()
{
return repository.getId();
}
/**
* Method description
*
*
* @return
*/
public Date getLastModified()
{
return getDate(repository.getLastModified());
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return repository.getName();
}
/**
* Method description
*
*
* @return
*/
public List<Permission> getPermissions()
{
return repository.getPermissions();
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return repository.getType();
}
/**
* Method description
*
*
* @return
*/
public String getUrl()
{
return repository.createUrl(baseUrl);
}
/**
* Method description
*
*
* @return
*/
public boolean isArchived()
{
return repository.isArchived();
}
/**
* Method description
*
*
* @return
*/
public boolean isPublicReadable()
{
return repository.isPublicReadable();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String baseUrl;
/** Field description */
private Repository repository;
}

View File

@@ -1,156 +0,0 @@
/**
* 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.wrapper;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.user.User;
//~--- JDK imports ------------------------------------------------------------
import java.util.Date;
/**
*
* @author Sebastian Sdorra
*/
public class UserWrapper extends AbstractWrapper
{
/**
* Constructs ...
*
*
* @param user
*/
public UserWrapper(User user)
{
this.user = user;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public Date getCreationDate()
{
return getDate(user.getCreationDate());
}
/**
* Method description
*
*
* @return
*/
public String getDisplayName()
{
return user.getDisplayName();
}
/**
* Method description
*
*
* @return
*/
public String getId()
{
return user.getId();
}
/**
* Method description
*
*
* @return
*/
public Date getLastModified()
{
return getDate(user.getLastModified());
}
/**
* Method description
*
*
* @return
*/
public String getMail()
{
return user.getMail();
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return user.getName();
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return user.getType();
}
/**
* Method description
*
*
* @return
*/
public boolean isAdmin()
{
return user.isAdmin();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private User user;
}

View File

@@ -1,127 +0,0 @@
/**
* 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.wrapper;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cli.config.ServerConfig;
import sonia.scm.group.Group;
import sonia.scm.repository.Repository;
import sonia.scm.user.User;
//~--- JDK imports ------------------------------------------------------------
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
*
* @author Sebastian Sdorra
*/
public final class WrapperUtil
{
/**
* Constructs ...
*
*/
private WrapperUtil() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param groups
*
* @return
*/
public static List<GroupWrapper> wrapGroups(Collection<Group> groups)
{
List<GroupWrapper> wrappers = new ArrayList<GroupWrapper>();
for (Group g : groups)
{
wrappers.add(new GroupWrapper(g));
}
return wrappers;
}
/**
* Method description
*
*
*
*
* @param config
* @param repositories
*
* @return
*/
public static List<RepositoryWrapper> wrapRepositories(ServerConfig config,
Collection<Repository> repositories)
{
List<RepositoryWrapper> wrappers = new ArrayList<RepositoryWrapper>();
for (Repository r : repositories)
{
wrappers.add(new RepositoryWrapper(config.getServerUrl(), r));
}
return wrappers;
}
/**
* Method description
*
*
* @param users
*
* @return
*/
public static List<UserWrapper> wrapUsers(Collection<User> users)
{
List<UserWrapper> wrappers = new ArrayList<UserWrapper>();
for (User u : users)
{
wrappers.add(new UserWrapper(u));
}
return wrappers;
}
}

View File

@@ -1,72 +0,0 @@
# 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
#
# config
sonia.scm.cli.cmd.StoreConfigSubCommand
sonia.scm.cli.cmd.DeleteConfigSubCommand
# repository
sonia.scm.cli.cmd.CreateRepositorySubCommand
sonia.scm.cli.cmd.ModifyRepositorySubCommand
sonia.scm.cli.cmd.GetRepositorySubCommand
sonia.scm.cli.cmd.ListRepositoriesSubCommand
sonia.scm.cli.cmd.DeleteRepositorySubCommand
sonia.scm.cli.cmd.ImportDirectorySubCommand
sonia.scm.cli.cmd.ImportUrlSubCommand
sonia.scm.cli.cmd.ImportBundleSubCommand
# permission
sonia.scm.cli.cmd.AddPermissionSubCommand
sonia.scm.cli.cmd.DeletePermissionSubCommand
# user
sonia.scm.cli.cmd.ListUsersSubCommand
sonia.scm.cli.cmd.GetUserSubCommand
sonia.scm.cli.cmd.CreateUserSubCommand
sonia.scm.cli.cmd.DeleteUserSubCommand
sonia.scm.cli.cmd.ModifyUserSubCommand
# group
sonia.scm.cli.cmd.ListGroupsSubCommand
sonia.scm.cli.cmd.GetGroupSubCommand
sonia.scm.cli.cmd.CreateGroupSubCommand
sonia.scm.cli.cmd.DeleteGroupSubCommand
sonia.scm.cli.cmd.ModifyGroupSubCommand
# member
sonia.scm.cli.cmd.AddMembersSubCommand
sonia.scm.cli.cmd.DeleteMembersSubCommand
# security
sonia.scm.cli.cmd.EncryptSubCommand
sonia.scm.cli.cmd.GenerateKeySubCommand
# misc
sonia.scm.cli.cmd.VersionSubCommand
sonia.scm.cli.cmd.ServerVersionSubCommand

View File

@@ -1,11 +0,0 @@
Name: ${group.name}
Type: ${group.type}
Description: ${group.description!""}
Creation-Date: <#if group.creationDate??>${group.creationDate?string("yyyy-MM-dd HH:mm:ss")}</#if>
Last-Modified: <#if group.lastModified??>${group.lastModified?string("yyyy-MM-dd HH:mm:ss")}</#if>
Members:
<#if group.members??>
<#list group.members as member>
${member}
</#list>
</#if>

View File

@@ -1,16 +0,0 @@
ID: ${repository.id}
Name: ${repository.name}
Type: ${repository.type}
E-Mail: ${repository.contact!""}
Description: ${repository.description!""}
Public: ${repository.publicReadable?string}
Archived: ${repository.archived?string}
Creation-Date: <#if repository.creationDate??>${repository.creationDate?string("yyyy-MM-dd HH:mm:ss")}</#if>
Last-Modified: <#if repository.lastModified??>${repository.lastModified?string("yyyy-MM-dd HH:mm:ss")}</#if>
URL: ${repository.url}
Permissions:
<#if repository.permissions??>
<#list repository.permissions as permission>
${permission.type} - ${permission.name} (Group: ${permission.groupPermission?string})
</#list>
</#if>

View File

@@ -1,8 +0,0 @@
Name: ${user.name}
Display Name: ${user.displayName}
Type: ${user.type}
E-Mail: ${user.mail!""}
Active: ${user.admin?string}
Administrator: ${user.admin?string}
Creation-Date: <#if user.creationDate??>${user.creationDate?string("yyyy-MM-dd HH:mm:ss")}</#if>
Last-Modified: <#if user.lastModified??>${user.lastModified?string("yyyy-MM-dd HH:mm:ss")}</#if>

View File

@@ -1,131 +0,0 @@
#
# 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
#
#
VAL = value
FILE = file
error = Error
subCommandsTitle = list of commands
optionConfig = Configuration name
optionServerUrl = SCM-Manager URL
optionUsername = Username
optionPassword = Password
optionHelpText = Shows this help
optionLoggingLevel = Logging level (DEBUG, INFO, WARN, ERROR)
optionTemplate = Template
optionTemplateFile = Template file
optionRepositoryId = Repository Id
optionRepositoryIdOrTypeAndName = Repository Id or type/name
optionRepositoryName = Repository name
optionRepositoryType = Repository type
optionRepositoryContact = Repository contact
optionRepositoryDescription = Repository description
optionRepositoryPublic = Repository public readable
optionRepositoryArchive = Repository archived
optionRemoteRepositoryUrl = Remote repository url
optionRepositoryBundle = Import repository from a bundle file (e.g. svn dump)
optionRepositoryBundleCompressed = Indicates that the bundle is gzip compressed
optionPermissionGroup = Group
optionPermissionName = Group or user name
optionPermissionType = Permission type (READ,WRITE or OWNER)
optionUserName = Username
optionUserDisplayName = Display name
optionUserMail = E-Mail address
optionUserPassword = Password
optionUserType = Type
optionUserAdmin = Administrator
optionGroupName = Name of the group
optionGroupDescription = Description
optionGroupType = Type
optionGroupMember = Member
optionEncryptValue = value to encrypt
repositoryNotFound = The repository is not available
userNotFound = The user could not be found
groupNotFoun = The group could not be found
config = configname
arg = subcommand arguments
command = subcommand
permissiontype = value
groupname = groupname
repositoryid = repositoryid
username = username
repositorytype = type
config = Configuration
misc = Miscellaneous
repository = Repository
group = Group
user = User
security = Security
level = Logging-Level
boolean = true or false
URL = url
bundle = file
options = Options
usage = scm-cli-client [options] command [command options]
# usages
usageAddMember = Add members to a existing group
usageAddPermission = Add permission to a existing repository
usageCreateGroup = Create a new group
usageCreateRepository = Create a new repository
usageCreateUser = Create a new user
usageDeleteConfig = Delete all stored configurations
usageDeleteGroup = Delete a group
usageDeleteMembers = Delete members of a group
usageDeletePermission = Delete a permission of a repository
usageDeleteRepository = Delete a repository
usageDeleteUser = Delete a user
usageGetGroup = Print a group
usageGetRepository = Print a repository
usageGetUser = Print a user
usageListGroups= Print a list of all groups
usageListUsers= Print a list of all users
usageListRepositories= Print a list of all repositories
usageModifyGroup = Modify a group
usageModifyUser = Modify a user
usageModifyRepository = Modify a repository
usageStoreConfig = Stores the current configuration
usageVersion = Show the version of scm-cli-client
usageServerVersion = Show the version of the scm-manager
usageImportDirectory = Import repositories from repository directory
usageImportUrl = Import repository from remote url
usageEncrypt = Encrypts the given value
usageGenerateKey = Generates a unique key

View File

@@ -1,9 +0,0 @@
Imported repositories:
<#list importedDirectories as imported>
- ${imported}
</#list>
Repositories failed to import:
<#list failedDirectories as failed>
- ${failed}
</#list>

View File

@@ -1,14 +0,0 @@
<#list groups as group>
Name: ${group.name}
Type: ${group.type}
Description: ${group.description!""}
Creation-Date: <#if group.creationDate??>${group.creationDate?string("yyyy-MM-dd HH:mm:ss")}</#if>
Last-Modified: <#if group.lastModified??>${group.lastModified?string("yyyy-MM-dd HH:mm:ss")}</#if>
Members:
<#if group.members??>
<#list group.members as member>
${member}
</#list>
</#if>
</#list>

View File

@@ -1,19 +0,0 @@
<#list repositories as repository>
ID: ${repository.id}
Name: ${repository.name}
Type: ${repository.type}
E-Mail: ${repository.contact!""}
Description: ${repository.description!""}
Public: ${repository.publicReadable?string}
Archived: ${repository.archived?string}
Creation-Date: <#if repository.creationDate??>${repository.creationDate?string("yyyy-MM-dd HH:mm:ss")}</#if>
Last-Modified: <#if repository.lastModified??>${repository.lastModified?string("yyyy-MM-dd HH:mm:ss")}</#if>
URL: ${repository.url}
Permissions:
<#if repository.permissions??>
<#list repository.permissions as permission>
${permission.type} - ${permission.name} (Group: ${permission.groupPermission?string})
</#list>
</#if>
</#list>

View File

@@ -1,11 +0,0 @@
<#list users as user>
Name: ${user.name}
Display Name: ${user.displayName}
Type: ${user.type}
E-Mail: ${user.mail!""}
Active: ${user.admin?string}
Administrator: ${user.admin?string}
Creation-Date: <#if user.creationDate??>${user.creationDate?string("yyyy-MM-dd HH:mm:ss")}</#if>
Last-Modified: <#if user.lastModified??>${user.lastModified?string("yyyy-MM-dd HH:mm:ss")}</#if>
</#list>

View File

@@ -1,129 +0,0 @@
/**
* 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<String> 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+", "");
}
}

View File

@@ -1,86 +0,0 @@
/**
* 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);
}
}

View File

@@ -1,70 +0,0 @@
/**
* 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);
}
}

View File

@@ -1,72 +0,0 @@
/**
* 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);
}
}

View File

@@ -1,65 +0,0 @@
/**
* 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);
}
}

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>sonia.scm.clients</groupId>
<artifactId>scm-clients</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>sonia.scm.clients</groupId>
<artifactId>scm-client-api</artifactId>
<packaging>jar</packaging>
<version>2.0.0-SNAPSHOT</version>
<name>scm-client-api</name>
<dependencies>
<!-- fix javadoc -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@@ -1,81 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
/**
*
* @author Sebastian Sdorra
* @since 1.8
*/
public interface ClientChangesetHandler
{
/**
* Method description
*
*
* @param revision
*
* @return
*
* @since 1.12
*/
public Changeset getChangeset(String revision);
/**
* Method description
*
*
* @param start
* @param limit
*
* @return
*/
public ChangesetPagingResult getChangesets(int start, int limit);
/**
* @param path
* @param revision
* @param start
* @param limit
* @return
*/
public ChangesetPagingResult getChangesets(String path, String revision,
int start, int limit);
}

View File

@@ -1,103 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- JDK imports ------------------------------------------------------------
import java.util.List;
/**
*
* @author Sebastian Sdorra
*
* @param <T>
*/
public interface ClientHandler<T>
{
/**
* Method description
*
*
*
* @param item
*/
public void create(T item);
/**
* Method description
*
*
* @param id
*/
public void delete(String id);
/**
* Method description
*
*
*
* @param item
*/
public void delete(T item);
/**
* Method description
*
*
*
* @param item
*/
public void modify(T item);
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param id
*
* @return
*/
public T get(String id);
/**
* Method description
*
*
* @return
*/
public List<T> getAll();
}

View File

@@ -1,100 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.BlameLine;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
*
* @author Sebastian Sdorra
* @since 1.8
*/
public interface ClientRepositoryBrowser
{
/**
* Method description
*
*
* @param revision
* @param path
*
* @return
*/
public List<BlameLine> getBlameLines(String revision, String path);
/**
* Method description
*
*
* @param revision
* @param path
*
* @return
*
* @throws IOException
*/
public InputStream getContent(String revision, String path)
throws IOException;
/**
* Method description
*
*
* @param revision
* @param path
*
* @return
*/
public List<FileObjectWrapper> getFiles(String revision, String path);
/**
* Method description
*
*
* @param revision
*
* @return
*/
public List<FileObjectWrapper> getFiles(String revision);
}

View File

@@ -1,193 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.BlameLine;
import sonia.scm.repository.FileObject;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
*
* @author Sebastian Sdorra
* @since 1.8
*/
public class FileObjectWrapper
{
/**
* Constructs ...
*
*
*
* @param repositoryBrowser
* @param revision
* @param file
*/
public FileObjectWrapper(ClientRepositoryBrowser repositoryBrowser,
String revision, FileObject file)
{
this.repositoryBrowser = repositoryBrowser;
this.revision = revision;
this.file = file;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public List<BlameLine> getBlameLines()
{
return repositoryBrowser.getBlameLines(revision, getPath());
}
/**
* Method description
*
*
* @return
*/
public List<FileObjectWrapper> getChildren()
{
List<FileObjectWrapper> children = null;
if (isDirectory())
{
children = repositoryBrowser.getFiles(revision, getPath());
}
return children;
}
/**
* Method description
*
*
* @return
*
* @throws IOException
*/
public InputStream getContent() throws IOException
{
return repositoryBrowser.getContent(revision, getPath());
}
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return file.getDescription();
}
/**
* Method description
*
*
* @return
*/
public Long getLastModified()
{
return file.getLastModified();
}
/**
* Method description
*
*
* @return
*/
public long getLength()
{
return file.getLength();
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return file.getName();
}
/**
* Method description
*
*
* @return
*/
public String getPath()
{
return file.getPath();
}
/**
* Method description
*
*
* @return
*/
public boolean isDirectory()
{
return file.isDirectory();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private FileObject file;
/** Field description */
private ClientRepositoryBrowser repositoryBrowser;
/** Field description */
private String revision;
}

View File

@@ -1,44 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.group.Group;
/**
*
* @author Sebastian Sdorra
*/
public interface GroupClientHandler extends ClientHandler<Group> {}

View File

@@ -1,139 +0,0 @@
/**
* Copyright (c) 2014, Sebastian Sdorra All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.io.ByteSource;
/**
*
* @author Sebastian Sdorra
* @since 1.43
*/
public class ImportBundleRequest
{
/**
* Constructs ...
*
*/
ImportBundleRequest() {}
/**
* Constructs ...
*
*
* @param type
* @param name
* @param bundle
*/
public ImportBundleRequest(String type, String name, ByteSource bundle)
{
this.type = type;
this.name = name;
this.bundle = bundle;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public ByteSource getBundle()
{
return bundle;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return type;
}
/**
* Method description
*
*
* @return
*/
public boolean isCompressed()
{
return compressed;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param compressed
*/
public void setCompressed(boolean compressed)
{
this.compressed = compressed;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private ByteSource bundle;
/** Field description */
private boolean compressed = false;
/** Field description */
private String name;
/** Field description */
private String type;
}

View File

@@ -1,184 +0,0 @@
/**
* Copyright (c) 2014, Sebastian Sdorra All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import sonia.scm.repository.ImportResult;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import java.util.List;
/**
*
* @author Sebastian Sdorra
* @since 1.43
*/
public class ImportResultWrapper
{
/**
* Constructs ...
*
*
* @param client
* @param type
* @param result
*/
public ImportResultWrapper(RepositoryClientHandler client, String type,
ImportResult result)
{
this.client = client;
this.type = type;
this.result = result;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public List<String> getFailedDirectories()
{
List<String> directories = result.getFailedDirectories();
if (directories == null)
{
directories = ImmutableList.of();
}
return directories;
}
/**
* Method description
*
*
* @return
*/
public List<String> getImportedDirectories()
{
List<String> directories = result.getImportedDirectories();
if (directories == null)
{
directories = ImmutableList.of();
}
return directories;
}
/**
* Method description
*
*
* @return
*/
public Iterable<Repository> getImportedRepositories()
{
return Iterables.transform(getImportedDirectories(),
new RepositoryResolver(client, type));
}
//~--- inner classes --------------------------------------------------------
/**
* Class description
*
*
* @version Enter version here..., 14/11/29
* @author Enter your name here...
*/
private static class RepositoryResolver
implements Function<String, Repository>
{
/**
* Constructs ...
*
*
* @param clientHandler
* @param type
*/
public RepositoryResolver(RepositoryClientHandler clientHandler,
String type)
{
this.clientHandler = clientHandler;
this.type = type;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param name
*
* @return
*/
@Override
public Repository apply(String name)
{
return clientHandler.get(type, type);
}
//~--- fields -------------------------------------------------------------
/** Field description */
private final RepositoryClientHandler clientHandler;
/** Field description */
private final String type;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private final RepositoryClientHandler client;
/** Field description */
private final ImportResult result;
/** Field description */
private final String type;
}

View File

@@ -1,118 +0,0 @@
/**
* Copyright (c) 2014, Sebastian Sdorra All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- JDK imports ------------------------------------------------------------
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author Sebastian Sdorra
* @since 1.43
*/
@XmlRootElement(name = "import")
@XmlAccessorType(XmlAccessType.FIELD)
public class ImportUrlRequest
{
/**
* Constructs ...
*
*/
ImportUrlRequest() {}
/**
* Constructs ...
*
*
* @param type
* @param name
* @param url
*/
public ImportUrlRequest(String type, String name, String url)
{
this.type = type;
this.name = name;
this.url = url;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return type;
}
/**
* Method description
*
*
* @return
*/
public String getUrl()
{
return url;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String name;
/** Field description */
@XmlTransient
private String type;
/** Field description */
private String url;
}

View File

@@ -1,149 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.NotSupportedFeatuerException;
import sonia.scm.Type;
import sonia.scm.repository.Repository;
import sonia.scm.repository.Tags;
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
/**
*
* @author Sebastian Sdorra
*/
public interface RepositoryClientHandler extends ClientHandler<Repository>
{
/**
* Method description
*
*
* @param type
*
* @return
*
* @since 1.43
*/
public ImportResultWrapper importFromDirectory(String type);
/**
* Method description
*
*
* @param request
*
* @return
*
* @since 1.43
*/
public Repository importFromBundle(ImportBundleRequest request);
/**
* Method description
*
*
* @param request
* @return
*
* @since 1.43
*/
public Repository importFromUrl(ImportUrlRequest request);
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param type
* @param name
*
* @return
* @since 1.11
*/
public Repository get(String type, String name);
/**
* Method description
*
*
* @param repository
*
* @return
* @since 1.8
*
* @throws NotSupportedFeatuerException
*/
public ClientChangesetHandler getChangesetHandler(Repository repository)
throws NotSupportedFeatuerException;
/**
* Method description
*
*
* @param repository
*
* @return
* @since 1.8
*
* @throws NotSupportedFeatuerException
*/
public ClientRepositoryBrowser getRepositoryBrowser(Repository repository)
throws NotSupportedFeatuerException;
/**
* Method description
*
*
* @return
*/
public Collection<Type> getRepositoryTypes();
/**
* Returns all tags of the given repository.
*
*
* @param repository repository
*
* @return all tags of the given repository
* @since 1.18
*/
public Tags getTags(Repository repository);
}

View File

@@ -1,135 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.ServiceUtil;
/**
*
* @author Sebastian Sdorra
*/
public final class ScmClient
{
/** Field description */
private static volatile ScmClientProvider provider = null;
/** the logger for ScmClient */
private static final Logger logger = LoggerFactory.getLogger(ScmClient.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private ScmClient() {}
//~--- methods --------------------------------------------------------------
/**
* Creates an ScmClientSession for the given user
*
*
* @param url
* @param username
* @param password
*
* @return
*
* @throws ScmClientException
*/
public static ScmClientSession createSession(String url, String username,
String password)
throws ScmClientException
{
return getProvider().createSession(url, username, password);
}
/**
* Creates an anonymous ScmClientSession
*
*
* @param url
*
* @return
*
* @throws ScmClientException
*/
public static ScmClientSession createSession(String url)
throws ScmClientException
{
return getProvider().createSession(url, null, null);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*
*/
private static ScmClientProvider getProvider()
{
if (provider == null)
{
synchronized (ScmClientProvider.class)
{
if (provider == null)
{
provider = ServiceUtil.getService(ScmClientProvider.class);
}
}
}
if (provider == null)
{
throw new ScmClientException("could not find a ScmClientProvider");
}
else if (logger.isInfoEnabled())
{
logger.info("create ScmClient with provider {}",
provider.getClass().getName());
}
return provider;
}
}

View File

@@ -1,174 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
/**
*
* @author Sebastian Sdorra
*/
public class ScmClientException extends RuntimeException
{
/** Field description */
public static final int SC_FORBIDDEN = 403;
/** Field description */
public static final int SC_NOTFOUND = 404;
/** Field description */
public static final int SC_UNAUTHORIZED = 401;
/** Field description */
public static final int SC_UNKNOWN = -1;
/** Field description */
private static final long serialVersionUID = -2302107106896701393L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param statusCode
*/
public ScmClientException(int statusCode)
{
this.statusCode = statusCode;
}
/**
* Constructs ...
*
*
* @param message
*/
public ScmClientException(String message)
{
super(message);
}
/**
* Constructs ...
*
*
* @param cause
*/
public ScmClientException(Throwable cause)
{
super(cause);
}
/**
* Constructs ...
*
*
*
* @param statusCode
* @param message
*/
public ScmClientException(int statusCode, String message)
{
super(message);
this.statusCode = statusCode;
}
/**
* Constructs ...
*
*
* @param message
* @param cause
*/
public ScmClientException(String message, Throwable cause)
{
super(message, cause);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getContent()
{
return content;
}
/**
* Method description
*
*
* @return
*/
public int getStatusCode()
{
return statusCode;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param content
*/
public void setContent(String content)
{
this.content = content;
}
/**
* Method description
*
*
* @param statusCode
*/
public void setStatusCode(int statusCode)
{
this.statusCode = statusCode;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String content;
/** Field description */
private int statusCode = SC_UNKNOWN;
}

View File

@@ -1,56 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
/**
*
* @author Sebastian Sdorra
*/
public interface ScmClientProvider
{
/**
* Method description
*
*
* @param url
* @param username
* @param password
*
* @return
*
*/
public ScmClientSession createSession(String url, String username,
String password);
}

View File

@@ -1,99 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.ScmState;
//~--- JDK imports ------------------------------------------------------------
import java.io.Closeable;
/**
*
* @author Sebastian Sdorra
*/
public interface ScmClientSession extends Closeable
{
/**
* Method description
*
*/
@Override
public void close();
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public GroupClientHandler getGroupHandler();
/**
* Method description
*
*
* @return
*/
public RepositoryClientHandler getRepositoryHandler();
/**
* Method description
*
*
* @return
*/
public SecurityClientHandler getSecurityHandler();
/**
* Method description
*
*
* @return
*/
public ScmState getState();
/**
* Method description
*
*
* @return
*/
public UserClientHandler getUserHandler();
}

View File

@@ -1,67 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
/**
*
* @author Sebastian Sdorra
*/
public class ScmForbiddenException extends ScmClientException
{
/** Field description */
private static final long serialVersionUID = 3937346624508458660L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public ScmForbiddenException()
{
super(SC_FORBIDDEN);
}
/**
* Constructs ...
*
*
* @param message
*/
public ScmForbiddenException(String message)
{
super(SC_FORBIDDEN, message);
}
}

View File

@@ -1,67 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
/**
*
* @author Sebastian Sdorra
*/
public class ScmNotFoundException extends ScmClientException
{
/** Field description */
private static final long serialVersionUID = -7015126639998723954L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public ScmNotFoundException()
{
super(SC_NOTFOUND);
}
/**
* Constructs ...
*
*
* @param message
*/
public ScmNotFoundException(String message)
{
super(SC_NOTFOUND, message);
}
}

View File

@@ -1,67 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
/**
*
* @author Sebastian Sdorra
*/
public class ScmUnauthorizedException extends ScmClientException
{
/** Field description */
private static final long serialVersionUID = 4398907424134588809L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public ScmUnauthorizedException()
{
super(SC_UNAUTHORIZED);
}
/**
* Constructs ...
*
*
* @param message
*/
public ScmUnauthorizedException(String message)
{
super(SC_UNAUTHORIZED, message);
}
}

View File

@@ -1,59 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
/**
*
* @author Sebastian Sdorra
* @since 1.41
*/
public interface SecurityClientHandler
{
/**
* Method description
*
*
* @param value
*
* @return
*/
public String encrypt(String value);
/**
* Method description
*
*
* @return
*/
public String generateKey();
}

View File

@@ -1,44 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.user.User;
/**
*
* @author Sebastian Sdorra
*/
public interface UserClientHandler extends ClientHandler<User> {}

View File

@@ -1,227 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>sonia.scm.clients</groupId>
<artifactId>scm-clients</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>sonia.scm.clients</groupId>
<artifactId>scm-client-impl</artifactId>
<packaging>jar</packaging>
<version>2.0.0-SNAPSHOT</version>
<name>scm-client-impl</name>
<dependencies>
<!-- fix javadoc -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>sonia.scm.clients</groupId>
<artifactId>scm-client-api</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-client.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${jersey-client.version}</version>
</dependency>
<!-- test scope -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>sonia.scm</groupId>
<artifactId>scm-test</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- for async-http-client -->
<repositories>
<repository>
<id>Sonatype</id>
<name>Sonatype Release</name>
<url>http://oss.sonatype.org/content/repositories/releases</url>
</repository>
<repository>
<id>maven.scm-manager.org</id>
<name>scm-manager release repository</name>
<url>http://maven.scm-manager.org/nexus/content/groups/public</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>it</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>sonia.scm</groupId>
<artifactId>scm-webapp</artifactId>
<version>${project.version}</version>
<type>war</type>
<outputDirectory>${project.build.directory}/webapp</outputDirectory>
<destFileName>scm-webapp.war</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.maven.version}</version>
<configuration>
<stopPort>8085</stopPort>
<stopKey>STOP</stopKey>
<systemProperties>
<systemProperty>
<name>scm.home</name>
<value>target/scm-it</value>
</systemProperty>
<systemProperty>
<name>file.encoding</name>
<value>UTF-8</value>
</systemProperty>
</systemProperties>
<httpConnector>
<port>8081</port>
</httpConnector>
<webApp>
<contextPath>/scm</contextPath>
</webApp>
<war>${project.build.directory}/webapp/scm-webapp.war</war>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy-war</goal>
</goals>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -1,346 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.ModelObject;
import sonia.scm.url.UrlProvider;
import sonia.scm.util.AssertUtil;
//~--- JDK imports ------------------------------------------------------------
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import java.util.List;
/**
*
* @author Sebastian Sdorra
*
* @param <T>
*/
public abstract class AbstractClientHandler<T extends ModelObject>
implements ClientHandler<T>
{
/** the logger for AbstractClientHandler */
private static final Logger logger =
LoggerFactory.getLogger(AbstractClientHandler.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param session
* @param itemClass
*/
public AbstractClientHandler(JerseyClientSession session, Class<T> itemClass)
{
this.session = session;
this.itemClass = itemClass;
this.client = session.getClient();
this.urlProvider = session.getUrlProvider();
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
*
* @return
*/
protected abstract GenericType<List<T>> createGenericListType();
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param itemId
*
* @return
*/
protected abstract String getItemUrl(String itemId);
/**
* Method description
*
*
* @return
*/
protected abstract String getItemsUrl();
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param item
*/
@Override
public void create(T item)
{
AssertUtil.assertIsNotNull(item);
WebResource resource = client.resource(getItemsUrl());
ClientResponse response = null;
try
{
response = resource.post(ClientResponse.class, item);
ClientUtil.checkResponse(response, 201);
String url = response.getHeaders().get("Location").get(0);
AssertUtil.assertIsNotEmpty(url);
T newItem = getItemByUrl(url);
AssertUtil.assertIsNotNull(newItem);
postCreate(response, item, newItem);
}
finally
{
ClientUtil.close(response);
}
}
/**
* Method description
*
*
* @param id
*/
@Override
public void delete(String id)
{
AssertUtil.assertIsNotEmpty(id);
WebResource resource = client.resource(getItemUrl(id));
ClientResponse response = null;
try
{
response = resource.delete(ClientResponse.class);
ClientUtil.checkResponse(response, 204);
}
finally
{
ClientUtil.close(response);
}
}
/**
* Method description
*
*
* @param item
*/
@Override
public void delete(T item)
{
AssertUtil.assertIsNotNull(item);
delete(item.getId());
}
/**
* Method description
*
*
* @param item
*/
@Override
public void modify(T item)
{
AssertUtil.assertIsNotNull(item);
String id = item.getId();
AssertUtil.assertIsNotEmpty(id);
WebResource resource = client.resource(getItemUrl(id));
ClientResponse response = null;
try
{
response = resource.put(ClientResponse.class, item);
ClientUtil.checkResponse(response, 204);
postModify(response, item);
}
finally
{
ClientUtil.close(response);
}
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param id
*
* @return
*/
@Override
public T get(String id)
{
return getItemByUrl(getItemUrl(id));
}
/**
* Method description
*
*
* @return
*/
@Override
public List<T> getAll()
{
List<T> items = null;
String url = getItemsUrl();
if (logger.isDebugEnabled())
{
logger.debug("fetch all items of {} from url", itemClass.getSimpleName(),
url);
}
WebResource resource = client.resource(url);
ClientResponse response = null;
try
{
response = resource.get(ClientResponse.class);
ClientUtil.checkResponse(response, 200);
items = response.getEntity(createGenericListType());
}
finally
{
ClientUtil.close(response);
}
return items;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param response
* @param item
* @param newItem
*/
protected void postCreate(ClientResponse response, T item, T newItem) {}
/**
* Method description
*
*
* @param response
* @param item
*/
protected void postModify(ClientResponse response, T item) {}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param url
*
* @return
*/
protected T getItemByUrl(String url)
{
if (logger.isDebugEnabled())
{
logger.debug("fetch item {} from url {}", itemClass.getSimpleName(), url);
}
T item = null;
WebResource resource = client.resource(url);
ClientResponse response = null;
try
{
response = resource.get(ClientResponse.class);
int sc = response.getStatus();
if (sc != ScmClientException.SC_NOTFOUND)
{
ClientUtil.checkResponse(response, 200);
item = response.getEntity(itemClass);
}
}
finally
{
ClientUtil.close(response);
}
return item;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
protected Client client;
/** Field description */
protected JerseyClientSession session;
/** Field description */
protected UrlProvider urlProvider;
/** Field description */
private Class<T> itemClass;
}

View File

@@ -1,238 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//~--- JDK imports ------------------------------------------------------------
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.LoggingFilter;
/**
*
* @author Sebastian Sdorra
*/
public final class ClientUtil
{
/** the logger for ClientUtil */
private static final Logger logger =
LoggerFactory.getLogger(ClientUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private ClientUtil() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param exception
* @param response
*/
public static void appendContent(ScmClientException exception,
ClientResponse response)
{
try
{
exception.setContent(response.getEntity(String.class));
}
catch (Exception ex)
{
logger.warn("could not read content", ex);
}
}
/**
* Method description
*
*
* @param response
* @param expectedStatusCode
*/
public static void checkResponse(ClientResponse response,
int expectedStatusCode)
{
int sc = response.getStatus();
if (sc != expectedStatusCode)
{
if (logger.isWarnEnabled())
{
logger.warn("response code {} expected, but {} returned",
expectedStatusCode, sc);
}
sendException(response, sc);
}
}
/**
* Method description
*
*
* @param response
*
*/
public static void checkResponse(ClientResponse response)
{
int sc = response.getStatus();
if (sc >= 300)
{
if (logger.isWarnEnabled())
{
logger.warn("request failed, response code {} returned", sc);
}
sendException(response, sc);
}
}
/**
* Method description
*
*
* @param response
*/
public static void close(ClientResponse response)
{
if (response != null)
{
response.close();
}
}
/**
* Method description
*
*
* @param client
* @param url
*
* @return
*/
public static WebResource createResource(Client client, String url)
{
return createResource(client, url, false);
}
/**
* Method description
*
*
* @param client
* @param url
* @param enableLogging
*
* @return
*/
public static WebResource createResource(Client client, String url,
boolean enableLogging)
{
WebResource resource = client.resource(url);
if (enableLogging)
{
resource.addFilter(new LoggingFilter());
}
return resource;
}
/**
* Method description
*
*
* @param response
* @param sc
*/
public static void sendException(ClientResponse response, int sc)
{
ScmClientException exception = null;
switch (sc)
{
case ScmClientException.SC_UNAUTHORIZED :
exception = new ScmUnauthorizedException();
break;
case ScmClientException.SC_FORBIDDEN :
exception = new ScmForbiddenException();
break;
case ScmClientException.SC_NOTFOUND :
exception = new ScmNotFoundException();
break;
default :
exception = new ScmClientException(sc);
appendContent(exception, response);
}
throw exception;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param response
*
* @return
*/
public static boolean isSuccessfull(ClientResponse response)
{
int status = response.getStatus();
return (status > 200) && (status < 300);
}
}

View File

@@ -1,191 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.Repository;
//~--- JDK imports ------------------------------------------------------------
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
/**
*
* @author Sebastian Sdorra
*/
public class JerseyClientChangesetHandler implements ClientChangesetHandler
{
/**
* Constructs ...
*
*
* @param session
* @param repository
*/
public JerseyClientChangesetHandler(JerseyClientSession session,
Repository repository)
{
this.session = session;
this.repository = repository;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param revision
*
* @return
*/
@Override
public Changeset getChangeset(String revision)
{
Changeset changeset = null;
String url =
session.getUrlProvider().getRepositoryUrlProvider().getChangesetUrl(
repository.getId(), revision);
WebResource resource = session.getClient().resource(url);
ClientResponse response = null;
try
{
response = resource.get(ClientResponse.class);
if (response.getStatus() != ScmClientException.SC_NOTFOUND)
{
ClientUtil.checkResponse(response, 200);
changeset = response.getEntity(Changeset.class);
}
}
finally
{
ClientUtil.close(response);
}
return changeset;
}
/**
* Method description
*
*
* @param start
* @param limit
*
* @return
*/
@Override
public ChangesetPagingResult getChangesets(int start, int limit)
{
ChangesetPagingResult result = null;
String url =
session.getUrlProvider().getRepositoryUrlProvider().getChangesetUrl(
repository.getId(), start, limit);
WebResource resource = session.getClient().resource(url);
ClientResponse response = null;
try
{
response = resource.get(ClientResponse.class);
if (response.getStatus() != ScmClientException.SC_NOTFOUND)
{
ClientUtil.checkResponse(response, 200);
result = response.getEntity(ChangesetPagingResult.class);
}
}
finally
{
ClientUtil.close(response);
}
return result;
}
/**
* Method description
*
*
*
* @param path
* @param revision
* @param start
* @param limit
*
* @return
*/
@Override
public ChangesetPagingResult getChangesets(String path, String revision,
int start, int limit)
{
ChangesetPagingResult result = null;
String url =
session.getUrlProvider().getRepositoryUrlProvider().getChangesetUrl(
repository.getId(), path, revision, start, limit);
WebResource resource = session.getClient().resource(url);
ClientResponse response = null;
try
{
response = resource.get(ClientResponse.class);
if (response.getStatus() != ScmClientException.SC_NOTFOUND)
{
ClientUtil.checkResponse(response, 200);
result = response.getEntity(ChangesetPagingResult.class);
}
}
finally
{
ClientUtil.close(response);
}
return result;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Repository repository;
/** Field description */
private JerseyClientSession session;
}

View File

@@ -1,282 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.ScmState;
import sonia.scm.url.UrlProvider;
import sonia.scm.url.UrlProviderFactory;
import sonia.scm.util.AssertUtil;
import sonia.scm.util.HttpUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientRequest;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.ClientFilter;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import com.sun.jersey.multipart.impl.MultiPartWriter;
import javax.ws.rs.core.MultivaluedMap;
/**
*
* @author Sebastian Sdorra
*/
public class JerseyClientProvider implements ScmClientProvider
{
/** the logger for JerseyClientProvider */
private static final Logger logger =
LoggerFactory.getLogger(JerseyClientProvider.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public JerseyClientProvider() {}
/**
* Constructs ...
*
*
* @param enableLogging
*/
public JerseyClientProvider(boolean enableLogging)
{
this.enableLogging = enableLogging;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param url
* @param username
* @param password
*
* @return
*
*/
@Override
public JerseyClientSession createSession(String url, String username,
String password)
{
AssertUtil.assertIsNotEmpty(url);
String user = "anonymous";
if (Util.isNotEmpty(username))
{
user = username;
}
logger.info("create new session for {} with username {}", url, user);
UrlProvider urlProvider = UrlProviderFactory.createUrlProvider(url,
UrlProviderFactory.TYPE_RESTAPI_XML);
Client client =
Client.create(new DefaultClientConfig(MultiPartWriter.class));
boolean loginAttempt = isLoginAttempt(username, password);
ClientResponse response;
if (loginAttempt)
{
response = login(urlProvider, client, username, password);
}
else
{
response = state(urlProvider, client);
}
ClientUtil.checkResponse(response);
ScmState state = response.getEntity(ScmState.class);
if (!state.isSuccess())
{
logger.warn("server returned state failed");
throw new ScmClientException("create ScmClientSession failed");
}
logger.info("create session successfully for user {}", user);
if (loginAttempt)
{
appendAuthenticationFilter(client, state);
}
return new JerseyClientSession(client, urlProvider, state);
}
private void appendAuthenticationFilter(Client client, ScmState state)
{
String token = state.getToken();
if (Strings.isNullOrEmpty(token))
{
throw new ScmClientException(
"scm-manager does not return a bearer token");
}
// authentication for further requests
client.addFilter(new AuthenticationFilter(token));
}
private ClientResponse login(UrlProvider urlProvider, Client client,
String username, String password)
{
String authUrl = urlProvider.getAuthenticationUrl();
if (logger.isDebugEnabled())
{
logger.debug("try login at {}", authUrl);
}
WebResource resource = ClientUtil.createResource(client, authUrl,
enableLogging);
if (logger.isDebugEnabled())
{
logger.debug("try login for {}", username);
}
MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
formData.add("username", username);
formData.add("password", password);
formData.add("grant_type", "password");
return resource.type("application/x-www-form-urlencoded").post(
ClientResponse.class, formData);
}
private ClientResponse state(UrlProvider urlProvider, Client client)
{
String stateUrl = urlProvider.getStateUrl();
if (logger.isDebugEnabled())
{
logger.debug("retrive state from {}", stateUrl);
}
WebResource resource = ClientUtil.createResource(client, stateUrl,
enableLogging);
if (logger.isDebugEnabled())
{
logger.debug("try anonymous login");
}
return resource.get(ClientResponse.class);
}
//~--- get methods ----------------------------------------------------------
private boolean isLoginAttempt(String username, String password)
{
return Util.isNotEmpty(username) && Util.isNotEmpty(password);
}
//~--- inner classes --------------------------------------------------------
/**
* Authentication filter
*/
private class AuthenticationFilter extends ClientFilter
{
/**
* Constructs ...
*
*
* @param bearerToken
*/
public AuthenticationFilter(String bearerToken)
{
this.bearerToken = bearerToken;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param request
*
* @return
*
* @throws ClientHandlerException
*/
@Override
public ClientResponse handle(ClientRequest request)
throws ClientHandlerException
{
request.getHeaders().putSingle(HttpUtil.HEADER_AUTHORIZATION,
HttpUtil.AUTHORIZATION_SCHEME_BEARER.concat(" ").concat(bearerToken));
return getNext().handle(request);
}
//~--- fields -------------------------------------------------------------
/** Field description */
private final String bearerToken;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private boolean enableLogging = false;
}

View File

@@ -1,232 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.BlameLine;
import sonia.scm.repository.BlameResult;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.FileObject;
import sonia.scm.repository.Repository;
import sonia.scm.util.AssertUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Sebastian Sdorra
*/
public class JerseyClientRepositoryBrowser implements ClientRepositoryBrowser
{
/**
* Constructs ...
*
*
* @param session
* @param repository
*/
public JerseyClientRepositoryBrowser(JerseyClientSession session,
Repository repository)
{
this.session = session;
this.repository = repository;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param revision
* @param path
*
* @return
*/
@Override
public List<BlameLine> getBlameLines(String revision, String path)
{
List<BlameLine> blameLines = null;
String url =
session.getUrlProvider().getRepositoryUrlProvider().getBlameUrl(
repository.getId(), path, revision);
WebResource resource = session.getClient().resource(url);
ClientResponse response = null;
try
{
response = resource.get(ClientResponse.class);
if (response.getStatus() != ScmClientException.SC_NOTFOUND)
{
ClientUtil.checkResponse(response, 200);
BlameResult result = response.getEntity(BlameResult.class);
AssertUtil.assertIsNotNull(result);
blameLines = result.getBlameLines();
}
}
finally
{
ClientUtil.close(response);
}
return blameLines;
}
/**
* Method description
*
*
* @param revision
* @param path
*
* @return
*
* @throws IOException
*/
@Override
public InputStream getContent(String revision, String path) throws IOException
{
InputStream input = null;
String url =
session.getUrlProvider().getRepositoryUrlProvider().getContentUrl(
repository.getId(), path, revision);
WebResource resource = session.getClient().resource(url);
ClientResponse response = null;
try
{
response = resource.get(ClientResponse.class);
if (response.getStatus() != ScmClientException.SC_NOTFOUND)
{
ClientUtil.checkResponse(response, 200);
input = response.getEntityInputStream();
}
}
finally
{
ClientUtil.close(response);
}
return input;
}
/**
* Method description
*
*
* @param revision
* @param path
*
* @return
*/
@Override
public List<FileObjectWrapper> getFiles(String revision, String path)
{
List<FileObjectWrapper> files = null;
String url =
session.getUrlProvider().getRepositoryUrlProvider().getBrowseUrl(
repository.getId(), path, revision);
WebResource resource = session.getClient().resource(url);
ClientResponse response = null;
try
{
response = resource.get(ClientResponse.class);
if (response.getStatus() != ScmClientException.SC_NOTFOUND)
{
ClientUtil.checkResponse(response, 200);
BrowserResult result = response.getEntity(BrowserResult.class);
AssertUtil.assertIsNotNull(result);
files = new ArrayList<FileObjectWrapper>();
List<FileObject> foList = result.getFiles();
if (Util.isNotEmpty(foList))
{
for (FileObject fo : foList)
{
files.add(new FileObjectWrapper(this, revision, fo));
}
}
}
}
finally
{
ClientUtil.close(response);
}
return files;
}
/**
* Method description
*
*
* @param revision
*
* @return
*/
@Override
public List<FileObjectWrapper> getFiles(String revision)
{
return getFiles(revision, Util.EMPTY_STRING);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Repository repository;
/** Field description */
private JerseyClientSession session;
}

View File

@@ -1,189 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.ScmState;
import sonia.scm.url.UrlProvider;
//~--- JDK imports ------------------------------------------------------------
import com.sun.jersey.api.client.Client;
/**
*
* @author Sebastian Sdorra
*/
public class JerseyClientSession implements ScmClientSession
{
/** the logger for JerseyClientSession */
private static final Logger logger =
LoggerFactory.getLogger(JerseyClientSession.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param client
* @param urlProvider
* @param state
*/
public JerseyClientSession(Client client, UrlProvider urlProvider,
ScmState state)
{
this.client = client;
this.urlProvider = urlProvider;
this.state = state;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
*/
@Override
public void close()
{
if (logger.isInfoEnabled())
{
logger.info("close client session");
}
client.destroy();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public Client getClient()
{
return client;
}
/**
* Method description
*
*
* @return
*/
@Override
public GroupClientHandler getGroupHandler()
{
return new JerseyGroupClientHandler(this);
}
/**
* Method description
*
*
* @return
*/
@Override
public RepositoryClientHandler getRepositoryHandler()
{
return new JerseyRepositoryClientHandler(this);
}
/**
* Method description
*
*
* @return
*/
@Override
public SecurityClientHandler getSecurityHandler()
{
return new JerseySecurityClientHandler(this);
}
/**
* Method description
*
*
* @return
*/
@Override
public ScmState getState()
{
return state;
}
/**
* Method description
*
*
* @return
*/
public UrlProvider getUrlProvider()
{
return urlProvider;
}
/**
* Method description
*
*
* @return
*/
@Override
public UserClientHandler getUserHandler()
{
return new JerseyUserClientHandler(this);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private final Client client;
/** Field description */
private final ScmState state;
/** Field description */
private final UrlProvider urlProvider;
}

Some files were not shown because too many files have changed in this diff Show More