diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000000..0609164d73
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,3 @@
+# ignore everything except scm-server.tar.gz
+**
+!scm-server/target/*.tar.gz
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000000..13c5268429
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,3 @@
+{
+ "extends": "@scm-manager/eslint-config"
+}
diff --git a/.hgignore b/.hgignore
index 6ff185f670..00efb50c1f 100644
--- a/.hgignore
+++ b/.hgignore
@@ -29,3 +29,8 @@ Desktop DF$
# jrebel
rebel.xml
\.pyc
+# ui
+scm-ui/build
+scm-ui/coverage
+/?node_modules/
+
diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000000..9cc84ea9b4
Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000000..8b4bf8dee1
--- /dev/null
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1,2 @@
+# Keep this version number in sync with Jenkinsfile
+distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000000..781a3e890b
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,20 @@
+FROM openjdk:8u171-alpine3.8
+
+ENV SCM_HOME=/var/lib/scm
+
+RUN set -x \
+ && apk add --no-cache mercurial bash \
+ && addgroup -S -g 1000 scm \
+ && adduser -S -s /bin/false -G scm -h /opt/scm-server -D -H -u 1000 scm \
+ && mkdir ${SCM_HOME} \
+ && chown scm:scm ${SCM_HOME}
+
+ADD scm-server/target/scm-server-app.tar.gz /opt
+RUN chown -R scm:scm /opt/scm-server
+
+WORKDIR /opt/scm-server
+VOLUME [ "${SCM_HOME}", "/opt/scm-server/var/log" ]
+EXPOSE 8080
+USER scm
+
+ENTRYPOINT [ "/opt/scm-server/bin/scm-server" ]
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000000..36135cf4a4
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,171 @@
+#!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@59d3e94')
+import com.cloudogu.ces.cesbuildlib.*
+
+node('docker') {
+
+ // Change this as when we go back to default - necessary for proper SonarQube analysis
+ mainBranch = '2.0.0-m3'
+
+ properties([
+ // Keep only the last 10 build to preserve space
+ buildDiscarder(logRotator(numToKeepStr: '10')),
+ disableConcurrentBuilds(),
+ parameters([
+ string(name: 'dockerTag', trim: true, defaultValue: 'latest', description: 'Extra Docker Tag for cloudogu/scm-manager image')
+ ])
+ ])
+
+ timeout(activity: true, time: 30, unit: 'MINUTES') {
+
+ catchError {
+
+ Maven mvn = setupMavenBuild()
+
+ stage('Checkout') {
+ checkout scm
+ }
+
+ stage('Build') {
+ mvn 'clean install -Pdoc -DskipTests'
+ }
+
+ stage('Unit Test') {
+ mvn 'test -Dsonia.scm.test.skip.hg=true -Dmaven.test.failure.ignore=true'
+ }
+
+ stage('Integration Test') {
+ mvn 'verify -Pit -pl :scm-webapp,:scm-it -Dmaven.test.failure.ignore=true'
+ }
+
+ stage('SonarQube') {
+
+ analyzeWith(mvn)
+
+ if (!waitForQualityGateWebhookToBeCalled()) {
+ currentBuild.result = 'UNSTABLE'
+ }
+ }
+
+ def commitHash = getCommitHash()
+ def dockerImageTag = "2.0.0-dev-${commitHash.substring(0,7)}-${BUILD_NUMBER}"
+
+ if (isMainBranch()) {
+
+ stage('Lifecycle') {
+ nexusPolicyEvaluation iqApplication: selectedApplication('scm'), iqScanPatterns: [[scanPattern: 'scm-server/target/scm-server-app.zip']], iqStage: 'build'
+ }
+
+ stage('Archive') {
+ archiveArtifacts 'scm-webapp/target/scm-webapp.war'
+ archiveArtifacts 'scm-server/target/scm-server-app.*'
+ archiveArtifacts 'scm-webapp/target/scm-webapp-restdocs.zip'
+ }
+
+ stage('Docker') {
+ def image = docker.build('cloudogu/scm-manager')
+ docker.withRegistry('', 'hub.docker.com-cesmarvin') {
+ image.push(dockerImageTag)
+ image.push('latest')
+ if (!'latest'.equals(params.dockerTag)) {
+ image.push(params.dockerTag)
+
+ def newDockerTag = "2.0.0-${commitHash.substring(0,7)}-dev-${params.dockerTag}"
+ currentBuild.description = newDockerTag
+ image.push(newDockerTag)
+ }
+ }
+ }
+
+ stage('Deployment') {
+ build job: 'scm-manager/next-scm.cloudogu.com', propagate: false, wait: false, parameters: [
+ string(name: 'changeset', value: commitHash),
+ string(name: 'imageTag', value: dockerImageTag)
+ ]
+ }
+ }
+ }
+
+ // Archive Unit and integration test results, if any
+ junit allowEmptyResults: true, testResults: '**/target/failsafe-reports/TEST-*.xml,**/target/surefire-reports/TEST-*.xml,**/target/jest-reports/TEST-*.xml'
+
+ // Find maven warnings and visualize in job
+ warnings consoleParsers: [[parserName: 'Maven']], canRunOnFailed: true
+
+ mailIfStatusChanged(commitAuthorEmail)
+ }
+}
+
+String mainBranch
+
+Maven setupMavenBuild() {
+ // Keep this version number in sync with .mvn/maven-wrapper.properties
+ Maven mvn = new MavenInDocker(this, '3.5.2-jdk-8')
+
+ if (isMainBranch()) {
+ // Release starts javadoc, which takes very long, so do only for certain branches
+ mvn.additionalArgs += ' -DperformRelease'
+ // JDK8 is more strict, we should fix this before the next release. Right now, this is just not the focus, yet.
+ mvn.additionalArgs += ' -Dmaven.javadoc.failOnError=false'
+ }
+ return mvn
+}
+
+void analyzeWith(Maven mvn) {
+
+ withSonarQubeEnv('sonarcloud.io-scm') {
+
+ String mvnArgs = "${env.SONAR_MAVEN_GOAL} " +
+ "-Dsonar.host.url=${env.SONAR_HOST_URL} " +
+ "-Dsonar.login=${env.SONAR_AUTH_TOKEN} "
+
+ if (isPullRequest()) {
+ echo "Analysing SQ in PR mode"
+ mvnArgs += "-Dsonar.pullrequest.base=${env.CHANGE_TARGET} " +
+ "-Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} " +
+ "-Dsonar.pullrequest.key=${env.CHANGE_ID} " +
+ "-Dsonar.pullrequest.provider=bitbucketcloud " +
+ "-Dsonar.pullrequest.bitbucketcloud.owner=sdorra " +
+ "-Dsonar.pullrequest.bitbucketcloud.repository=scm-manager " +
+ "-Dsonar.cpd.exclusions=**/*StoreFactory.java,**/*UserPassword.js "
+ } else {
+ mvnArgs += " -Dsonar.branch.name=${env.BRANCH_NAME} "
+ if (!isMainBranch()) {
+ // Avoid exception "The main branch must not have a target" on main branch
+ mvnArgs += " -Dsonar.branch.target=${mainBranch} "
+ }
+ }
+ mvn "${mvnArgs}"
+ }
+}
+
+boolean isMainBranch() {
+ return mainBranch.equals(env.BRANCH_NAME)
+}
+
+boolean waitForQualityGateWebhookToBeCalled() {
+ boolean isQualityGateSucceeded = true
+ timeout(time: 5, 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}"'
+}
+
+String getCommitHash() {
+ new Sh(this).returnStdOut 'hg log --branch . --limit 1 --template "{node}"'
+}
+
+String getCommitAuthorEmail() {
+ def matcher = getCommitAuthorComplete() =~ "<(.*?)>"
+ matcher ? matcher[0][1] : ""
+}
diff --git a/deployments/helm/.helmignore b/deployments/helm/.helmignore
new file mode 100644
index 0000000000..f0c1319444
--- /dev/null
+++ b/deployments/helm/.helmignore
@@ -0,0 +1,21 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
diff --git a/deployments/helm/Chart.yaml b/deployments/helm/Chart.yaml
new file mode 100644
index 0000000000..c5b5fff4cc
--- /dev/null
+++ b/deployments/helm/Chart.yaml
@@ -0,0 +1,5 @@
+apiVersion: v1
+appVersion: "1.0"
+description: A Helm chart for SCM-Manager
+name: scm-manager
+version: 0.1.0
diff --git a/deployments/helm/templates/NOTES.txt b/deployments/helm/templates/NOTES.txt
new file mode 100644
index 0000000000..a58c8f124a
--- /dev/null
+++ b/deployments/helm/templates/NOTES.txt
@@ -0,0 +1,19 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range .Values.ingress.hosts }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "scm-manager.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get svc -w {{ include "scm-manager.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "scm-manager.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ include "scm-manager.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl port-forward $POD_NAME 8080:80
+{{- end }}
diff --git a/deployments/helm/templates/_helpers.tpl b/deployments/helm/templates/_helpers.tpl
new file mode 100644
index 0000000000..23d4e1b03e
--- /dev/null
+++ b/deployments/helm/templates/_helpers.tpl
@@ -0,0 +1,32 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "scm-manager.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "scm-manager.fullname" -}}
+{{- if .Values.fullnameOverride -}}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- if contains $name .Release.Name -}}
+{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "scm-manager.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
diff --git a/deployments/helm/templates/configmap.yaml b/deployments/helm/templates/configmap.yaml
new file mode 100644
index 0000000000..1ccb773355
--- /dev/null
+++ b/deployments/helm/templates/configmap.yaml
@@ -0,0 +1,160 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "scm-manager.fullname" . }}
+ labels:
+ app: {{ include "scm-manager.name" . }}
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ release: "{{ .Release.Name }}"
+ heritage: "{{ .Release.Service }}"
+data:
+ server-config.xml: |
+
+
+
+
+
+
+ 16384
+ 16384
+
+ {{- if .Values.ingress.enabled -}}
+
+
+
+
+ {{- end }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /scm
+
+ /var/webapp/scm-webapp.war
+
+
+ org.eclipse.jetty.servlet.Default.dirAllowed
+ false
+
+
+ /work/scm
+
+
+
+
+ /
+
+
+
+
+
+ /var/webapp/docroot
+
+
+
+
+
+ /work/docroot
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ logging.xml: |
+
+
+
+
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/deployments/helm/templates/deployment.yaml b/deployments/helm/templates/deployment.yaml
new file mode 100644
index 0000000000..7e19f61e57
--- /dev/null
+++ b/deployments/helm/templates/deployment.yaml
@@ -0,0 +1,93 @@
+apiVersion: apps/v1beta2
+kind: Deployment
+metadata:
+ name: {{ include "scm-manager.fullname" . }}
+ labels:
+ app: {{ include "scm-manager.name" . }}
+ chart: {{ include "scm-manager.chart" . }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+spec:
+ replicas: 1 # could not be scaled
+ strategy:
+ type: Recreate
+ selector:
+ matchLabels:
+ app: {{ include "scm-manager.name" . }}
+ release: {{ .Release.Name }}
+ template:
+ metadata:
+ labels:
+ app: {{ include "scm-manager.name" . }}
+ release: {{ .Release.Name }}
+ spec:
+ initContainers:
+ - name: volume-permissions
+ image: alpine:3.8
+ imagePullPolicy: IfNotPresent
+ command: ['sh', '-c', 'chown 1000:1000 /data']
+ volumeMounts:
+ - name: data
+ mountPath: /data
+ {{- if .Values.plugins }}
+ - name: install-plugins
+ image: alpine:3.8
+ imagePullPolicy: IfNotPresent
+ command: ['sh', '/scripts/install-plugins.sh']
+ volumeMounts:
+ - name: data
+ mountPath: /data
+ - name: scripts
+ mountPath: /scripts
+ {{- end }}
+ containers:
+ - name: {{ .Chart.Name }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 8080
+ protocol: TCP
+ livenessProbe:
+ httpGet:
+ path: /scm
+ port: http
+ readinessProbe:
+ httpGet:
+ path: /scm
+ port: http
+ resources:
+{{ toYaml .Values.resources | indent 12 }}
+ volumeMounts:
+ - name: data
+ mountPath: /var/lib/scm
+ - name: config
+ mountPath: /opt/scm-server/conf
+ volumes:
+ - name: data
+ {{- if .Values.persistence.enabled }}
+ persistentVolumeClaim:
+ claimName: {{ include "scm-manager.fullname" . }}
+ {{- else }}
+ emptyDir: {}
+ {{- end }}
+ - name: config
+ configMap:
+ name: {{ include "scm-manager.fullname" . }}
+ {{- if .Values.plugins }}
+ - name: scripts
+ configMap:
+ name: {{ include "scm-manager.fullname" . }}-scripts
+ {{- end }}
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+{{ toYaml . | indent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+{{ toYaml . | indent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+{{ toYaml . | indent 8 }}
+ {{- end }}
diff --git a/deployments/helm/templates/ingress.yaml b/deployments/helm/templates/ingress.yaml
new file mode 100644
index 0000000000..66912c9d96
--- /dev/null
+++ b/deployments/helm/templates/ingress.yaml
@@ -0,0 +1,38 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "scm-manager.fullname" . -}}
+{{- $ingressPath := .Values.ingress.path -}}
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ app: {{ include "scm-manager.name" . }}
+ chart: {{ include "scm-manager.chart" . }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+{{- with .Values.ingress.annotations }}
+ annotations:
+{{ toYaml . | indent 4 }}
+{{- end }}
+spec:
+{{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+{{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ . | quote }}
+ http:
+ paths:
+ - path: {{ $ingressPath }}
+ backend:
+ serviceName: {{ $fullName }}
+ servicePort: http
+ {{- end }}
+{{- end }}
diff --git a/deployments/helm/templates/pvc.yaml b/deployments/helm/templates/pvc.yaml
new file mode 100644
index 0000000000..0e7d0f6db4
--- /dev/null
+++ b/deployments/helm/templates/pvc.yaml
@@ -0,0 +1,24 @@
+{{- if .Values.persistence.enabled -}}
+kind: PersistentVolumeClaim
+apiVersion: v1
+metadata:
+ name: {{ include "scm-manager.fullname" . }}
+ labels:
+ app: {{ include "scm-manager.name" . }}
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ release: "{{ .Release.Name }}"
+ heritage: "{{ .Release.Service }}"
+spec:
+ accessModes:
+ - {{ .Values.persistence.accessMode | quote }}
+ resources:
+ requests:
+ storage: {{ .Values.persistence.size | quote }}
+{{- if .Values.persistence.storageClass }}
+{{- if (eq "-" .Values.persistence.storageClass) }}
+ storageClassName: ""
+{{- else }}
+ storageClassName: "{{ .Values.persistence.storageClass }}"
+{{- end }}
+{{- end }}
+{{- end -}}
diff --git a/deployments/helm/templates/scripts.yaml b/deployments/helm/templates/scripts.yaml
new file mode 100644
index 0000000000..43a442a8e2
--- /dev/null
+++ b/deployments/helm/templates/scripts.yaml
@@ -0,0 +1,21 @@
+{{- if .Values.plugins }}
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "scm-manager.fullname" . }}-scripts
+ labels:
+ app: {{ include "scm-manager.name" . }}
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ release: "{{ .Release.Name }}"
+ heritage: "{{ .Release.Service }}"
+data:
+ install-plugins.sh: |
+ #!/bin/sh
+ mkdir -p /data/plugins
+ chown 1000:1000 /data/plugins
+ {{ range $i, $plugin := .Values.plugins }}
+ # install plugin {{ $plugin.name }}
+ wget -O /data/plugins/{{ $plugin.name }}.smp {{ $plugin.url }}
+ chown 1000:1000 /data/plugins/{{ $plugin.name }}.smp
+ {{ end }}
+{{- end }}
diff --git a/deployments/helm/templates/service.yaml b/deployments/helm/templates/service.yaml
new file mode 100644
index 0000000000..f3a8207908
--- /dev/null
+++ b/deployments/helm/templates/service.yaml
@@ -0,0 +1,19 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "scm-manager.fullname" . }}
+ labels:
+ app: {{ include "scm-manager.name" . }}
+ chart: {{ include "scm-manager.chart" . }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: 8080
+ protocol: TCP
+ name: http
+ selector:
+ app: {{ include "scm-manager.name" . }}
+ release: {{ .Release.Name }}
diff --git a/deployments/helm/values.yaml b/deployments/helm/values.yaml
new file mode 100644
index 0000000000..0b107a8168
--- /dev/null
+++ b/deployments/helm/values.yaml
@@ -0,0 +1,69 @@
+# Default values for scm-manager.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+# replicaCount: 1
+
+image:
+ repository: cloudogu/scm-manager
+ # TODO change after release, to something more stable
+ tag: latest
+ pullPolicy: Always
+
+# plugins:
+# - name: scm-review-plugin
+# url: https://oss.cloudogu.com/jenkins/job/scm-manager/job/scm-manager-bitbucket/job/scm-review-plugin/job/develop/lastSuccessfulBuild/artifact/target/scm-review-plugin-2.0.0-SNAPSHOT.smp
+
+nameOverride: ""
+fullnameOverride: ""
+
+service:
+ type: LoadBalancer
+ port: 80
+
+ingress:
+ enabled: false
+ annotations: {}
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ path: /
+ hosts:
+ - scm-manager.local
+ tls: []
+ # - secretName: scm-manager-tls
+ # hosts:
+ # - scm-manager.local
+
+## Enable persistence using Persistent Volume Claims
+## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
+##
+persistence:
+ enabled: true
+ ## ghost data Persistent Volume Storage Class
+ ## If defined, storageClassName:
+ ## If set to "-", storageClassName: "", which disables dynamic provisioning
+ ## If undefined (the default) or set to null, no storageClassName spec is
+ ## set, choosing the default provisioner. (gp2 on AWS, standard on
+ ## GKE, AWS & OpenStack)
+ ##
+ # storageClass: "-"
+ accessMode: ReadWriteOnce
+ size: 12Gi
+
+resources:
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ limits:
+ cpu: 2000m
+ memory: 2048Mi
+ requests:
+ cpu: 50m
+ memory: 256Mi
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/docs/dtd/plugin/2.0.0-01.dtd b/docs/dtd/plugin/2.0.0-01.dtd
index eec149f3e8..954a2c2219 100644
--- a/docs/dtd/plugin/2.0.0-01.dtd
+++ b/docs/dtd/plugin/2.0.0-01.dtd
@@ -29,46 +29,28 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
@@ -121,4 +103,4 @@
-
\ No newline at end of file
+
diff --git a/docs/logo/favicon_16x16px.ico b/docs/logo/favicon_16x16px.ico
new file mode 100644
index 0000000000..3436795fdf
Binary files /dev/null and b/docs/logo/favicon_16x16px.ico differ
diff --git a/scm-webapp/src/main/webapp/resources/images/favicon.ico b/docs/logo/favicon_16x16px_transparent.ico
old mode 100755
new mode 100644
similarity index 100%
rename from scm-webapp/src/main/webapp/resources/images/favicon.ico
rename to docs/logo/favicon_16x16px_transparent.ico
diff --git a/docs/logo/scm-manager_logo.ai b/docs/logo/scm-manager_logo.ai
new file mode 100644
index 0000000000..6fe98a15e0
--- /dev/null
+++ b/docs/logo/scm-manager_logo.ai
@@ -0,0 +1 @@
+%!PS-Adobe-2.0
%%Creator: Adobe Photoshop(TM) Pen Path Export 7.0
%%Title: (scm-manager_logo.ai)
%%DocumentNeededResources: procset Adobe_packedarray 2.0 0
%%+ procset Adobe_IllustratorA_AI3 1.0 1
%%ColorUsage: Black&White
%%BoundingBox: 0 0 800 275
%%HiResBoundingBox: 0 0 800 275
%AI3_Cropmarks: 0 0 800 275
%%DocumentPreview: None
%%EndComments
%%BeginProlog
%%IncludeResource: procset Adobe_packedarray 2.0 0
Adobe_packedarray /initialize get exec
%%IncludeResource: procset Adobe_IllustratorA_AI3 1.0 1
%%EndProlog
%%BeginSetup
Adobe_IllustratorA_AI3 /initialize get exec
n
%%EndSetup
0.0 0.0 0.0 1.0 k
0 i 0 J 0 j 1 w 4 M []0 d
%%Note:
%%Trailer
%%EOF
\ No newline at end of file
diff --git a/docs/logo/scm-manager_logo.jpg b/docs/logo/scm-manager_logo.jpg
new file mode 100644
index 0000000000..f518e3f2b2
Binary files /dev/null and b/docs/logo/scm-manager_logo.jpg differ
diff --git a/docs/logo/scm-manager_logo.png b/docs/logo/scm-manager_logo.png
new file mode 100644
index 0000000000..90a17c7ee4
Binary files /dev/null and b/docs/logo/scm-manager_logo.png differ
diff --git a/docs/logo/scm-manager_logo_img.jpg b/docs/logo/scm-manager_logo_img.jpg
new file mode 100644
index 0000000000..f2d3b35b66
Binary files /dev/null and b/docs/logo/scm-manager_logo_img.jpg differ
diff --git a/docs/logo/scm-manager_logo_img.png b/docs/logo/scm-manager_logo_img.png
new file mode 100644
index 0000000000..f349fc5d22
Binary files /dev/null and b/docs/logo/scm-manager_logo_img.png differ
diff --git a/docs/logo/scm-manager_logo_img_neg.jpg b/docs/logo/scm-manager_logo_img_neg.jpg
new file mode 100644
index 0000000000..1b56b5e627
Binary files /dev/null and b/docs/logo/scm-manager_logo_img_neg.jpg differ
diff --git a/docs/logo/scm-manager_logo_img_neg.png b/docs/logo/scm-manager_logo_img_neg.png
new file mode 100644
index 0000000000..796a02882c
Binary files /dev/null and b/docs/logo/scm-manager_logo_img_neg.png differ
diff --git a/docs/logo/scm-manager_logo_neg.jpg b/docs/logo/scm-manager_logo_neg.jpg
new file mode 100644
index 0000000000..0d6704d0e3
Binary files /dev/null and b/docs/logo/scm-manager_logo_neg.jpg differ
diff --git a/docs/logo/scm-manager_logo_neg.png b/docs/logo/scm-manager_logo_neg.png
new file mode 100644
index 0000000000..3eb75aa3ee
Binary files /dev/null and b/docs/logo/scm-manager_logo_neg.png differ
diff --git a/docs/logo/scm-manager_logo_neg1.jpg b/docs/logo/scm-manager_logo_neg1.jpg
new file mode 100644
index 0000000000..d776c6b6e6
Binary files /dev/null and b/docs/logo/scm-manager_logo_neg1.jpg differ
diff --git a/docs/logo/scm-manager_logo_neg1.png b/docs/logo/scm-manager_logo_neg1.png
new file mode 100644
index 0000000000..817785710b
Binary files /dev/null and b/docs/logo/scm-manager_logo_neg1.png differ
diff --git a/docs/logo/scm-manager_logo_pos1.jpg b/docs/logo/scm-manager_logo_pos1.jpg
new file mode 100644
index 0000000000..fd2533c198
Binary files /dev/null and b/docs/logo/scm-manager_logo_pos1.jpg differ
diff --git a/docs/logo/scm-manager_logo_pos1.png b/docs/logo/scm-manager_logo_pos1.png
new file mode 100644
index 0000000000..b911417358
Binary files /dev/null and b/docs/logo/scm-manager_logo_pos1.png differ
diff --git a/docs/mercurial/clone-empty.md b/docs/mercurial/clone-empty.md
new file mode 100644
index 0000000000..44a81de20c
--- /dev/null
+++ b/docs/mercurial/clone-empty.md
@@ -0,0 +1,76 @@
+# Clone empty repository
+
+```http
+GET /scm/hg/hgtest?cmd=capabilities HTTP/1.1.
+Accept-Encoding: identity.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1efk0qxy1dj5v133hev91zwsf4;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 05:57:18 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 130.
+Server: Jetty(7.6.21.v20160908).
+.
+lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=bookmarks.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1rsxj8u1rq9wizawhyyxok2p5;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 05:57:18 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 0.
+Server: Jetty(7.6.21.v20160908).
+
+GET /scm/hg/hgtest?cmd=batch HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: cmds=heads+%3Bknown+nodes%3D.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=ewyx4m53d8dajjsob6gxobne;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 05:57:18 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 42.
+Server: Jetty(7.6.21.v20160908).
+
+0000000000000000000000000000000000000000
+;
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=phases.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1o0hou15jtiywsywutf30qwm8;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 05:57:18 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 15.
+Server: Jetty(7.6.21.v20160908).
+.
+publishing.True
+```
diff --git a/docs/mercurial/push-bookmark.md b/docs/mercurial/push-bookmark.md
new file mode 100644
index 0000000000..9ed591f9f4
--- /dev/null
+++ b/docs/mercurial/push-bookmark.md
@@ -0,0 +1,117 @@
+# Push bookmark
+
+```http
+GET /scm/hg/hgtest?cmd=capabilities HTTP/1.1.
+Accept-Encoding: identity.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=7rq9vpp9svfm1sicq7h9vetmv;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 08:08:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 130.
+Server: Jetty(7.6.21.v20160908).
+
+lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024
+
+GET /scm/hg/hgtest?cmd=batch HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: cmds=heads+%3Bknown+nodes%3Def5993bb4abb32a0565c347844c6d939fc4f4b98.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+T 172.17.0.2:8080 -> 172.17.0.1:36576 [AP]
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1553csz4sf7scyvw8mqnqfirn;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 08:08:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 43.
+Server: Jetty(7.6.21.v20160908).
+
+ef5993bb4abb32a0565c347844c6d939fc4f4b98
+;1
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=phases.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=11xa5u3nrmx8k1nar3sazg6jzh;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 08:08:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 15.
+Server: Jetty(7.6.21.v20160908).
+
+publishing.True
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=bookmarks.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1p1uzcvfe1pvzh2buzo658rxw;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 08:08:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 0.
+Server: Jetty(7.6.21.v20160908).
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=phases.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1mhlj3ucfzdp6ifmzoua4zwit;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 08:08:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 15.
+Server: Jetty(7.6.21.v20160908).
+
+publishing.True
+
+POST /scm/hg/hgtest?cmd=pushkey HTTP/1.1.
+Accept-Encoding: identity.
+content-type: application/mercurial-0.1.
+vary: X-HgArg-1.
+x-hgarg-1: key=markone&namespace=bookmarks&new=ef5993bb4abb32a0565c347844c6d939fc4f4b98&old=.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+content-length: 0.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=s4vtagb303dv1xg809wnp7e8z;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 08:08:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 2.
+Server: Jetty(7.6.21.v20160908).
+.
+1
+```
diff --git a/docs/mercurial/push-multiple-branches-to-new.md b/docs/mercurial/push-multiple-branches-to-new.md
new file mode 100644
index 0000000000..734c479fef
--- /dev/null
+++ b/docs/mercurial/push-multiple-branches-to-new.md
@@ -0,0 +1,167 @@
+# Push multiple branches to new repository
+
+```http
+GET /scm/hg/hgtest?cmd=capabilities HTTP/1.1.
+Accept-Encoding: identity.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1wu06ykfd4bcv1uv731y4hss2m;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 07:55:14 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 130.
+Server: Jetty(7.6.21.v20160908).
+
+lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024
+
+GET /scm/hg/hgtest?cmd=batch HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: cmds=heads+%3Bknown+nodes%3Def5993bb4abb32a0565c347844c6d939fc4f4b98.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1rajglvqx222g5nppcq3jdfk0;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 07:55:14 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 43.
+Server: Jetty(7.6.21.v20160908).
+
+0000000000000000000000000000000000000000
+;0
+
+GET /scm/hg/hgtest?cmd=known HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: nodes=c0ceccb3b2f0f5c977ff32b9337519e5f37942c2+187ddf37e237c370514487a0bb1a226f11a780b3+b5914611f84eae14543684b2721eec88b0edac12+8b63a323606f10c86b30465570c2574eb7a3a989.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=a5vykp1f0ga2186l8v3gu6lid;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 07:55:14 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 4.
+Server: Jetty(7.6.21.v20160908).
+
+0000
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=phases.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=s8lpwqm4c2nqs9kwcg2ca6vm;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 07:55:14 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 15.
+Server: Jetty(7.6.21.v20160908).
+
+publishing.True
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=bookmarks.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1d2qj3kynxlhvk31oli4kk7vf;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 07:55:14 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 0.
+Server: Jetty(7.6.21.v20160908).
+
+POST /scm/hg/hgtest?cmd=unbundle HTTP/1.1.
+Accept-Encoding: identity.
+content-type: application/mercurial-0.1.
+vary: X-HgArg-1.
+x-hgarg-1: heads=686173686564+6768033e216468247bd031a0a2d9876d79818f8f.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+content-length: 913.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HG10GZx...oh.U......E.1.....2q.<...s.1.YK*e#..b..{....{..%A.....
+,\.....Y.XV....Q/J......`Q/.z.{...<.7....r.s.~?.?..5.~`..?..........O.j.0.....Ih.....!@.P... ..a
+;!y..cT...]q.8Zg=...<..,.tq.*.........l........';..w^...w...-......Co..Fs.HYg...
+9.F#.P......1..;......D.H.9$@.^....r:E..18...H....3..h...-.=.6l......=q .)."Yg..p\...s@.#.H.*....c8&96..2.GjJ.`.J....r...=Q1..@R.3.o{q...|.......yq.k..,cY..:[... ...S.2...VYp..c5..&.SFR.............V.d..o..........,.. A..M....k...0_.LO1..1"4.;...B....5.9.".U.m.e......]\../p..;?C..W9.........n.~o..gW...Q;..$....S..X.CN.5I].H..!.@...U..J...L.lY.../.-...6.:.Q.'...>.e'..<#3........OL}.52ra[..g*Y:Y....w...=..Z\...S.......tz..;..mf...W......&yUN.r.......4...........`..F...nT..U9................_.~..?...BwzUN.r....B.
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=163487i0ayf9s1k2ng9e1azadj;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 07:55:14 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 102.
+Server: Jetty(7.6.21.v20160908).
+
+1
+adding changesets
+adding manifests
+adding file changes
+added 5 changesets with 3 changes to 3 files
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=phases.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=a3i712yjss6t1xsxltnssq0tl;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 07:55:14 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 58.
+Server: Jetty(7.6.21.v20160908).
+
+c0ceccb3b2f0f5c977ff32b9337519e5f37942c2.1
+publishing.True
+
+POST /scm/hg/hgtest?cmd=pushkey HTTP/1.1.
+Accept-Encoding: identity.
+content-type: application/mercurial-0.1.
+vary: X-HgArg-1.
+x-hgarg-1: key=ef5993bb4abb32a0565c347844c6d939fc4f4b98&namespace=phases&new=0&old=1.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+content-length: 0.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=g8cavdze42d83knmuasrlg10;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 07:55:14 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 2.
+Server: Jetty(7.6.21.v20160908).
+.
+1
+```
diff --git a/docs/mercurial/push-multiple-branches.md b/docs/mercurial/push-multiple-branches.md
new file mode 100644
index 0000000000..5827cb0ceb
--- /dev/null
+++ b/docs/mercurial/push-multiple-branches.md
@@ -0,0 +1,183 @@
+# Push multiple branches
+
+```http
+GET /scm/hg/hgtest?cmd=capabilities HTTP/1.1.
+Accept-Encoding: identity.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1mvm1rxg8333iib7754ksusxc;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:16:50 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 130.
+Server: Jetty(7.6.21.v20160908).
+
+lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024
+
+GET /scm/hg/hgtest?cmd=batch HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: cmds=heads+%3Bknown+nodes%3Def5993bb4abb32a0565c347844c6d939fc4f4b98.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=58p9y9vcnz5cjs22dtw8mpwk;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:16:50 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 43.
+Server: Jetty(7.6.21.v20160908).
+
+c0ceccb3b2f0f5c977ff32b9337519e5f37942c2
+;0
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=phases.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=v5wfwj8k4t261dp6808cdouoa;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:16:50 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 15.
+Server: Jetty(7.6.21.v20160908).
+
+publishing.True
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=bookmarks.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=3pgqytfhm4za1dco9p41j9yz5;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:16:50 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 0.
+Server: Jetty(7.6.21.v20160908).
+
+GET /scm/hg/hgtest?cmd=branchmap HTTP/1.1.
+Accept-Encoding: identity.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+.
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1tiz6zf7ui54e1j3d4vouxig5m;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:16:50 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 48.
+Server: Jetty(7.6.21.v20160908).
+
+default c0ceccb3b2f0f5c977ff32b9337519e5f37942c2
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=bookmarks.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1augu4tc71xax1dit20dtxzkez;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:16:50 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 0.
+Server: Jetty(7.6.21.v20160908).
+
+POST /scm/hg/hgtest?cmd=unbundle HTTP/1.1.
+Accept-Encoding: identity.
+content-type: application/mercurial-0.1.
+vary: X-HgArg-1.
+x-hgarg-1: heads=686173686564+95373ca7cd5371cb6c49bb755ee451d9ec585845.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+content-length: 746.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HG10GZx...]H.Q...z..r.,.Y..Bw.~..c.Z&...hf.:......e.XK.X,...
+,2.E1.B+...(.B"."*..z1.*......M...........93..k|..I..<...h..J_.L.9>.h..@.....op..^.....#....;.*..W....T@....!..dY....jT..A0O6.}..S.2..JPU.O6...aa...rY.VOf9.....7Ukj.&..<...z...j......%}..Jc.8c....k.."9.&".I.P.\..$.At......0..1..g.2.)<..$.. E..dn#....#.Y$3...n...5....J.e.......SNHN.q.MD..4..."I..`PF..?GH1..F..uES..Rl$47.....a........D.1...87.k.t..D..O_.3..6'cN.w.M..|@E.).X!.h*....U.B.X.....h..$.`4...
+-..O.:./..oWN.....3...x.L......_[..../..k.R$.x.2..kkv.\2R....4...@.2...1Q..T
+..(..m....s.Uo.......{.d.....Y....TYO...S.Pl`a5. ."N$.@...b...qJ.l.).n...1..F.Zy.....&>v;.q.....Jy..X.?.;....>U..|.....d.Y.*.q...NR.3...h.T..x..,.]...p{.^S.S...~..`..q.\j{.oCI.............K.....l9n.s......
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1e4fnqpncil9z1f7a2pya26nt7;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:16:50 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 102.
+Server: Jetty(7.6.21.v20160908).
+
+1
+adding changesets
+adding manifests
+adding file changes
+added 4 changesets with 2 changes to 2 files
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=phases.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=f9hvrjssniym1qe33q0u8r2m8;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:16:50 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 101.
+Server: Jetty(7.6.21.v20160908).
+
+b5914611f84eae14543684b2721eec88b0edac12.1
+187ddf37e237c370514487a0bb1a226f11a780b3.1
+publishing.True
+
+POST /scm/hg/hgtest?cmd=pushkey HTTP/1.1.
+Accept-Encoding: identity.
+content-type: application/mercurial-0.1.
+vary: X-HgArg-1.
+x-hgarg-1: key=ef5993bb4abb32a0565c347844c6d939fc4f4b98&namespace=phases&new=0&old=1.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+content-length: 0.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=z5lrut6940a650sw6x9bls8a;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:16:50 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 2.
+Server: Jetty(7.6.21.v20160908).
+
+1
+```
diff --git a/docs/mercurial/push-single-changeset.md b/docs/mercurial/push-single-changeset.md
new file mode 100644
index 0000000000..499b4c21c3
--- /dev/null
+++ b/docs/mercurial/push-single-changeset.md
@@ -0,0 +1,147 @@
+# Push single changeset
+
+```http
+GET /scm/hg/hgtest?cmd=capabilities HTTP/1.1.
+Accept-Encoding: identity.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=18r2i2jsba46d14ncsmcjdhaem;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:03:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 130.
+Server: Jetty(7.6.21.v20160908).
+
+lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch stream unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024
+
+GET /scm/hg/hgtest?cmd=batch HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: cmds=heads+%3Bknown+nodes%3Dc0ceccb3b2f0f5c977ff32b9337519e5f37942c2.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=1fw0i0c5zpy281gfgha0f26git;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:03:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 43.
+Server: Jetty(7.6.21.v20160908).
+
+0000000000000000000000000000000000000000
+;0
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=phases.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=dfa46uaqgf39w3jhk857oymu;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:03:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 15.
+Server: Jetty(7.6.21.v20160908).
+
+publishing.True
+
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=bookmarks.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=2sk1llvrsagg33xgmwyirfpi;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:03:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 0.
+Server: Jetty(7.6.21.v20160908).
+
+POST /scm/hg/hgtest?cmd=unbundle HTTP/1.1.
+Accept-Encoding: identity.
+content-type: application/mercurial-0.1.
+vary: X-HgArg-1.
+x-hgarg-1: heads=686173686564+6768033e216468247bd031a0a2d9876d79818f8f.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+content-length: 261.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HG10GZx.c``8w.....>|=Y..h.q.....N.......%......Z....&&&.&...YZ.&.&[$.........$.%q..&%..d&.).....%*.....Y.....9z...v\..FF......
+..F..\.z%.%\\.)).)
+.P[....D..[un..L).nc..q.m*.H.l#C...eZJ..YJ.Q.qR...e.aJ.EjjJ.AZ..A.Q..E.1.T.'D..C....7s.}..4G........3.S.mL.0.....zk
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=hlucs5utn1ifnpehqmjpt593;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:03:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 102.
+Server: Jetty(7.6.21.v20160908).
+
+1
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+
+T 172.17.0.1:33206 -> 172.17.0.2:8080 [AP]
+GET /scm/hg/hgtest?cmd=listkeys HTTP/1.1.
+Accept-Encoding: identity.
+vary: X-HgArg-1.
+x-hgarg-1: namespace=phases.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=15xomlrxl8qja1cj47rjpqda0y;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:03:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 58.
+Server: Jetty(7.6.21.v20160908).
+
+c0ceccb3b2f0f5c977ff32b9337519e5f37942c2.1
+publishing.True
+
+POST /scm/hg/hgtest?cmd=pushkey HTTP/1.1.
+Accept-Encoding: identity.
+content-type: application/mercurial-0.1.
+vary: X-HgArg-1.
+x-hgarg-1: key=c0ceccb3b2f0f5c977ff32b9337519e5f37942c2&namespace=phases&new=0&old=1.
+accept: application/mercurial-0.1.
+authorization: Basic c2NtYWRtaW46c2NtYWRtaW4=.
+content-length: 0.
+host: localhost:8080.
+user-agent: mercurial/proto-1.0 (Mercurial 4.3.1).
+
+HTTP/1.1 200 OK.
+Set-Cookie: JSESSIONID=5zrop5v8e661ipk12tvru525;Path=/scm.
+Expires: Thu, 01 Jan 1970 00:00:00 GMT.
+Set-Cookie: rememberMe=deleteMe; Path=/scm; Max-Age=0; Expires=Wed, 28-Mar-2018 06:03:35 GMT.
+Content-Type: application/mercurial-0.1.
+Content-Length: 2.
+Server: Jetty(7.6.21.v20160908).
+
+1
+```
diff --git a/lerna.json b/lerna.json
new file mode 100644
index 0000000000..405d16a397
--- /dev/null
+++ b/lerna.json
@@ -0,0 +1,9 @@
+{
+ "packages": [
+ "scm-ui/*",
+ "scm-plugins/*"
+ ],
+ "npmClient": "yarn",
+ "useWorkspaces": true,
+ "version": "2.0.0-SNAPSHOT"
+}
diff --git a/mvnw b/mvnw
new file mode 100755
index 0000000000..5bf251c077
--- /dev/null
+++ b/mvnw
@@ -0,0 +1,225 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Migwn, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+ # TODO classpath?
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`which java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+echo $MAVEN_PROJECTBASEDIR
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
new file mode 100644
index 0000000000..019bd74d76
--- /dev/null
+++ b/mvnw.cmd
@@ -0,0 +1,143 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven2 Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/package.json b/package.json
new file mode 100644
index 0000000000..b2f14826c5
--- /dev/null
+++ b/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "root",
+ "private": true,
+ "workspaces": [
+ "scm-ui/*",
+ "scm-plugins/*"
+ ],
+ "scripts": {
+ "build": "webpack --mode=production --config=scm-ui/ui-scripts/src/webpack.config.js",
+ "build:dev": "webpack --mode=development --config=scm-ui/ui-scripts/src/webpack.config.js",
+ "test": "lerna run --scope '@scm-manager/ui-*' test",
+ "typecheck": "lerna run --scope '@scm-manager/ui-*' typecheck",
+ "serve": "webpack-dev-server --mode=development --config=scm-ui/ui-scripts/src/webpack.config.js",
+ "deploy": "ui-scripts publish"
+ },
+ "devDependencies": {
+ "babel-plugin-reflow": "^0.2.7",
+ "lerna": "^3.17.0"
+ },
+ "resolutions": {
+ "babel-core": "7.0.0-bridge.0",
+ "gitdiff-parser": "https://github.com/scm-manager/gitdiff-parser#6baa7278824ecd17a199d842ca720d0453f68982"
+ },
+ "babel": {
+ "presets": [
+ "@scm-manager/babel-preset"
+ ]
+ },
+ "jest": {
+ "preset": "@scm-manager/jest-preset"
+ },
+ "prettier": "@scm-manager/prettier-config",
+ "dependencies": {}
+}
diff --git a/pom.xml b/pom.xml
index 3ef98ec8d1..910287abf0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,6 @@
-
+4.0.0
@@ -68,11 +69,12 @@
scm-annotation-processorscm-corescm-test
+ scm-uiscm-pluginsscm-dao-xmlscm-webappscm-server
- scm-clients
+ scm-it
@@ -82,15 +84,6 @@
scm-manager release repositoryhttp://maven.scm-manager.org/nexus/content/groups/public
-
-
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
-
- true
- daily
-
-
@@ -112,43 +105,368 @@
+
+
- junit
- junit
- ${junit.version}
- test
+ org.junit.jupiter
+ junit-jupiter-api
+
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+ org.junit-pioneer
+ junit-pioneerorg.hamcresthamcrest-core
- ${hamcrest.version}testorg.hamcresthamcrest-library
- ${hamcrest.version}testorg.mockito
- mockito-all
- ${mokito.version}
- test
+ mockito-core
-
+
+
+ org.mockito
+ mockito-junit-jupiter
+
+
+
+ org.assertj
+ assertj-core
+
+
+
+
+
+
+ com.github.sdorra
+ shiro-unit
+ 1.0.1
+ test
+
+
+
+ com.github.sdorra
+ ssp-lib
+ ${ssp.version}
+
+
+
+ com.github.sdorra
+ ssp-processor
+ ${ssp.version}
+ true
+
+
+
+ com.webcohesion.enunciate
+ enunciate-core-annotations
+ ${enunciate.version}
+
+
+
+ org.mapstruct
+ mapstruct-jdk8
+ ${org.mapstruct.version}
+
+
+
+ org.mapstruct
+ mapstruct-processor
+ ${org.mapstruct.version}
+ provided
+
+
+
+ de.otto.edison
+ edison-hal
+ 2.0.1
+
+
+
+ org.projectlombok
+ lombok
+ 1.16.18
+ provided
+
+
+
+
+
+ org.jboss.resteasy
+ resteasy-jaxrs
+ ${resteasy.version}
+
+
+
+ org.jboss.resteasy
+ resteasy-jaxb-provider
+ ${resteasy.version}
+
+
+
+ org.jboss.resteasy
+ resteasy-jackson2-provider
+ ${resteasy.version}
+
+
+
+ org.jboss.resteasy
+ resteasy-multipart-provider
+ ${resteasy.version}
+
+
+
+ org.jboss.resteasy
+ resteasy-guice
+ ${resteasy.version}
+
+
+
+ org.jboss.resteasy
+ resteasy-servlet-initializer
+ ${resteasy.version}
+
+
+
+ javax.ws.rs
+ javax.ws.rs-api
+ ${jaxrs.version}
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson.version}
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ ${jackson.version}
+
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.version}
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ ${junit.version}
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.version}
+ test
+
+
+
+ org.junit.vintage
+ junit-vintage-engine
+ ${junit.version}
+ test
+
+
+
+ org.junit-pioneer
+ junit-pioneer
+ 0.3.0
+ test
+
+
+
+ org.hamcrest
+ hamcrest-core
+ ${hamcrest.version}
+ test
+
+
+
+ org.hamcrest
+ hamcrest-library
+ ${hamcrest.version}
+ test
+
+
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
+
+
+ org.mockito
+ mockito-junit-jupiter
+ ${mockito.version}
+ test
+
+
+
+ org.assertj
+ assertj-core
+ 3.10.0
+ test
+
+
+
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.5
+
+
+
+
+
+ slf4j-api
+ org.slf4j
+ ${slf4j.version}
+
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+
+
+
+ javax.xml.bind
+ jaxb-api
+ ${jaxb.version}
+
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ ${jaxb.version}
+
+
+
+ org.glassfish.jaxb
+ jaxb-runtime
+ ${jaxb.version}
+
+
+
+ javax.activation
+ activation
+ 1.1.1
+
+
+
+
+
+ commons-codec
+ commons-codec
+ 1.13
+
+
+
+
+
+
+
+
+
+ com.github.sdorra
+ buildfrontend-maven-plugin
+ 2.5.0
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.0.1
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 2.6
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 2.3
+
+
+
+ com.webcohesion.enunciate
+ enunciate-maven-plugin
+ ${enunciate.version}
+
+
+
+ sonia.scm.maven
+ smp-maven-plugin
+ 1.0.0-alpha-8
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+
+
-
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.0
+
+
org.apache.maven.pluginsmaven-enforcer-plugin
- 1.4.1
+ 3.0.0-M1enforce-java
@@ -170,17 +488,39 @@
[3.1,)
+
+
+ 1.8
+
+
+ module-info
+
+ true
+
+
+ org.codehaus.mojo
+ extra-enforcer-rules
+ 1.0-beta-7
+
+ org.codehaus.mojoanimal-sniffer-maven-plugin
- 1.15
+
+ 1.16org.codehaus.mojo.signature
@@ -198,6 +538,25 @@
+
+ com.github.legman
+ legman-maven-plugin
+ ${legman.version}
+
+ true
+
+
+
+ process-classes
+
+
+ guava-migration-check
+
+
+
+
+
org.apache.maven.pluginsmaven-compiler-plugin
@@ -215,13 +574,13 @@
see https://blogs.oracle.com/darcy/entry/bootclasspath_older_source
-->
-Xlint:unchecked,-options
+ -parametersorg.apache.maven.pluginsmaven-resources-plugin
- 2.6${project.build.sourceEncoding}
@@ -248,7 +607,6 @@
org.apache.maven.pluginsmaven-javadoc-plugin
- 2.9true${project.build.sourceEncoding}
@@ -261,7 +619,6 @@
http://download.oracle.com/javase/8/docs/api/
http://download.oracle.com/docs/cd/E17802_01/products/products/servlet/2.5/docs/servlet-2_5-mr2/
- http://jersey.java.net/nonav/apidocs/${jersey.version}/jersey/
https://google.github.io/guice/api-docs/${guice.version}/javadoc
http://www.slf4j.org/api/
http://shiro.apache.org/static/current/apidocs/
@@ -290,7 +647,6 @@
org.apache.maven.pluginsmaven-deploy-plugin
- 2.7
@@ -316,13 +672,13 @@
maven-eclipse-plugin2.6
-
+
-
+
org.jacocojacoco-maven-plugin
- 0.7.7.201606060606
+ 0.8.1
@@ -338,59 +694,59 @@
-
+
org.apache.maven.pluginsmaven-site-plugin
- 3.2
-
-
-
-
- org.apache.maven.plugins
- maven-project-info-reports-plugin
- 2.4
-
-
-
- org.apache.maven.plugins
- maven-jxr-plugin
- 2.3
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- 2.4.0
-
-
-
- org.apache.maven.plugins
- maven-surefire-report-plugin
- 2.12
-
-
-
- org.apache.maven.plugins
- maven-pmd-plugin
- 2.7.1
-
- true
- ${project.build.sourceEncoding}
- ${project.build.javaLevel}
-
-
-
-
-
+ 3.7
+
+
+
+
+ org.apache.maven.plugins
+ maven-project-info-reports-plugin
+ 2.4
+
+
+
+ org.apache.maven.plugins
+ maven-jxr-plugin
+ 2.3
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+ 2.4.0
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-report-plugin
+ 2.12
+
+
+
+ org.apache.maven.plugins
+ maven-pmd-plugin
+ 2.7.1
+
+ ${project.build.sourceEncoding}
+ ${project.build.javaLevel}
+
+
+
+
+
+
@@ -434,18 +790,9 @@
org.apache.maven.pluginsmaven-javadoc-plugin
- 2.8.1
+ 3.0.0
- org.jboss.apiviz.APIviz
-
- org.jboss.apiviz
- apiviz
- 1.3.2.GA
-
-
- -sourceclasspath ${project.build.outputDirectory}
- -nopackagediagram
-
+ false
@@ -474,41 +821,62 @@
- 1.10.19
+ 2.23.01.3
- 4.12
+ 5.2.0
- 1.7.22
- 1.1.10
+ 1.7.25
+ 1.2.33.0.1
+
+ 2.1.1
+ 3.6.2.Final
+ 1.19.4
+ 2.11.1
+ 2.10.04.0
- 1.19.4
-
+ 2.3.0
+
- 1.2.0
-
+ 1.5.1
+
- 9.2.10.v20150310
- 9.2.10.v20150310
+ 9.4.22.v20191022
+ 9.4.22.v20191022
- 1.0.0-SNAPSHOT
- 1.4.0-RC2
+ 1.2.0
+ 1.4.1
-
- v4.5.2.201704071617-r-scm1
- 1.8.15-scm1
+
+ v5.4.0.201906121030-r-scm2
+ 1.9.0-scm3
- 22.0
- 2.2.3
+ 26.0-jre
+
+
+ 10.16.0
+ 1.16.01.8
+ 1.8UTF-8SCM-BSD
+ 1.2.0.Final
+
+
+
+
+
+ **/*StoreFactory.java,**/*UserPassword.js
+
+ ./scm-ui/target/frontend/buildfrontend-node/node-v${nodejs.version}-linux-x64/bin/node
+
+
diff --git a/scm-annotation-processor/pom.xml b/scm-annotation-processor/pom.xml
index 622bddd221..fc4419ba41 100644
--- a/scm-annotation-processor/pom.xml
+++ b/scm-annotation-processor/pom.xml
@@ -8,7 +8,8 @@
scm2.0.0-SNAPSHOT
-
+
+ sonia.scmscm-annotation-processor2.0.0-SNAPSHOTscm-annotation-processor
@@ -26,9 +27,9 @@
- com.sun.jersey
- jersey-core
- ${jersey.version}
+ javax.ws.rs
+ javax.ws.rs-api
+ ${jaxrs.version}
diff --git a/scm-annotation-processor/src/main/java/sonia/scm/annotation/ScmAnnotationProcessor.java b/scm-annotation-processor/src/main/java/sonia/scm/annotation/ScmAnnotationProcessor.java
index 6d53276498..38961ccaf8 100644
--- a/scm-annotation-processor/src/main/java/sonia/scm/annotation/ScmAnnotationProcessor.java
+++ b/scm-annotation-processor/src/main/java/sonia/scm/annotation/ScmAnnotationProcessor.java
@@ -1,9 +1,9 @@
/**
* 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
@@ -11,7 +11,7 @@
* 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
@@ -22,13 +22,11 @@
* 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.annotation;
//~--- non-JDK imports --------------------------------------------------------
@@ -104,35 +102,28 @@ import javax.xml.transform.stream.StreamResult;
import static javax.lang.model.util.ElementFilter.methodsIn;
/**
- *
* @author Sebastian Sdorra
*/
@SupportedAnnotationTypes("*")
@MetaInfServices(Processor.class)
-@SuppressWarnings({ "Since16", "Since15" })
+@SuppressWarnings({"Since16", "Since15"})
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public final class ScmAnnotationProcessor extends AbstractProcessor {
private static final String DESCRIPTOR_MODULE = "META-INF/scm/module.xml";
private static final String DESCRIPTOR_PLUGIN = "META-INF/scm/plugin.xml";
-
private static final String EL_MODULE = "module";
-
private static final String EMPTY = "";
-
private static final String PROPERTY_VALUE = "yes";
-
- private static final Set SUBSCRIBE_ANNOTATIONS = ImmutableSet.of(Subscribe.class.getName());
-
- private static final Set CLASS_ANNOTATIONS = ImmutableSet.of(
- new ClassAnnotation("rest-resource", Path.class),
- new ClassAnnotation("rest-provider", Provider.class)
- );
-
- //~--- methods --------------------------------------------------------------
+ private static final Set SUBSCRIBE_ANNOTATIONS =
+ ImmutableSet.of(Subscribe.class.getName());
+ private static final Set CLASS_ANNOTATIONS =
+ ImmutableSet.of(new ClassAnnotation("rest-resource", Path.class),
+ new ClassAnnotation("rest-provider", Provider.class));
@Override
- public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ public boolean process(Set extends TypeElement> annotations,
+ RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
Set descriptorElements = Sets.newHashSet();
Set subscriberAnnotations = Sets.newHashSet();
@@ -150,10 +141,12 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
}
for (ClassAnnotation ca : CLASS_ANNOTATIONS) {
- TypeElement annotation = findAnnotation(annotations, ca.annotationClass);
+ TypeElement annotation = findAnnotation(annotations,
+ ca.annotationClass);
if (annotation != null) {
- scanForClassAnnotations(descriptorElements, roundEnv, annotation, ca.elementName);
+ scanForClassAnnotations(descriptorElements, roundEnv, annotation,
+ ca.elementName);
}
}
@@ -167,6 +160,7 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
return false;
}
+
private void close(Closeable closeable) {
if (closeable != null) {
try {
@@ -177,13 +171,14 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
}
}
+
private TypeElement findAnnotation(Set extends TypeElement> annotations,
Class extends Annotation> annotationClass) {
TypeElement annotation = null;
- for (TypeElement te : annotations) {
- if (te.getQualifiedName().toString().equals(annotationClass.getName())) {
- annotation = te;
+ for (TypeElement typeElement : annotations) {
+ if (typeElement.getQualifiedName().toString().equals(annotationClass.getName())) {
+ annotation = typeElement;
break;
}
@@ -192,18 +187,22 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
return annotation;
}
+
private File findDescriptor(Filer filer) throws IOException {
- FileObject f = filer.getResource(StandardLocation.CLASS_OUTPUT, EMPTY, DESCRIPTOR_PLUGIN);
+ FileObject f = filer.getResource(StandardLocation.CLASS_OUTPUT, EMPTY,
+ DESCRIPTOR_PLUGIN);
File file = new File(f.toUri());
if (!file.exists()) {
- f = filer.getResource(StandardLocation.CLASS_OUTPUT, EMPTY, DESCRIPTOR_MODULE);
+ f = filer.getResource(StandardLocation.CLASS_OUTPUT, EMPTY,
+ DESCRIPTOR_MODULE);
file = new File(f.toUri());
}
return file;
}
+
private Document parseDocument(File file) {
Document doc = null;
InputStream input = null;
@@ -219,8 +218,8 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
doc = builder.newDocument();
doc.appendChild(doc.createElement(EL_MODULE));
}
- }
- catch (ParserConfigurationException | SAXException | IOException | DOMException ex) {
+ } catch (ParserConfigurationException | SAXException | IOException
+ | DOMException ex) {
printException("could not parse document", ex);
} finally {
close(input);
@@ -229,6 +228,7 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
return doc;
}
+
private String prepareArrayElement(Object obj) {
String v = obj.toString();
@@ -243,6 +243,7 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
return v;
}
+
private void printException(String msg, Throwable throwable) {
processingEnv.getMessager().printMessage(Kind.ERROR, msg);
@@ -251,11 +252,16 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
processingEnv.getMessager().printMessage(Kind.ERROR, stack);
}
- private void scanForClassAnnotations(Set descriptorElements,
- RoundEnvironment roundEnv, TypeElement annotation, String elementName) {
+
+ private void scanForClassAnnotations(
+ Set descriptorElements, RoundEnvironment roundEnv,
+ TypeElement annotation, String elementName) {
+
Set classes = Sets.newHashSet();
+
for (Element e : roundEnv.getElementsAnnotatedWith(annotation)) {
- if (e.getKind().isClass() || e.getKind().isInterface()) {
+
+ if (isClassOrInterface(e)) {
TypeElement type = (TypeElement) e;
String desc = processingEnv.getElementUtils().getDocComment(type);
@@ -265,9 +271,7 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
classes.add(
new ClassWithAttributes(
- type.getQualifiedName().toString(),
- desc,
- getAttributesFromAnnotation(e, annotation)
+ type.getQualifiedName().toString(), desc, getAttributesFromAnnotation(e, annotation)
)
);
}
@@ -276,8 +280,15 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
descriptorElements.add(new ClassSetElement(elementName, classes));
}
- private void scanForSubscriberAnnotations(Set descriptorElements, RoundEnvironment roundEnv,
- TypeElement annotation) {
+
+ private boolean isClassOrInterface(Element e) {
+ return e.getKind().isClass() || e.getKind().isInterface();
+ }
+
+
+ private void scanForSubscriberAnnotations(
+ Set descriptorElements, RoundEnvironment roundEnv,
+ TypeElement annotation) {
for (Element el : roundEnv.getElementsAnnotatedWith(annotation)) {
if (el.getKind() == ElementKind.METHOD) {
ExecutableElement ee = (ExecutableElement) el;
@@ -305,6 +316,7 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
}
}
+
private void write(Set descriptorElements) {
Filer filer = processingEnv.getFiler();
@@ -327,6 +339,7 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
}
}
+
private void writeDocument(Document doc, File file) {
Writer writer = null;
@@ -346,26 +359,30 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
}
}
- //~--- get methods ----------------------------------------------------------
- private Map getAttributesFromAnnotation(Element el, TypeElement annotation) {
+ private Map getAttributesFromAnnotation(Element el,
+ TypeElement annotation) {
Map attributes = Maps.newHashMap();
- for (AnnotationMirror am : el.getAnnotationMirrors()) {
- String qn = am.getAnnotationType().asElement().toString();
+ for (AnnotationMirror annotationMirror : el.getAnnotationMirrors()) {
+ String qn = annotationMirror.getAnnotationType().asElement().toString();
if (qn.equals(annotation.toString())) {
- for (Entry extends ExecutableElement, ? extends AnnotationValue> entry : am.getElementValues().entrySet()) {
+ for (Entry extends ExecutableElement,
+ ? extends AnnotationValue> entry : annotationMirror.getElementValues().entrySet()) {
attributes.put(entry.getKey().getSimpleName().toString(),
getValue(entry.getValue()));
}
// add default values
- for (ExecutableElement meth : methodsIn(am.getAnnotationType().asElement().getEnclosedElements())) {
+ for (ExecutableElement meth : methodsIn(annotationMirror.getAnnotationType().asElement().getEnclosedElements())) {
String attribute = meth.getSimpleName().toString();
AnnotationValue defaultValue = meth.getDefaultValue();
if (defaultValue != null && !attributes.containsKey(attribute)) {
- attributes.put(attribute, getValue(defaultValue));
+ String value = getValue(defaultValue);
+ if (value != null && !value.isEmpty()) {
+ attributes.put(attribute, value);
+ }
}
}
}
@@ -374,6 +391,7 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
return attributes;
}
+
private String getValue(AnnotationValue v) {
String value;
Object object = v.getValue();
@@ -388,7 +406,6 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
if (it.hasNext()) {
buffer.append(",");
}
-
}
value = buffer.toString();
@@ -399,17 +416,17 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
return value;
}
- //~--- inner classes --------------------------------------------------------
private static final class ClassAnnotation {
- private final String elementName;
- private final Class extends Annotation> annotationClass;
+ public ClassAnnotation(String elementName,
+ Class extends Annotation> annotationClass) {
- ClassAnnotation(String elementName, Class extends Annotation> annotationClass) {
this.elementName = elementName;
this.annotationClass = annotationClass;
}
+ private final Class extends Annotation> annotationClass;
+ private final String elementName;
}
}
diff --git a/scm-annotations/src/main/java/sonia/scm/api/v2/resources/Enrich.java b/scm-annotations/src/main/java/sonia/scm/api/v2/resources/Enrich.java
new file mode 100644
index 0000000000..a1269dfc00
--- /dev/null
+++ b/scm-annotations/src/main/java/sonia/scm/api/v2/resources/Enrich.java
@@ -0,0 +1,26 @@
+package sonia.scm.api.v2.resources;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to specify the source of an enricher.
+ *
+ * @author Sebastian Sdorra
+ * @since 2.0.0
+ */
+@Documented
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Enrich {
+
+ /**
+ * Source mapping class.
+ *
+ * @return source mapping class
+ */
+ Class> value();
+}
diff --git a/scm-annotations/src/main/java/sonia/scm/plugin/ExtensionPoint.java b/scm-annotations/src/main/java/sonia/scm/plugin/ExtensionPoint.java
index 5417317627..b36a28f993 100644
--- a/scm-annotations/src/main/java/sonia/scm/plugin/ExtensionPoint.java
+++ b/scm-annotations/src/main/java/sonia/scm/plugin/ExtensionPoint.java
@@ -33,8 +33,6 @@
package sonia.scm.plugin;
-//~--- JDK imports ------------------------------------------------------------
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/scm-annotations/src/main/java/sonia/scm/security/AllowAnonymousAccess.java b/scm-annotations/src/main/java/sonia/scm/security/AllowAnonymousAccess.java
new file mode 100644
index 0000000000..b770914d69
--- /dev/null
+++ b/scm-annotations/src/main/java/sonia/scm/security/AllowAnonymousAccess.java
@@ -0,0 +1,15 @@
+package sonia.scm.security;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Use this annotation to mark REST resource methods that may be accessed without authentication.
+ * To mark all methods of a complete class you can annotate the class instead.
+ */
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AllowAnonymousAccess {
+}
diff --git a/scm-clients/pom.xml b/scm-clients/pom.xml
deleted file mode 100644
index e78be6afa5..0000000000
--- a/scm-clients/pom.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
- 4.0.0
-
-
- sonia.scm
- scm
- 2.0.0-SNAPSHOT
-
-
- sonia.scm.clients
- scm-clients
- pom
- 2.0.0-SNAPSHOT
- scm-clients
-
-
- scm-client-api
- scm-client-impl
- scm-cli-client
-
-
-
-
-
-
-
- scm-core
- sonia.scm
- jar
- 2.0.0-SNAPSHOT
-
-
- shiro-core
- org.apache.shiro
-
-
- aopalliance
- aopalliance
-
-
- guice
- com.google.inject
-
-
- guice-multibindings
- com.google.inject.extensions
-
-
- guice-servlet
- com.google.inject.extensions
-
-
- jersey-core
- com.sun.jersey
-
-
- guice-throwingproviders
- com.google.inject.extensions
-
-
- commons-lang
- commons-lang
-
-
-
-
-
-
-
diff --git a/scm-clients/scm-cli-client/pom.xml b/scm-clients/scm-cli-client/pom.xml
deleted file mode 100644
index 7e32b5c397..0000000000
--- a/scm-clients/scm-cli-client/pom.xml
+++ /dev/null
@@ -1,218 +0,0 @@
-
-
-
- 4.0.0
-
-
- scm-clients
- sonia.scm.clients
- 2.0.0-SNAPSHOT
-
-
- scm-cli-client
- 2.0.0-SNAPSHOT
- scm-cli-client
-
-
-
-
-
-
- javax.servlet
- javax.servlet-api
- ${servlet.version}
-
-
-
- javax.transaction
- jta
- 1.1
- provided
-
-
-
- sonia.scm.clients
- scm-client-impl
- 2.0.0-SNAPSHOT
-
-
-
- args4j
- args4j
- 2.0.29
-
-
-
- ch.qos.logback
- logback-classic
- ${logback.version}
-
-
-
- org.freemarker
- freemarker
- 2.3.21
-
-
-
-
-
-
-
-
- com.mycila.maven-license-plugin
- maven-license-plugin
- 1.9.0
-
- http://download.scm-manager.org/licenses/mvn-license.txt
-
- src/**
- **/test/**
-
-
- target/**
- .hg/**
- **/*.ftl
-
- true
-
-
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
- 2.3
-
-
-
- sonia.scm.cli.App
-
-
-
- jar-with-dependencies
-
-
-
-
- package
-
- single
-
-
-
-
-
-
-
-
-
-
-
- it
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
- 2.4
-
-
- package
-
- copy
-
-
-
-
- sonia.scm
- scm-webapp
- ${project.version}
- war
- ${project.build.directory}/webapp
- scm-webapp.war
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-failsafe-plugin
- 2.12
-
-
- ${project.version}
-
-
-
-
- integration-test
-
- integration-test
-
-
-
- verify
-
- verify
-
-
-
-
-
-
- org.eclipse.jetty
- jetty-maven-plugin
- ${jetty.maven.version}
-
- 8085
- STOP
-
-
- scm.home
- target/scm-it
-
-
- file.encoding
- UTF-8
-
-
-
- 8081
-
-
- /scm
-
- ${project.build.directory}/webapp/scm-webapp.war
- 0
- true
-
-
-
- start-jetty
- pre-integration-test
-
- deploy-war
-
-
-
- stop-jetty
- post-integration-test
-
- stop
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/App.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/App.java
deleted file mode 100644
index 5bf070258e..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/App.java
+++ /dev/null
@@ -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 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 arguments = new ArrayList<>();
-
- /** 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/BooleanModifyOptionHandler.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/BooleanModifyOptionHandler.java
deleted file mode 100644
index 46d18badb6..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/BooleanModifyOptionHandler.java
+++ /dev/null
@@ -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
-{
-
- /**
- * 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;
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/I18n.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/I18n.java
deleted file mode 100644
index 8147c59b44..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/I18n.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/LoggingLevelOptionHandler.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/LoggingLevelOptionHandler.java
deleted file mode 100644
index 2622abecfb..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/LoggingLevelOptionHandler.java
+++ /dev/null
@@ -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
-{
-
- /**
- * 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;
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/SimpleLocalizable.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/SimpleLocalizable.java
deleted file mode 100644
index 33fc3ef0b5..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/SimpleLocalizable.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/AddMembersSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/AddMembersSubCommand.java
deleted file mode 100644
index 2538367fb0..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/AddMembersSubCommand.java
+++ /dev/null
@@ -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 members)
- {
- group.getMembers().addAll(members);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/AddPermissionSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/AddPermissionSubCommand.java
deleted file mode 100644
index 621ebe54de..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/AddPermissionSubCommand.java
+++ /dev/null
@@ -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 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/Command.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/Command.java
deleted file mode 100644
index ea6e988dae..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/Command.java
+++ /dev/null
@@ -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";
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CommandDescriptor.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CommandDescriptor.java
deleted file mode 100644
index ce51657ea9..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CommandDescriptor.java
+++ /dev/null
@@ -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
-{
-
- /** 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 = "";
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CreateGroupSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CreateGroupSubCommand.java
deleted file mode 100644
index 5fba296532..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CreateGroupSubCommand.java
+++ /dev/null
@@ -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 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 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 env = new HashMap<>();
-
- 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 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";
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CreateRepositorySubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CreateRepositorySubCommand.java
deleted file mode 100644
index a0d675e2be..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CreateRepositorySubCommand.java
+++ /dev/null
@@ -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 env = new HashMap<>();
-
- 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CreateUserSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CreateUserSubCommand.java
deleted file mode 100644
index 805c05d83b..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/CreateUserSubCommand.java
+++ /dev/null
@@ -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 env = new HashMap<>();
-
- 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";
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteConfigSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteConfigSubCommand.java
deleted file mode 100644
index 93c2ad253e..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteConfigSubCommand.java
+++ /dev/null
@@ -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();
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteGroupSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteGroupSubCommand.java
deleted file mode 100644
index 345cf5baec..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteGroupSubCommand.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteMembersSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteMembersSubCommand.java
deleted file mode 100644
index 449fab5181..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteMembersSubCommand.java
+++ /dev/null
@@ -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 members)
- {
- group.getMembers().removeAll(members);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeletePermissionSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeletePermissionSubCommand.java
deleted file mode 100644
index 2b482c0f4e..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeletePermissionSubCommand.java
+++ /dev/null
@@ -1,105 +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 java.util.List;
-
-//~--- JDK imports ------------------------------------------------------------
-
-/**
- *
- * @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 permissions)
- {
- permissions.removeIf(p -> name.equals(p.getName()));
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- @Option(
- name = "--name",
- usage = "optionPermissionName",
- required = true,
- aliases = { "-n" }
- )
- private String name;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteRepositorySubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteRepositorySubCommand.java
deleted file mode 100644
index 742eb72f80..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteRepositorySubCommand.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteUserSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteUserSubCommand.java
deleted file mode 100644
index c254a2e7e3..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/DeleteUserSubCommand.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/EncryptSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/EncryptSubCommand.java
deleted file mode 100644
index af76698062..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/EncryptSubCommand.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GenerateKeySubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GenerateKeySubCommand.java
deleted file mode 100644
index b8658391b0..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GenerateKeySubCommand.java
+++ /dev/null
@@ -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());
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GetGroupSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GetGroupSubCommand.java
deleted file mode 100644
index 9bb02a4703..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GetGroupSubCommand.java
+++ /dev/null
@@ -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 env = new HashMap<>();
-
- 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GetRepositorySubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GetRepositorySubCommand.java
deleted file mode 100644
index 5dd27db525..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GetRepositorySubCommand.java
+++ /dev/null
@@ -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 env = new HashMap<>();
-
- 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GetUserSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GetUserSubCommand.java
deleted file mode 100644
index 2356d6323a..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/GetUserSubCommand.java
+++ /dev/null
@@ -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 env = new HashMap<>();
-
- 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportBundleSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportBundleSubCommand.java
deleted file mode 100644
index d746df0828..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportBundleSubCommand.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportDirectorySubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportDirectorySubCommand.java
deleted file mode 100644
index 788eef4fae..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportDirectorySubCommand.java
+++ /dev/null
@@ -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 env = Maps.newHashMap();
-
- env.put("importedDirectories", wrapper.getImportedDirectories());
- env.put("failedDirectories", wrapper.getFailedDirectories());
- renderTemplate(env, TEMPLATE);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportSubCommand.java
deleted file mode 100644
index 7c8efe704d..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportSubCommand.java
+++ /dev/null
@@ -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 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportUrlSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportUrlSubCommand.java
deleted file mode 100644
index 7b1ac86237..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ImportUrlSubCommand.java
+++ /dev/null
@@ -1,142 +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 org.kohsuke.args4j.Option;
-import sonia.scm.client.ImportUrlRequest;
-import sonia.scm.client.ScmClientSession;
-import sonia.scm.repository.Repository;
-
-import java.net.URL;
-
-//~--- JDK imports ------------------------------------------------------------
-
-/**
- *
- * @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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ListGroupsSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ListGroupsSubCommand.java
deleted file mode 100644
index 80b9428f6b..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ListGroupsSubCommand.java
+++ /dev/null
@@ -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 groups = session.getGroupHandler().getAll();
- Map env = new HashMap<>();
-
- env.put("groups", WrapperUtil.wrapGroups(groups));
- renderTemplate(env, TEMPLATE);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ListRepositoriesSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ListRepositoriesSubCommand.java
deleted file mode 100644
index f876d2a878..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ListRepositoriesSubCommand.java
+++ /dev/null
@@ -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 repositories = session.getRepositoryHandler().getAll();
- Map env = new HashMap<>();
-
- env.put("repositories", WrapperUtil.wrapRepositories(config, repositories));
- renderTemplate(env, TEMPLATE);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ListUsersSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ListUsersSubCommand.java
deleted file mode 100644
index 9f17f59160..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ListUsersSubCommand.java
+++ /dev/null
@@ -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 users = session.getUserHandler().getAll();
- Map env = new HashMap<>();
-
- env.put("users", WrapperUtil.wrapUsers(users));
- renderTemplate(env, TEMPLATE);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/MembersSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/MembersSubCommand.java
deleted file mode 100644
index 490a239cd3..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/MembersSubCommand.java
+++ /dev/null
@@ -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 members);
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- public List getMembers()
- {
- return members;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getName()
- {
- return name;
- }
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param members
- */
- public void setMembers(List 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 env = new HashMap<>();
-
- 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 members;
-
- /** Field description */
- @Argument(
- usage = "optionGroupName",
- metaVar = "groupname",
- required = true
- )
- private String name;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ModifyGroupSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ModifyGroupSubCommand.java
deleted file mode 100644
index 6cb151e22d..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ModifyGroupSubCommand.java
+++ /dev/null
@@ -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 env = new HashMap<>();
-
- 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ModifyRepositorySubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ModifyRepositorySubCommand.java
deleted file mode 100644
index b0d64242d0..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ModifyRepositorySubCommand.java
+++ /dev/null
@@ -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 env = new HashMap<>();
-
- 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ModifyUserSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ModifyUserSubCommand.java
deleted file mode 100644
index 63a25d5d07..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ModifyUserSubCommand.java
+++ /dev/null
@@ -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 env = new HashMap<>();
-
- 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/PermissionSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/PermissionSubCommand.java
deleted file mode 100644
index d40c50c38a..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/PermissionSubCommand.java
+++ /dev/null
@@ -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 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 permissions = repository.getPermissions();
-
- if (permissions == null)
- {
- permissions = new ArrayList<>();
- }
-
- modifyPermissions(permissions);
- repository.setPermissions(permissions);
- handler.modify(repository);
-
- Map env = new HashMap<>();
-
- 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ServerVersionSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ServerVersionSubCommand.java
deleted file mode 100644
index e5c60f0779..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/ServerVersionSubCommand.java
+++ /dev/null
@@ -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 );
- }
-
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/StoreConfigSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/StoreConfigSubCommand.java
deleted file mode 100644
index 3fcd06e479..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/StoreConfigSubCommand.java
+++ /dev/null
@@ -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();
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/SubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/SubCommand.java
deleted file mode 100644
index 09dcf344ef..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/SubCommand.java
+++ /dev/null
@@ -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 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/SubCommandHandler.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/SubCommandHandler.java
deleted file mode 100644
index 36f39d470c..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/SubCommandHandler.java
+++ /dev/null
@@ -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<>();
- 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 getDescriptors()
- {
- List descs =
- new ArrayList<>(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 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 subCommands;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/SubCommandOptionHandler.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/SubCommandOptionHandler.java
deleted file mode 100644
index 39957c2158..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/SubCommandOptionHandler.java
+++ /dev/null
@@ -1,115 +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.OptionDef;
-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
-{
-
- /**
- * 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";
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/TemplateSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/TemplateSubCommand.java
deleted file mode 100644
index b9d985b3b9..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/TemplateSubCommand.java
+++ /dev/null
@@ -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 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/VersionSubCommand.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/VersionSubCommand.java
deleted file mode 100644
index 285739f2c2..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/cmd/VersionSubCommand.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ConfigOptionHandler.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ConfigOptionHandler.java
deleted file mode 100644
index 15e030b8bc..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ConfigOptionHandler.java
+++ /dev/null
@@ -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
-{
-
- /**
- * 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";
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ScmClientConfig.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ScmClientConfig.java
deleted file mode 100644
index 68c50731b7..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ScmClientConfig.java
+++ /dev/null
@@ -1,183 +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.*;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @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<>();
- }
-
- //~--- 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)
- {
- return serverConfigMap.computeIfAbsent(name, k -> new ServerConfig());
- }
-
- /**
- * 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 serverConfigMap;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ScmClientConfigFileHandler.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ScmClientConfigFileHandler.java
deleted file mode 100644
index 5cc2c46978..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ScmClientConfigFileHandler.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ScmConfigException.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ScmConfigException.java
deleted file mode 100644
index 33fbef093e..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ScmConfigException.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ServerConfig.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ServerConfig.java
deleted file mode 100644
index c7fb4108c5..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/ServerConfig.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/XmlConfigAdapter.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/XmlConfigAdapter.java
deleted file mode 100644
index c7471cf601..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/XmlConfigAdapter.java
+++ /dev/null
@@ -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>
-{
-
- /**
- * Method description
- *
- *
- * @param map
- *
- * @return
- *
- * @throws Exception
- */
- @Override
- public XmlConfigSet marshal(Map map) throws Exception
- {
- Set set = new HashSet<>();
-
- for (Map.Entry 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 unmarshal(XmlConfigSet set) throws Exception
- {
- Map map = new HashMap<>();
-
- for (XmlConfigElement e : set)
- {
- map.put(e.getName(), e.getConfig());
- }
-
- return map;
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/XmlConfigElement.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/XmlConfigElement.java
deleted file mode 100644
index f4e3eb2c04..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/XmlConfigElement.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/XmlConfigSet.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/XmlConfigSet.java
deleted file mode 100644
index 9bd3370775..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/config/XmlConfigSet.java
+++ /dev/null
@@ -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
-{
-
- /**
- * Constructs ...
- *
- */
- public XmlConfigSet() {}
-
- /**
- * Constructs ...
- *
- *
- * @param configSet
- */
- public XmlConfigSet(Set configSet)
- {
- this.configSet = configSet;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public Iterator iterator()
- {
- return configSet.iterator();
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- public Set getConfigSet()
- {
- return configSet;
- }
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param configSet
- */
- public void setConfigSet(Set configSet)
- {
- this.configSet = configSet;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- @XmlElement(name = "server")
- private Set configSet;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/AbstractWrapper.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/AbstractWrapper.java
deleted file mode 100644
index 0e72aec28e..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/AbstractWrapper.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/GroupWrapper.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/GroupWrapper.java
deleted file mode 100644
index d26225b5f7..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/GroupWrapper.java
+++ /dev/null
@@ -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 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/RepositoryWrapper.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/RepositoryWrapper.java
deleted file mode 100644
index 216afde624..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/RepositoryWrapper.java
+++ /dev/null
@@ -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 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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/UserWrapper.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/UserWrapper.java
deleted file mode 100644
index 55ccc6681c..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/UserWrapper.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/WrapperUtil.java b/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/WrapperUtil.java
deleted file mode 100644
index 466cf55019..0000000000
--- a/scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/wrapper/WrapperUtil.java
+++ /dev/null
@@ -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 wrapGroups(Collection groups)
- {
- List wrappers = new ArrayList<>();
-
- for (Group g : groups)
- {
- wrappers.add(new GroupWrapper(g));
- }
-
- return wrappers;
- }
-
- /**
- * Method description
- *
- *
- *
- *
- * @param config
- * @param repositories
- *
- * @return
- */
- public static List wrapRepositories(ServerConfig config,
- Collection repositories)
- {
- List wrappers = new ArrayList<>();
-
- for (Repository r : repositories)
- {
- wrappers.add(new RepositoryWrapper(config.getServerUrl(), r));
- }
-
- return wrappers;
- }
-
- /**
- * Method description
- *
- *
- * @param users
- *
- * @return
- */
- public static List wrapUsers(Collection users)
- {
- List wrappers = new ArrayList<>();
-
- for (User u : users)
- {
- wrappers.add(new UserWrapper(u));
- }
-
- return wrappers;
- }
-}
diff --git a/scm-clients/scm-cli-client/src/main/resources/META-INF/services/sonia.scm.cli.cmd.SubCommand b/scm-clients/scm-cli-client/src/main/resources/META-INF/services/sonia.scm.cli.cmd.SubCommand
deleted file mode 100644
index 91f2345948..0000000000
--- a/scm-clients/scm-cli-client/src/main/resources/META-INF/services/sonia.scm.cli.cmd.SubCommand
+++ /dev/null
@@ -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
diff --git a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/get-group.ftl b/scm-clients/scm-cli-client/src/main/resources/sonia/resources/get-group.ftl
deleted file mode 100644
index 6126b6d81f..0000000000
--- a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/get-group.ftl
+++ /dev/null
@@ -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>
diff --git a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/get-repository.ftl b/scm-clients/scm-cli-client/src/main/resources/sonia/resources/get-repository.ftl
deleted file mode 100644
index 7ac5d4c38f..0000000000
--- a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/get-repository.ftl
+++ /dev/null
@@ -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>
diff --git a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/get-user.ftl b/scm-clients/scm-cli-client/src/main/resources/sonia/resources/get-user.ftl
deleted file mode 100644
index 45f08e56d1..0000000000
--- a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/get-user.ftl
+++ /dev/null
@@ -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>
diff --git a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/i18n.properties b/scm-clients/scm-cli-client/src/main/resources/sonia/resources/i18n.properties
deleted file mode 100644
index 9d6afd3dda..0000000000
--- a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/i18n.properties
+++ /dev/null
@@ -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
\ No newline at end of file
diff --git a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/import-from-directory.ftl b/scm-clients/scm-cli-client/src/main/resources/sonia/resources/import-from-directory.ftl
deleted file mode 100644
index 33cf9e083e..0000000000
--- a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/import-from-directory.ftl
+++ /dev/null
@@ -1,9 +0,0 @@
-Imported repositories:
-<#list importedDirectories as imported>
-- ${imported}
-#list>
-
-Repositories failed to import:
-<#list failedDirectories as failed>
-- ${failed}
-#list>
\ No newline at end of file
diff --git a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/list-groups.ftl b/scm-clients/scm-cli-client/src/main/resources/sonia/resources/list-groups.ftl
deleted file mode 100644
index b25340f8f1..0000000000
--- a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/list-groups.ftl
+++ /dev/null
@@ -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>
\ No newline at end of file
diff --git a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/list-repositories.ftl b/scm-clients/scm-cli-client/src/main/resources/sonia/resources/list-repositories.ftl
deleted file mode 100644
index c78c51b505..0000000000
--- a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/list-repositories.ftl
+++ /dev/null
@@ -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>
diff --git a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/list-users.ftl b/scm-clients/scm-cli-client/src/main/resources/sonia/resources/list-users.ftl
deleted file mode 100644
index eab8106c3c..0000000000
--- a/scm-clients/scm-cli-client/src/main/resources/sonia/resources/list-users.ftl
+++ /dev/null
@@ -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>
diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/AbstractITCaseBase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/AbstractITCaseBase.java
deleted file mode 100644
index 5184ea37ed..0000000000
--- a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/AbstractITCaseBase.java
+++ /dev/null
@@ -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 cmdList = Lists.newArrayList();
-
- cmdList.add("--server");
- cmdList.add("http://localhost:8081/scm");
- cmdList.add("--user");
- cmdList.add("scmadmin");
- cmdList.add("--password");
- cmdList.add("scmadmin");
- cmdList.addAll(Arrays.asList(cmd));
-
- return execute(cmdList.toArray(new String[cmdList.size()]));
- }
-
- /**
- * Method description
- *
- *
- * @param values
- *
- * @return
- */
- protected String prepareForTest(String values)
- {
- return values.replaceAll("\\n", ";").replaceAll("\\s+", "");
- }
-}
diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/RepositoriesITCase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/RepositoriesITCase.java
deleted file mode 100644
index d09e912157..0000000000
--- a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/RepositoriesITCase.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/ServerVersionITCase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/ServerVersionITCase.java
deleted file mode 100644
index 7e424587fb..0000000000
--- a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/ServerVersionITCase.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/UsersITCase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/UsersITCase.java
deleted file mode 100644
index e5b29457a9..0000000000
--- a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/UsersITCase.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/VersionITCase.java b/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/VersionITCase.java
deleted file mode 100644
index 3d9563c34e..0000000000
--- a/scm-clients/scm-cli-client/src/test/java/sonia/scm/cli/VersionITCase.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/scm-clients/scm-client-api/pom.xml b/scm-clients/scm-client-api/pom.xml
deleted file mode 100644
index ce9561d2e5..0000000000
--- a/scm-clients/scm-client-api/pom.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
- 4.0.0
-
-
- sonia.scm.clients
- scm-clients
- 2.0.0-SNAPSHOT
-
-
- scm-client-api
- jar
- 2.0.0-SNAPSHOT
- scm-client-api
-
-
-
-
-
-
- javax.servlet
- javax.servlet-api
- ${servlet.version}
- provided
-
-
-
- javax.transaction
- jta
- 1.1
- provided
-
-
-
-
-
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientChangesetHandler.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientChangesetHandler.java
deleted file mode 100644
index 2207d2c6b9..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientChangesetHandler.java
+++ /dev/null
@@ -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);
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientHandler.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientHandler.java
deleted file mode 100644
index b178ab3680..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientHandler.java
+++ /dev/null
@@ -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
- */
-public interface ClientHandler
-{
-
- /**
- * 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 getAll();
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientRepositoryBrowser.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientRepositoryBrowser.java
deleted file mode 100644
index 5c1f753e63..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ClientRepositoryBrowser.java
+++ /dev/null
@@ -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 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 getFiles(String revision, String path);
-
- /**
- * Method description
- *
- *
- * @param revision
- *
- * @return
- */
- public List getFiles(String revision);
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/FileObjectWrapper.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/FileObjectWrapper.java
deleted file mode 100644
index ddbeef69a3..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/FileObjectWrapper.java
+++ /dev/null
@@ -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 getBlameLines()
- {
- return repositoryBrowser.getBlameLines(revision, getPath());
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public List getChildren()
- {
- List 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;
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/GroupClientHandler.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/GroupClientHandler.java
deleted file mode 100644
index 93fe52cc8d..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/GroupClientHandler.java
+++ /dev/null
@@ -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 {}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ImportBundleRequest.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ImportBundleRequest.java
deleted file mode 100644
index c6c9e71016..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ImportBundleRequest.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ImportResultWrapper.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ImportResultWrapper.java
deleted file mode 100644
index 1417e3b888..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ImportResultWrapper.java
+++ /dev/null
@@ -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 getFailedDirectories()
- {
- List directories = result.getFailedDirectories();
-
- if (directories == null)
- {
- directories = ImmutableList.of();
- }
-
- return directories;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public List getImportedDirectories()
- {
- List directories = result.getImportedDirectories();
-
- if (directories == null)
- {
- directories = ImmutableList.of();
- }
-
- return directories;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public Iterable 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
- {
-
- /**
- * 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;
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ImportUrlRequest.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ImportUrlRequest.java
deleted file mode 100644
index 66969f4a86..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ImportUrlRequest.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/RepositoryClientHandler.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/RepositoryClientHandler.java
deleted file mode 100644
index 9c0060aaff..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/RepositoryClientHandler.java
+++ /dev/null
@@ -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
-{
-
- /**
- * 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 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);
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClient.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClient.java
deleted file mode 100644
index c57e4992bb..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClient.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientException.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientException.java
deleted file mode 100644
index 2a15a277f7..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientException.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientProvider.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientProvider.java
deleted file mode 100644
index 1a03696400..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientProvider.java
+++ /dev/null
@@ -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);
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientSession.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientSession.java
deleted file mode 100644
index 7f58a94852..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmClientSession.java
+++ /dev/null
@@ -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();
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmForbiddenException.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmForbiddenException.java
deleted file mode 100644
index d029d654a8..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmForbiddenException.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmNotFoundException.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmNotFoundException.java
deleted file mode 100644
index ae0835e8cb..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmNotFoundException.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmUnauthorizedException.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmUnauthorizedException.java
deleted file mode 100644
index fc561117e1..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmUnauthorizedException.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/SecurityClientHandler.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/SecurityClientHandler.java
deleted file mode 100644
index a0131a7f1c..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/SecurityClientHandler.java
+++ /dev/null
@@ -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();
-}
diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/UserClientHandler.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/UserClientHandler.java
deleted file mode 100644
index 59192ba5a7..0000000000
--- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/UserClientHandler.java
+++ /dev/null
@@ -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 {}
diff --git a/scm-clients/scm-client-impl/pom.xml b/scm-clients/scm-client-impl/pom.xml
deleted file mode 100644
index 84548301e6..0000000000
--- a/scm-clients/scm-client-impl/pom.xml
+++ /dev/null
@@ -1,226 +0,0 @@
-
-
-
- 4.0.0
-
-
- sonia.scm.clients
- scm-clients
- 2.0.0-SNAPSHOT
-
-
- scm-client-impl
- jar
- 2.0.0-SNAPSHOT
- scm-client-impl
-
-
-
-
-
-
- javax.servlet
- javax.servlet-api
- ${servlet.version}
- provided
-
-
-
- javax.transaction
- jta
- 1.1
- provided
-
-
-
- sonia.scm.clients
- scm-client-api
- 2.0.0-SNAPSHOT
-
-
-
- com.sun.jersey
- jersey-client
- ${jersey.version}
-
-
-
- com.sun.jersey.contribs
- jersey-multipart
- ${jersey.version}
-
-
-
-
-
- org.slf4j
- jul-to-slf4j
- ${slf4j.version}
- test
-
-
-
- ch.qos.logback
- logback-classic
- ${logback.version}
- test
-
-
-
- sonia.scm
- scm-test
- 2.0.0-SNAPSHOT
- test
-
-
-
-
-
-
-
-
-
- Sonatype
- Sonatype Release
- http://oss.sonatype.org/content/repositories/releases
-
-
-
- maven.scm-manager.org
- scm-manager release repository
- http://maven.scm-manager.org/nexus/content/groups/public
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
- 2.3
-
-
- jar-with-dependencies
-
-
-
-
- package
-
- single
-
-
-
-
-
-
-
-
-
-
-
- it
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
- 2.4
-
-
- package
-
- copy
-
-
-
-
- sonia.scm
- scm-webapp
- ${project.version}
- war
- ${project.build.directory}/webapp
- scm-webapp.war
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-failsafe-plugin
- 2.12
-
-
- integration-test
-
- integration-test
-
-
-
- verify
-
- verify
-
-
-
-
-
-
- org.eclipse.jetty
- jetty-maven-plugin
- ${jetty.maven.version}
-
- 8085
- STOP
-
-
- scm.home
- target/scm-it
-
-
- file.encoding
- UTF-8
-
-
-
- 8081
-
-
- /scm
-
- ${project.build.directory}/webapp/scm-webapp.war
- 0
- true
-
-
-
- start-jetty
- pre-integration-test
-
- deploy-war
-
-
-
- stop-jetty
- post-integration-test
-
- stop
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/AbstractClientHandler.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/AbstractClientHandler.java
deleted file mode 100644
index 0e29456adc..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/AbstractClientHandler.java
+++ /dev/null
@@ -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
- */
-public abstract class AbstractClientHandler
- implements ClientHandler
-{
-
- /** the logger for AbstractClientHandler */
- private static final Logger logger =
- LoggerFactory.getLogger(AbstractClientHandler.class);
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- *
- * @param session
- * @param itemClass
- */
- public AbstractClientHandler(JerseyClientSession session, Class itemClass)
- {
- this.session = session;
- this.itemClass = itemClass;
- this.client = session.getClient();
- this.urlProvider = session.getUrlProvider();
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- *
- * @return
- */
- protected abstract GenericType> 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 getAll()
- {
- List 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 itemClass;
-}
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/ClientUtil.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/ClientUtil.java
deleted file mode 100644
index e297405026..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/ClientUtil.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientChangesetHandler.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientChangesetHandler.java
deleted file mode 100644
index 8cc8abb60a..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientChangesetHandler.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientProvider.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientProvider.java
deleted file mode 100644
index eb9825d470..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientProvider.java
+++ /dev/null
@@ -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 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;
-}
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientRepositoryBrowser.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientRepositoryBrowser.java
deleted file mode 100644
index 1b68cdc63d..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientRepositoryBrowser.java
+++ /dev/null
@@ -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 getBlameLines(String revision, String path)
- {
- List 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 getFiles(String revision, String path)
- {
- List 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<>();
-
- List 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 getFiles(String revision)
- {
- return getFiles(revision, Util.EMPTY_STRING);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private Repository repository;
-
- /** Field description */
- private JerseyClientSession session;
-}
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientSession.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientSession.java
deleted file mode 100644
index 5e0531be4e..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyClientSession.java
+++ /dev/null
@@ -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;
-}
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyGroupClientHandler.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyGroupClientHandler.java
deleted file mode 100644
index 0c22798279..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyGroupClientHandler.java
+++ /dev/null
@@ -1,122 +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;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.GenericType;
-
-import java.util.List;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JerseyGroupClientHandler extends AbstractClientHandler
- implements GroupClientHandler
-{
-
- /**
- * Constructs ...
- *
- *
- * @param session
- */
- public JerseyGroupClientHandler(JerseyClientSession session)
- {
- super(session, Group.class);
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected GenericType> createGenericListType()
- {
- return new GenericType>() {}
- ;
- }
-
- /**
- * Method description
- *
- *
- * @param response
- * @param item
- * @param newItem
- */
- @Override
- protected void postCreate(ClientResponse response, Group item, Group newItem)
- {
- newItem.copyProperties(item);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param itemId
- *
- * @return
- */
- @Override
- protected String getItemUrl(String itemId)
- {
- return urlProvider.getGroupUrlProvider().getDetailUrl(itemId);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected String getItemsUrl()
- {
- return urlProvider.getGroupUrlProvider().getAllUrl();
- }
-}
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyRepositoryClientHandler.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyRepositoryClientHandler.java
deleted file mode 100644
index ff611c9aa2..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyRepositoryClientHandler.java
+++ /dev/null
@@ -1,386 +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 sonia.scm.NotSupportedFeatuerException;
-import sonia.scm.Type;
-import sonia.scm.repository.ImportResult;
-import sonia.scm.repository.Repository;
-import sonia.scm.repository.Tags;
-import sonia.scm.util.HttpUtil;
-import sonia.scm.util.IOUtil;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.GenericType;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.multipart.FormDataMultiPart;
-import com.sun.jersey.multipart.file.StreamDataBodyPart;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import java.util.Collection;
-import java.util.List;
-
-import javax.ws.rs.core.MediaType;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JerseyRepositoryClientHandler
- extends AbstractClientHandler implements RepositoryClientHandler
-{
-
- /** Field description */
- private static final String IMPORT_TYPE_BUNDLE = "bundle";
-
- /** Field description */
- private static final String IMPORT_TYPE_DIRECTORY = "directory";
-
- /** Field description */
- private static final String IMPORT_TYPE_URL = "url";
-
- /** Field description */
- private static final String PARAM_BUNDLE = "bundle";
-
- /** Field description */
- private static final String PARAM_COMPRESSED = "compressed";
-
- /** Field description */
- private static final String PARAM_NAME = "name";
-
- /** Field description */
- private static final String URL_IMPORT = "import/repositories/";
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- *
- * @param session
- */
- public JerseyRepositoryClientHandler(JerseyClientSession session)
- {
- super(session, Repository.class);
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param request
- *
- * @return
- */
- @Override
- public Repository importFromBundle(ImportBundleRequest request)
- {
- WebResource r = client.resource(getImportUrl(request.getType(),
- IMPORT_TYPE_BUNDLE)).queryParam(PARAM_COMPRESSED,
- Boolean.toString(request.isCompressed()));
- Repository repository = null;
- InputStream stream = null;
-
- try
- {
- stream = request.getBundle().openStream();
-
- FormDataMultiPart form = new FormDataMultiPart();
-
- form.field(PARAM_NAME, request.getName());
- form.bodyPart(new StreamDataBodyPart(PARAM_BUNDLE, stream));
-
- ClientResponse response =
- r.type(MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);
-
- ClientUtil.checkResponse(response);
-
- String location =
- response.getHeaders().getFirst(HttpUtil.HEADER_LOCATION);
-
- if (Strings.isNullOrEmpty(location))
- {
- throw new ScmClientException("no location header found after import");
- }
-
- repository = getItemByUrl(location);
- }
- catch (IOException ex)
- {
- throw new ScmClientException("could not import bundle", ex);
- }
- finally
- {
- IOUtil.close(stream);
- }
-
- return repository;
- }
-
- /**
- * Method description
- *
- *
- * @param type
- *
- * @return
- */
- @Override
- public ImportResultWrapper importFromDirectory(String type)
- {
- WebResource r = client.resource(getImportUrl(type, IMPORT_TYPE_DIRECTORY));
- ClientResponse response = r.post(ClientResponse.class);
-
- ClientUtil.checkResponse(response);
-
- return new ImportResultWrapper(this, type,
- response.getEntity(ImportResult.class));
- }
-
- /**
- * Method description
- *
- *
- * @param request
- *
- * @return
- */
- @Override
- public Repository importFromUrl(ImportUrlRequest request)
- {
- WebResource r = client.resource(getImportUrl(request.getType(),
- IMPORT_TYPE_URL));
- ClientResponse response = r.post(ClientResponse.class, request);
-
- ClientUtil.checkResponse(response);
-
- String location = response.getHeaders().getFirst(HttpUtil.HEADER_LOCATION);
-
- if (Strings.isNullOrEmpty(location))
- {
- throw new ScmClientException("no location header found after import");
- }
-
- return getItemByUrl(location);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param type
- * @param name
- *
- * @return
- */
- @Override
- public Repository get(String type, String name)
- {
- String url = urlProvider.getRepositoryUrlProvider().getDetailUrl(type,
- name);
-
- return getItemByUrl(url);
- }
-
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @return
- *
- * @throws NotSupportedFeatuerException
- */
- @Override
- public ClientChangesetHandler getChangesetHandler(Repository repository)
- throws NotSupportedFeatuerException
- {
- return new JerseyClientChangesetHandler(session, repository);
- }
-
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @return
- *
- */
- @Override
- public JerseyClientRepositoryBrowser getRepositoryBrowser(
- Repository repository)
- {
- return new JerseyClientRepositoryBrowser(session, repository);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public Collection getRepositoryTypes()
- {
- return session.getState().getRepositoryTypes();
- }
-
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @return
- */
- @Override
- public Tags getTags(Repository repository)
- {
- Tags tags = null;
- String url = session.getUrlProvider().getRepositoryUrlProvider().getTagsUrl(
- repository.getId());
- 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);
- tags = response.getEntity(Tags.class);
- }
- }
- finally
- {
- ClientUtil.close(response);
- }
-
- return tags;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected GenericType> createGenericListType()
- {
- return new GenericType>() {}
- ;
- }
-
- /**
- * Method description
- *
- *
- * @param response
- * @param repository
- * @param newRepository
- */
- @Override
- protected void postCreate(ClientResponse response, Repository repository,
- Repository newRepository)
- {
- newRepository.copyProperties(repository);
-
- // copyProperties does not copy the repository id
- repository.setId(newRepository.getId());
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param itemId
- *
- * @return
- */
- @Override
- protected String getItemUrl(String itemId)
- {
- return urlProvider.getRepositoryUrlProvider().getDetailUrl(itemId);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected String getItemsUrl()
- {
- return urlProvider.getRepositoryUrlProvider().getAllUrl();
- }
-
- /**
- * Method description
- *
- *
- * @param type
- * @param importType
- *
- * @return
- */
- private String getImportUrl(String type, String importType)
- {
- StringBuilder buffer = new StringBuilder(URL_IMPORT);
-
- buffer.append(type).append(HttpUtil.SEPARATOR_PATH).append(importType);
-
- return HttpUtil.append(urlProvider.getBaseUrl(), buffer.toString());
- }
-}
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseySecurityClientHandler.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseySecurityClientHandler.java
deleted file mode 100644
index 5f24752078..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseySecurityClientHandler.java
+++ /dev/null
@@ -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.client;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JerseySecurityClientHandler implements SecurityClientHandler
-{
-
- /**
- * Constructs ...
- *
- *
- * @param session
- */
- JerseySecurityClientHandler(JerseyClientSession session)
- {
- this.session = session;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param value
- *
- * @return
- */
- @Override
- public String encrypt(String value)
- {
- String url =
- session.getUrlProvider().getSecurityUrlProvider().getEncryptUrl();
-
- return session.getClient().resource(url).post(String.class, value);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String generateKey()
- {
- String url =
- session.getUrlProvider().getSecurityUrlProvider().getGenerateKeyUrl();
-
- return session.getClient().resource(url).get(String.class);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private final JerseyClientSession session;
-}
diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyUserClientHandler.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyUserClientHandler.java
deleted file mode 100644
index a353434379..0000000000
--- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyUserClientHandler.java
+++ /dev/null
@@ -1,122 +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;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.GenericType;
-
-import java.util.List;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JerseyUserClientHandler extends AbstractClientHandler
- implements UserClientHandler
-{
-
- /**
- * Constructs ...
- *
- *
- * @param session
- */
- public JerseyUserClientHandler(JerseyClientSession session)
- {
- super(session, User.class);
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected GenericType> createGenericListType()
- {
- return new GenericType>() {}
- ;
- }
-
- /**
- * Method description
- *
- *
- * @param response
- * @param item
- * @param newItem
- */
- @Override
- protected void postCreate(ClientResponse response, User item, User newItem)
- {
- newItem.copyProperties(item);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param itemId
- *
- * @return
- */
- @Override
- protected String getItemUrl(String itemId)
- {
- return urlProvider.getUserUrlProvider().getDetailUrl(itemId);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected String getItemsUrl()
- {
- return urlProvider.getUserUrlProvider().getAllUrl();
- }
-}
diff --git a/scm-clients/scm-client-impl/src/main/resources/META-INF/services/sonia.scm.client.ScmClientProvider b/scm-clients/scm-client-impl/src/main/resources/META-INF/services/sonia.scm.client.ScmClientProvider
deleted file mode 100644
index ac345b3480..0000000000
--- a/scm-clients/scm-client-impl/src/main/resources/META-INF/services/sonia.scm.client.ScmClientProvider
+++ /dev/null
@@ -1 +0,0 @@
-sonia.scm.client.JerseyClientProvider
\ No newline at end of file
diff --git a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/AbstractClientHandlerTestBase.java b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/AbstractClientHandlerTestBase.java
deleted file mode 100644
index fe4547ecb8..0000000000
--- a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/AbstractClientHandlerTestBase.java
+++ /dev/null
@@ -1,295 +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.it;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.junit.Test;
-
-import sonia.scm.ModelObject;
-import sonia.scm.client.ClientHandler;
-import sonia.scm.client.JerseyClientSession;
-import sonia.scm.client.ScmForbiddenException;
-import sonia.scm.client.ScmUnauthorizedException;
-
-import static org.junit.Assert.*;
-
-import static sonia.scm.client.it.ClientTestUtil.*;
-
-/**
- *
- * @author Sebastian Sdorra
- *
- * @param
- */
-public abstract class AbstractClientHandlerTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param session
- *
- * @return
- */
- protected abstract ClientHandler createHandler(
- JerseyClientSession session);
-
- /**
- * Method description
- *
- *
- * @return
- */
- protected abstract ModifyTest createModifyTest();
-
- /**
- * Method description
- *
- *
- * @param number
- *
- * @return
- */
- protected abstract T createTestData(int number);
-
- /**
- * Method description
- *
- *
- */
- @Test
- public void testCreate()
- {
- JerseyClientSession session = createAdminSession();
- T item = createTestData(1);
- ClientHandler handler = createHandler(session);
-
- handler.create(item);
- assertIsValid(item);
-
- String id = item.getId();
- T o = handler.get(id);
-
- assertNotNull(o);
- assertEquals(item.getId(), o.getId());
- session.close();
- }
-
- /**
- * Method description
- *
- *
- */
- @Test
- public void testDelete()
- {
- JerseyClientSession session = createAdminSession();
- T item = createTestData(2);
- ClientHandler handler = createHandler(session);
-
- handler.create(item);
- assertIsValid(item);
-
- String id = item.getId();
-
- handler.delete(item);
-
- T o = handler.get(id);
-
- assertNull(o);
- }
-
- /**
- * Method description
- *
- *
- */
- @Test(expected = ScmUnauthorizedException.class)
- public void testDisabledCreateAnonymous()
- {
- JerseyClientSession session = createAnonymousSession();
- T item = createTestData(3);
-
- createHandler(session).create(item);
- session.close();
- }
-
- /**
- * Method description
- *
- *
- */
- @Test
- public void testEnabledCreateAnonymous()
- {
- setAnonymousAccess(true);
-
- JerseyClientSession session = createAnonymousSession();
- T item = createTestData(3);
- boolean forbidden = false;
-
- try
- {
- createHandler(session).create(item);
- }
- catch (ScmForbiddenException ex)
- {
- forbidden = true;
- }
-
- assertTrue(forbidden);
- session.close();
- setAnonymousAccess(false);
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testEnabledModifyAnonymous()
- {
- setAnonymousAccess(true);
-
- JerseyClientSession session = createAdminSession();
- T item = createTestData(4);
-
- createHandler(session).create(item);
- assertIsValid(item);
- session.close();
- session = createAnonymousSession();
-
- ModifyTest mt = createModifyTest();
-
- mt.modify(item);
-
- boolean notfound = false;
-
- try
- {
- createHandler(session).modify(item);
- }
- catch (ScmForbiddenException ex)
- {
- notfound = true;
- }
-
- setAnonymousAccess(false);
- session.close();
- session = createAdminSession();
- createHandler(session).delete(item);
- session.close();
- assertTrue(notfound);
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testModify()
- {
- long start = System.currentTimeMillis();
- JerseyClientSession session = createAdminSession();
- T item = createTestData(4);
- ClientHandler handler = createHandler(session);
-
- handler.create(item);
- assertIsValid(item);
- item = handler.get(item.getId());
-
- ModifyTest mt = createModifyTest();
-
- mt.modify(item);
- handler.modify(item);
- item = handler.get(item.getId());
- assertIsValid(item);
- assertTrue(mt.isCorrectModified(item));
- assertNotNull(item.getLastModified());
- assertTrue(item.getLastModified() > start);
- assertTrue(item.getLastModified() < System.currentTimeMillis());
- handler.delete(item);
- session.close();
- }
-
- /**
- * Method description
- *
- *
- * @param item
- */
- protected void assertIsValid(T item)
- {
- assertNotNull(item);
- assertNotNull(item.getId());
- assertTrue(item.getId().length() > 0);
- }
-
- //~--- inner interfaces -----------------------------------------------------
-
- /**
- * Interface description
- *
- *
- * @param
- *
- * @version Enter version here..., 11/05/13
- * @author Enter your name here...
- */
- protected interface ModifyTest
- {
-
- /**
- * Method description
- *
- *
- * @param item
- */
- public void modify(T item);
-
- //~--- get methods --------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param item
- *
- * @return
- */
- public boolean isCorrectModified(T item);
- }
-}
diff --git a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/ClientTestUtil.java b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/ClientTestUtil.java
deleted file mode 100644
index c567ff0e86..0000000000
--- a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/ClientTestUtil.java
+++ /dev/null
@@ -1,144 +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.it;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.client.ClientUtil;
-import sonia.scm.client.JerseyClientProvider;
-import sonia.scm.client.JerseyClientSession;
-import sonia.scm.config.ScmConfiguration;
-import sonia.scm.url.UrlProvider;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.WebResource;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public final class ClientTestUtil
-{
-
- /** Field description */
- public static final String ADMIN_PASSWORD = "scmadmin";
-
- /** Field description */
- public static final String ADMIN_USERNAME = "scmadmin";
-
- /** Field description */
- public static final String REPOSITORY_TYPE = "git";
-
- /** Field description */
- public static final String URL_BASE = "http://localhost:8081/scm";
-
- /** Field description */
- public static final boolean REQUEST_LOGGING = false;
-
- private ClientTestUtil()
- {
- }
-
-
-
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- *
- */
- public static JerseyClientSession createAdminSession()
- {
- return createSession(ADMIN_USERNAME, ADMIN_PASSWORD);
- }
-
- /**
- * Method description
- *
- *
- * @return
- *
- */
- public static JerseyClientSession createAnonymousSession()
- {
- return createSession(null, null);
- }
-
- /**
- * Method description
- *
- *
- * @param username
- * @param password
- *
- * @return
- *
- */
- public static JerseyClientSession createSession(String username,
- String password)
- {
- JerseyClientProvider provider = new JerseyClientProvider(REQUEST_LOGGING);
-
- return provider.createSession(URL_BASE, username, password);
- }
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param access
- *
- */
- public static void setAnonymousAccess(boolean access)
- {
- JerseyClientSession adminSession = createAdminSession();
- UrlProvider up = adminSession.getUrlProvider();
- Client client = adminSession.getClient();
- WebResource resource = ClientUtil.createResource(client, up.getConfigUrl(),
- REQUEST_LOGGING);
- ScmConfiguration config = resource.get(ScmConfiguration.class);
-
- config.setAnonymousAccessEnabled(access);
- resource.post(config);
- adminSession.close();
- }
-}
diff --git a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientProviderITCase.java b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientProviderITCase.java
deleted file mode 100644
index 3aab675b0b..0000000000
--- a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyClientProviderITCase.java
+++ /dev/null
@@ -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.client.it;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.junit.Test;
-
-import sonia.scm.client.JerseyClientSession;
-import sonia.scm.client.ScmClientException;
-import sonia.scm.client.ScmUnauthorizedException;
-
-import static org.junit.Assert.*;
-
-import static sonia.scm.client.it.ClientTestUtil.*;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.IOException;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JerseyClientProviderITCase
-{
-
- /**
- * Method description
- *
- *
- *
- */
- @Test(expected = ScmUnauthorizedException.class)
- public void createSessionAnonymousFailedTest()
- {
- createAnonymousSession().close();
- }
-
- /**
- * Method description
- *
- *
- *
- */
- @Test
- public void createSessionAnonymousTest()
- {
-
- // enable anonymous access
- setAnonymousAccess(true);
-
- // test anonymous access
- createAnonymousSession().close();
-
- // disable anonymous access
- setAnonymousAccess(false);
- }
-
- /**
- * Method description
- *
- *
- *
- */
- @Test
- public void createSessionTest()
- {
- JerseyClientSession session = createAdminSession();
-
- assertNotNull(session);
- assertNotNull(session.getState());
- assertNotNull(session.getState().getUser());
- assertEquals(session.getState().getUser().getName(), "scmadmin");
- session.close();
- }
-
- /**
- * Method description
- *
- *
- *
- * @throws IOException
- * @throws ScmClientException
- */
- @Test(expected = ScmUnauthorizedException.class)
- public void createSessionWithUnkownUserTest()
- throws ScmClientException, IOException
- {
- createSession("dent", "dent123").close();
- }
-
- /**
- * Method description
- *
- *
- *
- * @throws IOException
- * @throws ScmClientException
- */
- @Test(expected = ScmUnauthorizedException.class)
- public void createSessionWithWrongPasswordTest()
- throws ScmClientException, IOException
- {
- createSession("scmadmin", "ka123").close();
- }
-}
diff --git a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyGroupClientHandlerITCase.java b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyGroupClientHandlerITCase.java
deleted file mode 100644
index 0650564741..0000000000
--- a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyGroupClientHandlerITCase.java
+++ /dev/null
@@ -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.client.it;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.client.ClientHandler;
-import sonia.scm.client.JerseyClientSession;
-import sonia.scm.client.it.AbstractClientHandlerTestBase.ModifyTest;
-import sonia.scm.group.Group;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JerseyGroupClientHandlerITCase
- extends AbstractClientHandlerTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param session
- *
- * @return
- */
- @Override
- protected ClientHandler createHandler(JerseyClientSession session)
- {
- return session.getGroupHandler();
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected ModifyTest createModifyTest()
- {
- return new ModifyTest()
- {
- @Override
- public void modify(Group item)
- {
- item.setDescription("Modified Description");
- }
- @Override
- public boolean isCorrectModified(Group item)
- {
- return "Modified Description".equals(item.getDescription());
- }
- };
- }
-
- /**
- * Method description
- *
- *
- * @param number
- *
- * @return
- */
- @Override
- protected Group createTestData(int number)
- {
- return new Group("xml", "group-" + number);
- }
-}
diff --git a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyRepositoryClientHandlerITCase.java b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyRepositoryClientHandlerITCase.java
deleted file mode 100644
index d960d57392..0000000000
--- a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyRepositoryClientHandlerITCase.java
+++ /dev/null
@@ -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.it;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.client.ClientHandler;
-import sonia.scm.client.JerseyClientSession;
-import sonia.scm.client.it.AbstractClientHandlerTestBase.ModifyTest;
-import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryTestData;
-
-import static org.junit.Assert.*;
-
-import static sonia.scm.client.it.ClientTestUtil.*;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JerseyRepositoryClientHandlerITCase
- extends AbstractClientHandlerTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param item
- */
- @Override
- protected void assertIsValid(Repository item)
- {
- super.assertIsValid(item);
- assertNotNull(item.getCreationDate());
- assertTrue(item.getCreationDate() > 0);
- assertTrue(item.getCreationDate() < System.currentTimeMillis());
- }
-
- /**
- * Method description
- *
- *
- * @param session
- *
- * @return
- */
- @Override
- protected ClientHandler createHandler(JerseyClientSession session)
- {
- return session.getRepositoryHandler();
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected ModifyTest createModifyTest()
- {
- return new ModifyTest()
- {
- @Override
- public void modify(Repository item)
- {
- item.setDescription("Modified description");
- }
- @Override
- public boolean isCorrectModified(Repository item)
- {
- return "Modified description".equals(item.getDescription());
- }
- };
- }
-
- /**
- * Method description
- *
- *
- * @param number
- *
- * @return
- */
- @Override
- protected Repository createTestData(int number)
- {
- Repository repository = null;
-
- switch (number)
- {
- case 1 :
- repository = RepositoryTestData.createHeartOfGold(REPOSITORY_TYPE);
-
- break;
-
- case 2 :
- repository = RepositoryTestData.createHappyVerticalPeopleTransporter(
- REPOSITORY_TYPE);
-
- break;
-
- case 3 :
- repository = RepositoryTestData.create42Puzzle(REPOSITORY_TYPE);
-
- break;
-
- case 4 :
- repository = RepositoryTestData.createRestaurantAtTheEndOfTheUniverse(
- REPOSITORY_TYPE);
-
- break;
- }
-
- return repository;
- }
-}
diff --git a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyUserClientHandlerITCase.java b/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyUserClientHandlerITCase.java
deleted file mode 100644
index d84deabb42..0000000000
--- a/scm-clients/scm-client-impl/src/test/java/sonia/scm/client/it/JerseyUserClientHandlerITCase.java
+++ /dev/null
@@ -1,128 +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.it;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.client.ClientHandler;
-import sonia.scm.client.JerseyClientSession;
-import sonia.scm.client.it.AbstractClientHandlerTestBase.ModifyTest;
-import sonia.scm.user.User;
-import sonia.scm.user.UserTestData;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JerseyUserClientHandlerITCase
- extends AbstractClientHandlerTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param session
- *
- * @return
- */
- @Override
- protected ClientHandler createHandler(JerseyClientSession session)
- {
- return session.getUserHandler();
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected ModifyTest createModifyTest()
- {
- return new ModifyTest()
- {
- @Override
- public void modify(User item)
- {
- item.setDisplayName("Modified DisplayName");
- }
- @Override
- public boolean isCorrectModified(User item)
- {
- return "Modified DisplayName".equals(item.getDisplayName());
- }
- };
- }
-
- /**
- * Method description
- *
- *
- * @param number
- *
- * @return
- */
- @Override
- protected User createTestData(int number)
- {
- User user = null;
-
- switch (number)
- {
- case 1 :
- user = UserTestData.createAdams();
-
- break;
-
- case 2 :
- user = UserTestData.createDent();
-
- break;
-
- case 3 :
- user = UserTestData.createMarvin();
-
- break;
-
- case 4 :
- user = UserTestData.createPerfect();
-
- break;
- }
-
- return user;
- }
-}
diff --git a/scm-clients/scm-client-impl/src/test/resources/logback.xml b/scm-clients/scm-client-impl/src/test/resources/logback.xml
deleted file mode 100644
index 26effea73e..0000000000
--- a/scm-clients/scm-client-impl/src/test/resources/logback.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/scm-core/pom.xml b/scm-core/pom.xml
index 3b88e2fa9a..8437b256b2 100644
--- a/scm-core/pom.xml
+++ b/scm-core/pom.xml
@@ -9,6 +9,7 @@
2.0.0-SNAPSHOT
+ sonia.scmscm-core2.0.0-SNAPSHOTscm-core
@@ -23,15 +24,22 @@
${servlet.version}provided
-
+
-
+
sonia.scmscm-annotations2.0.0-SNAPSHOT
-
+
+
+ org.projectlombok
+ lombok
+ provided
+
+
+
@@ -39,7 +47,13 @@
org.slf4j${slf4j.version}
-
+
+
+ jcl-over-slf4j
+ org.slf4j
+ ${slf4j.version}
+
+
@@ -67,83 +81,155 @@
guice-servlet${guice.version}
-
+
com.google.inject.extensionsguice-throwingproviders${guice.version}
-
+
- com.sun.jersey
- jersey-core
- ${jersey.version}
+ javax.ws.rs
+ javax.ws.rs-api
+ provided
-
+
+
+ org.jboss.resteasy
+ resteasy-jaxrs
+ test
+
+
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+
+
+
+
+ de.otto.edison
+ edison-hal
+
+
+
+
+ org.mapstruct
+ mapstruct-jdk8
+
+
+
+ org.mapstruct
+ mapstruct-processor
+ provided
+
+
+
+
+ com.webcohesion.enunciate
+ enunciate-core-annotations
+
+
-
+
com.github.legmancore${legman.version}
-
+
+
+
+
+ javax.xml.bind
+ jaxb-api
+
+
+
+ com.sun.xml.bind
+ jaxb-impl
+
+
+
+ org.glassfish.jaxb
+ jaxb-runtime
+
+
+
+ javax.activation
+ activation
+
+
-
+
com.google.guavaguava${guava.version}
-
+
commons-langcommons-lang2.6
-
+
-
+
sonia.scmscm-annotation-processor2.0.0-SNAPSHOTprovided
-
+
com.github.sdorrassp-lib
- ${ssp.version}com.github.sdorrassp-processor
- ${ssp.version}true
-
+
com.github.sdorrashiro-unit
- 1.0.0test
+
+ org.hibernate
+ hibernate-validator
+ 5.3.6.Final
+ compile
+
-
+
-
+
org.apache.maven.pluginsmaven-javadoc-plugin
- 2.9
+ 3.0.0true${project.build.sourceEncoding}
@@ -162,15 +248,28 @@
http://download.oracle.com/javase/6/docs/api/
http://download.oracle.com/docs/cd/E17802_01/products/products/servlet/2.5/docs/servlet-2_5-mr2/
- http://jersey.java.net/nonav/apidocs/${jersey.version}/jersey/
https://google.github.io/guice/api-docs/${guice.version}/javadoc
http://www.slf4j.org/api/
http://shiro.apache.org/static/${shiro.version}/apidocs/
+ org.jboss.apiviz.APIviz
+
+ org.jboss.apiviz
+ apiviz
+ 1.3.2.GA
+
+
+
+ -sourceclasspath ${project.build.outputDirectory}
+
+
+ -nopackagediagram
+
+
-
+
-
+
diff --git a/scm-core/src/main/java/sonia/scm/AlreadyExistsException.java b/scm-core/src/main/java/sonia/scm/AlreadyExistsException.java
new file mode 100644
index 0000000000..3ca8335346
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/AlreadyExistsException.java
@@ -0,0 +1,34 @@
+package sonia.scm;
+
+import java.util.List;
+
+import static java.util.Collections.singletonList;
+import static java.util.stream.Collectors.joining;
+
+public class AlreadyExistsException extends ExceptionWithContext {
+
+ private static final String CODE = "FtR7UznKU1";
+
+ public AlreadyExistsException(ModelObject object) {
+ this(singletonList(new ContextEntry(object.getClass(), object.getId())));
+ }
+
+ public static AlreadyExistsException alreadyExists(ContextEntry.ContextBuilder builder) {
+ return new AlreadyExistsException(builder.build());
+ }
+
+ private AlreadyExistsException(List context) {
+ super(context, createMessage(context));
+ }
+
+ @Override
+ public String getCode() {
+ return CODE;
+ }
+
+ private static String createMessage(List context) {
+ return context.stream()
+ .map(c -> c.getType().toLowerCase() + " with id " + c.getId())
+ .collect(joining(" in ", "", " already exists"));
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/ArgumentIsInvalidException.java b/scm-core/src/main/java/sonia/scm/ArgumentIsInvalidException.java
deleted file mode 100644
index 727e9a8160..0000000000
--- a/scm-core/src/main/java/sonia/scm/ArgumentIsInvalidException.java
+++ /dev/null
@@ -1,85 +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;
-
-/**
- *
- * @author Sebastian Sdorra
- * @since 1.17
- */
-public class ArgumentIsInvalidException extends IllegalStateException
-{
-
- /**
- * Constructs ...
- *
- */
- public ArgumentIsInvalidException()
- {
- super();
- }
-
- /**
- * Constructs ...
- *
- *
- * @param s
- */
- public ArgumentIsInvalidException(String s)
- {
- super(s);
- }
-
- /**
- * Constructs ...
- *
- *
- * @param cause
- */
- public ArgumentIsInvalidException(Throwable cause)
- {
- super(cause);
- }
-
- /**
- * Constructs ...
- *
- *
- * @param message
- * @param cause
- */
- public ArgumentIsInvalidException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/BadRequestException.java b/scm-core/src/main/java/sonia/scm/BadRequestException.java
new file mode 100644
index 0000000000..3290e77521
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/BadRequestException.java
@@ -0,0 +1,13 @@
+package sonia.scm;
+
+import java.util.List;
+
+public abstract class BadRequestException extends ExceptionWithContext {
+ public BadRequestException(List context, String message) {
+ super(context, message);
+ }
+
+ public BadRequestException(List context, String message, Exception cause) {
+ super(context, message, cause);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/BasicContextProvider.java b/scm-core/src/main/java/sonia/scm/BasicContextProvider.java
index f6507fc453..f4ed04c3f5 100644
--- a/scm-core/src/main/java/sonia/scm/BasicContextProvider.java
+++ b/scm-core/src/main/java/sonia/scm/BasicContextProvider.java
@@ -35,6 +35,7 @@ package sonia.scm;
//~--- non-JDK imports --------------------------------------------------------
+import com.google.common.annotations.VisibleForTesting;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
@@ -43,6 +44,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Path;
import java.util.Locale;
import java.util.Properties;
@@ -105,19 +107,24 @@ public class BasicContextProvider implements SCMContextProvider
}
}
+ @VisibleForTesting
+ BasicContextProvider(File baseDirectory, String version, Stage stage) {
+ this.baseDirectory = baseDirectory;
+ this.version = version;
+ this.stage = stage;
+ }
+
//~--- methods --------------------------------------------------------------
- /**
- * {@inheritDoc}
- */
- @Override
- public void close() throws IOException {}
- /**
- * {@inheritDoc}
- */
@Override
- public void init() {}
+ public Path resolve(Path path) {
+ if (path.isAbsolute()) {
+ return path;
+ }
+
+ return baseDirectory.toPath().resolve(path);
+ }
//~--- get methods ----------------------------------------------------------
diff --git a/scm-core/src/main/java/sonia/scm/BasicPropertiesAware.java b/scm-core/src/main/java/sonia/scm/BasicPropertiesAware.java
index f0b7772a77..cfd4284fae 100644
--- a/scm-core/src/main/java/sonia/scm/BasicPropertiesAware.java
+++ b/scm-core/src/main/java/sonia/scm/BasicPropertiesAware.java
@@ -37,18 +37,15 @@ package sonia.scm;
import com.google.common.base.Objects;
import com.google.common.collect.Maps;
-
import sonia.scm.xml.XmlMapStringAdapter;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.Serializable;
-
-import java.util.Map;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.io.Serializable;
+import java.util.Map;
+
+//~--- JDK imports ------------------------------------------------------------
/**
* Default implementation of {@link PropertiesAware} interface.
diff --git a/scm-core/src/main/java/sonia/scm/ConcurrentModificationException.java b/scm-core/src/main/java/sonia/scm/ConcurrentModificationException.java
new file mode 100644
index 0000000000..990d05181b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/ConcurrentModificationException.java
@@ -0,0 +1,35 @@
+package sonia.scm;
+
+import java.util.Collections;
+import java.util.List;
+
+import static java.util.stream.Collectors.joining;
+
+public class ConcurrentModificationException extends ExceptionWithContext {
+
+ private static final String CODE = "2wR7UzpPG1";
+
+ public ConcurrentModificationException(Class type, String id) {
+ this(Collections.singletonList(new ContextEntry(type, id)));
+ }
+
+ public ConcurrentModificationException(String type, String id) {
+ this(Collections.singletonList(new ContextEntry(type, id)));
+ }
+
+ public ConcurrentModificationException(List context) {
+ super(context, createMessage(context));
+ }
+
+ @Override
+ public String getCode() {
+ return CODE;
+ }
+
+ private static String createMessage(List context) {
+ return context.stream()
+ .map(c -> c.getType().toLowerCase() + " with id " + c.getId())
+ .collect(joining(" in ", "", " has been modified concurrently"));
+ }
+}
+
diff --git a/scm-core/src/main/java/sonia/scm/ContextEntry.java b/scm-core/src/main/java/sonia/scm/ContextEntry.java
new file mode 100644
index 0000000000..bbd2fadc5d
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/ContextEntry.java
@@ -0,0 +1,84 @@
+package sonia.scm;
+
+import sonia.scm.repository.NamespaceAndName;
+import sonia.scm.repository.Repository;
+import sonia.scm.util.AssertUtil;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+public class ContextEntry {
+ private final String type;
+ private final String id;
+
+ ContextEntry(Class type, String id) {
+ this(type.getSimpleName(), id);
+ }
+
+ ContextEntry(String type, String id) {
+ AssertUtil.assertIsNotEmpty(type);
+ AssertUtil.assertIsNotEmpty(id);
+ this.type = type;
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+
+ public static class ContextBuilder {
+ private final List context = new LinkedList<>();
+
+ public static List noContext() {
+ return new ContextBuilder().build();
+ }
+
+ public static List only(String type, String id) {
+ return new ContextBuilder().in(type, id).build();
+ }
+
+ public static ContextBuilder entity(Repository repository) {
+ return new ContextBuilder().in(repository.getNamespaceAndName());
+ }
+
+ public static ContextBuilder entity(NamespaceAndName namespaceAndName) {
+ return new ContextBuilder().in(Repository.class, namespaceAndName.logString());
+ }
+
+ public static ContextBuilder entity(Class type, String id) {
+ return new ContextBuilder().in(type, id);
+ }
+
+ public static ContextBuilder entity(String type, String id) {
+ return new ContextBuilder().in(type, id);
+ }
+
+ public ContextBuilder in(Repository repository) {
+ return in(repository.getNamespaceAndName());
+ }
+
+ public ContextBuilder in(NamespaceAndName namespaceAndName) {
+ return this.in(Repository.class, namespaceAndName.logString());
+ }
+
+ public ContextBuilder in(Class type, String id) {
+ context.add(new ContextEntry(type, id));
+ return this;
+ }
+
+ public ContextBuilder in(String type, String id) {
+ context.add(new ContextEntry(type, id));
+ return this;
+ }
+
+ public List build() {
+ return Collections.unmodifiableList(context);
+ }
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/DisplayManager.java b/scm-core/src/main/java/sonia/scm/DisplayManager.java
new file mode 100644
index 0000000000..72113a483d
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/DisplayManager.java
@@ -0,0 +1,19 @@
+package sonia.scm;
+
+import java.util.Collection;
+import java.util.Optional;
+
+public interface DisplayManager {
+
+ int DEFAULT_LIMIT = 5;
+
+ /**
+ * Returns a {@link Collection} of filtered objects
+ *
+ * @param filter the searched string
+ * @return filtered object from the store
+ */
+ Collection autocomplete(String filter);
+
+ Optional get(String id);
+}
diff --git a/scm-core/src/main/java/sonia/scm/ExceptionWithContext.java b/scm-core/src/main/java/sonia/scm/ExceptionWithContext.java
new file mode 100644
index 0000000000..8702567880
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/ExceptionWithContext.java
@@ -0,0 +1,28 @@
+package sonia.scm;
+
+import java.util.List;
+
+import static java.util.Collections.unmodifiableList;
+
+public abstract class ExceptionWithContext extends RuntimeException {
+
+ private static final long serialVersionUID = 4327413456580409224L;
+
+ private final List context;
+
+ public ExceptionWithContext(List context, String message) {
+ super(message);
+ this.context = context;
+ }
+
+ public ExceptionWithContext(List context, String message, Exception cause) {
+ super(message, cause);
+ this.context = context;
+ }
+
+ public List getContext() {
+ return unmodifiableList(context);
+ }
+
+ public abstract String getCode();
+}
diff --git a/scm-core/src/main/java/sonia/scm/FeatureNotSupportedException.java b/scm-core/src/main/java/sonia/scm/FeatureNotSupportedException.java
new file mode 100644
index 0000000000..2d64af4318
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/FeatureNotSupportedException.java
@@ -0,0 +1,63 @@
+/**
+ * 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;
+
+import java.util.Collections;
+
+/**
+ *
+ * @author Sebastian Sdorra
+ * @version 1.6
+ */
+@SuppressWarnings("squid:MaximumInheritanceDepth") // exceptions have a deep inheritance depth themselves; therefore we accept this here
+public class FeatureNotSupportedException extends BadRequestException {
+
+ private static final long serialVersionUID = 256498734456613496L;
+
+ private static final String CODE = "9SR8G0kmU1";
+
+ public FeatureNotSupportedException(String feature)
+ {
+ super(Collections.emptyList(),createMessage(feature));
+ }
+
+ @Override
+ public String getCode() {
+ return CODE;
+ }
+
+ private static String createMessage(String feature) {
+ return "feature " + feature + " is not supported by this repository";
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/GenericDAO.java b/scm-core/src/main/java/sonia/scm/GenericDAO.java
index b63a96f733..003c73806c 100644
--- a/scm-core/src/main/java/sonia/scm/GenericDAO.java
+++ b/scm-core/src/main/java/sonia/scm/GenericDAO.java
@@ -114,4 +114,5 @@ public interface GenericDAO
* @return all items
*/
public Collection getAll();
+
}
diff --git a/scm-core/src/main/java/sonia/scm/Handler.java b/scm-core/src/main/java/sonia/scm/Handler.java
index 67ec039fba..a4e927ed7b 100644
--- a/scm-core/src/main/java/sonia/scm/Handler.java
+++ b/scm-core/src/main/java/sonia/scm/Handler.java
@@ -39,11 +39,8 @@ package sonia.scm;
* @author Sebastian Sdorra
*
* @param a typed object
- * @param
*/
-public interface Handler
- extends HandlerBase
-{
+public interface Handler extends HandlerBase {
/**
* Returns the type object of the handler.
@@ -51,7 +48,7 @@ public interface Handler
*
* @return type object of the handler
*/
- public Type getType();
+ Type getType();
/**
* Returns true if the hanlder is configured.
@@ -59,5 +56,5 @@ public interface Handler
*
* @return true if the hanlder is configured
*/
- public boolean isConfigured();
+ boolean isConfigured();
}
diff --git a/scm-core/src/main/java/sonia/scm/HandlerBase.java b/scm-core/src/main/java/sonia/scm/HandlerBase.java
index 0baea8d929..d960cc6107 100644
--- a/scm-core/src/main/java/sonia/scm/HandlerBase.java
+++ b/scm-core/src/main/java/sonia/scm/HandlerBase.java
@@ -36,7 +36,6 @@ package sonia.scm;
//~--- JDK imports ------------------------------------------------------------
import java.io.Closeable;
-import java.io.IOException;
/**
* The base class of all handlers.
@@ -44,42 +43,31 @@ import java.io.IOException;
* @author Sebastian Sdorra
*
* @param type object of the handler
- * @param exception type of the handler
*/
-public interface HandlerBase
+public interface HandlerBase
extends Initable, Closeable
{
/**
* Persists a new object.
*
- *
- * @param object to store
- *
- * @throws E
- * @throws IOException
+ * @return The persisted object.
*/
- public void create(T object) throws E, IOException;
+ T create(T object);
/**
* Removes a persistent object.
*
*
* @param object to delete
- *
- * @throws E
- * @throws IOException
*/
- public void delete(T object) throws E, IOException;
+ void delete(T object);
/**
* Modifies a persistent object.
*
*
* @param object to modify
- *
- * @throws E
- * @throws IOException
*/
- public void modify(T object) throws E, IOException;
+ void modify(T object);
}
diff --git a/scm-core/src/main/java/sonia/scm/IllegalIdentifierChangeException.java b/scm-core/src/main/java/sonia/scm/IllegalIdentifierChangeException.java
new file mode 100644
index 0000000000..63b9d0d4fc
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/IllegalIdentifierChangeException.java
@@ -0,0 +1,21 @@
+package sonia.scm;
+
+import java.util.Collections;
+
+public class IllegalIdentifierChangeException extends BadRequestException {
+
+ private static final String CODE = "thbsUFokjk";
+
+ public IllegalIdentifierChangeException(ContextEntry.ContextBuilder context, String message) {
+ super(context.build(), message);
+ }
+
+ public IllegalIdentifierChangeException(String message) {
+ super(Collections.emptyList(), message);
+ }
+
+ @Override
+ public String getCode() {
+ return CODE;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/Manager.java b/scm-core/src/main/java/sonia/scm/Manager.java
index 600ab268ca..6e0b72295c 100644
--- a/scm-core/src/main/java/sonia/scm/Manager.java
+++ b/scm-core/src/main/java/sonia/scm/Manager.java
@@ -33,12 +33,9 @@
package sonia.scm;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.IOException;
-
import java.util.Collection;
import java.util.Comparator;
+import java.util.function.Predicate;
/**
* Base interface for all manager classes.
@@ -46,22 +43,21 @@ import java.util.Comparator;
* @author Sebastian Sdorra
*
* @param type of the model object
- * @param type of the exception
*/
-public interface Manager
- extends HandlerBase, LastModifiedAware
+public interface Manager
+ extends HandlerBase, LastModifiedAware
{
+
/**
* Reloads a object from store and overwrites all changes.
*
*
* @param object to refresh
*
- * @throws E
- * @throws IOException
+ * @throws NotFoundException
*/
- public void refresh(T object) throws E, IOException;
+ void refresh(T object);
//~--- get methods ----------------------------------------------------------
@@ -73,7 +69,7 @@ public interface Manager
*
* @return object with the given id
*/
- public T get(String id);
+ T get(String id);
/**
* Returns a {@link java.util.Collection} of all objects in the store.
@@ -81,17 +77,18 @@ public interface Manager
*
* @return all object in the store
*/
- public Collection getAll();
+ Collection getAll();
/**
* Returns all object of the store sorted by the given {@link java.util.Comparator}
*
*
+ * @param filter to filter the returned objects
* @param comparator to sort the returned objects
* @since 1.4
* @return all object of the store sorted by the given {@link java.util.Comparator}
*/
- public Collection getAll(Comparator comparator);
+ Collection getAll(Predicate filter, Comparator comparator);
/**
* Returns objects from the store which are starts at the given start
@@ -102,14 +99,14 @@ public interface Manager
* @param limit parameter
*
* @since 1.4
- * @return objects from the store which are starts at the given
+ * @return objects from the store which are starts at the given
* start parameter
*/
- public Collection getAll(int start, int limit);
+ Collection getAll(int start, int limit);
/**
* Returns objects from the store which are starts at the given start
- * parameter sorted by the given {@link java.util.Comparator}.
+ * parameter sorted by the given {@link java.util.Comparator}.
* The objects returned are limited by the limit parameter.
*
*
@@ -118,8 +115,30 @@ public interface Manager
* @param limit parameter
*
* @since 1.4
- * @return objects from the store which are starts at the given
+ * @return objects from the store which are starts at the given
* start parameter
*/
- public Collection getAll(Comparator comparator, int start, int limit);
+ Collection getAll(Comparator comparator, int start, int limit);
+
+ /**
+ * Returns objects from the store divided into pages with the given page
+ * size for the given page number (zero based) and sorted by the given
+ * {@link java.util.Comparator}.
+ *
This default implementation reads all items, first, so you might want to adapt this
+ * whenever reading is expensive!
+ *
+ * @param filter to filter returned objects
+ * @param comparator to sort the returned objects
+ * @param pageNumber the number of the page to be returned (zero based)
+ * @param pageSize the size of the pages
+ *
+ * @since 2.0
+ * @return {@link PageResult} with the objects from the store for the requested
+ * page. If the requested page number exceeds the existing pages, an
+ * empty page result is returned.
+ */
+ default PageResult getPage(Predicate filter, Comparator comparator, int pageNumber, int pageSize) {
+ return PageResult.createPage(getAll(filter, comparator), pageNumber, pageSize);
+ }
+
}
diff --git a/scm-core/src/main/java/sonia/scm/ManagerDecorator.java b/scm-core/src/main/java/sonia/scm/ManagerDecorator.java
index af0215202c..0c46366a56 100644
--- a/scm-core/src/main/java/sonia/scm/ManagerDecorator.java
+++ b/scm-core/src/main/java/sonia/scm/ManagerDecorator.java
@@ -35,9 +35,9 @@ package sonia.scm;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
-
import java.util.Collection;
import java.util.Comparator;
+import java.util.function.Predicate;
/**
* Basic decorator for manager classes.
@@ -46,11 +46,8 @@ import java.util.Comparator;
* @since 1.23
*
* @param model type
- * @param exception type
*/
-public class ManagerDecorator
- implements Manager
-{
+public class ManagerDecorator implements Manager {
/**
* Constructs a new ManagerDecorator.
@@ -58,125 +55,78 @@ public class ManagerDecorator
*
* @param decorated manager implementation
*/
- public ManagerDecorator(Manager decorated)
+ public ManagerDecorator(Manager decorated)
{
this.decorated = decorated;
}
- //~--- methods --------------------------------------------------------------
-
- /**
- * {@inheritDoc}
- */
@Override
public void close() throws IOException
{
decorated.close();
}
- /**
- * {@inheritDoc}
- */
@Override
- public void create(T object) throws E, IOException
- {
- decorated.create(object);
+ public T create(T object) {
+ return decorated.create(object);
}
- /**
- * {@inheritDoc}
- */
@Override
- public void delete(T object) throws E, IOException
- {
+ public void delete(T object){
decorated.delete(object);
}
- /**
- * {@inheritDoc}
- */
@Override
public void init(SCMContextProvider context)
{
decorated.init(context);
}
- /**
- * {@inheritDoc}
- */
@Override
- public void modify(T object) throws E, IOException
- {
+ public void modify(T object){
decorated.modify(object);
}
- /**
- * {@inheritDoc}
- */
@Override
- public void refresh(T object) throws E, IOException
- {
+ public void refresh(T object){
decorated.refresh(object);
}
- //~--- get methods ----------------------------------------------------------
-
- /**
- * {@inheritDoc}
- */
@Override
public T get(String id)
{
return decorated.get(id);
}
- /**
- * {@inheritDoc}
- */
@Override
public Collection getAll()
{
return decorated.getAll();
}
- /**
- * {@inheritDoc}
- */
@Override
- public Collection getAll(Comparator comparator)
+ public Collection getAll(Predicate filter, Comparator comparator)
{
- return decorated.getAll(comparator);
+ return decorated.getAll(filter, comparator);
}
- /**
- * {@inheritDoc}
- */
@Override
public Collection getAll(int start, int limit)
{
return decorated.getAll(start, limit);
}
- /**
- * {@inheritDoc}
- */
@Override
public Collection getAll(Comparator comparator, int start, int limit)
{
return decorated.getAll(comparator, start, limit);
}
- /**
- * {@inheritDoc}
- */
@Override
public Long getLastModified()
{
return decorated.getLastModified();
}
- //~--- fields ---------------------------------------------------------------
-
- /** manager implementation */
- private Manager decorated;
+ private Manager decorated;
}
diff --git a/scm-core/src/main/java/sonia/scm/ModelObject.java b/scm-core/src/main/java/sonia/scm/ModelObject.java
index 76ba021e67..cca9608ceb 100644
--- a/scm-core/src/main/java/sonia/scm/ModelObject.java
+++ b/scm-core/src/main/java/sonia/scm/ModelObject.java
@@ -53,5 +53,11 @@ public interface ModelObject
*
* @return unique id
*/
- public String getId();
+ String getId();
+
+ void setLastModified(Long timestamp);
+
+ Long getCreationDate();
+
+ void setCreationDate(Long timestamp);
}
diff --git a/scm-core/src/main/java/sonia/scm/NoChangesMadeException.java b/scm-core/src/main/java/sonia/scm/NoChangesMadeException.java
new file mode 100644
index 0000000000..9bf0363398
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/NoChangesMadeException.java
@@ -0,0 +1,18 @@
+package sonia.scm;
+
+import sonia.scm.repository.Repository;
+
+public class NoChangesMadeException extends BadRequestException {
+ public NoChangesMadeException(Repository repository, String branch) {
+ super(ContextEntry.ContextBuilder.entity(repository).build(), "no changes detected to branch " + branch);
+ }
+
+ public NoChangesMadeException(Repository repository) {
+ super(ContextEntry.ContextBuilder.entity(repository).build(), "no changes detected");
+ }
+
+ @Override
+ public String getCode() {
+ return "40RaYIeeR1";
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/NotFoundException.java b/scm-core/src/main/java/sonia/scm/NotFoundException.java
new file mode 100644
index 0000000000..9c478da855
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/NotFoundException.java
@@ -0,0 +1,40 @@
+package sonia.scm;
+
+import java.util.Collections;
+import java.util.List;
+
+import static java.util.stream.Collectors.joining;
+
+public class NotFoundException extends ExceptionWithContext {
+
+ private static final long serialVersionUID = 1710455380886499111L;
+
+ private static final String CODE = "AGR7UzkhA1";
+
+ public NotFoundException(Class type, String id) {
+ this(Collections.singletonList(new ContextEntry(type, id)));
+ }
+
+ public NotFoundException(String type, String id) {
+ this(Collections.singletonList(new ContextEntry(type, id)));
+ }
+
+ public static NotFoundException notFound(ContextEntry.ContextBuilder contextBuilder) {
+ return new NotFoundException(contextBuilder.build());
+ }
+
+ private NotFoundException(List context) {
+ super(context, createMessage(context));
+ }
+
+ @Override
+ public String getCode() {
+ return CODE;
+ }
+
+ private static String createMessage(List context) {
+ return context.stream()
+ .map(c -> c.getType().toLowerCase() + " with id " + c.getId())
+ .collect(joining(" in ", "could not find ", ""));
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/NotSupportedFeatuerException.java b/scm-core/src/main/java/sonia/scm/NotSupportedFeatuerException.java
deleted file mode 100644
index e6fea6cfa7..0000000000
--- a/scm-core/src/main/java/sonia/scm/NotSupportedFeatuerException.java
+++ /dev/null
@@ -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;
-
-/**
- *
- * @author Sebastian Sdorra
- * @version 1.6
- */
-public class NotSupportedFeatuerException extends Exception
-{
-
- /** Field description */
- private static final long serialVersionUID = 256498734456613496L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
- public NotSupportedFeatuerException() {}
-
- /**
- * Constructs ...
- *
- *
- * @param message
- */
- public NotSupportedFeatuerException(String message)
- {
- super(message);
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/PageResult.java b/scm-core/src/main/java/sonia/scm/PageResult.java
new file mode 100644
index 0000000000..983a4e5dd1
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/PageResult.java
@@ -0,0 +1,45 @@
+package sonia.scm;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static sonia.scm.util.Util.createSubCollection;
+
+/**
+ * This represents the result of a page request. Contains the results for
+ * the page and the overall count of all elements.
+ */
+public class PageResult {
+
+ private final Collection entities;
+ private final int overallCount;
+
+ public static PageResult createPage(Collection allEntities, int pageNumber, int pageSize) {
+ checkArgument(pageSize > 0, "pageSize must be at least 1");
+ checkArgument(pageNumber >= 0, "pageNumber must be non-negative");
+
+ Collection pagedEntities = createSubCollection(allEntities, pageNumber * pageSize, pageSize);
+
+ return new PageResult<>(pagedEntities, allEntities.size());
+ }
+
+ public PageResult(Collection entities, int overallCount) {
+ this.entities = entities;
+ this.overallCount = overallCount;
+ }
+
+ /**
+ * The entities for the current page.
+ */
+ public Collection getEntities() {
+ return Collections.unmodifiableCollection(entities);
+ }
+
+ /**
+ * The overall count of all available elements.
+ */
+ public int getOverallCount() {
+ return overallCount;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/ReducedModelObject.java b/scm-core/src/main/java/sonia/scm/ReducedModelObject.java
new file mode 100644
index 0000000000..b8db8c3ee0
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/ReducedModelObject.java
@@ -0,0 +1,15 @@
+package sonia.scm;
+
+
+/**
+ * This is a reduced form of a model object.
+ * It can be used as search result to avoid returning the whole object properties.
+ *
+ * @author Mohamed Karray
+ */
+public interface ReducedModelObject {
+
+ String getId();
+
+ String getDisplayName();
+}
diff --git a/scm-core/src/main/java/sonia/scm/SCMContext.java b/scm-core/src/main/java/sonia/scm/SCMContext.java
index f2c1af81d0..f5367625bb 100644
--- a/scm-core/src/main/java/sonia/scm/SCMContext.java
+++ b/scm-core/src/main/java/sonia/scm/SCMContext.java
@@ -39,7 +39,7 @@ import sonia.scm.user.User;
import sonia.scm.util.ServiceUtil;
/**
- * The SCMConext searches a implementation of {@link SCMContextProvider} and
+ * The SCMContext searches a implementation of {@link SCMContextProvider} and
* holds a singleton instance of this implementation.
*
* @author Sebastian Sdorra
@@ -51,7 +51,7 @@ public final class SCMContext
public static final String DEFAULT_PACKAGE = "sonia.scm";
/** Name of the anonymous user */
- public static final String USER_ANONYMOUS = "anonymous";
+ public static final String USER_ANONYMOUS = "_anonymous";
/**
* the anonymous user
@@ -59,7 +59,7 @@ public final class SCMContext
*/
public static final User ANONYMOUS = new User(USER_ANONYMOUS,
"SCM Anonymous",
- "scm-anonymous@scm-manager.com");
+ "scm-anonymous@scm-manager.org");
/** Singleton instance of {@link SCMContextProvider} */
private static volatile SCMContextProvider provider;
@@ -94,8 +94,6 @@ public final class SCMContext
{
provider = new BasicContextProvider();
}
-
- provider.init();
}
}
}
diff --git a/scm-core/src/main/java/sonia/scm/SCMContextProvider.java b/scm-core/src/main/java/sonia/scm/SCMContextProvider.java
index 18328403fe..dac03baed0 100644
--- a/scm-core/src/main/java/sonia/scm/SCMContextProvider.java
+++ b/scm-core/src/main/java/sonia/scm/SCMContextProvider.java
@@ -37,6 +37,7 @@ package sonia.scm;
import java.io.Closeable;
import java.io.File;
+import java.nio.file.Path;
/**
* The main class for retrieving the home and the version of the SCM-Manager.
@@ -45,25 +46,25 @@ import java.io.File;
*
* @author Sebastian Sdorra
*/
-public interface SCMContextProvider extends Closeable
-{
-
- /**
- * Initializes the {@link SCMContextProvider}.
- * This method is called when the SCM manager is started.
- *
- */
- public void init();
-
- //~--- get methods ----------------------------------------------------------
-
+public interface SCMContextProvider {
/**
* Returns the base directory of the SCM-Manager.
*
*
* @return base directory of the SCM-Manager
*/
- public File getBaseDirectory();
+ File getBaseDirectory();
+
+ /**
+ * Resolves the given path against the base directory.
+ *
+ * @param path path to resolve
+ *
+ * @return absolute resolved path
+ *
+ * @since 2.0.0
+ */
+ Path resolve(Path path);
/**
* Returns the current stage of SCM-Manager.
@@ -72,7 +73,7 @@ public interface SCMContextProvider extends Closeable
* @return stage of SCM-Manager
* @since 1.12
*/
- public Stage getStage();
+ Stage getStage();
/**
* Returns a exception which is occurred on context startup.
@@ -82,7 +83,7 @@ public interface SCMContextProvider extends Closeable
* @return startup exception of null
* @since 1.14
*/
- public Throwable getStartupError();
+ Throwable getStartupError();
/**
* Returns the version of the SCM-Manager.
@@ -90,5 +91,5 @@ public interface SCMContextProvider extends Closeable
*
* @return version of the SCM-Manager
*/
- public String getVersion();
+ String getVersion();
}
diff --git a/scm-core/src/main/java/sonia/scm/ScmClientConfig.java b/scm-core/src/main/java/sonia/scm/ScmClientConfig.java
deleted file mode 100644
index 40b7d36aaa..0000000000
--- a/scm-core/src/main/java/sonia/scm/ScmClientConfig.java
+++ /dev/null
@@ -1,181 +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;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.config.ScmConfiguration;
-
-/**
- * Configuration object for a SCM-Manager
- * client (WebInterface, RestClient, ...).
- *
- * @author Sebastian Sdorra
- */
-public class ScmClientConfig
-{
-
- /**
- * Constructs {@link ScmClientConfig} object
- *
- */
- public ScmClientConfig() {}
-
- /**
- * Constructs {@link ScmClientConfig} object
- *
- *
- * @param configuration SCM-Manager main configuration
- * @since 1.14
- */
- public ScmClientConfig(ScmConfiguration configuration)
- {
- this.dateFormat = configuration.getDateFormat();
- this.disableGroupingGrid = configuration.isDisableGroupingGrid();
- this.enableRepositoryArchive = configuration.isEnableRepositoryArchive();
- }
-
- /**
- * Constructs {@link ScmClientConfig} object
- *
- *
- * @param dateFormat
- */
- public ScmClientConfig(String dateFormat)
- {
- this.dateFormat = dateFormat;
- }
-
- /**
- * Constructs {@link ScmClientConfig} object
- *
- * @since 1.9
- *
- * @param dateFormat
- * @param disableGroupingGrid true to disable repository grouping
- */
- public ScmClientConfig(String dateFormat, boolean disableGroupingGrid)
- {
- this.dateFormat = dateFormat;
- this.disableGroupingGrid = disableGroupingGrid;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Returns the date format for the user interface. This format is a
- * JavaScript date format.
- *
- * @see Date Format
- * @return JavaScript date format
- */
- public String getDateFormat()
- {
- return dateFormat;
- }
-
- /**
- * Returns true if the grouping of repositories is disabled.
- *
- * @since 1.9
- *
- * @return true if the grouping of repositories is disabled
- */
- public boolean isDisableGroupingGrid()
- {
- return disableGroupingGrid;
- }
-
- /**
- * Returns true if the repository archive is disabled.
- *
- *
- * @return true if the repository archive is disabled
- * @since 1.14
- */
- public boolean isEnableRepositoryArchive()
- {
- return enableRepositoryArchive;
- }
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Setter for the date format
- *
- *
- *
- * @param dateFormat - JavaScript date format
- */
- public void setDateFormat(String dateFormat)
- {
- this.dateFormat = dateFormat;
- }
-
- /**
- * Enables or disables the grouping of repositories.
- *
- * @since 1.9
- *
- *
- * @param disableGroupingGrid
- */
- public void setDisableGroupingGrid(boolean disableGroupingGrid)
- {
- this.disableGroupingGrid = disableGroupingGrid;
- }
-
- /**
- * Enable or disable the repository archive. Default is disabled.
- *
- *
- * @param enableRepositoryArchive true to disable the repository archive
- * @since 1.14
- */
- public void setEnableRepositoryArchive(boolean enableRepositoryArchive)
- {
- this.enableRepositoryArchive = enableRepositoryArchive;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String dateFormat;
-
- /** Field description */
- private boolean enableRepositoryArchive = true;
-
- /** Field description */
- private boolean disableGroupingGrid = true;
-}
diff --git a/scm-core/src/main/java/sonia/scm/ScmConstraintViolationException.java b/scm-core/src/main/java/sonia/scm/ScmConstraintViolationException.java
new file mode 100644
index 0000000000..a28812eb8a
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/ScmConstraintViolationException.java
@@ -0,0 +1,136 @@
+package sonia.scm;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import static java.util.Collections.unmodifiableCollection;
+
+/**
+ * Use this exception to handle invalid input values that cannot be handled using
+ * JEE bean validation.
+ * Use the {@link Builder} to conditionally create a new exception:
+ *
+ * Builder
+ * .doThrow()
+ * .violation("name or alias must not be empty if not anonymous", "myParameter", "name")
+ * .violation("name or alias must not be empty if not anonymous", "myParameter", "alias")
+ * .when(myParameter.getName() == null && myParameter.getAlias() == null && !myParameter.isAnonymous())
+ * .andThrow()
+ * .violation("name must be empty if anonymous", "myParameter", "name")
+ * .when(myParameter.getName() != null && myParameter.isAnonymous());
+ *
+ * Mind that using this way you do not have to use if-else constructs.
+ */
+public class ScmConstraintViolationException extends RuntimeException implements Serializable {
+
+ private static final long serialVersionUID = 6904534307450229887L;
+
+ private final Collection violations;
+
+ private final String furtherInformation;
+
+ private ScmConstraintViolationException(Collection violations, String furtherInformation) {
+ this.violations = violations;
+ this.furtherInformation = furtherInformation;
+ }
+
+ /**
+ * The violations that caused this exception.
+ */
+ public Collection getViolations() {
+ return unmodifiableCollection(violations);
+ }
+
+ /**
+ * An optional URL for more informations about this constraint violation.
+ */
+ public String getUrl() {
+ return furtherInformation;
+ }
+
+ /**
+ * Builder to conditionally create constraint violations.
+ */
+ public static class Builder {
+ private final Collection violations = new ArrayList<>();
+ private String furtherInformation;
+
+ /**
+ * Use this to create a new builder instance.
+ */
+ public static Builder doThrow() {
+ return new Builder();
+ }
+
+ /**
+ * Resets this builder to check for further violations.
+ * @return this builder instance.
+ */
+ public Builder andThrow() {
+ this.violations.clear();
+ this.furtherInformation = null;
+ return this;
+ }
+
+ /**
+ * Describes the violation with a custom message and the affected property. When more than one property is affected,
+ * you can call this method multiple times.
+ * @param message The message describing the violation.
+ * @param pathElements The affected property denoted by the path to reach this property,
+ * eg. "someParameter", "complexProperty", "attribute"
+ * @return this builder instance.
+ */
+ public Builder violation(String message, String... pathElements) {
+ this.violations.add(new ScmConstraintViolation(message, pathElements));
+ return this;
+ }
+
+ /**
+ * Use this to specify a URL with further information about this violation and hints how to solve this.
+ * This is optional.
+ * @return this builder instance.
+ */
+ public Builder withFurtherInformation(String furtherInformation) {
+ this.furtherInformation = furtherInformation;
+ return this;
+ }
+
+ /**
+ * When the given condition is true, a exception will be thrown. Otherwise this simply resets this
+ * builder and does nothing else.
+ * @param condition The condition that indicates a violation of this constraint.
+ * @return this builder instance.
+ */
+ public Builder when(boolean condition) {
+ if (condition && !this.violations.isEmpty()) {
+ throw new ScmConstraintViolationException(violations, furtherInformation);
+ }
+ return andThrow();
+ }
+ }
+
+ /**
+ * A single constraint violation.
+ */
+ public static class ScmConstraintViolation implements Serializable {
+
+ private static final long serialVersionUID = -6900317468157084538L;
+
+ private final String message;
+ private final String path;
+
+ private ScmConstraintViolation(String message, String... pathElements) {
+ this.message = message;
+ this.path = String.join(".", pathElements);
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getPropertyPath() {
+ return path;
+ }
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/ScmState.java b/scm-core/src/main/java/sonia/scm/ScmState.java
deleted file mode 100644
index 5610a40c08..0000000000
--- a/scm-core/src/main/java/sonia/scm/ScmState.java
+++ /dev/null
@@ -1,254 +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;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.security.PermissionDescriptor;
-import sonia.scm.user.User;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.util.Collection;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * This class represents the current state of the SCM-Manager.
- *
- * @author Sebastian Sdorra
- */
-@XmlRootElement(name = "state")
-@XmlAccessorType(XmlAccessType.FIELD)
-public final class ScmState
-{
-
- /**
- * Constructs {@link ScmState} object.
- * This constructor is required by JAXB.
- *
- */
- ScmState() {}
-
- /**
- * Constructs {@link ScmState} object.
- *
- *
- * @param version scm-manager version
- * @param user current user
- * @param groups groups of the current user
- * @param token authentication token
- * @param repositoryTypes available repository types
- * @param defaultUserType default user type
- * @param clientConfig client configuration
- * @param assignedPermission assigned permissions
- * @param availablePermissions list of available permissions
- *
- * @since 2.0.0
- */
- public ScmState(String version, User user, Collection groups,
- String token, Collection repositoryTypes, String defaultUserType,
- ScmClientConfig clientConfig, List assignedPermission,
- List availablePermissions)
- {
- this.version = version;
- this.user = user;
- this.groups = groups;
- this.token = token;
- this.repositoryTypes = repositoryTypes;
- this.clientConfig = clientConfig;
- this.defaultUserType = defaultUserType;
- this.assignedPermissions = assignedPermission;
- this.availablePermissions = availablePermissions;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Return a list of assigned permissions.
- *
- *
- * @return list of assigned permissions
- * @since 1.31
- */
- public List getAssignedPermissions()
- {
- return assignedPermissions;
- }
-
- /**
- * Returns a list of available global permissions.
- *
- *
- * @return available global permissions
- * @since 1.31
- */
- public List getAvailablePermissions()
- {
- return availablePermissions;
- }
-
- /**
- * Returns configuration for SCM-Manager clients.
- *
- *
- * @return configuration for SCM-Manager clients
- */
- public ScmClientConfig getClientConfig()
- {
- return clientConfig;
- }
-
- /**
- * Returns the default user type
- *
- *
- * @return default user type
- *
- * @since 1.14
- */
- public String getDefaultUserType()
- {
- return defaultUserType;
- }
-
- /**
- * Returns a {@link java.util.Collection} of groups names which are associated
- * to the current user.
- *
- *
- * @return a {@link java.util.Collection} of groups names
- */
- public Collection getGroups()
- {
- return groups;
- }
-
- /**
- * Returns all available repository types.
- *
- *
- * @return all available repository types
- */
- public Collection getRepositoryTypes()
- {
- return repositoryTypes;
- }
-
- /**
- * Returns authentication token or {@code null}.
- *
- *
- * @return authentication token or {@code null}
- *
- * @since 2.0.0
- */
- public String getToken()
- {
- return token;
- }
-
- /**
- * Returns the current logged in user.
- *
- *
- * @return current logged in user
- */
- public User getUser()
- {
- return user;
- }
-
- /**
- * Returns the version of the SCM-Manager.
- *
- *
- * @return version of the SCM-Manager
- */
- public String getVersion()
- {
- return version;
- }
-
- /**
- * Returns true if the request was successful.
- * This method is required by extjs.
- *
- * @return true if the request was successful
- */
- public boolean isSuccess()
- {
- return success;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** marker for extjs */
- private final boolean success = true;
-
- /** authentication token */
- private String token;
-
- /** Field description */
- private List assignedPermissions;
-
- /**
- * Avaliable global permission
- * @since 1.31
- */
- private List availablePermissions;
-
- /** Field description */
- private ScmClientConfig clientConfig;
-
- /** Field description */
- private String defaultUserType;
-
- /** Field description */
- private Collection groups;
-
- /** Field description */
- @XmlElement(name = "repositoryTypes")
- private Collection repositoryTypes;
-
- /** Field description */
- private User user;
-
- /** Field description */
- private String version;
-}
diff --git a/scm-core/src/main/java/sonia/scm/ScmStateFactory.java b/scm-core/src/main/java/sonia/scm/ScmStateFactory.java
deleted file mode 100644
index 41502a6850..0000000000
--- a/scm-core/src/main/java/sonia/scm/ScmStateFactory.java
+++ /dev/null
@@ -1,185 +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;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import com.google.common.collect.ImmutableList;
-
-import org.apache.shiro.subject.PrincipalCollection;
-import org.apache.shiro.subject.Subject;
-
-import sonia.scm.config.ScmConfiguration;
-import sonia.scm.group.GroupNames;
-import sonia.scm.repository.RepositoryManager;
-import sonia.scm.security.AuthorizationCollector;
-import sonia.scm.security.PermissionDescriptor;
-import sonia.scm.security.Role;
-import sonia.scm.security.SecuritySystem;
-import sonia.scm.user.User;
-import sonia.scm.user.UserManager;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import javax.inject.Inject;
-
-/**
- * Factory to create {@link ScmState}.
- *
- * @author Sebastian Sdorra
- * @since 2.0.0
- */
-public final class ScmStateFactory
-{
-
- /**
- * Constructs a new {@link ScmStateFactory}.
- *
- *
- * @param contextProvider context provider
- * @param configuration configuration
- * @param repositoryManger repository manager
- * @param userManager user manager
- * @param securitySystem security system
- * @param authorizationCollector authorization collector
- */
- @Inject
- public ScmStateFactory(SCMContextProvider contextProvider,
- ScmConfiguration configuration, RepositoryManager repositoryManger,
- UserManager userManager, SecuritySystem securitySystem,
- AuthorizationCollector authorizationCollector)
- {
- this.contextProvider = contextProvider;
- this.configuration = configuration;
- this.repositoryManger = repositoryManger;
- this.userManager = userManager;
- this.securitySystem = securitySystem;
- this.authorizationCollector = authorizationCollector;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Returns anonymous state.
- *
- *
- * @return anonymous state
- */
- @SuppressWarnings("unchecked")
- public ScmState createAnonymousState()
- {
- return createState(SCMContext.ANONYMOUS, Collections.EMPTY_LIST, null,
- Collections.EMPTY_LIST, Collections.EMPTY_LIST);
- }
-
- /**
- * Creates an state from the given subject.
- *
- *
- * @param subject subject
- *
- * @return state from subject
- */
- public ScmState createState(Subject subject)
- {
- return createState(subject, null);
- }
-
- /**
- * Creates an state from the given subject and authentication token.
- *
- *
- * @param subject subject
- * @param token authentication token
- *
- * @return state from subject and authentication token
- */
- @SuppressWarnings("unchecked")
- public ScmState createState(Subject subject, String token)
- {
- PrincipalCollection collection = subject.getPrincipals();
- User user = collection.oneByType(User.class);
- GroupNames groups = collection.oneByType(GroupNames.class);
-
- List ap = Collections.EMPTY_LIST;
-
- if (subject.hasRole(Role.ADMIN))
- {
- ap = securitySystem.getAvailablePermissions();
- }
-
- List permissions =
- ImmutableList.copyOf(
- authorizationCollector.collect().getStringPermissions());
-
- return createState(user, groups.getCollection(), token, permissions, ap);
- }
-
- private ScmState createState(User user, Collection groups,
- String token, List assignedPermissions,
- List availablePermissions)
- {
- User u = user.clone();
-
- // do not return password on authentication
- u.setPassword(null);
-
- return new ScmState(contextProvider.getVersion(), u, groups, token,
- repositoryManger.getConfiguredTypes(), userManager.getDefaultType(),
- new ScmClientConfig(configuration), assignedPermissions,
- availablePermissions);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** authorization collector */
- private final AuthorizationCollector authorizationCollector;
-
- /** configuration */
- private final ScmConfiguration configuration;
-
- /** context provider */
- private final SCMContextProvider contextProvider;
-
- /** repository manager */
- private final RepositoryManager repositoryManger;
-
- /** security system */
- private final SecuritySystem securitySystem;
-
- /** user manager */
- private final UserManager userManager;
-}
diff --git a/scm-core/src/main/java/sonia/scm/TransformFilter.java b/scm-core/src/main/java/sonia/scm/TransformFilter.java
index e872ab384f..fa798fe36e 100644
--- a/scm-core/src/main/java/sonia/scm/TransformFilter.java
+++ b/scm-core/src/main/java/sonia/scm/TransformFilter.java
@@ -39,8 +39,10 @@ package sonia.scm;
* @author Sebastian Sdorra
*
* @param type of objects to transform
+ * @param result type of the transformation
*/
-public interface TransformFilter
+@FunctionalInterface
+public interface TransformFilter
{
/**
@@ -52,5 +54,5 @@ public interface TransformFilter
*
* @return tranformed object
*/
- public T accept(T item);
+ R accept(T item);
}
diff --git a/scm-core/src/main/java/sonia/scm/TypeManager.java b/scm-core/src/main/java/sonia/scm/TypeManager.java
index 52a43e5593..6f13cb82d8 100644
--- a/scm-core/src/main/java/sonia/scm/TypeManager.java
+++ b/scm-core/src/main/java/sonia/scm/TypeManager.java
@@ -44,10 +44,8 @@ import java.util.Collection;
*
* @param type of the model object
* @param type of the handler
- * @param type of the exception
*/
-public interface TypeManager,
- E extends Exception> extends Manager
+public interface TypeManager> extends Manager
{
/**
@@ -58,7 +56,7 @@ public interface TypeManager,
*
* @return the handler for given type
*/
- public H getHandler(String type);
+ H getHandler(String type);
/**
* Returns a {@link java.util.Collection} of all
@@ -66,5 +64,5 @@ public interface TypeManager,
*
* @return all available types
*/
- public Collection getTypes();
+ Collection getTypes();
}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/BaseDtoMapper.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/BaseDtoMapper.java
new file mode 100644
index 0000000000..8d67822c1b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/BaseDtoMapper.java
@@ -0,0 +1,12 @@
+package sonia.scm.api.v2.resources;
+
+import java.time.Instant;
+
+class BaseDtoMapper {
+ Long mapDate(Instant value) {
+ if (value != null) {
+ return value.toEpochMilli();
+ }
+ return null;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/BaseMapper.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/BaseMapper.java
new file mode 100644
index 0000000000..eba8173de1
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/BaseMapper.java
@@ -0,0 +1,10 @@
+package sonia.scm.api.v2.resources;
+
+import de.otto.edison.hal.HalRepresentation;
+import org.mapstruct.Mapping;
+
+public abstract class BaseMapper extends HalAppenderMapper implements InstantAttributeMapper {
+
+ @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes
+ public abstract D map(T modelObject);
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/ChangesetDto.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/ChangesetDto.java
new file mode 100644
index 0000000000..6759f5cb8c
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/ChangesetDto.java
@@ -0,0 +1,40 @@
+package sonia.scm.api.v2.resources;
+
+import de.otto.edison.hal.Embedded;
+import de.otto.edison.hal.HalRepresentation;
+import de.otto.edison.hal.Links;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.time.Instant;
+
+@Getter
+@Setter
+@NoArgsConstructor
+public class ChangesetDto extends HalRepresentation {
+
+ /**
+ * The changeset identification string
+ */
+ private String id;
+
+ /**
+ * The author of the changeset
+ */
+ private PersonDto author;
+
+ /**
+ * The date when the changeset was committed
+ */
+ private Instant date;
+
+ /**
+ * The text of the changeset description
+ */
+ private String description;
+
+ public ChangesetDto(Links links, Embedded embedded) {
+ super(links, embedded);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/ChangesetToChangesetDtoMapper.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/ChangesetToChangesetDtoMapper.java
new file mode 100644
index 0000000000..cd7d7ecebe
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/ChangesetToChangesetDtoMapper.java
@@ -0,0 +1,14 @@
+package sonia.scm.api.v2.resources;
+
+import org.mapstruct.Context;
+import org.mapstruct.Mapping;
+import sonia.scm.repository.Changeset;
+import sonia.scm.repository.Repository;
+
+public interface ChangesetToChangesetDtoMapper {
+
+ @Mapping(target = "attributes", ignore = true) // We do not map HAL attributes
+ ChangesetDto map(Changeset changeset, @Context Repository repository);
+
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/CollectionToDtoMapper.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/CollectionToDtoMapper.java
new file mode 100644
index 0000000000..523629ce3b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/CollectionToDtoMapper.java
@@ -0,0 +1,32 @@
+package sonia.scm.api.v2.resources;
+
+import de.otto.edison.hal.HalRepresentation;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static de.otto.edison.hal.Embedded.embeddedBuilder;
+import static de.otto.edison.hal.Links.linkingTo;
+
+public abstract class CollectionToDtoMapper {
+
+ private final String collectionName;
+ private final BaseMapper mapper;
+
+ protected CollectionToDtoMapper(String collectionName, BaseMapper mapper) {
+ this.collectionName = collectionName;
+ this.mapper = mapper;
+ }
+
+ public HalRepresentation map(Collection collection) {
+ List dtos = collection.stream().map(mapper::map).collect(Collectors.toList());
+ return new HalRepresentation(
+ linkingTo().self(createSelfLink()).build(),
+ embeddedBuilder().with(collectionName, dtos).build()
+ );
+ }
+
+ protected abstract String createSelfLink();
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/HalAppender.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalAppender.java
new file mode 100644
index 0000000000..b313f68af8
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalAppender.java
@@ -0,0 +1,66 @@
+package sonia.scm.api.v2.resources;
+
+import de.otto.edison.hal.HalRepresentation;
+
+import java.util.List;
+
+/**
+ * The {@link HalAppender} can be used within an {@link HalEnricher} to append hateoas links to a json response.
+ *
+ * @author Sebastian Sdorra
+ * @since 2.0.0
+ */
+public interface HalAppender {
+
+ /**
+ * Appends one link to the json response.
+ *
+ * @param rel name of relation
+ * @param href link uri
+ */
+ void appendLink(String rel, String href);
+
+ /**
+ * Returns a builder which is able to append an array of links to the resource.
+ *
+ * @param rel name of link relation
+ * @return multi link builder
+ */
+ LinkArrayBuilder linkArrayBuilder(String rel);
+
+ /**
+ * Appends one embedded object to the json response.
+ *
+ * @param rel name of relation
+ * @param embeddedItem embedded object
+ */
+ void appendEmbedded(String rel, HalRepresentation embeddedItem);
+
+ /**
+ * Appends a list of embedded objects to the json response.
+ *
+ * @param rel name of relation
+ * @param embeddedItems embedded objects
+ */
+ void appendEmbedded(String rel, List embeddedItems);
+
+ /**
+ * Builder for link arrays.
+ */
+ interface LinkArrayBuilder {
+
+ /**
+ * Append a link to the array.
+ *
+ * @param name name of link
+ * @param href link target
+ * @return {@code this}
+ */
+ LinkArrayBuilder append(String name, String href);
+
+ /**
+ * Builds the array and appends the it to the json response.
+ */
+ void build();
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/HalAppenderMapper.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalAppenderMapper.java
new file mode 100644
index 0000000000..dd49b765bc
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalAppenderMapper.java
@@ -0,0 +1,36 @@
+package sonia.scm.api.v2.resources;
+
+import com.google.common.annotations.VisibleForTesting;
+
+import javax.inject.Inject;
+
+public class HalAppenderMapper {
+
+ @Inject
+ private HalEnricherRegistry registry;
+
+ @VisibleForTesting
+ void setRegistry(HalEnricherRegistry registry) {
+ this.registry = registry;
+ }
+
+ protected void applyEnrichers(HalAppender appender, Object source, Object... contextEntries) {
+ // null check is only their to not break existing tests
+ if (registry != null) {
+
+ Object[] ctx = new Object[contextEntries.length + 1];
+ ctx[0] = source;
+ for (int i = 0; i < contextEntries.length; i++) {
+ ctx[i + 1] = contextEntries[i];
+ }
+
+ HalEnricherContext context = HalEnricherContext.of(ctx);
+
+ Iterable enrichers = registry.allByType(source.getClass());
+ for (HalEnricher enricher : enrichers) {
+ enricher.enrich(context, appender);
+ }
+ }
+ }
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/HalEnricher.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalEnricher.java
new file mode 100644
index 0000000000..647a1cf74e
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalEnricher.java
@@ -0,0 +1,26 @@
+package sonia.scm.api.v2.resources;
+
+import sonia.scm.plugin.ExtensionPoint;
+
+/**
+ * A {@link HalEnricher} can be used to append hal specific attributes, such as links, to the json response.
+ * To register an enricher use the {@link Enrich} annotation or the {@link HalEnricherRegistry} which is available
+ * via injection.
+ *
+ * Warning: enrichers are always registered as singletons.
+ *
+ * @author Sebastian Sdorra
+ * @since 2.0.0
+ */
+@ExtensionPoint
+@FunctionalInterface
+public interface HalEnricher {
+
+ /**
+ * Enriches the response with hal specific attributes.
+ *
+ * @param context contains the source for the json mapping and related objects
+ * @param appender can be used to append links or embedded objects to the json response
+ */
+ void enrich(HalEnricherContext context, HalAppender appender);
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/HalEnricherContext.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalEnricherContext.java
new file mode 100644
index 0000000000..36128087b8
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalEnricherContext.java
@@ -0,0 +1,72 @@
+package sonia.scm.api.v2.resources;
+
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+
+/**
+ * Context object for the {@link HalEnricher}. The context holds the source object for the json and all related
+ * objects, which can be useful for the enrichment.
+ *
+ * @author Sebastian Sdorra
+ * @since 2.0.0
+ */
+public final class HalEnricherContext {
+
+ private final Map instanceMap;
+
+ private HalEnricherContext(Map instanceMap) {
+ this.instanceMap = instanceMap;
+ }
+
+ /**
+ * Creates a context with the given entries
+ *
+ * @param instances entries of the context
+ *
+ * @return context of given entries
+ */
+ public static HalEnricherContext of(Object... instances) {
+ ImmutableMap.Builder builder = ImmutableMap.builder();
+ for (Object instance : instances) {
+ builder.put(instance.getClass(), instance);
+ }
+ return new HalEnricherContext(builder.build());
+ }
+
+ /**
+ * Returns the registered object from the context. The method will return an empty optional, if no object with the
+ * given type was registered.
+ *
+ * @param type type of instance
+ * @param type of instance
+ * @return optional instance
+ */
+ public Optional oneByType(Class type) {
+ Object instance = instanceMap.get(type);
+ if (instance != null) {
+ return Optional.of(type.cast(instance));
+ }
+ return Optional.empty();
+ }
+
+ /**
+ * Returns the registered object from the context, but throws an {@link NoSuchElementException} if the type was not
+ * registered.
+ *
+ * @param type type of instance
+ * @param type of instance
+ * @return instance
+ */
+ public T oneRequireByType(Class type) {
+ Optional instance = oneByType(type);
+ if (instance.isPresent()) {
+ return instance.get();
+ } else {
+ throw new NoSuchElementException("No instance for given type present");
+ }
+ }
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/HalEnricherRegistry.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalEnricherRegistry.java
new file mode 100644
index 0000000000..3fadbfa388
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/HalEnricherRegistry.java
@@ -0,0 +1,40 @@
+package sonia.scm.api.v2.resources;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+import sonia.scm.plugin.Extension;
+
+import javax.inject.Singleton;
+
+/**
+ * The {@link HalEnricherRegistry} is responsible for binding {@link HalEnricher} instances to their source types.
+ *
+ * @author Sebastian Sdorra
+ * @since 2.0.0
+ */
+@Extension
+@Singleton
+public final class HalEnricherRegistry {
+
+ private final Multimap enrichers = HashMultimap.create();
+
+ /**
+ * Registers a new {@link HalEnricher} for the given source type.
+ *
+ * @param sourceType type of json mapping source
+ * @param enricher link enricher instance
+ */
+ public void register(Class sourceType, HalEnricher enricher) {
+ enrichers.put(sourceType, enricher);
+ }
+
+ /**
+ * Returns all registered {@link HalEnricher} for the given type.
+ *
+ * @param sourceType type of json mapping source
+ * @return all registered enrichers
+ */
+ public Iterable allByType(Class sourceType) {
+ return enrichers.get(sourceType);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/Index.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/Index.java
new file mode 100644
index 0000000000..346ce83816
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/Index.java
@@ -0,0 +1,10 @@
+package sonia.scm.api.v2.resources;
+
+/**
+ * The {@link Index} object can be used to register a {@link HalEnricher} for the index resource.
+ *
+ * @author Sebastian Sdorra
+ * @since 2.0.0
+ */
+public final class Index {
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/InstantAttributeMapper.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/InstantAttributeMapper.java
new file mode 100644
index 0000000000..468bdfc137
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/InstantAttributeMapper.java
@@ -0,0 +1,9 @@
+package sonia.scm.api.v2.resources;
+
+import java.time.Instant;
+
+public interface InstantAttributeMapper {
+ default Instant mapTime(Long epochMilli) {
+ return epochMilli == null? null: Instant.ofEpochMilli(epochMilli);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/LinkBuilder.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/LinkBuilder.java
new file mode 100644
index 0000000000..0797134c9f
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/LinkBuilder.java
@@ -0,0 +1,114 @@
+package sonia.scm.api.v2.resources;
+
+import com.google.common.collect.ImmutableList;
+
+import javax.ws.rs.core.UriBuilder;
+import java.net.URI;
+import java.util.Arrays;
+
+/**
+ * This class is used to create links for JAX-RS resources. Create a new instance specifying all resource classes used
+ * to process the request. Then for each of these classes call builder.method(...).parameters(...) for each
+ * of these classes consecutively. The builder itself is immutable, so that each instance is reusable and you get a new
+ * builder for each method.
+ *
+ *
+ */
+@SuppressWarnings("WeakerAccess") // Non-public will result in IllegalAccessError for plugins
+public class LinkBuilder {
+ private final ScmPathInfo pathInfo;
+ private final Class[] classes;
+ private final ImmutableList calls;
+
+ public LinkBuilder(ScmPathInfo pathInfo, Class... classes) {
+ this(pathInfo, classes, ImmutableList.of());
+ }
+
+ private LinkBuilder(ScmPathInfo pathInfo, Class[] classes, ImmutableList calls) {
+ this.pathInfo = pathInfo;
+ this.classes = classes;
+ this.calls = calls;
+ }
+
+ public Parameters method(String method) {
+ if (calls.size() >= classes.length) {
+ throw new IllegalStateException("no more classes for methods");
+ }
+ return new Parameters(method);
+ }
+
+ public URI create() {
+ if (calls.size() < classes.length) {
+ throw new IllegalStateException("not enough methods for all classes");
+ }
+
+ URI baseUri = pathInfo.getApiRestUri();
+ URI relativeUri = createRelativeUri();
+ return baseUri.resolve(relativeUri);
+ }
+
+ public String href() {
+ return create().toString();
+ }
+
+ private LinkBuilder add(String method, String[] parameters) {
+ return new LinkBuilder(pathInfo, classes, appendNewCall(method, parameters));
+ }
+
+ private ImmutableList appendNewCall(String method, String[] parameters) {
+ return ImmutableList. builder().addAll(calls).add(createNewCall(method, parameters)).build();
+ }
+
+ private Call createNewCall(String method, String[] parameters) {
+ return new Call(LinkBuilder.this.classes[calls.size()], method, parameters);
+ }
+
+ private URI createRelativeUri() {
+ UriBuilder uriBuilder = userUriBuilder();
+ calls.forEach(call -> uriBuilder.path(call.clazz, call.method));
+ String[] concatenatedParameters = calls
+ .stream()
+ .map(call -> call.parameters)
+ .flatMap(Arrays::stream)
+ .toArray(String[]::new);
+ return uriBuilder.build((Object[]) concatenatedParameters);
+ }
+
+ private UriBuilder userUriBuilder() {
+ return UriBuilder.fromResource(classes[0]);
+ }
+
+ public class Parameters {
+
+ private final String method;
+
+ private Parameters(String method) {
+ this.method = method;
+ }
+
+ public LinkBuilder parameters(String... parameters) {
+ return LinkBuilder.this.add(method, parameters);
+ }
+ }
+
+ private static class Call {
+ private final Class clazz;
+ private final String method;
+
+ private final String[] parameters;
+
+ private Call(Class clazz, String method, String[] parameters) {
+ this.clazz = clazz;
+ this.method = method;
+ this.parameters = parameters;
+ }
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/LogoutRedirection.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/LogoutRedirection.java
new file mode 100644
index 0000000000..84fe2ddf7b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/LogoutRedirection.java
@@ -0,0 +1,12 @@
+package sonia.scm.api.v2.resources;
+
+import sonia.scm.plugin.ExtensionPoint;
+
+import java.net.URI;
+import java.util.Optional;
+
+@ExtensionPoint(multi = false)
+@FunctionalInterface
+public interface LogoutRedirection {
+ Optional afterLogoutRedirectTo();
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/Me.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/Me.java
new file mode 100644
index 0000000000..a027a78d79
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/Me.java
@@ -0,0 +1,10 @@
+package sonia.scm.api.v2.resources;
+
+/**
+ * The {@link Me} object can be used to register a {@link HalEnricher} for the me resource.
+ *
+ * @author Sebastian Sdorra
+ * @since 2.0.0
+ */
+public final class Me {
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/MergeCommandDto.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/MergeCommandDto.java
new file mode 100644
index 0000000000..0661d6a4ef
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/MergeCommandDto.java
@@ -0,0 +1,14 @@
+package sonia.scm.api.v2.resources;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.hibernate.validator.constraints.NotEmpty;
+
+@Getter @Setter
+public class MergeCommandDto {
+
+ @NotEmpty
+ private String sourceRevision;
+ @NotEmpty
+ private String targetRevision;
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/PersonDto.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/PersonDto.java
new file mode 100644
index 0000000000..ce35b507c8
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/PersonDto.java
@@ -0,0 +1,22 @@
+package sonia.scm.api.v2.resources;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Getter
+@Setter
+@NoArgsConstructor
+public class PersonDto {
+
+ /**
+ * mail address of the person
+ */
+ private String mail;
+
+ /**
+ * name of the person
+ */
+ private String name;
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/ScmPathInfo.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/ScmPathInfo.java
new file mode 100644
index 0000000000..496c87b440
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/ScmPathInfo.java
@@ -0,0 +1,14 @@
+package sonia.scm.api.v2.resources;
+
+import java.net.URI;
+
+public interface ScmPathInfo {
+
+ String REST_API_PATH = "/api";
+
+ URI getApiRestUri();
+
+ default URI getRootUri() {
+ return getApiRestUri().resolve("..");
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/api/v2/resources/ScmPathInfoStore.java b/scm-core/src/main/java/sonia/scm/api/v2/resources/ScmPathInfoStore.java
new file mode 100644
index 0000000000..c88bd4a2b5
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/api/v2/resources/ScmPathInfoStore.java
@@ -0,0 +1,18 @@
+package sonia.scm.api.v2.resources;
+
+public class ScmPathInfoStore {
+
+ private ScmPathInfo pathInfo;
+
+ public ScmPathInfo get() {
+ return pathInfo;
+ }
+
+ public void set(ScmPathInfo info) {
+ if (this.pathInfo != null) {
+ throw new IllegalStateException("UriInfo already set");
+ }
+ this.pathInfo = info;
+ }
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/cache/CacheStatistics.java b/scm-core/src/main/java/sonia/scm/cache/CacheStatistics.java
index 3507763820..cc791ff91f 100644
--- a/scm-core/src/main/java/sonia/scm/cache/CacheStatistics.java
+++ b/scm-core/src/main/java/sonia/scm/cache/CacheStatistics.java
@@ -103,10 +103,10 @@ public final class CacheStatistics
{
//J-
return MoreObjects.toStringHelper(this)
- .add("name", name)
- .add("hitCount", hitCount)
- .add("missCount", missCount)
- .toString();
+ .add("name", name)
+ .add("hitCount", hitCount)
+ .add("missCount", missCount)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/config/Configuration.java b/scm-core/src/main/java/sonia/scm/config/Configuration.java
new file mode 100644
index 0000000000..4019925c27
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/config/Configuration.java
@@ -0,0 +1,29 @@
+package sonia.scm.config;
+
+import com.github.sdorra.ssp.PermissionObject;
+import com.github.sdorra.ssp.StaticPermissions;
+
+/**
+ * Base for all kinds of configurations.
+ *
+ * Allows for permission like
+ *
+ *
+ *
"configuration:read:global",
+ *
"configuration:write:svn",
+ *
"configuration:*:git",
+ *
"configuration:*"
+ *
+ *
+ *
+ *
+ * And for permission checks like {@code ConfigurationPermissions.read(configurationObject).check();}
+ */
+@StaticPermissions(
+ value = "configuration",
+ permissions = {"read", "write"},
+ globalPermissions = {"list"},
+ custom = true, customGlobal = true
+)
+public interface Configuration extends PermissionObject {
+}
diff --git a/scm-core/src/main/java/sonia/scm/config/ScmConfiguration.java b/scm-core/src/main/java/sonia/scm/config/ScmConfiguration.java
index a136bb0b36..edf842f94e 100644
--- a/scm-core/src/main/java/sonia/scm/config/ScmConfiguration.java
+++ b/scm-core/src/main/java/sonia/scm/config/ScmConfiguration.java
@@ -1,19 +1,19 @@
/**
* 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.
+ * 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.
+ * 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.
- *
+ * 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
@@ -24,39 +24,33 @@
* 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.config;
-//~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.Sets;
import com.google.inject.Singleton;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.event.ScmEventBus;
import sonia.scm.util.HttpUtil;
import sonia.scm.xml.XmlSetStringAdapter;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
-
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
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;
+import java.io.File;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+//~--- JDK imports ------------------------------------------------------------
/**
* The main configuration object for SCM-Manager.
@@ -64,41 +58,139 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
*
* @author Sebastian Sdorra
*/
+
@Singleton
@XmlRootElement(name = "scm-config")
@XmlAccessorType(XmlAccessType.FIELD)
-public class ScmConfiguration
-{
+public class ScmConfiguration implements Configuration {
- /** Default JavaScript date format */
+ /**
+ * Default JavaScript date format
+ */
public static final String DEFAULT_DATEFORMAT = "YYYY-MM-DD HH:mm:ss";
- /** Default plugin url */
+ /**
+ * Default plugin url
+ */
public static final String DEFAULT_PLUGINURL =
- "http://plugins.scm-manager.org/scm-plugin-backend/api/{version}/plugins?os={os}&arch={arch}&snapshot=false";
+ "https://plugin-center-api.scm-manager.org/api/v1/plugins/{version}?os={os}&arch={arch}";
- /** Default plugin url from version 1.0 */
+ /**
+ * Default url for login information (plugin and feature tips on the login page).
+ */
+ public static final String DEFAULT_LOGIN_INFO_URL = "https://login-info.scm-manager.org/api/v1/login-info";
+
+ /**
+ * Default plugin url from version 1.0
+ */
public static final String OLD_PLUGINURL =
"http://plugins.scm-manager.org/plugins.xml.gz";
- /** Path to the configuration file */
+ /**
+ * Path to the configuration file
+ */
public static final String PATH =
"config".concat(File.separator).concat("config.xml");
- /** the logger for ScmConfiguration */
- private static final Logger logger =
- LoggerFactory.getLogger(ScmConfiguration.class);
+ /**
+ * the logger for ScmConfiguration
+ */
+ private static final Logger logger = LoggerFactory.getLogger(ScmConfiguration.class);
+
+ @SuppressWarnings("WeakerAccess") // This might be needed for permission checking
+ public static final String PERMISSION = "global";
+
+ @XmlElement(name = "base-url")
+ private String baseUrl;
+
+
+ @XmlElement(name = "force-base-url")
+ private boolean forceBaseUrl;
+
+ /**
+ * Maximum allowed login attempts.
+ *
+ * @since 1.34
+ */
+ @XmlElement(name = "login-attempt-limit")
+ private int loginAttemptLimit = -1;
+
+ /**
+ * glob patterns for urls which are excluded from proxy
+ */
+ @XmlElement(name = "proxy-excludes")
+ @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
+ private Set proxyExcludes;
+
+
+ private String proxyPassword;
+
+
+ private int proxyPort = 8080;
+
+
+ private String proxyServer = "proxy.mydomain.com";
+
+
+ private String proxyUser;
+
+ /**
+ * Skip failed authenticators.
+ *
+ * @since 1.36
+ */
+ @XmlElement(name = "skip-failed-authenticators")
+ private boolean skipFailedAuthenticators = false;
+
+
+ @XmlElement(name = "plugin-url")
+ private String pluginUrl = DEFAULT_PLUGINURL;
+
+ /**
+ * Login attempt timeout.
+ *
+ * @since 1.34
+ */
+ @XmlElement(name = "login-attempt-limit-timeout")
+ private long loginAttemptLimitTimeout = TimeUnit.MINUTES.toSeconds(5l);
+
+
+ private boolean enableProxy = false;
+
+ /**
+ * Authentication realm for basic authentication.
+ */
+ private String realmDescription = HttpUtil.AUTHENTICATION_REALM;
+ private boolean disableGroupingGrid = false;
+ /**
+ * JavaScript date format from moment.js
+ *
+ * @see http://momentjs.com/docs/#/parsing/
+ */
+ private String dateFormat = DEFAULT_DATEFORMAT;
+ private boolean anonymousAccessEnabled = false;
+
+ /**
+ * Enables xsrf cookie protection.
+ *
+ * @since 1.47
+ */
+ @XmlElement(name = "xsrf-protection")
+ private boolean enabledXsrfProtection = true;
+
+ @XmlElement(name = "namespace-strategy")
+ private String namespaceStrategy = "UsernameNamespaceStrategy";
+
+ @XmlElement(name = "login-info-url")
+ private String loginInfoUrl = DEFAULT_LOGIN_INFO_URL;
- //~--- methods --------------------------------------------------------------
/**
* Calls the {@link sonia.scm.ConfigChangedListener#configChanged(Object)}
* method of all registered listeners.
*/
- public void fireChangeEvent()
- {
- if (logger.isDebugEnabled())
- {
+ public void fireChangeEvent() {
+ if (logger.isDebugEnabled()) {
logger.debug("fire config changed event");
}
@@ -109,18 +201,13 @@ public class ScmConfiguration
/**
* Load all properties from another {@link ScmConfiguration} object.
*
- *
- *
* @param other
*/
- public void load(ScmConfiguration other)
- {
+ public void load(ScmConfiguration other) {
this.realmDescription = other.realmDescription;
this.dateFormat = other.dateFormat;
this.pluginUrl = other.pluginUrl;
this.anonymousAccessEnabled = other.anonymousAccessEnabled;
- this.adminUsers = other.adminUsers;
- this.adminGroups = other.adminGroups;
this.enableProxy = other.enableProxy;
this.proxyPort = other.proxyPort;
this.proxyServer = other.proxyServer;
@@ -130,46 +217,22 @@ public class ScmConfiguration
this.forceBaseUrl = other.forceBaseUrl;
this.baseUrl = other.baseUrl;
this.disableGroupingGrid = other.disableGroupingGrid;
- this.enableRepositoryArchive = other.enableRepositoryArchive;
this.skipFailedAuthenticators = other.skipFailedAuthenticators;
this.loginAttemptLimit = other.loginAttemptLimit;
this.loginAttemptLimitTimeout = other.loginAttemptLimitTimeout;
this.enabledXsrfProtection = other.enabledXsrfProtection;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Returns a set of admin group names.
- *
- *
- * @return set of admin group names
- */
- public Set getAdminGroups()
- {
- return adminGroups;
- }
-
- /**
- * Returns a set of admin user names.
- *
- *
- * @return set of admin user names
- */
- public Set getAdminUsers()
- {
- return adminUsers;
+ this.namespaceStrategy = other.namespaceStrategy;
+ this.loginInfoUrl = other.loginInfoUrl;
}
/**
* Returns the complete base url of the scm-manager including the context path.
* For example http://localhost:8080/scm
*
- * @since 1.5
* @return complete base url of the scm-manager
+ * @since 1.5
*/
- public String getBaseUrl()
- {
+ public String getBaseUrl() {
return baseUrl;
}
@@ -177,23 +240,14 @@ public class ScmConfiguration
* Returns the date format for the user interface. This format is a
* JavaScript date format, from the library moment.js.
*
- * @see http://momentjs.com/docs/#/parsing/
* @return moment.js date format
+ * @see http://momentjs.com/docs/#/parsing/
*/
- public String getDateFormat()
- {
+ public String getDateFormat() {
return dateFormat;
}
- /**
- * Returns maximum allowed login attempts.
- *
- * @return maximum allowed login attempts
- *
- * @since 1.34
- */
- public int getLoginAttemptLimit()
- {
+ public int getLoginAttemptLimit() {
return loginAttemptLimit;
}
@@ -202,11 +256,9 @@ public class ScmConfiguration
* because of too many failed login attempts.
*
* @return login attempt timeout in seconds
- *
* @since 1.34
*/
- public long getLoginAttemptLimitTimeout()
- {
+ public long getLoginAttemptLimitTimeout() {
return loginAttemptLimitTimeout;
}
@@ -222,8 +274,7 @@ public class ScmConfiguration
*
* @return the complete plugin url.
*/
- public String getPluginUrl()
- {
+ public String getPluginUrl() {
return pluginUrl;
}
@@ -231,289 +282,122 @@ public class ScmConfiguration
* Returns a set of glob patterns for urls which should excluded from
* proxy settings.
*
- *
* @return set of glob patterns
* @since 1.23
*/
- public Set getProxyExcludes()
- {
- if (proxyExcludes == null)
- {
+ public Set getProxyExcludes() {
+ if (proxyExcludes == null) {
proxyExcludes = Sets.newHashSet();
}
return proxyExcludes;
}
- /**
- * Method description
- *
- *
- * @return
- * @since 1.7
- */
- public String getProxyPassword()
- {
+ public String getProxyPassword() {
return proxyPassword;
}
- /**
- * Returns the proxy port.
- *
- *
- * @return proxy port
- */
- public int getProxyPort()
- {
+ public int getProxyPort() {
return proxyPort;
}
/**
* Returns the servername or ip of the proxyserver.
*
- *
* @return servername or ip of the proxyserver
*/
- public String getProxyServer()
- {
+ public String getProxyServer() {
return proxyServer;
}
- /**
- * Method description
- *
- *
- * @return
- * @since 1.7
- */
- public String getProxyUser()
- {
+ public String getProxyUser() {
return proxyUser;
}
- /**
- * Returns the realm description.
- *
- *
- * @return realm description
- * @since 1.36
- */
- public String getRealmDescription()
- {
+ public String getRealmDescription() {
return realmDescription;
}
-
- /**
- * Returns true if the anonymous access to the SCM-Manager is enabled.
- *
- *
- * @return true if the anonymous access to the SCM-Manager is enabled
- */
- public boolean isAnonymousAccessEnabled()
- {
+ public boolean isAnonymousAccessEnabled() {
return anonymousAccessEnabled;
}
- /**
- * Method description
- *
- * @since 1.9
- * @return
- */
- public boolean isDisableGroupingGrid()
- {
+ public boolean isDisableGroupingGrid() {
return disableGroupingGrid;
}
/**
* Returns {@code true} if the cookie xsrf protection is enabled.
- *
- * @see Issue 793
+ *
* @return {@code true} if the cookie xsrf protection is enabled
- *
+ * @see Issue 793
* @since 1.47
*/
- public boolean isEnabledXsrfProtection()
- {
+ public boolean isEnabledXsrfProtection() {
return enabledXsrfProtection;
}
- /**
- * Returns true if proxy is enabled.
- *
- *
- * @return true if proxy is enabled
- */
- public boolean isEnableProxy()
- {
+ public boolean isEnableProxy() {
return enableProxy;
}
- /**
- * Returns true if the repository archive is enabled.
- *
- *
- * @return true if the repository archive is enabled
- * @since 1.14
- */
- public boolean isEnableRepositoryArchive()
- {
- return enableRepositoryArchive;
- }
-
- /**
- * Returns true if force base url is enabled.
- *
- * @since 1.5
- * @return true if force base url is enabled
- */
- public boolean isForceBaseUrl()
- {
+ public boolean isForceBaseUrl() {
return forceBaseUrl;
}
- /**
- * Returns true if the login attempt limit is enabled.
- *
- *
- * @return true if login attempt limit is enabled
- *
- * @since 1.37
- */
- public boolean isLoginAttemptLimitEnabled()
- {
+ public boolean isLoginAttemptLimitEnabled() {
return loginAttemptLimit > 0;
}
+ public String getNamespaceStrategy() {
+ return namespaceStrategy;
+ }
+
+ public String getLoginInfoUrl() {
+ return loginInfoUrl;
+ }
+
/**
* Returns true if failed authenticators are skipped.
*
- *
* @return true if failed authenticators are skipped
- *
* @since 1.36
*/
- public boolean isSkipFailedAuthenticators()
- {
+ public boolean isSkipFailedAuthenticators() {
return skipFailedAuthenticators;
}
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param adminGroups
- */
- public void setAdminGroups(Set adminGroups)
- {
- this.adminGroups = adminGroups;
- }
-
- /**
- * Method description
- *
- *
- * @param adminUsers
- */
- public void setAdminUsers(Set adminUsers)
- {
- this.adminUsers = adminUsers;
- }
-
- /**
- * Method description
- *
- *
- * @param anonymousAccessEnabled
- */
- public void setAnonymousAccessEnabled(boolean anonymousAccessEnabled)
- {
+ public void setAnonymousAccessEnabled(boolean anonymousAccessEnabled) {
this.anonymousAccessEnabled = anonymousAccessEnabled;
}
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @since 1.5
- */
- public void setBaseUrl(String baseUrl)
- {
+ public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
- /**
- * Sets the date format for the ui.
- *
- *
- * @param dateFormat date format for ui
- */
- public void setDateFormat(String dateFormat)
- {
+ public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
}
- /**
- * Method description
- *
- * @since 1.9
- *
- * @param disableGroupingGrid
- */
- public void setDisableGroupingGrid(boolean disableGroupingGrid)
- {
+ public void setDisableGroupingGrid(boolean disableGroupingGrid) {
this.disableGroupingGrid = disableGroupingGrid;
}
- /**
- * Method description
- *
- *
- * @param enableProxy
- */
- public void setEnableProxy(boolean enableProxy)
- {
+ public void setEnableProxy(boolean enableProxy) {
this.enableProxy = enableProxy;
}
- /**
- * Enable or disable the repository archive. Default is disabled.
- *
- *
- * @param enableRepositoryArchive true to disable the repository archive
- * @since 1.14
- */
- public void setEnableRepositoryArchive(boolean enableRepositoryArchive)
- {
- this.enableRepositoryArchive = enableRepositoryArchive;
- }
-
- /**
- * Method description
- *
- *
- * @param forceBaseUrl
- * @since 1.5
- */
- public void setForceBaseUrl(boolean forceBaseUrl)
- {
+ public void setForceBaseUrl(boolean forceBaseUrl) {
this.forceBaseUrl = forceBaseUrl;
}
/**
* Set maximum allowed login attempts.
*
- *
* @param loginAttemptLimit login attempt limit
- *
* @since 1.34
*/
- public void setLoginAttemptLimit(int loginAttemptLimit)
- {
+ public void setLoginAttemptLimit(int loginAttemptLimit) {
this.loginAttemptLimit = loginAttemptLimit;
}
@@ -522,22 +406,13 @@ public class ScmConfiguration
* because of too many failed login attempts.
*
* @param loginAttemptLimitTimeout login attempt timeout in seconds
- *
* @since 1.34
*/
- public void setLoginAttemptLimitTimeout(long loginAttemptLimitTimeout)
- {
+ public void setLoginAttemptLimitTimeout(long loginAttemptLimitTimeout) {
this.loginAttemptLimitTimeout = loginAttemptLimitTimeout;
}
- /**
- * Method description
- *
- *
- * @param pluginUrl
- */
- public void setPluginUrl(String pluginUrl)
- {
+ public void setPluginUrl(String pluginUrl) {
this.pluginUrl = pluginUrl;
}
@@ -545,194 +420,68 @@ public class ScmConfiguration
* Set glob patterns for urls which are should be excluded from proxy
* settings.
*
- *
* @param proxyExcludes glob patterns
* @since 1.23
*/
- public void setProxyExcludes(Set proxyExcludes)
- {
+ public void setProxyExcludes(Set proxyExcludes) {
this.proxyExcludes = proxyExcludes;
}
- /**
- * Method description
- *
- *
- * @param proxyPassword
- * @since 1.7
- */
- public void setProxyPassword(String proxyPassword)
- {
+ public void setProxyPassword(String proxyPassword) {
this.proxyPassword = proxyPassword;
}
- /**
- * Method description
- *
- *
- * @param proxyPort
- */
- public void setProxyPort(int proxyPort)
- {
+ public void setProxyPort(int proxyPort) {
this.proxyPort = proxyPort;
}
- /**
- * Method description
- *
- *
- * @param proxyServer
- */
- public void setProxyServer(String proxyServer)
- {
+ public void setProxyServer(String proxyServer) {
this.proxyServer = proxyServer;
}
- /**
- * Method description
- *
- *
- * @param proxyUser
- * @since 1.7
- */
- public void setProxyUser(String proxyUser)
- {
+ public void setProxyUser(String proxyUser) {
this.proxyUser = proxyUser;
}
- /**
- * Sets the realm description.
- *
- *
- * @param realmDescription
- * @since 1.36
- */
- public void setRealmDescription(String realmDescription)
- {
+ public void setRealmDescription(String realmDescription) {
this.realmDescription = realmDescription;
}
/**
- * If set to true the authentication chain is not stopped, if an
+ * If set to true the authentication chain is not stopped, if an
* authenticator finds the user but fails to authenticate the user.
*
* @param skipFailedAuthenticators true to skip failed authenticators
- *
* @since 1.36
*/
- public void setSkipFailedAuthenticators(boolean skipFailedAuthenticators)
- {
+ public void setSkipFailedAuthenticators(boolean skipFailedAuthenticators) {
this.skipFailedAuthenticators = skipFailedAuthenticators;
}
/**
* Set {@code true} to enable xsrf cookie protection.
- *
+ *
* @param enabledXsrfProtection {@code true} to enable xsrf protection
* @see Issue 793
- *
* @since 1.47
*/
- public void setEnabledXsrfProtection(boolean enabledXsrfProtection)
- {
+ public void setEnabledXsrfProtection(boolean enabledXsrfProtection) {
this.enabledXsrfProtection = enabledXsrfProtection;
}
- //~--- fields ---------------------------------------------------------------
+ public void setNamespaceStrategy(String namespaceStrategy) {
+ this.namespaceStrategy = namespaceStrategy;
+ }
- /** Field description */
- @XmlElement(name = "admin-groups")
- @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
- private Set adminGroups;
+ public void setLoginInfoUrl(String loginInfoUrl) {
+ this.loginInfoUrl = loginInfoUrl;
+ }
- /** Field description */
- @XmlElement(name = "admin-users")
- @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
- private Set adminUsers;
-
- /** Field description */
- @XmlElement(name = "base-url")
- private String baseUrl;
-
- /** Field description */
- @XmlElement(name = "force-base-url")
- private boolean forceBaseUrl;
-
- /**
- * Maximum allowed login attempts.
- *
- * @since 1.34
- */
- @XmlElement(name = "login-attempt-limit")
- private int loginAttemptLimit = -1;
-
- /** glob patterns for urls which are excluded from proxy */
- @XmlElement(name = "proxy-excludes")
- @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
- private Set proxyExcludes;
-
- /** Field description */
- private String proxyPassword;
-
- /** Field description */
- private int proxyPort = 8080;
-
- /** Field description */
- private String proxyServer = "proxy.mydomain.com";
-
- /** Field description */
- private String proxyUser;
-
- /**
- * Skip failed authenticators.
- *
- * @since 1.36
- */
- @XmlElement(name = "skip-failed-authenticators")
- private boolean skipFailedAuthenticators = false;
-
- /** Field description */
- @XmlElement(name = "plugin-url")
- private String pluginUrl = DEFAULT_PLUGINURL;
-
- /**
- * Login attempt timeout.
- *
- * @since 1.34
- */
- @XmlElement(name = "login-attempt-limit-timeout")
- private long loginAttemptLimitTimeout = TimeUnit.MINUTES.toSeconds(5L);
-
- /** Field description */
- private boolean enableProxy = false;
-
- /**
- *
- * Authentication realm for basic authentication.
- *
- */
- private String realmDescription = HttpUtil.AUTHENTICATION_REALM;
-
- /** Field description */
- private boolean enableRepositoryArchive = false;
-
- /** Field description */
- private boolean disableGroupingGrid = false;
-
- /**
- * JavaScript date format from moment.js
- * @see http://momentjs.com/docs/#/parsing/
- */
- private String dateFormat = DEFAULT_DATEFORMAT;
-
- /** Field description */
- private boolean anonymousAccessEnabled = false;
-
- /**
- * Enables xsrf cookie protection.
- *
- * @since 1.47
- */
- @XmlElement(name = "xsrf-protection")
- private boolean enabledXsrfProtection = true;
+ @Override
+ // Only for permission checks, don't serialize to XML
+ @XmlTransient
+ public String getId() {
+ // Don't change this without migrating SCM permission configuration!
+ return PERMISSION;
+ }
}
diff --git a/scm-core/src/main/java/sonia/scm/config/ScmConfigurationChangedListener.java b/scm-core/src/main/java/sonia/scm/config/ScmConfigurationChangedListener.java
new file mode 100644
index 0000000000..5cbda6d1e1
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/config/ScmConfigurationChangedListener.java
@@ -0,0 +1,33 @@
+package sonia.scm.config;
+
+import com.github.legman.Subscribe;
+import com.google.inject.Inject;
+import sonia.scm.EagerSingleton;
+import sonia.scm.SCMContext;
+import sonia.scm.plugin.Extension;
+import sonia.scm.user.UserManager;
+
+@Extension
+@EagerSingleton
+public class ScmConfigurationChangedListener {
+
+ private UserManager userManager;
+
+ @Inject
+ public ScmConfigurationChangedListener(UserManager userManager) {
+ this.userManager = userManager;
+ }
+
+ @Subscribe
+ public void handleEvent(ScmConfigurationChangedEvent event) {
+ createAnonymousUserIfRequired(event);
+ }
+
+ private void createAnonymousUserIfRequired(ScmConfigurationChangedEvent event) {
+ if (event.getConfiguration().isAnonymousAccessEnabled() && !userManager.contains(SCMContext.USER_ANONYMOUS)) {
+ userManager.create(SCMContext.ANONYMOUS);
+ }
+ }
+}
+
+
diff --git a/scm-core/src/main/java/sonia/scm/event/AbstractHandlerEvent.java b/scm-core/src/main/java/sonia/scm/event/AbstractHandlerEvent.java
index f828af9635..1582247f35 100644
--- a/scm-core/src/main/java/sonia/scm/event/AbstractHandlerEvent.java
+++ b/scm-core/src/main/java/sonia/scm/event/AbstractHandlerEvent.java
@@ -35,7 +35,6 @@ package sonia.scm.event;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-
import sonia.scm.HandlerEventType;
/**
@@ -129,10 +128,10 @@ public class AbstractHandlerEvent implements HandlerEvent
{
//J-
return MoreObjects.toStringHelper(this)
- .add("eventType", eventType)
- .add("item", item)
- .add("oldItem", oldItem)
- .toString();
+ .add("eventType", eventType)
+ .add("item", item)
+ .add("oldItem", oldItem)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/filter/Filters.java b/scm-core/src/main/java/sonia/scm/filter/Filters.java
index b6a45811bc..d3ac708296 100644
--- a/scm-core/src/main/java/sonia/scm/filter/Filters.java
+++ b/scm-core/src/main/java/sonia/scm/filter/Filters.java
@@ -31,6 +31,8 @@
package sonia.scm.filter;
+import static sonia.scm.api.v2.resources.ScmPathInfo.REST_API_PATH;
+
/**
* Useful constants for filter implementations.
*
@@ -43,27 +45,11 @@ public final class Filters
/** Field description */
public static final String PATTERN_ALL = "/*";
- /** Field description */
- public static final String PATTERN_CONFIG = "/api/rest/config*";
-
/** Field description */
public static final String PATTERN_DEBUG = "/debug.html";
/** Field description */
- public static final String PATTERN_GROUPS = "/api/rest/groups*";
-
- /** Field description */
- public static final String PATTERN_PLUGINS = "/api/rest/plugins*";
-
- /** Field description */
- public static final String PATTERN_RESOURCE_REGEX =
- "^/(?:resources|api|plugins|index)[\\./].*(?:html|\\.css|\\.js|\\.xml|\\.json|\\.txt)";
-
- /** Field description */
- public static final String PATTERN_RESTAPI = "/api/rest/*";
-
- /** Field description */
- public static final String PATTERN_USERS = "/api/rest/users*";
+ public static final String PATTERN_RESTAPI = REST_API_PATH + "/*";
/** authentication priority */
public static final int PRIORITY_AUTHENTICATION = 5000;
diff --git a/scm-core/src/main/java/sonia/scm/filter/GZipFilter.java b/scm-core/src/main/java/sonia/scm/filter/GZipFilter.java
deleted file mode 100644
index 49fa8ebebf..0000000000
--- a/scm-core/src/main/java/sonia/scm/filter/GZipFilter.java
+++ /dev/null
@@ -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.filter;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import sonia.scm.Priority;
-import sonia.scm.util.WebUtil;
-import sonia.scm.web.filter.HttpFilter;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Filter for gzip encoding.
- *
- * @author Sebastian Sdorra
- * @since 1.15
- */
-@Priority(Filters.PRIORITY_PRE_BASEURL)
-@WebElement(value = Filters.PATTERN_RESOURCE_REGEX, regex = true)
-public class GZipFilter extends HttpFilter
-{
-
- /**
- * the logger for GZipFilter
- */
- private static final Logger logger =
- LoggerFactory.getLogger(GZipFilter.class);
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Return the configuration for the gzip filter.
- *
- *
- * @return gzip filter configuration
- */
- public GZipFilterConfig getConfig()
- {
- return config;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Encodes the response, if the request has support for gzip encoding.
- *
- *
- * @param request http request
- * @param response http response
- * @param chain filter chain
- *
- * @throws IOException
- * @throws ServletException
- */
- @Override
- protected void doFilter(HttpServletRequest request,
- HttpServletResponse response, FilterChain chain)
- throws IOException, ServletException
- {
- if (WebUtil.isGzipSupported(request))
- {
- if (logger.isTraceEnabled())
- {
- logger.trace("compress output with gzip");
- }
-
- GZipResponseWrapper wrappedResponse = new GZipResponseWrapper(response,
- config);
-
- chain.doFilter(request, wrappedResponse);
- wrappedResponse.finishResponse();
- }
- else
- {
- chain.doFilter(request, response);
- }
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** gzip filter configuration */
- private GZipFilterConfig config = new GZipFilterConfig();
-}
diff --git a/scm-core/src/main/java/sonia/scm/filter/GZipResponseFilter.java b/scm-core/src/main/java/sonia/scm/filter/GZipResponseFilter.java
new file mode 100644
index 0000000000..ef0ec8a5ef
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/filter/GZipResponseFilter.java
@@ -0,0 +1,59 @@
+package sonia.scm.filter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.inject.Provider;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.ext.WriterInterceptor;
+import javax.ws.rs.ext.WriterInterceptorContext;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Locale;
+import java.util.zip.GZIPOutputStream;
+
+@javax.ws.rs.ext.Provider
+public class GZipResponseFilter implements WriterInterceptor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(GZipResponseFilter.class);
+
+ private final Provider requestProvider;
+
+ @Inject
+ public GZipResponseFilter(Provider requestProvider) {
+ this.requestProvider = requestProvider;
+ }
+
+ @Override
+ public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
+ if (isGZipSupported()) {
+ LOG.trace("compress output with gzip");
+ encodeWithGZip(context);
+ } else {
+ context.proceed();
+ }
+ }
+
+ private void encodeWithGZip(WriterInterceptorContext context) throws IOException {
+ context.getHeaders().remove(HttpHeaders.CONTENT_LENGTH);
+ context.getHeaders().add(HttpHeaders.CONTENT_ENCODING, "gzip");
+
+ OutputStream outputStream = context.getOutputStream();
+ GZIPOutputStream compressedOutputStream = new GZIPOutputStream(outputStream);
+ context.setOutputStream(compressedOutputStream);
+ try {
+ context.proceed();
+ } finally {
+ compressedOutputStream.finish();
+ context.setOutputStream(outputStream);
+ }
+ }
+
+ private boolean isGZipSupported() {
+ Object encoding = requestProvider.get().getHeader(HttpHeaders.ACCEPT_ENCODING);
+ return encoding != null && encoding.toString().toLowerCase(Locale.ENGLISH).contains("gzip");
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/group/DisplayGroup.java b/scm-core/src/main/java/sonia/scm/group/DisplayGroup.java
new file mode 100644
index 0000000000..a16a3046e9
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/group/DisplayGroup.java
@@ -0,0 +1,26 @@
+package sonia.scm.group;
+
+import sonia.scm.ReducedModelObject;
+
+public class DisplayGroup implements ReducedModelObject {
+
+ private final String id;
+ private final String displayName;
+
+ public static DisplayGroup from(Group group) {
+ return new DisplayGroup(group.getId(), group.getDescription());
+ }
+
+ private DisplayGroup(String id, String displayName) {
+ this.id = id;
+ this.displayName = displayName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/group/Group.java b/scm-core/src/main/java/sonia/scm/group/Group.java
index cb1e4e9cda..8673804185 100644
--- a/scm-core/src/main/java/sonia/scm/group/Group.java
+++ b/scm-core/src/main/java/sonia/scm/group/Group.java
@@ -42,6 +42,7 @@ import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import sonia.scm.BasicPropertiesAware;
import sonia.scm.ModelObject;
+import sonia.scm.ReducedModelObject;
import sonia.scm.util.Util;
import sonia.scm.util.ValidationUtil;
@@ -49,23 +50,27 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Arrays;
-import java.util.Iterator;
+import java.util.Collections;
import java.util.List;
//~--- JDK imports ------------------------------------------------------------
/**
* Organizes users into a group for easier permissions management.
- *
+ *
* TODO for 2.0: Use a set instead of a list for members
*
* @author Sebastian Sdorra
*/
-@StaticPermissions("group")
+@StaticPermissions(
+ value = "group",
+ globalPermissions = {"create", "list", "autocomplete"},
+ custom = true, customGlobal = true
+)
@XmlRootElement(name = "groups")
@XmlAccessorType(XmlAccessType.FIELD)
public class Group extends BasicPropertiesAware
- implements ModelObject, Iterable, PermissionObject
+ implements ModelObject, PermissionObject, ReducedModelObject
{
/** Field description */
@@ -191,6 +196,7 @@ public class Group extends BasicPropertiesAware
group.setMembers(members);
group.setType(type);
group.setDescription(description);
+ group.setExternal(external);
}
/**
@@ -220,6 +226,7 @@ public class Group extends BasicPropertiesAware
&& Objects.equal(description, other.description)
&& Objects.equal(members, other.members)
&& Objects.equal(type, other.type)
+ && Objects.equal(external, other.external)
&& Objects.equal(creationDate, other.creationDate)
&& Objects.equal(lastModified, other.lastModified)
&& Objects.equal(properties, other.properties);
@@ -238,18 +245,6 @@ public class Group extends BasicPropertiesAware
lastModified, properties);
}
- /**
- * Returns a {@link java.util.Iterator} for the members of this {@link Group}.
- *
- *
- * @return a {@link java.util.Iterator} for the members of this {@link Group}
- */
- @Override
- public Iterator iterator()
- {
- return getMembers().iterator();
- }
-
/**
* Remove the given member from this group.
*
@@ -274,14 +269,15 @@ public class Group extends BasicPropertiesAware
{
//J-
return MoreObjects.toStringHelper(this)
- .add("name", name)
- .add("description", description)
- .add("members", members)
- .add("type", type)
- .add("creationDate", creationDate)
- .add("lastModified", lastModified)
- .add("properties", properties)
- .toString();
+ .add("name", name)
+ .add("description", description)
+ .add("members", members)
+ .add("type", type)
+ .add("external", external)
+ .add("creationDate", creationDate)
+ .add("lastModified", lastModified)
+ .add("properties", properties)
+ .toString();
//J+
}
@@ -322,6 +318,11 @@ public class Group extends BasicPropertiesAware
return name;
}
+ @Override
+ public String getDisplayName() {
+ return description;
+ }
+
/**
* Returns a timestamp of the last modified date of this group.
*
@@ -342,8 +343,9 @@ public class Group extends BasicPropertiesAware
*/
public List getMembers()
{
- if (members == null)
- {
+ if (external) {
+ return Collections.emptyList();
+ } else if (members == null) {
members = Lists.newArrayList();
}
@@ -373,6 +375,15 @@ public class Group extends BasicPropertiesAware
return type;
}
+ /**
+ * Returns {@code true} if the members of the groups managed external of scm-manager.
+ *
+ * @return {@code true} if the group is an external group
+ */
+ public boolean isExternal() {
+ return external;
+ }
+
/**
* Returns true if the member is a member of this group.
*
@@ -466,8 +477,21 @@ public class Group extends BasicPropertiesAware
this.type = type;
}
+ /**
+ * {@code true} to mark the group as external.
+ *
+ * @param {@code true} for a external group
+ */
+ public void setExternal(boolean external)
+ {
+ this.external = external;
+ }
+
//~--- fields ---------------------------------------------------------------
+ /** external group */
+ private boolean external = false;
+
/** timestamp of the creation date of this group */
private Long creationDate;
diff --git a/scm-core/src/main/java/sonia/scm/group/GroupAlreadyExistsException.java b/scm-core/src/main/java/sonia/scm/group/GroupAlreadyExistsException.java
deleted file mode 100644
index 8389900098..0000000000
--- a/scm-core/src/main/java/sonia/scm/group/GroupAlreadyExistsException.java
+++ /dev/null
@@ -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.group;
-
-/**
- * This {@link Exception} is thrown when trying to create a group
- * that already exists.
- *
- * @author Sebastian Sdorra
- */
-public class GroupAlreadyExistsException extends GroupException
-{
-
- /** Field description */
- private static final long serialVersionUID = 4042878550219750430L;
-
- /**
- * Constructs a new instance.
- *
- * @param message exception message
- */
- public GroupAlreadyExistsException(String message) {
- super(message);
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/group/GroupCollector.java b/scm-core/src/main/java/sonia/scm/group/GroupCollector.java
new file mode 100644
index 0000000000..4546db1bc4
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/group/GroupCollector.java
@@ -0,0 +1,10 @@
+package sonia.scm.group;
+
+import java.util.Set;
+
+public interface GroupCollector {
+
+ String AUTHENTICATED = "_authenticated";
+
+ Set collect(String principal);
+}
diff --git a/scm-core/src/main/java/sonia/scm/group/GroupDisplayManager.java b/scm-core/src/main/java/sonia/scm/group/GroupDisplayManager.java
new file mode 100644
index 0000000000..d9188e9402
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/group/GroupDisplayManager.java
@@ -0,0 +1,6 @@
+package sonia.scm.group;
+
+import sonia.scm.DisplayManager;
+
+public interface GroupDisplayManager extends DisplayManager {
+}
diff --git a/scm-core/src/main/java/sonia/scm/group/GroupException.java b/scm-core/src/main/java/sonia/scm/group/GroupException.java
deleted file mode 100644
index e0dc799e92..0000000000
--- a/scm-core/src/main/java/sonia/scm/group/GroupException.java
+++ /dev/null
@@ -1,91 +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.group;
-
-/**
- * General {@link Exception} for group errors.
- *
- * @author Sebastian Sdorra
- */
-public class GroupException extends Exception
-{
-
- /** Field description */
- private static final long serialVersionUID = 5191341492098994225L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs a {@link GroupException} object.
- *
- */
- public GroupException()
- {
- super();
- }
-
- /**
- * Constructs a {@link GroupException} object.
- *
- *
- * @param message for the exception
- */
- public GroupException(String message)
- {
- super(message);
- }
-
- /**
- * Constructs a {@link GroupException} object.
- *
- *
- * @param cause of the exception
- */
- public GroupException(Throwable cause)
- {
- super(cause);
- }
-
- /**
- * Constructs a {@link GroupException} object.
- *
- *
- * @param message of the exception
- * @param cause of the exception
- */
- public GroupException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/group/GroupManager.java b/scm-core/src/main/java/sonia/scm/group/GroupManager.java
index 428559edef..288196894d 100644
--- a/scm-core/src/main/java/sonia/scm/group/GroupManager.java
+++ b/scm-core/src/main/java/sonia/scm/group/GroupManager.java
@@ -38,10 +38,10 @@ package sonia.scm.group;
import sonia.scm.Manager;
import sonia.scm.search.Searchable;
-//~--- JDK imports ------------------------------------------------------------
-
import java.util.Collection;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* The central class for managing {@link Group}s.
* This class is a singleton and is available via injection.
@@ -49,7 +49,7 @@ import java.util.Collection;
* @author Sebastian Sdorra
*/
public interface GroupManager
- extends Manager, Searchable
+ extends Manager, Searchable
{
/**
diff --git a/scm-core/src/main/java/sonia/scm/group/GroupManagerDecorator.java b/scm-core/src/main/java/sonia/scm/group/GroupManagerDecorator.java
index 955e218b43..e2367d863c 100644
--- a/scm-core/src/main/java/sonia/scm/group/GroupManagerDecorator.java
+++ b/scm-core/src/main/java/sonia/scm/group/GroupManagerDecorator.java
@@ -38,10 +38,10 @@ package sonia.scm.group;
import sonia.scm.ManagerDecorator;
import sonia.scm.search.SearchRequest;
-//~--- JDK imports ------------------------------------------------------------
-
import java.util.Collection;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* Decorator for {@link GroupManager}.
*
@@ -49,7 +49,7 @@ import java.util.Collection;
* @since 1.23
*/
public class GroupManagerDecorator
- extends ManagerDecorator implements GroupManager
+ extends ManagerDecorator implements GroupManager
{
/**
diff --git a/scm-core/src/main/java/sonia/scm/group/GroupNames.java b/scm-core/src/main/java/sonia/scm/group/GroupNames.java
deleted file mode 100644
index 43ca462d32..0000000000
--- a/scm-core/src/main/java/sonia/scm/group/GroupNames.java
+++ /dev/null
@@ -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.group;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import com.google.common.base.Joiner;
-import com.google.common.base.Objects;
-import com.google.common.collect.Lists;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.Serializable;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * This class represents all associated groups for a user.
- *
- * @author Sebastian Sdorra
- * @since 1.21
- */
-public final class GroupNames implements Serializable, Iterable
-{
-
- /**
- * Group for all authenticated users
- * @since 1.31
- */
- public static final String AUTHENTICATED = "_authenticated";
-
- /** Field description */
- private static final long serialVersionUID = 8615685985213897947L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
- @SuppressWarnings("unchecked")
- public GroupNames()
- {
- this.collection = Collections.EMPTY_LIST;
- }
-
- /**
- * Constructs ...
- *
- *
- * @param collection
- */
- public GroupNames(Collection collection)
- {
- this.collection = Collections.unmodifiableCollection(collection);
- }
-
- /**
- * Constructs ...
- *
- *
- * @param groupName
- * @param groupNames
- */
- public GroupNames(String groupName, String... groupNames)
- {
- this.collection = Lists.asList(groupName, groupNames);
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param groupName
- *
- * @return
- */
- public boolean contains(String groupName)
- {
- return collection.contains(groupName);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
- return false;
- }
-
- if (getClass() != obj.getClass())
- {
- return false;
- }
-
- final GroupNames other = (GroupNames) obj;
-
- return Objects.equal(collection, other.collection);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode()
- {
- return Objects.hashCode(collection);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public Iterator iterator()
- {
- return collection.iterator();
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String toString()
- {
- return Joiner.on(", ").join(collection);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- public Collection getCollection()
- {
- return collection;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private final Collection collection;
-}
diff --git a/scm-core/src/main/java/sonia/scm/group/GroupNotFoundException.java b/scm-core/src/main/java/sonia/scm/group/GroupNotFoundException.java
deleted file mode 100644
index f4b9934128..0000000000
--- a/scm-core/src/main/java/sonia/scm/group/GroupNotFoundException.java
+++ /dev/null
@@ -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.group;
-
-/**
- * The GroupNotFoundException is thrown e.g. from the
- * modify method of the {@link GroupManager}, if the group does not exists.
- *
- * @author Sebastian Sdorra
- *
- * @since 1.28
- */
-public class GroupNotFoundException extends GroupException
-{
-
- /** Field description */
- private static final long serialVersionUID = -1617037899954718001L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs a new GroupNotFoundException.
- *
- */
- public GroupNotFoundException() {}
-
- /**
- * Constructs a new GroupNotFoundException.
- *
- *
- * @param message message for the exception
- */
- public GroupNotFoundException(String message)
- {
- super(message);
- }
-
- /**
- * Constructs a new GroupNotFoundException.
- *
- *
- * @param throwable root cause
- */
- public GroupNotFoundException(Throwable throwable)
- {
- super(throwable);
- }
-
- /**
- * Constructs a new GroupNotFoundException.
- *
- *
- * @param message message for the exception
- * @param throwable root cause
- */
- public GroupNotFoundException(String message, Throwable throwable)
- {
- super(message, throwable);
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/group/GroupResolver.java b/scm-core/src/main/java/sonia/scm/group/GroupResolver.java
new file mode 100644
index 0000000000..5aba63c93b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/group/GroupResolver.java
@@ -0,0 +1,10 @@
+package sonia.scm.group;
+
+import sonia.scm.plugin.ExtensionPoint;
+
+import java.util.Set;
+
+@ExtensionPoint
+public interface GroupResolver {
+ Set resolve(String principal);
+}
diff --git a/scm-core/src/main/java/sonia/scm/i18n/I18nMessages.java b/scm-core/src/main/java/sonia/scm/i18n/I18nMessages.java
index 9c4a9353be..0af1cef895 100644
--- a/scm-core/src/main/java/sonia/scm/i18n/I18nMessages.java
+++ b/scm-core/src/main/java/sonia/scm/i18n/I18nMessages.java
@@ -36,16 +36,13 @@ package sonia.scm.i18n;
import com.google.common.base.Objects;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
-
import sonia.scm.util.ClassLoaders;
-//~--- JDK imports ------------------------------------------------------------
-
+import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
-
import java.util.Locale;
-import javax.servlet.http.HttpServletRequest;
+//~--- JDK imports ------------------------------------------------------------
/**
* The I18nMessages class instantiates a class and initializes all {@link String}
diff --git a/scm-core/src/main/java/sonia/scm/boot/RestartEvent.java b/scm-core/src/main/java/sonia/scm/lifecycle/RestartEvent.java
similarity index 90%
rename from scm-core/src/main/java/sonia/scm/boot/RestartEvent.java
rename to scm-core/src/main/java/sonia/scm/lifecycle/RestartEvent.java
index 244bc8f03c..1978cb9d7c 100644
--- a/scm-core/src/main/java/sonia/scm/boot/RestartEvent.java
+++ b/scm-core/src/main/java/sonia/scm/lifecycle/RestartEvent.java
@@ -29,18 +29,20 @@
-package sonia.scm.boot;
+package sonia.scm.lifecycle;
//~--- non-JDK imports --------------------------------------------------------
-import sonia.scm.Stage;
import sonia.scm.event.Event;
/**
* This event can be used to force a restart of the webapp context. The restart
* event is useful during plugin development, because we don't have to restart
- * the whole server, to see our changes. The restart event can only be used in
- * stage {@link Stage#DEVELOPMENT}.
+ * the whole server, to see our changes. The restart event could also be used
+ * to install or upgrade plugins.
+ *
+ * But the restart event should be used carefully, because the whole context
+ * will be restarted and that process could take some time.
*
* @author Sebastian Sdorra
* @since 2.0.0
diff --git a/scm-core/src/main/java/sonia/scm/migration/MigrationDAO.java b/scm-core/src/main/java/sonia/scm/migration/MigrationDAO.java
new file mode 100644
index 0000000000..acc37ce8ee
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/migration/MigrationDAO.java
@@ -0,0 +1,7 @@
+package sonia.scm.migration;
+
+import java.util.Collection;
+
+public interface MigrationDAO {
+ Collection getAll();
+}
diff --git a/scm-core/src/main/java/sonia/scm/migration/MigrationInfo.java b/scm-core/src/main/java/sonia/scm/migration/MigrationInfo.java
new file mode 100644
index 0000000000..19f5d8ba3a
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/migration/MigrationInfo.java
@@ -0,0 +1,38 @@
+package sonia.scm.migration;
+
+public class MigrationInfo {
+
+ private final String id;
+ private final String protocol;
+ private final String originalRepositoryName;
+ private final String namespace;
+ private final String name;
+
+ public MigrationInfo(String id, String protocol, String originalRepositoryName, String namespace, String name) {
+ this.id = id;
+ this.protocol = protocol;
+ this.originalRepositoryName = originalRepositoryName;
+ this.namespace = namespace;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public String getOriginalRepositoryName() {
+ return originalRepositoryName;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/migration/UpdateException.java b/scm-core/src/main/java/sonia/scm/migration/UpdateException.java
new file mode 100644
index 0000000000..946db59536
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/migration/UpdateException.java
@@ -0,0 +1,17 @@
+package sonia.scm.migration;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UpdateException extends RuntimeException {
+ private static Logger LOG = LoggerFactory.getLogger(UpdateException.class);
+
+ public UpdateException(String message) {
+ super(message);
+ }
+
+ public UpdateException(String message, Throwable cause) {
+ super(message, cause);
+ LOG.error(message, cause);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/migration/UpdateStep.java b/scm-core/src/main/java/sonia/scm/migration/UpdateStep.java
new file mode 100644
index 0000000000..ed5f60a630
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/migration/UpdateStep.java
@@ -0,0 +1,82 @@
+package sonia.scm.migration;
+
+import sonia.scm.plugin.ExtensionPoint;
+import sonia.scm.version.Version;
+
+/**
+ * This is the main interface for data migration/update. Using this interface, SCM-Manager provides the possibility to
+ * change data structures between versions for a given type of data.
+ *
The data type can be an arbitrary string, but it is considered a best practice to use a qualified name, for
+ * example
+ *
+ *
com.example.myPlugin.configuration
for data in plugins, or
+ *
com.cloudogu.scm.repository
for core data structures.
+ *
+ *
+ *
The version is unrelated to other versions and therefore can be chosen freely, so that a data type can be updated
+ * without in various ways independent of other data types or the official version of the plugin or the core.
+ * A coordination between different data types and their versions is only necessary, when update steps of different data
+ * types rely on each other. If a update step of data type A has to run before another step for data type
+ * B, the version number of the second step has to be greater in regards to {@link Version#compareTo(Version)}.
+ *
+ *
The algorithm looks something like this:
+ * Whenever the SCM-Manager starts,
+ *
+ *
it creates a so called bootstrap guice context, that contains
+ *
+ *
a {@link sonia.scm.security.KeyGenerator},
+ *
the {@link sonia.scm.repository.RepositoryLocationResolver},
+ *
the {@link sonia.scm.io.FileSystem},
+ *
the {@link sonia.scm.security.CipherHandler},
+ *
a {@link sonia.scm.store.ConfigurationStoreFactory},
+ *
a {@link sonia.scm.store.ConfigurationEntryStoreFactory},
+ *
a {@link sonia.scm.store.DataStoreFactory},
+ *
a {@link sonia.scm.store.BlobStoreFactory}, and
+ *
the {@link sonia.scm.plugin.PluginLoader}.
+ *
+ * Mind, that there are no DAOs, Managers or the like available at this time!
+ *
+ *
It then checks whether there are instances of this interface that have not run before, that is either
+ *
+ *
their version number given by {@link #getTargetVersion()} is bigger than the last recorded target version of an
+ * executed update step for the data type given by {@link #getAffectedDataType()}, or
+ *
+ *
there is no version number known for the given data type.
+ *
+ *
+ * These are the relevant update steps.
+ *
+ *
These relevant update steps are then sorted ascending by their target version given by
+ * {@link #getTargetVersion()}.
+ *
+ *
Finally, these sorted steps are executed one after another calling {@link #doUpdate()} of each step, updating the
+ * version for the data type accordingly.
+ *
+ *
If all works well, SCM-Manager then creates the runtime guice context by loading all further modules.
+ *
If any of the update steps fails, the whole process is interrupted and SCM-Manager will not start up and will
+ * not record the version number of this update step.
+ *
+ *
+ *
+ */
+@ExtensionPoint
+public interface UpdateStep {
+ /**
+ * Implement this to update the data to the new version. If any {@link Exception} is thrown, SCM-Manager will not
+ * start up.
+ */
+ void doUpdate() throws Exception;
+
+ /**
+ * Declares the new version of the data type given by {@link #getAffectedDataType()}. A update step will only be
+ * executed, when this version is bigger than the last recorded version for its data type according to
+ * {@link Version#compareTo(Version)}
+ */
+ Version getTargetVersion();
+
+ /**
+ * Declares the data type this update step will take care of. This should be a qualified name, like
+ * com.example.myPlugin.configuration.
+ */
+ String getAffectedDataType();
+}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/AvailablePlugin.java b/scm-core/src/main/java/sonia/scm/plugin/AvailablePlugin.java
new file mode 100644
index 0000000000..c05e970e50
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/plugin/AvailablePlugin.java
@@ -0,0 +1,32 @@
+package sonia.scm.plugin;
+
+import com.google.common.base.Preconditions;
+
+public class AvailablePlugin implements Plugin {
+
+ private final AvailablePluginDescriptor pluginDescriptor;
+ private final boolean pending;
+
+ public AvailablePlugin(AvailablePluginDescriptor pluginDescriptor) {
+ this(pluginDescriptor, false);
+ }
+
+ private AvailablePlugin(AvailablePluginDescriptor pluginDescriptor, boolean pending) {
+ this.pluginDescriptor = pluginDescriptor;
+ this.pending = pending;
+ }
+
+ @Override
+ public AvailablePluginDescriptor getDescriptor() {
+ return pluginDescriptor;
+ }
+
+ public boolean isPending() {
+ return pending;
+ }
+
+ AvailablePlugin install() {
+ Preconditions.checkState(!pending, "installation is already pending");
+ return new AvailablePlugin(pluginDescriptor, true);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/AvailablePluginDescriptor.java b/scm-core/src/main/java/sonia/scm/plugin/AvailablePluginDescriptor.java
new file mode 100644
index 0000000000..1c164a0d81
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/plugin/AvailablePluginDescriptor.java
@@ -0,0 +1,47 @@
+package sonia.scm.plugin;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * @since 2.0.0
+ */
+public class AvailablePluginDescriptor implements PluginDescriptor {
+
+ private final PluginInformation information;
+ private final PluginCondition condition;
+ private final Set dependencies;
+ private final String url;
+ private final String checksum;
+
+ public AvailablePluginDescriptor(PluginInformation information, PluginCondition condition, Set dependencies, String url, String checksum) {
+ this.information = information;
+ this.condition = condition;
+ this.dependencies = dependencies;
+ this.url = url;
+ this.checksum = checksum;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public Optional getChecksum() {
+ return Optional.ofNullable(checksum);
+ }
+
+ @Override
+ public PluginInformation getInformation() {
+ return information;
+ }
+
+ @Override
+ public PluginCondition getCondition() {
+ return condition;
+ }
+
+ @Override
+ public Set getDependencies() {
+ return dependencies;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/ClassElement.java b/scm-core/src/main/java/sonia/scm/plugin/ClassElement.java
index 1b43a41ad6..813a5a850f 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/ClassElement.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/ClassElement.java
@@ -36,10 +36,10 @@ package sonia.scm.plugin;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-//~--- JDK imports ------------------------------------------------------------
-
import javax.xml.bind.annotation.XmlElement;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -119,9 +119,9 @@ public final class ClassElement
{
//J-
return MoreObjects.toStringHelper(this)
- .add("clazz", clazz)
- .add("description", description)
- .toString();
+ .add("clazz", clazz)
+ .add("description", description)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/ExtensionPointElement.java b/scm-core/src/main/java/sonia/scm/plugin/ExtensionPointElement.java
index eda91d4e6f..7f6f1efe07 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/ExtensionPointElement.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/ExtensionPointElement.java
@@ -36,13 +36,13 @@ package sonia.scm.plugin;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-//~--- 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;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -131,11 +131,11 @@ public final class ExtensionPointElement
{
//J-
return MoreObjects.toStringHelper(this)
- .add("class", clazz)
- .add("description", description)
- .add("multiple", multiple)
- .add("autoBind", autoBind)
- .toString();
+ .add("class", clazz)
+ .add("description", description)
+ .add("multiple", multiple)
+ .add("autoBind", autoBind)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/InstalledPlugin.java b/scm-core/src/main/java/sonia/scm/plugin/InstalledPlugin.java
new file mode 100644
index 0000000000..09f05e2c99
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/plugin/InstalledPlugin.java
@@ -0,0 +1,164 @@
+/**
+ * Copyright (c) 2010, Sebastian Sdorra All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. Neither the name of SCM-Manager;
+ * nor the names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+
+
+package sonia.scm.plugin;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.nio.file.Path;
+
+/**
+ * Wrapper for a {@link InstalledPluginDescriptor}. The wrapper holds the directory,
+ * {@link ClassLoader} and {@link WebResourceLoader} of a plugin.
+ *
+ * @author Sebastian Sdorra
+ * @since 2.0.0
+ */
+public final class InstalledPlugin implements Plugin
+{
+
+ public static final String UNINSTALL_MARKER_FILENAME = "uninstall";
+
+ /**
+ * Constructs a new plugin wrapper.
+ * @param descriptor wrapped plugin
+ * @param classLoader plugin class loader
+ * @param webResourceLoader web resource loader
+ * @param directory plugin directory
+ * @param core marked as core or not
+ */
+ public InstalledPlugin(InstalledPluginDescriptor descriptor, ClassLoader classLoader,
+ WebResourceLoader webResourceLoader, Path directory, boolean core)
+ {
+ this.descriptor = descriptor;
+ this.classLoader = classLoader;
+ this.webResourceLoader = webResourceLoader;
+ this.directory = directory;
+ this.core = core;
+ }
+
+ //~--- get methods ----------------------------------------------------------
+
+ /**
+ * Returns plugin class loader.
+ *
+ *
+ * @return plugin class loader
+ */
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ /**
+ * Returns plugin directory.
+ *
+ *
+ * @return plugin directory
+ */
+ public Path getDirectory()
+ {
+ return directory;
+ }
+
+ /**
+ * Returns the id of the plugin.
+ *
+ *
+ * @return id of plugin
+ */
+ public String getId()
+ {
+ return descriptor.getInformation().getId();
+ }
+
+ /**
+ * Returns the plugin descriptor.
+ *
+ *
+ * @return plugin descriptor
+ */
+ @Override
+ public InstalledPluginDescriptor getDescriptor()
+ {
+ return descriptor;
+ }
+
+ /**
+ * Returns the {@link WebResourceLoader} for this plugin.
+ *
+ *
+ * @return web resource loader
+ */
+ public WebResourceLoader getWebResourceLoader()
+ {
+ return webResourceLoader;
+ }
+
+ public boolean isCore() {
+ return core;
+ }
+
+ public boolean isMarkedForUninstall() {
+ return markedForUninstall;
+ }
+
+ public void setMarkedForUninstall(boolean markedForUninstall) {
+ this.markedForUninstall = markedForUninstall;
+ }
+
+ public boolean isUninstallable() {
+ return uninstallable;
+ }
+
+ public void setUninstallable(boolean uninstallable) {
+ this.uninstallable = uninstallable;
+ }
+
+//~--- fields ---------------------------------------------------------------
+
+ /** plugin class loader */
+ private final ClassLoader classLoader;
+
+ /** plugin directory */
+ private final Path directory;
+
+ /** plugin */
+ private final InstalledPluginDescriptor descriptor;
+
+ /** plugin web resource loader */
+ private final WebResourceLoader webResourceLoader;
+
+ private final boolean core;
+
+ private boolean markedForUninstall = false;
+ private boolean uninstallable = false;
+}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/InstalledPluginDescriptor.java b/scm-core/src/main/java/sonia/scm/plugin/InstalledPluginDescriptor.java
new file mode 100644
index 0000000000..88ae4c5dff
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/plugin/InstalledPluginDescriptor.java
@@ -0,0 +1,259 @@
+/**
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of SCM-Manager; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+
+
+package sonia.scm.plugin;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Set;
+
+//~--- JDK imports ------------------------------------------------------------
+
+/**
+ *
+ * @author Sebastian Sdorra
+ */
+@XmlRootElement(name = "plugin")
+@XmlAccessorType(XmlAccessType.FIELD)
+public final class InstalledPluginDescriptor extends ScmModule implements PluginDescriptor
+{
+
+ /**
+ * Constructs ...
+ *
+ */
+ InstalledPluginDescriptor() {}
+
+ /**
+ * Constructs ...
+ *
+ *
+ * @param scmVersion
+ * @param information
+ * @param resources
+ * @param condition
+ * @param childFirstClassLoader
+ * @param dependencies
+ */
+ public InstalledPluginDescriptor(int scmVersion, PluginInformation information,
+ PluginResources resources, PluginCondition condition,
+ boolean childFirstClassLoader, Set dependencies)
+ {
+ this.scmVersion = scmVersion;
+ this.information = information;
+ this.resources = resources;
+ this.condition = condition;
+ this.childFirstClassLoader = childFirstClassLoader;
+ this.dependencies = dependencies;
+ }
+
+ //~--- methods --------------------------------------------------------------
+
+ /**
+ * Method description
+ *
+ *
+ * @param obj
+ *
+ * @return
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ {
+ return false;
+ }
+
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+
+ final InstalledPluginDescriptor other = (InstalledPluginDescriptor) obj;
+
+ return Objects.equal(scmVersion, other.scmVersion)
+ && Objects.equal(condition, other.condition)
+ && Objects.equal(information, other.information)
+ && Objects.equal(resources, other.resources)
+ && Objects.equal(childFirstClassLoader, other.childFirstClassLoader)
+ && Objects.equal(dependencies, other.dependencies);
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ @Override
+ public int hashCode()
+ {
+ return Objects.hashCode(scmVersion, condition, information, resources,
+ childFirstClassLoader, dependencies);
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ @Override
+ public String toString()
+ {
+ //J-
+ return MoreObjects.toStringHelper(this)
+ .add("scmVersion", scmVersion)
+ .add("condition", condition)
+ .add("information", information)
+ .add("resources", resources)
+ .add("childFirstClassLoader", childFirstClassLoader)
+ .add("dependencies", dependencies)
+ .toString();
+ //J+
+ }
+
+ //~--- get methods ----------------------------------------------------------
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ @Override
+ public PluginCondition getCondition()
+ {
+ return condition;
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ *
+ * @since 2.0.0
+ */
+ @Override
+ public Set getDependencies()
+ {
+ if (dependencies == null)
+ {
+ dependencies = ImmutableSet.of();
+ }
+
+ return dependencies;
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ @Override
+ public PluginInformation getInformation()
+ {
+ return information;
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ public PluginResources getResources()
+ {
+ return resources;
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ public int getScmVersion()
+ {
+ return scmVersion;
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ public boolean isChildFirstClassLoader()
+ {
+ return childFirstClassLoader;
+ }
+
+ //~--- fields ---------------------------------------------------------------
+
+ /** Field description */
+ @XmlElement(name = "child-first-classloader")
+ private boolean childFirstClassLoader;
+
+ /** Field description */
+ @XmlElement(name = "conditions")
+ private PluginCondition condition;
+
+ /** Field description */
+ @XmlElement(name = "dependency")
+ @XmlElementWrapper(name = "dependencies")
+ private Set dependencies;
+
+ /** Field description */
+ @XmlElement(name = "information")
+ private PluginInformation information;
+
+ /** Field description */
+ private PluginResources resources;
+
+ /** Field description */
+ @XmlElement(name = "scm-version")
+ private int scmVersion = 1;
+}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/Plugin.java b/scm-core/src/main/java/sonia/scm/plugin/Plugin.java
index 438ca2184c..8b440f8ab9 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/Plugin.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/Plugin.java
@@ -1,251 +1,6 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
package sonia.scm.plugin;
-//~--- non-JDK imports --------------------------------------------------------
+public interface Plugin {
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableSet;
-
-import javax.xml.bind.annotation.*;
-import java.util.Set;
-
-//~--- JDK imports ------------------------------------------------------------
-
-/**
- *
- * @author Sebastian Sdorra
- */
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public final class Plugin extends ScmModule
-{
-
- /**
- * Constructs ...
- *
- */
- Plugin() {}
-
- /**
- * Constructs ...
- *
- *
- * @param scmVersion
- * @param information
- * @param resources
- * @param condition
- * @param childFirstClassLoader
- * @param dependencies
- */
- public Plugin(int scmVersion, PluginInformation information,
- PluginResources resources, PluginCondition condition,
- boolean childFirstClassLoader, Set dependencies)
- {
- this.scmVersion = scmVersion;
- this.information = information;
- this.resources = resources;
- this.condition = condition;
- this.childFirstClassLoader = childFirstClassLoader;
- this.dependencies = dependencies;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param obj
- *
- * @return
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
- return false;
- }
-
- if (getClass() != obj.getClass())
- {
- return false;
- }
-
- final Plugin other = (Plugin) obj;
-
- return Objects.equal(scmVersion, other.scmVersion)
- && Objects.equal(condition, other.condition)
- && Objects.equal(information, other.information)
- && Objects.equal(resources, other.resources)
- && Objects.equal(childFirstClassLoader, other.childFirstClassLoader)
- && Objects.equal(dependencies, other.dependencies);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public int hashCode()
- {
- return Objects.hashCode(scmVersion, condition, information, resources,
- childFirstClassLoader, dependencies);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String toString()
- {
- //J-
- return MoreObjects.toStringHelper(this)
- .add("scmVersion", scmVersion)
- .add("condition", condition)
- .add("information", information)
- .add("resources", resources)
- .add("childFirstClassLoader", childFirstClassLoader)
- .add("dependencies", dependencies)
- .toString();
- //J+
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- public PluginCondition getCondition()
- {
- return condition;
- }
-
- /**
- * Method description
- *
- *
- * @return
- *
- * @since 2.0.0
- */
- public Set getDependencies()
- {
- if (dependencies == null)
- {
- dependencies = ImmutableSet.of();
- }
-
- return dependencies;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public PluginInformation getInformation()
- {
- return information;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public PluginResources getResources()
- {
- return resources;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public int getScmVersion()
- {
- return scmVersion;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public boolean isChildFirstClassLoader()
- {
- return childFirstClassLoader;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- @XmlElement(name = "child-first-classloader")
- private boolean childFirstClassLoader;
-
- /** Field description */
- @XmlElement(name = "conditions")
- private PluginCondition condition;
-
- /** Field description */
- @XmlElement(name = "dependency")
- @XmlElementWrapper(name = "dependencies")
- private Set dependencies;
-
- /** Field description */
- private PluginInformation information;
-
- /** Field description */
- private PluginResources resources;
-
- /** Field description */
- @XmlElement(name = "scm-version")
- private int scmVersion = 1;
+ PluginDescriptor getDescriptor();
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginCenter.java b/scm-core/src/main/java/sonia/scm/plugin/PluginCenter.java
deleted file mode 100644
index e4de29eb26..0000000000
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginCenter.java
+++ /dev/null
@@ -1,120 +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.plugin;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.Serializable;
-
-import java.util.HashSet;
-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.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-@XmlRootElement(name = "plugin-center")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class PluginCenter implements Serializable
-{
-
- /** Field description */
- private static final long serialVersionUID = -6414175308610267397L;
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- public Set getPlugins()
- {
- return plugins;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public Set getRepositories()
- {
- return repositories;
- }
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param plugins
- */
- public void setPlugins(Set plugins)
- {
- this.plugins = plugins;
- }
-
- /**
- * Method description
- *
- *
- * @param repositories
- */
- public void setRepositories(Set repositories)
- {
- this.repositories = repositories;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- @XmlElement(name = "plugin")
- @XmlElementWrapper(name = "plugins")
- private Set plugins = new HashSet<>();
-
- /** Field description */
- @XmlElement(name = "repository")
- @XmlElementWrapper(name = "repositories")
- private Set repositories = new HashSet<>();
-}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginCondition.java b/scm-core/src/main/java/sonia/scm/plugin/PluginCondition.java
index fb03b66351..e70821d0df 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginCondition.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/PluginCondition.java
@@ -43,7 +43,11 @@ import sonia.scm.util.SystemUtil;
import sonia.scm.util.Util;
import sonia.scm.version.Version;
-import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -102,7 +106,7 @@ public class PluginCondition implements Cloneable, Serializable
if (Util.isNotEmpty(os))
{
- clone.setOs(new ArrayList<>(os));
+ clone.setOs(new ArrayList(os));
}
return clone;
@@ -159,10 +163,10 @@ public class PluginCondition implements Cloneable, Serializable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("arch", arch)
- .add("minVersion", minVersion)
- .add("os", os)
- .toString();
+ .add("arch", arch)
+ .add("minVersion", minVersion)
+ .add("os", os)
+ .toString();
//J+
}
@@ -309,14 +313,14 @@ public class PluginCondition implements Cloneable, Serializable
osType = osType.toLowerCase(Locale.ENGLISH);
//J-
- return ((osType.contains("win")) && (PlatformType.WINDOWS == type))
- || ((osType.contains("unix")) && type.isUnix())
- || ((osType.contains("posix")) && type.isPosix())
- || ((osType.contains("mac")) && (PlatformType.MAC == type))
- || ((osType.contains("linux")) && (PlatformType.LINUX == type))
- || ((osType.contains("solaris")) && (PlatformType.SOLARIS == type))
- || ((osType.contains("openbsd")) && (PlatformType.OPENBSD == type))
- || ((osType.contains("freebsd")) && (PlatformType.FREEBSD == type));
+ return ((osType.indexOf("win") >= 0) && (PlatformType.WINDOWS == type))
+ || ((osType.indexOf("unix") >= 0) && type.isUnix())
+ || ((osType.indexOf("posix") >= 0) && type.isPosix())
+ || ((osType.indexOf("mac") >= 0) && (PlatformType.MAC == type))
+ || ((osType.indexOf("linux") >= 0) && (PlatformType.LINUX == type))
+ || ((osType.indexOf("solaris") >= 0) && (PlatformType.SOLARIS == type))
+ || ((osType.indexOf("openbsd") >= 0) && (PlatformType.OPENBSD == type))
+ || ((osType.indexOf("freebsd") >= 0) && (PlatformType.FREEBSD == type));
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginDescriptor.java b/scm-core/src/main/java/sonia/scm/plugin/PluginDescriptor.java
new file mode 100644
index 0000000000..6e800faff0
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/plugin/PluginDescriptor.java
@@ -0,0 +1,13 @@
+package sonia.scm.plugin;
+
+import java.util.Set;
+
+public interface PluginDescriptor {
+
+ PluginInformation getInformation();
+
+ PluginCondition getCondition();
+
+ Set getDependencies();
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginInformation.java b/scm-core/src/main/java/sonia/scm/plugin/PluginInformation.java
index cab5245f6a..b669cb63fa 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginInformation.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/PluginInformation.java
@@ -1,19 +1,19 @@
/**
* 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.
+ * 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.
+ * 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.
- *
+ * 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
@@ -24,553 +24,82 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* http://bitbucket.org/sdorra/scm-manager
- *
*/
-
package sonia.scm.plugin;
//~--- non-JDK imports --------------------------------------------------------
import com.github.sdorra.ssp.PermissionObject;
import com.github.sdorra.ssp.StaticPermissions;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
+import lombok.Data;
import sonia.scm.Validateable;
import sonia.scm.util.Util;
-import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
//~--- JDK imports ------------------------------------------------------------
/**
- *
* @author Sebastian Sdorra
*/
+@Data
@StaticPermissions(
- value = "plugin",
- generatedClass = "PluginPermissions",
+ value = "plugin",
+ generatedClass = "PluginPermissions",
permissions = {},
- globalPermissions = { "read", "manage" }
+ globalPermissions = {"read", "manage"},
+ custom = true, customGlobal = true
)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "plugin-information")
-public class PluginInformation
- implements PermissionObject, Validateable, Cloneable, Serializable
-{
+public class PluginInformation implements PermissionObject, Validateable, Cloneable, Serializable {
- /** Field description */
private static final long serialVersionUID = 461382048865977206L;
- //~--- methods --------------------------------------------------------------
+ private String name;
+ private String version;
+ private String displayName;
+ private String description;
+ private String author;
+ private String category;
+ private String avatarUrl;
- /**
- * Method description
- *
- *
- * @return
- *
- * @since 1.11
- */
@Override
- public PluginInformation clone()
- {
+ public PluginInformation clone() {
PluginInformation clone = new PluginInformation();
-
- clone.setArtifactId(artifactId);
+ clone.setName(name);
+ clone.setVersion(version);
+ clone.setDisplayName(displayName);
+ clone.setDescription(description);
clone.setAuthor(author);
clone.setCategory(category);
- clone.setTags(tags);
-
- if (condition != null)
- {
- clone.setCondition(condition.clone());
- }
-
- clone.setDescription(description);
- clone.setGroupId(groupId);
- clone.setName(name);
-
- if (Util.isNotEmpty(screenshots))
- {
- clone.setScreenshots(new ArrayList<>(screenshots));
- }
-
- clone.setState(state);
- clone.setUrl(url);
- clone.setVersion(version);
- clone.setWiki(wiki);
-
+ clone.setAvatarUrl(avatarUrl);
return clone;
}
- /**
- * Method description
- *
- *
- * @param obj
- *
- * @return
- */
@Override
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
- return false;
- }
-
- if (getClass() != obj.getClass())
- {
- return false;
- }
-
- final PluginInformation other = (PluginInformation) obj;
-
- //J-
- return Objects.equal(artifactId, other.artifactId)
- && Objects.equal(author, other.author)
- && Objects.equal(category, other.category)
- && Objects.equal(tags, other.tags)
- && Objects.equal(condition, other.condition)
- && Objects.equal(description, other.description)
- && Objects.equal(groupId, other.groupId)
- && Objects.equal(name, other.name)
- && Objects.equal(screenshots, other.screenshots)
- && Objects.equal(state, other.state)
- && Objects.equal(url, other.url)
- && Objects.equal(version, other.version)
- && Objects.equal(wiki, other.wiki);
- //J+
+ public String getId() {
+ return getName(true);
}
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public int hashCode()
- {
- return Objects.hashCode(artifactId, author, category, tags, condition,
- description, groupId, name, screenshots, state, url, version, wiki);
- }
+ public String getName(boolean withVersion) {
+ StringBuilder id = new StringBuilder(name);
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String toString()
- {
- //J-
- return MoreObjects.toStringHelper(this)
- .add("artifactId", artifactId)
- .add("author", author)
- .add("category", category)
- .add("tags", tags)
- .add("condition", condition)
- .add("description", description)
- .add("groupId", groupId)
- .add("name", name)
- .add("screenshots", screenshots)
- .add("state", state)
- .add("url", url)
- .add("version", version)
- .add("wiki", wiki)
- .toString();
- //J+
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getArtifactId()
- {
- return artifactId;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getAuthor()
- {
- return author;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getCategory()
- {
- return category;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public PluginCondition getCondition()
- {
- return condition;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getDescription()
- {
- return description;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getGroupId()
- {
- return groupId;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String getId()
- {
- return getId(true);
- }
-
- /**
- * Method description
- *
- *
- * @param withVersion
- *
- * @return
- * @since 1.21
- */
- public String getId(boolean withVersion)
- {
- StringBuilder id = new StringBuilder(groupId);
-
- id.append(":").append(artifactId);
-
- if (withVersion)
- {
+ if (withVersion) {
id.append(":").append(version);
}
-
return id.toString();
}
- /**
- * Method description
- *
- *
- * @return
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public List getScreenshots()
- {
- return screenshots;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public PluginState getState()
- {
- return state;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public List getTags()
- {
- return tags;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getUrl()
- {
- return url;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getVersion()
- {
- return version;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getWiki()
- {
- return wiki;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
@Override
- public boolean isValid()
- {
- return Util.isNotEmpty(groupId) && Util.isNotEmpty(artifactId)
- && Util.isNotEmpty(name) && Util.isNotEmpty(version);
+ public boolean isValid() {
+ return Util.isNotEmpty(name) && Util.isNotEmpty(version);
}
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param artifactId
- */
- public void setArtifactId(String artifactId)
- {
- this.artifactId = artifactId;
- }
-
- /**
- * Method description
- *
- *
- * @param author
- */
- public void setAuthor(String author)
- {
- this.author = author;
- }
-
- /**
- * Method description
- *
- *
- * @param category
- */
- public void setCategory(String category)
- {
- this.category = category;
- }
-
- /**
- * Method description
- *
- *
- * @param condition
- */
- public void setCondition(PluginCondition condition)
- {
- this.condition = condition;
- }
-
- /**
- * Method description
- *
- *
- * @param description
- */
- public void setDescription(String description)
- {
- this.description = description;
- }
-
- /**
- * Method description
- *
- *
- * @param groupId
- */
- public void setGroupId(String groupId)
- {
- this.groupId = groupId;
- }
-
- /**
- * Method description
- *
- *
- * @param name
- */
- public void setName(String name)
- {
- this.name = name;
- }
-
- /**
- * Method description
- *
- *
- * @param screenshots
- */
- public void setScreenshots(List screenshots)
- {
- this.screenshots = screenshots;
- }
-
- /**
- * Method description
- *
- *
- * @param state
- */
- public void setState(PluginState state)
- {
- this.state = state;
- }
-
- /**
- * Method description
- *
- *
- * @param tags
- */
- public void setTags(List tags)
- {
- this.tags = tags;
- }
-
- /**
- * Method description
- *
- *
- * @param url
- */
- public void setUrl(String url)
- {
- this.url = url;
- }
-
- /**
- * Method description
- *
- *
- * @param version
- */
- public void setVersion(String version)
- {
- this.version = version;
- }
-
- /**
- * Method description
- *
- *
- * @param wiki
- */
- public void setWiki(String wiki)
- {
- this.wiki = wiki;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String artifactId;
-
- /** Field description */
- private String author;
-
- /** Field description */
- private String category;
-
- /** Field description */
- private PluginCondition condition;
-
- /** Field description */
- private String description;
-
- /** Field description */
- private String groupId;
-
- /** Field description */
- private String name;
-
- /** Field description */
- @XmlElement(name = "screenshot")
- @XmlElementWrapper(name = "screenshots")
- private List screenshots;
-
- /** Field description */
- private PluginState state;
-
- /** Field description */
- @XmlElement(name = "tag")
- @XmlElementWrapper(name = "tags")
- private List tags;
-
- /** Field description */
- private String url;
-
- /** Field description */
- private String version;
-
- /** Field description */
- private String wiki;
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginInformationComparator.java b/scm-core/src/main/java/sonia/scm/plugin/PluginInformationComparator.java
deleted file mode 100644
index f44de35e8a..0000000000
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginInformationComparator.java
+++ /dev/null
@@ -1,106 +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.plugin;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.Util;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.Serializable;
-
-import java.util.Comparator;
-
-/**
- *
- * @author Sebastian Sdorra
- * @since 1.6
- */
-public class PluginInformationComparator
- implements Comparator, Serializable
-{
-
- /** Field description */
- public static final PluginInformationComparator INSTANCE =
- new PluginInformationComparator();
-
- /** Field description */
- private static final long serialVersionUID = -8339752498853225668L;
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param plugin
- * @param other
- *
- * @return
- */
- @Override
- public int compare(PluginInformation plugin, PluginInformation other)
- {
- int result = 0;
-
- result = Util.compare(plugin.getGroupId(), other.getGroupId());
-
- if (result == 0)
- {
- result = Util.compare(plugin.getArtifactId(), other.getArtifactId());
-
- if (result == 0)
- {
- PluginState state = plugin.getState();
- PluginState otherState = other.getState();
-
- if ((state != null) && (otherState != null))
- {
- result = state.getCompareValue() - otherState.getCompareValue();
- }
- else if ((state == null) && (otherState != null))
- {
- result = 1;
- }
- else if ((state != null) && (otherState == null))
- {
- result = -1;
- }
- }
- }
-
- return result;
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginLoader.java b/scm-core/src/main/java/sonia/scm/plugin/PluginLoader.java
index a843bea773..e82d945024 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginLoader.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/PluginLoader.java
@@ -33,6 +33,8 @@
package sonia.scm.plugin;
+//~--- non-JDK imports --------------------------------------------------------
+
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
@@ -66,7 +68,7 @@ public interface PluginLoader
*
* @return
*/
- public Collection getInstalledPlugins();
+ public Collection getInstalledPlugins();
/**
* Returns a {@link ClassLoader} which is able to load classes and resources
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginManager.java b/scm-core/src/main/java/sonia/scm/plugin/PluginManager.java
index b1ec502fc4..4c8fcd7306 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginManager.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/PluginManager.java
@@ -33,113 +33,81 @@
package sonia.scm.plugin;
-//~--- JDK imports ------------------------------------------------------------
-
-import com.google.common.base.Predicate;
-import java.io.IOException;
-import java.io.InputStream;
-
-import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
/**
+ * The plugin manager is responsible for plugin related tasks, such as install, uninstall or updating.
*
* @author Sebastian Sdorra
*/
-public interface PluginManager
-{
+public interface PluginManager {
/**
- * Method description
- *
+ * Returns the available plugin with the given name.
+ * @param name of plugin
+ * @return optional available plugin.
*/
- public void clearCache();
+ Optional getAvailable(String name);
/**
- * Method description
- *
- *
- * @param id
+ * Returns the installed plugin with the given name.
+ * @param name of plugin
+ * @return optional installed plugin.
*/
- public void install(String id);
+ Optional getInstalled(String name);
+
/**
- * Installs a plugin package from a inputstream.
+ * Returns all installed plugins.
*
- *
- * @param packageStream package input stream
- *
- * @throws IOException
- * @since 1.21
+ * @return a list of installed plugins.
*/
- public void installPackage(InputStream packageStream) throws IOException;
+ List getInstalled();
/**
- * Method description
+ * Returns all available plugins. The list contains the plugins which are loaded from the plugin center, but without
+ * the installed plugins.
*
- *
- * @param id
+ * @return a list of available plugins.
*/
- public void uninstall(String id);
+ List getAvailable();
/**
- * Method description
+ * Returns all updatable plugins.
*
- *
- * @param id
+ * @return a list of updatable plugins.
*/
- public void update(String id);
-
- //~--- get methods ----------------------------------------------------------
+ List getUpdatable();
/**
- * Method description
+ * Installs the plugin with the given name from the list of available plugins.
*
- *
- * @param id
- *
- * @return
+ * @param name plugin name
+ * @param restartAfterInstallation restart context after plugin installation
*/
- public PluginInformation get(String id);
+ void install(String name, boolean restartAfterInstallation);
/**
- * Method description
+ * Marks the plugin with the given name for uninstall.
*
- *
- * @param filter
- *
- * @return
+ * @param name plugin name
+ * @param restartAfterInstallation restart context after plugin has been marked to really uninstall the plugin
*/
- public Collection get(Predicate filter);
+ void uninstall(String name, boolean restartAfterInstallation);
/**
- * Method description
- *
- *
- * @return
+ * Install all pending plugins and restart the scm context.
*/
- public Collection getAll();
+ void executePendingAndRestart();
/**
- * Method description
- *
- *
- * @return
+ * Cancel all pending plugins.
*/
- public Collection getAvailable();
+ void cancelPending();
/**
- * Method description
- *
- *
- * @return
+ * Update all installed plugins.
*/
- public Collection getAvailableUpdates();
-
- /**
- * Method description
- *
- *
- * @return
- */
- public Collection getInstalled();
+ void updateAll();
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginRepository.java b/scm-core/src/main/java/sonia/scm/plugin/PluginRepository.java
deleted file mode 100644
index c75e555d9f..0000000000
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginRepository.java
+++ /dev/null
@@ -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.plugin;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-import java.io.Serializable;
-
-//~--- JDK imports ------------------------------------------------------------
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class PluginRepository implements Serializable
-{
-
- /** Field description */
- private static final long serialVersionUID = -9504354306304731L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
- PluginRepository() {}
-
- /**
- * Constructs ...
- *
- *
- * @param id
- * @param url
- */
- public PluginRepository(String id, String url)
- {
- this.id = id;
- this.url = url;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param obj
- *
- * @return
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
- return false;
- }
-
- if (getClass() != obj.getClass())
- {
- return false;
- }
-
- final PluginRepository other = (PluginRepository) obj;
-
- return Objects.equal(id, other.id) && Objects.equal(url, other.url);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public int hashCode()
- {
- return Objects.hashCode(id, url);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String toString()
- {
- return MoreObjects.toStringHelper(this)
- .add("id", id)
- .add("url", url)
- .toString();
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getUrl()
- {
- return url;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String id;
-
- /** Field description */
- private String url;
-}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginResources.java b/scm-core/src/main/java/sonia/scm/plugin/PluginResources.java
index c6c8b3aead..07e35e0e4f 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginResources.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/PluginResources.java
@@ -125,9 +125,9 @@ public class PluginResources
{
//J-
return MoreObjects.toStringHelper(this)
- .add("scriptResources", scriptResources)
- .add("stylesheetResources", stylesheetResources)
- .toString();
+ .add("scriptResources", scriptResources)
+ .add("stylesheetResources", stylesheetResources)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginState.java b/scm-core/src/main/java/sonia/scm/plugin/PluginState.java
deleted file mode 100644
index 39803d3455..0000000000
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginState.java
+++ /dev/null
@@ -1,74 +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.plugin;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public enum PluginState
-{
- CORE(100), AVAILABLE(60), INSTALLED(80), NEWER_VERSION_INSTALLED(20),
- UPDATE_AVAILABLE(40);
-
- /**
- * Constructs ...
- *
- *
- * @param compareValue
- */
- private PluginState(int compareValue)
- {
- this.compareValue = compareValue;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @since 1.6
- * @return
- */
- public int getCompareValue()
- {
- return compareValue;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private final int compareValue;
-}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/PluginWrapper.java b/scm-core/src/main/java/sonia/scm/plugin/PluginWrapper.java
deleted file mode 100644
index 46c3a4a980..0000000000
--- a/scm-core/src/main/java/sonia/scm/plugin/PluginWrapper.java
+++ /dev/null
@@ -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.plugin;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.nio.file.Path;
-
-/**
- * Wrapper for a {@link Plugin}. The wrapper holds the directory,
- * {@link ClassLoader} and {@link WebResourceLoader} of a plugin.
- *
- * @author Sebastian Sdorra
- * @since 2.0.0
- */
-public final class PluginWrapper
-{
-
- /**
- * Constructs a new plugin wrapper.
- *
- * @param plugin wrapped plugin
- * @param classLoader plugin class loader
- * @param webResourceLoader web resource loader
- * @param directory plugin directory
- */
- public PluginWrapper(Plugin plugin, ClassLoader classLoader,
- WebResourceLoader webResourceLoader, Path directory)
- {
- this.plugin = plugin;
- this.classLoader = classLoader;
- this.webResourceLoader = webResourceLoader;
- this.directory = directory;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Returns plugin class loader.
- *
- *
- * @return plugin class loader
- */
- public ClassLoader getClassLoader()
- {
- return classLoader;
- }
-
- /**
- * Returns plugin directory.
- *
- *
- * @return plugin directory
- */
- public Path getDirectory()
- {
- return directory;
- }
-
- /**
- * Returns the id of the plugin.
- *
- *
- * @return id of plugin
- */
- public String getId()
- {
- return plugin.getInformation().getId();
- }
-
- /**
- * Returns the plugin.
- *
- *
- * @return plugin
- */
- public Plugin getPlugin()
- {
- return plugin;
- }
-
- /**
- * Returns the {@link WebResourceLoader} for this plugin.
- *
- *
- * @return web resource loader
- */
- public WebResourceLoader getWebResourceLoader()
- {
- return webResourceLoader;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** plugin class loader */
- private final ClassLoader classLoader;
-
- /** plugin directory */
- private final Path directory;
-
- /** plugin */
- private final Plugin plugin;
-
- /** plugin web resource loader */
- private final WebResourceLoader webResourceLoader;
-}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/Plugins.java b/scm-core/src/main/java/sonia/scm/plugin/Plugins.java
index 6359850712..f33a254581 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/Plugins.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/Plugins.java
@@ -65,7 +65,7 @@ public final class Plugins
{
try
{
- context = JAXBContext.newInstance(Plugin.class, ScmModule.class);
+ context = JAXBContext.newInstance(InstalledPluginDescriptor.class, ScmModule.class);
}
catch (JAXBException ex)
{
@@ -91,7 +91,7 @@ public final class Plugins
*
* @return
*/
- public static Plugin parsePluginDescriptor(Path path)
+ public static InstalledPluginDescriptor parsePluginDescriptor(Path path)
{
return parsePluginDescriptor(Files.asByteSource(path.toFile()));
}
@@ -104,15 +104,15 @@ public final class Plugins
*
* @return
*/
- public static Plugin parsePluginDescriptor(ByteSource data)
+ public static InstalledPluginDescriptor parsePluginDescriptor(ByteSource data)
{
Preconditions.checkNotNull(data, "data parameter is required");
- Plugin plugin;
+ InstalledPluginDescriptor plugin;
try (InputStream stream = data.openStream())
{
- plugin = (Plugin) context.createUnmarshaller().unmarshal(stream);
+ plugin = (InstalledPluginDescriptor) context.createUnmarshaller().unmarshal(stream);
}
catch (JAXBException ex)
{
diff --git a/scm-core/src/main/java/sonia/scm/plugin/SmpArchive.java b/scm-core/src/main/java/sonia/scm/plugin/SmpArchive.java
index 63d5e8fb8f..e1ea622bdf 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/SmpArchive.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/SmpArchive.java
@@ -206,7 +206,7 @@ public final class SmpArchive
*
* @throws IOException
*/
- public Plugin getPlugin() throws IOException
+ public InstalledPluginDescriptor getPlugin() throws IOException
{
if (plugin == null)
{
@@ -219,16 +219,10 @@ public final class SmpArchive
throw new PluginException("could not find information section");
}
- if (Strings.isNullOrEmpty(info.getGroupId()))
+ if (Strings.isNullOrEmpty(info.getName()))
{
throw new PluginException(
- "could not find groupId in plugin descriptor");
- }
-
- if (Strings.isNullOrEmpty(info.getArtifactId()))
- {
- throw new PluginException(
- "could not find artifactId in plugin descriptor");
+ "could not find name in plugin descriptor");
}
if (Strings.isNullOrEmpty(info.getVersion()))
@@ -251,9 +245,9 @@ public final class SmpArchive
*
* @throws IOException
*/
- private Plugin createPlugin() throws IOException
+ private InstalledPluginDescriptor createPlugin() throws IOException
{
- Plugin p = null;
+ InstalledPluginDescriptor p = null;
NonClosingZipInputStream zis = null;
try
@@ -418,5 +412,5 @@ public final class SmpArchive
private final ByteSource archive;
/** Field description */
- private Plugin plugin;
+ private InstalledPluginDescriptor plugin;
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/StatePluginPredicate.java b/scm-core/src/main/java/sonia/scm/plugin/StatePluginPredicate.java
deleted file mode 100644
index ef7836f74a..0000000000
--- a/scm-core/src/main/java/sonia/scm/plugin/StatePluginPredicate.java
+++ /dev/null
@@ -1,78 +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.plugin;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import com.google.common.base.Predicate;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class StatePluginPredicate implements Predicate
-{
-
- /**
- * Constructs ...
- *
- *
- * @param state
- */
- public StatePluginPredicate(PluginState state)
- {
- this.state = state;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param plugin
- *
- * @return
- */
- @Override
- public boolean apply(PluginInformation plugin)
- {
- return state == plugin.getState();
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private final PluginState state;
-}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/SubscriberElement.java b/scm-core/src/main/java/sonia/scm/plugin/SubscriberElement.java
index 75c83003ce..5cc98d0bf9 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/SubscriberElement.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/SubscriberElement.java
@@ -36,13 +36,13 @@ package sonia.scm.plugin;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-//~--- 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;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -128,10 +128,10 @@ public final class SubscriberElement
{
//J-
return MoreObjects.toStringHelper(this)
- .add("eventClass", eventClass)
- .add("subscriberClass", subscriberClass)
- .add("description", description)
- .toString();
+ .add("eventClass", eventClass)
+ .add("subscriberClass", subscriberClass)
+ .add("description", description)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/WebResourceLoader.java b/scm-core/src/main/java/sonia/scm/plugin/WebResourceLoader.java
index 94b31ac844..454003c922 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/WebResourceLoader.java
+++ b/scm-core/src/main/java/sonia/scm/plugin/WebResourceLoader.java
@@ -33,9 +33,8 @@ package sonia.scm.plugin;
//~--- JDK imports ------------------------------------------------------------
-import java.net.URL;
-
import javax.servlet.ServletContext;
+import java.net.URL;
/**
* The WebResourceLoader is able to load web resources. The resources are loaded
@@ -53,9 +52,11 @@ public interface WebResourceLoader
* Returns a {@link URL} for the given path. The method will return null if no
* resources could be found for the given path.
*
+ * Note: The path is a web path and uses "/" as path separator
+ *
* @param path resource path
*
* @return url object for the given path or null
*/
- public URL getResource(String path);
+ URL getResource(String path);
}
diff --git a/scm-core/src/main/java/sonia/scm/protocolcommand/CommandContext.java b/scm-core/src/main/java/sonia/scm/protocolcommand/CommandContext.java
new file mode 100644
index 0000000000..44a1cce95a
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/protocolcommand/CommandContext.java
@@ -0,0 +1,20 @@
+package sonia.scm.protocolcommand;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+@Getter
+@AllArgsConstructor
+public class CommandContext {
+
+ private String command;
+ private String[] args;
+
+ private InputStream inputStream;
+ private OutputStream outputStream;
+ private OutputStream errorStream;
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/protocolcommand/CommandInterpreter.java b/scm-core/src/main/java/sonia/scm/protocolcommand/CommandInterpreter.java
new file mode 100644
index 0000000000..24bf7d30fa
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/protocolcommand/CommandInterpreter.java
@@ -0,0 +1,10 @@
+package sonia.scm.protocolcommand;
+
+public interface CommandInterpreter {
+
+ String[] getParsedArgs();
+
+ ScmCommandProtocol getProtocolHandler();
+
+ RepositoryContextResolver getRepositoryContextResolver();
+}
diff --git a/scm-core/src/main/java/sonia/scm/protocolcommand/CommandInterpreterFactory.java b/scm-core/src/main/java/sonia/scm/protocolcommand/CommandInterpreterFactory.java
new file mode 100644
index 0000000000..9d6bfa1d7f
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/protocolcommand/CommandInterpreterFactory.java
@@ -0,0 +1,10 @@
+package sonia.scm.protocolcommand;
+
+import sonia.scm.plugin.ExtensionPoint;
+
+import java.util.Optional;
+
+@ExtensionPoint
+public interface CommandInterpreterFactory {
+ Optional canHandle(String command);
+}
diff --git a/scm-core/src/main/java/sonia/scm/protocolcommand/RepositoryContext.java b/scm-core/src/main/java/sonia/scm/protocolcommand/RepositoryContext.java
new file mode 100644
index 0000000000..a64d5a6047
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/protocolcommand/RepositoryContext.java
@@ -0,0 +1,23 @@
+package sonia.scm.protocolcommand;
+
+import sonia.scm.repository.Repository;
+
+import java.nio.file.Path;
+
+public class RepositoryContext {
+ private Repository repository;
+ private Path directory;
+
+ public RepositoryContext(Repository repository, Path directory) {
+ this.repository = repository;
+ this.directory = directory;
+ }
+
+ public Repository getRepository() {
+ return repository;
+ }
+
+ public Path getDirectory() {
+ return directory;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/protocolcommand/RepositoryContextResolver.java b/scm-core/src/main/java/sonia/scm/protocolcommand/RepositoryContextResolver.java
new file mode 100644
index 0000000000..2c48ece185
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/protocolcommand/RepositoryContextResolver.java
@@ -0,0 +1,8 @@
+package sonia.scm.protocolcommand;
+
+@FunctionalInterface
+public interface RepositoryContextResolver {
+
+ RepositoryContext resolve(String[] args);
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/protocolcommand/ScmCommandProtocol.java b/scm-core/src/main/java/sonia/scm/protocolcommand/ScmCommandProtocol.java
new file mode 100644
index 0000000000..e7dbf65cad
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/protocolcommand/ScmCommandProtocol.java
@@ -0,0 +1,9 @@
+package sonia.scm.protocolcommand;
+
+import java.io.IOException;
+
+public interface ScmCommandProtocol {
+
+ void handle(CommandContext context, RepositoryContext repositoryContext) throws IOException;
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/AbstactImportHandler.java b/scm-core/src/main/java/sonia/scm/repository/AbstactImportHandler.java
index 958280a39b..63d4638ab8 100644
--- a/scm-core/src/main/java/sonia/scm/repository/AbstactImportHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/AbstactImportHandler.java
@@ -35,20 +35,16 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
-import com.google.common.base.Throwables;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.repository.ImportResult.Builder;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.File;
import java.io.IOException;
-
import java.util.List;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* Abstract base class for directory based {@link ImportHandler} and
* {@link AdvancedImportHandler}.
@@ -89,9 +85,7 @@ public abstract class AbstactImportHandler implements AdvancedImportHandler
* {@inheritDoc}
*/
@Override
- public List importRepositories(RepositoryManager manager)
- throws IOException, RepositoryException
- {
+ public List importRepositories(RepositoryManager manager) throws IOException {
return doRepositoryImport(manager, true).getImportedDirectories();
}
@@ -101,16 +95,7 @@ public abstract class AbstactImportHandler implements AdvancedImportHandler
@Override
public ImportResult importRepositoriesFromDirectory(RepositoryManager manager)
{
- try
- {
- return doRepositoryImport(manager, false);
- }
- catch (IOException | RepositoryException ex)
- {
-
- // should never happen
- throw Throwables.propagate(ex);
- }
+ return doRepositoryImport(manager, false);
}
/**
@@ -123,16 +108,11 @@ public abstract class AbstactImportHandler implements AdvancedImportHandler
* @return repository
*
* @throws IOException
- * @throws RepositoryException
*/
- protected Repository createRepository(File repositoryDirectory,
- String repositoryName)
- throws IOException, RepositoryException
- {
+ protected Repository createRepository(File repositoryDirectory, String repositoryName) throws IOException {
Repository repository = new Repository();
repository.setName(repositoryName);
- repository.setPublicReadable(false);
repository.setType(getTypeName());
return repository;
@@ -148,33 +128,30 @@ public abstract class AbstactImportHandler implements AdvancedImportHandler
* @return import result
*
* @throws IOException
- * @throws RepositoryException
*/
- private ImportResult doRepositoryImport(RepositoryManager manager,
- boolean throwExceptions)
- throws IOException, RepositoryException
- {
+ private ImportResult doRepositoryImport(RepositoryManager manager, boolean throwExceptions) {
Builder builder = ImportResult.builder();
logger.trace("search for repositories to import");
- try
- {
-
- List repositoryNames =
- RepositoryUtil.getRepositoryNames(getRepositoryHandler(),
- getDirectoryNames());
-
- for (String repositoryName : repositoryNames)
- {
- importRepository(manager, builder, throwExceptions, repositoryName);
- }
-
- }
- catch (IOException ex)
- {
- handleException(ex, throwExceptions);
- }
+ // TODO #8783
+// try
+// {
+//
+// List repositoryNames =
+// RepositoryUtil.getRepositoryNames(getRepositoryHandler(),
+// getDirectoryNames());
+//
+// for (String repositoryName : repositoryNames)
+// {
+// importRepository(manager, builder, throwExceptions, repositoryName);
+// }
+//
+// }
+// catch (IOException ex)
+// {
+// handleException(ex, throwExceptions);
+// }
return builder.build();
}
@@ -208,93 +185,53 @@ public abstract class AbstactImportHandler implements AdvancedImportHandler
* @param manager
* @param builder
* @param throwExceptions
- * @param repositoryName
+ * @param directoryName
*
* @throws IOException
- * @throws RepositoryException
*/
private void importRepository(RepositoryManager manager, Builder builder,
- boolean throwExceptions, String repositoryName)
- throws IOException, RepositoryException
+ boolean throwExceptions, String directoryName)
+ throws IOException
{
- logger.trace("check repository {} for import", repositoryName);
+ logger.trace("check repository {} for import", directoryName);
- Repository repository = manager.get(getTypeName(), repositoryName);
-
- if (repository == null)
- {
- try
- {
- importRepository(manager, repositoryName);
- builder.addImportedDirectory(repositoryName);
- }
- catch (IOException ex)
- {
- builder.addFailedDirectory(repositoryName);
- handleException(ex, throwExceptions);
- }
- catch (IllegalStateException ex)
- {
- builder.addFailedDirectory(repositoryName);
- handleException(ex, throwExceptions);
- }
- catch (RepositoryException ex)
- {
- builder.addFailedDirectory(repositoryName);
- handleException(ex, throwExceptions);
- }
- }
- else if (logger.isDebugEnabled())
- {
- logger.debug("repository {} is allready managed", repositoryName);
- }
+ // TODO #8783
+//
+// Repository repository = manager.get(namespaceAndName);
+//
+// if (repository == null)
+// {
+// try
+// {
+// importRepository(manager, repositoryName);
+// builder.addImportedDirectory(repositoryName);
+// }
+// catch (IOException ex)
+// {
+// builder.addFailedDirectory(repositoryName);
+// handleException(ex, throwExceptions);
+// }
+// catch (IllegalStateException ex)
+// {
+// builder.addFailedDirectory(repositoryName);
+// handleException(ex, throwExceptions);
+// }
+// catch (RepositoryException ex)
+// {
+// builder.addFailedDirectory(repositoryName);
+// handleException(ex, throwExceptions);
+// }
+// }
+// else if (logger.isDebugEnabled())
+// {
+// logger.debug("repository {} is already managed", repositoryName);
+// }
}
- /**
- * Method description
- *
- *
- * @param manager
- * @param repositoryName
- *
- *
- * @return
- * @throws IOException
- * @throws RepositoryException
- */
- private void importRepository(RepositoryManager manager,
- String repositoryName)
- throws IOException, RepositoryException
- {
- Repository repository =
- createRepository(getRepositoryDirectory(repositoryName), repositoryName);
- if (logger.isInfoEnabled())
- {
- logger.info("import repository {} of type {}", repositoryName,
- getTypeName());
- }
-
- manager.importRepository(repository);
- }
//~--- get methods ----------------------------------------------------------
- /**
- * Method description
- *
- *
- * @param repositoryName
- *
- * @return
- */
- private File getRepositoryDirectory(String repositoryName)
- {
- return new File(
- getRepositoryHandler().getConfig().getRepositoryDirectory(),
- repositoryName);
- }
-
/**
* Method description
*
diff --git a/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java b/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java
index 5ad5d0f9ca..1e9cc3d374 100644
--- a/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java
@@ -38,7 +38,7 @@ package sonia.scm.repository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import sonia.scm.NotSupportedFeatuerException;
+import sonia.scm.FeatureNotSupportedException;
import sonia.scm.SCMContextProvider;
import sonia.scm.event.ScmEventBus;
@@ -56,7 +56,7 @@ import sonia.scm.store.ConfigurationStoreFactory;
*
* @param
*/
-public abstract class AbstractRepositoryHandler
+public abstract class AbstractRepositoryHandler
implements RepositoryHandler
{
@@ -72,9 +72,11 @@ public abstract class AbstractRepositoryHandler(config));
+ new RepositoryHandlerConfigChangedEvent(config));
}
//~--- fields ---------------------------------------------------------------
diff --git a/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryRoleManager.java b/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryRoleManager.java
new file mode 100644
index 0000000000..1db0065e8b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryRoleManager.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of SCM-Manager; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+
+
+package sonia.scm.repository;
+
+import sonia.scm.HandlerEventType;
+import sonia.scm.event.ScmEventBus;
+
+/**
+ * Abstract base class for {@link RepositoryRoleManager} implementations. This class
+ * implements the listener methods of the {@link RepositoryRoleManager} interface.
+ */
+public abstract class AbstractRepositoryRoleManager implements RepositoryRoleManager {
+
+ /**
+ * Send a {@link RepositoryRoleEvent} to the {@link ScmEventBus}.
+ *
+ * @param event type of change event
+ * @param repositoryRole repositoryRole that has changed
+ * @param oldRepositoryRole old repositoryRole
+ */
+ protected void fireEvent(HandlerEventType event, RepositoryRole repositoryRole, RepositoryRole oldRepositoryRole)
+ {
+ fireEvent(new RepositoryRoleModificationEvent(event, repositoryRole, oldRepositoryRole));
+ }
+
+ /**
+ * Creates a new {@link RepositoryRoleEvent} and calls {@link #fireEvent(RepositoryRoleEvent)}.
+ *
+ * @param repositoryRole repositoryRole that has changed
+ * @param event type of change event
+ */
+ protected void fireEvent(HandlerEventType event, RepositoryRole repositoryRole)
+ {
+ fireEvent(new RepositoryRoleEvent(event, repositoryRole));
+ }
+
+ /**
+ * Send a {@link RepositoryRoleEvent} to the {@link ScmEventBus}.
+ *
+ * @param event repositoryRole event
+ * @since 1.48
+ */
+ protected void fireEvent(RepositoryRoleEvent event)
+ {
+ ScmEventBus.getInstance().post(event);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/AbstractSimpleRepositoryHandler.java b/scm-core/src/main/java/sonia/scm/repository/AbstractSimpleRepositoryHandler.java
index 670cab93e1..62dfd476af 100644
--- a/scm-core/src/main/java/sonia/scm/repository/AbstractSimpleRepositoryHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/AbstractSimpleRepositoryHandler.java
@@ -1,19 +1,19 @@
/**
* 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.
+ * 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.
+ * 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.
- *
+ * 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
@@ -24,466 +24,152 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* http://bitbucket.org/sdorra/scm-manager
- *
*/
-
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Charsets;
-import com.google.common.base.Throwables;
import com.google.common.io.Resources;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.ConfigurationException;
import sonia.scm.io.CommandResult;
import sonia.scm.io.ExtendedCommand;
-import sonia.scm.io.FileSystem;
-import sonia.scm.util.IOUtil;
-
-//~--- JDK imports ------------------------------------------------------------
+import sonia.scm.plugin.PluginLoader;
+import sonia.scm.store.ConfigurationStoreFactory;
import java.io.File;
import java.io.IOException;
-
import java.net.URL;
-import sonia.scm.store.ConfigurationStoreFactory;
+import java.nio.file.Path;
+
+//~--- JDK imports ------------------------------------------------------------
/**
- *
- * @author Sebastian Sdorra
- *
- *
* @param
+ * @author Sebastian Sdorra
*/
-public abstract class AbstractSimpleRepositoryHandler
- extends AbstractRepositoryHandler implements RepositoryDirectoryHandler
-{
+public abstract class AbstractSimpleRepositoryHandler
+ extends AbstractRepositoryHandler implements RepositoryDirectoryHandler {
- /** Field description */
public static final String DEFAULT_VERSION_INFORMATION = "unknown";
- /** Field description */
- public static final String DIRECTORY_REPOSITORY = "repositories";
-
- /** Field description */
- public static final String DOT = ".";
-
- /** the logger for AbstractSimpleRepositoryHandler */
+ /**
+ * the logger for AbstractSimpleRepositoryHandler
+ */
private static final Logger logger =
LoggerFactory.getLogger(AbstractSimpleRepositoryHandler.class);
- //~--- constructors ---------------------------------------------------------
+ private final RepositoryLocationResolver repositoryLocationResolver;
+ private final PluginLoader pluginLoader;
- /**
- * Constructs ...
- *
- *
- * @param storeFactory
- * @param fileSystem
- */
public AbstractSimpleRepositoryHandler(ConfigurationStoreFactory storeFactory,
- FileSystem fileSystem)
- {
+ RepositoryLocationResolver repositoryLocationResolver,
+ PluginLoader pluginLoader) {
super(storeFactory);
- this.fileSystem = fileSystem;
+ this.repositoryLocationResolver = repositoryLocationResolver;
+ this.pluginLoader = pluginLoader;
}
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @throws IOException
- * @throws RepositoryException
- */
@Override
- public void create(Repository repository)
- throws RepositoryException, IOException
- {
- File directory = getDirectory(repository);
-
- if (directory.exists())
- {
- throw RepositoryAlreadyExistsException.create(repository);
- }
-
- checkPath(directory);
-
- try
- {
- fileSystem.create(directory);
- create(repository, directory);
- postCreate(repository, directory);
- }
- catch (Exception ex)
- {
- if (directory.exists())
- {
- if (logger.isDebugEnabled())
- {
- logger.debug(
- "delete repository directory {}, because of failed repository creation",
- directory);
- }
-
- fileSystem.destroy(directory);
- }
-
- Throwables.propagateIfPossible(ex, RepositoryException.class,
- IOException.class);
+ public Repository create(Repository repository) {
+ File nativeDirectory = resolveNativeDirectory(repository.getId());
+ try {
+ create(repository, nativeDirectory);
+ postCreate(repository, nativeDirectory);
+ } catch (IOException e) {
+ throw new InternalRepositoryException(repository, "could not create native repository directory", e);
}
+ return repository;
}
- /**
- * Method description
- *
- *
- *
- * @param repository
- * @return
- */
@Override
- public String createResourcePath(Repository repository)
- {
- StringBuilder path = new StringBuilder("/");
-
- path.append(getType().getName()).append("/").append(repository.getName());
-
- return path.toString();
+ public void delete(Repository repository) {
}
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @throws IOException
- * @throws RepositoryException
- */
@Override
- public void delete(Repository repository)
- throws RepositoryException, IOException
- {
- File directory = getDirectory(repository);
-
- if (directory.exists())
- {
- fileSystem.destroy(directory);
- cleanupEmptyDirectories(config.getRepositoryDirectory(),
- directory.getParentFile());
- }
- else if (logger.isWarnEnabled())
- {
- logger.warn("repository {} not found", repository);
- }
- }
-
- /**
- * Method description
- *
- */
- @Override
- public void loadConfig()
- {
+ public void loadConfig() {
super.loadConfig();
- if (config == null)
- {
+ if (config == null) {
config = createInitialConfig();
-
- if (config != null)
- {
- File repositoryDirectory = config.getRepositoryDirectory();
-
- if (repositoryDirectory == null)
- {
- repositoryDirectory = new File(
- baseDirectory,
- DIRECTORY_REPOSITORY.concat(File.separator).concat(
- getType().getName()));
- config.setRepositoryDirectory(repositoryDirectory);
- }
-
- IOUtil.mkdirs(repositoryDirectory);
- storeConfig();
- }
}
}
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @throws IOException
- * @throws RepositoryException
- */
@Override
- public void modify(Repository repository)
- throws RepositoryException, IOException
- {
+ public void modify(Repository repository) {
- // nothing todo
+ // nothing to do
}
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @return
- */
@Override
- public File getDirectory(Repository repository)
- {
- File directory = null;
-
- if (isConfigured())
- {
- File repositoryDirectory = config.getRepositoryDirectory();
-
- directory = new File(repositoryDirectory, repository.getName());
-
- if (!IOUtil.isChild(repositoryDirectory, directory))
- {
- StringBuilder msg = new StringBuilder(directory.getPath());
-
- msg.append("is not a child of ").append(repositoryDirectory.getPath());
-
- throw new ConfigurationException(msg.toString());
- }
- }
- else
- {
+ public File getDirectory(String repositoryId) {
+ File directory;
+ if (isConfigured()) {
+ directory = resolveNativeDirectory(repositoryId);
+ } else {
throw new ConfigurationException("RepositoryHandler is not configured");
}
-
return directory;
}
- /**
- * Method description
- *
- *
- * @return
- */
@Override
- public String getVersionInformation()
- {
+ public String getVersionInformation() {
return DEFAULT_VERSION_INFORMATION;
}
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param repository
- * @param directory
- *
- * @return
- */
protected ExtendedCommand buildCreateCommand(Repository repository,
- File directory)
- {
+ File directory) {
throw new UnsupportedOperationException("method is not implemented");
}
- /**
- * Method description
- *
- *
- * @param repository
- * @param directory
- *
- * @throws IOException
- * @throws RepositoryException
- */
protected void create(Repository repository, File directory)
- throws RepositoryException, IOException
- {
+ throws IOException {
ExtendedCommand cmd = buildCreateCommand(repository, directory);
CommandResult result = cmd.execute();
- if (!result.isSuccessfull())
- {
- StringBuilder msg = new StringBuilder("command exit with error ");
-
- msg.append(result.getReturnCode()).append(" and message: '");
- msg.append(result.getOutput()).append("'");
-
- throw new RepositoryException(msg.toString());
+ if (!result.isSuccessfull()) {
+ throw new IOException(("command exit with error " + result.getReturnCode() + " and message: '" + result.getOutput() + "'"));
}
}
- /**
- * Method description
- *
- *
- * @return
- */
- protected C createInitialConfig()
- {
+ protected C createInitialConfig() {
return null;
}
- /**
- * Method description
- *
- *
- * @param repository
- * @param directory
- *
- * @throws IOException
- * @throws RepositoryException
- */
protected void postCreate(Repository repository, File directory)
- throws IOException, RepositoryException {}
-
- //~--- get methods ----------------------------------------------------------
+ throws IOException {
+ }
/**
* Returns the content of a classpath resource or the given default content.
*
- *
- * @param resource path of a classpath resource
+ * @param resource path of a classpath resource
* @param defaultContent default content to return
- *
* @return content of a classpath resource or defaultContent
*/
- protected String getStringFromResource(String resource, String defaultContent)
- {
+ protected String getStringFromResource(String resource, String defaultContent) {
String content = defaultContent;
- try
- {
- URL url = Resources.getResource(resource);
+ try {
+ URL url = pluginLoader.getUberClassLoader().getResource(resource);
- if (url != null)
- {
+ if (url != null) {
content = Resources.toString(url, Charsets.UTF_8);
}
- }
- catch (IOException ex)
- {
+ } catch (IOException ex) {
logger.error("could not read resource", ex);
}
return content;
}
- /**
- * Returns true if the directory is a repository.
- *
- *
- * @param directory directory to check
- *
- * @return true if the directory is a repository
- * @since 1.9
- */
- protected boolean isRepository(File directory)
- {
- return new File(directory, DOT.concat(getType().getName())).exists();
+ private File resolveNativeDirectory(String repositoryId) {
+ return repositoryLocationResolver.create(Path.class).getLocation(repositoryId).resolve(REPOSITORIES_NATIVE_DIRECTORY).toFile();
}
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Check path for existing repositories
- *
- *
- * @param directory repository target directory
- *
- * @throws RepositoryAlreadyExistsException
- */
- private void checkPath(File directory) throws RepositoryAlreadyExistsException
- {
- File repositoryDirectory = config.getRepositoryDirectory();
- File parent = directory.getParentFile();
-
- while ((parent != null) &&!repositoryDirectory.equals(parent))
- {
- if (logger.isTraceEnabled())
- {
- logger.trace("check {} for existing repository", parent);
- }
-
- if (isRepository(parent))
- {
- if (logger.isErrorEnabled())
- {
- logger.error("parent path {} is a repository", parent);
- }
-
- StringBuilder buffer = new StringBuilder("repository with name ");
- buffer.append(directory.getName()).append(" already exists");
- throw new RepositoryAlreadyExistsException(buffer.toString());
- }
-
- parent = parent.getParentFile();
- }
- }
-
- /**
- * Method description
- *
- *
- * @param baseDirectory
- * @param directory
- */
- private void cleanupEmptyDirectories(File baseDirectory, File directory)
- {
- if (IOUtil.isChild(baseDirectory, directory))
- {
- if (IOUtil.isEmpty(directory))
- {
-
- // TODO use filesystem
- if (directory.delete())
- {
- if (logger.isInfoEnabled())
- {
- logger.info("successfully deleted directory {}", directory);
- }
-
- cleanupEmptyDirectories(baseDirectory, directory.getParentFile());
- }
- else if (logger.isWarnEnabled())
- {
- logger.warn("could not delete directory {}", directory);
- }
- }
- else if (logger.isDebugEnabled())
- {
- logger.debug("could not remove non empty directory {}", directory);
- }
- }
- else if (logger.isWarnEnabled())
- {
- logger.warn("directory {} is not a child of {}", directory,
- baseDirectory);
- }
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private FileSystem fileSystem;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/BasicRepositoryLocationResolver.java b/scm-core/src/main/java/sonia/scm/repository/BasicRepositoryLocationResolver.java
new file mode 100644
index 0000000000..c69b9a4a61
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/BasicRepositoryLocationResolver.java
@@ -0,0 +1,15 @@
+package sonia.scm.repository;
+
+public abstract class BasicRepositoryLocationResolver extends RepositoryLocationResolver {
+
+ private final Class type;
+
+ protected BasicRepositoryLocationResolver(Class type) {
+ this.type = type;
+ }
+
+ @Override
+ public boolean supportsLocationType(Class> type) {
+ return type.isAssignableFrom(this.type);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/BlameLine.java b/scm-core/src/main/java/sonia/scm/repository/BlameLine.java
index 771450874c..08bd2dad58 100644
--- a/scm-core/src/main/java/sonia/scm/repository/BlameLine.java
+++ b/scm-core/src/main/java/sonia/scm/repository/BlameLine.java
@@ -38,10 +38,10 @@ package sonia.scm.repository;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.Serializable;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* Single line of a file, in a {@link BlameResult}.
*
@@ -142,13 +142,13 @@ public class BlameLine implements Serializable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("lineNumber", lineNumber)
- .add("revision", revision)
- .add("author", author)
- .add("when", when)
- .add("code", code)
- .add("description", description)
- .toString();
+ .add("lineNumber", lineNumber)
+ .add("revision", revision)
+ .add("author", author)
+ .add("when", when)
+ .add("code", code)
+ .add("description", description)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/BlameResult.java b/scm-core/src/main/java/sonia/scm/repository/BlameResult.java
index c282aa92d1..58fafe9811 100644
--- a/scm-core/src/main/java/sonia/scm/repository/BlameResult.java
+++ b/scm-core/src/main/java/sonia/scm/repository/BlameResult.java
@@ -39,7 +39,11 @@ import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
-import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
@@ -159,9 +163,9 @@ public class BlameResult implements Serializable, Iterable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("total", total)
- .add("blameLines", blameLines)
- .toString();
+ .add("total", total)
+ .add("blameLines", blameLines)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Branch.java b/scm-core/src/main/java/sonia/scm/repository/Branch.java
index ca64085077..c0a7289912 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Branch.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Branch.java
@@ -66,7 +66,7 @@ public final class Branch implements Serializable
* This constructor should only be called from JAXB.
*
*/
- public Branch() {}
+ Branch() {}
/**
* Constructs a new branch.
@@ -75,10 +75,19 @@ public final class Branch implements Serializable
* @param name name of the branch
* @param revision latest revision of the branch
*/
- public Branch(String name, String revision)
+ Branch(String name, String revision, boolean defaultBranch)
{
this.name = name;
this.revision = revision;
+ this.defaultBranch = defaultBranch;
+ }
+
+ public static Branch normalBranch(String name, String revision) {
+ return new Branch(name, revision, false);
+ }
+
+ public static Branch defaultBranch(String name, String revision) {
+ return new Branch(name, revision, true);
}
//~--- methods --------------------------------------------------------------
@@ -107,7 +116,8 @@ public final class Branch implements Serializable
final Branch other = (Branch) obj;
return Objects.equal(name, other.name)
- && Objects.equal(revision, other.revision);
+ && Objects.equal(revision, other.revision)
+ && Objects.equal(defaultBranch, other.defaultBranch);
}
/**
@@ -133,9 +143,9 @@ public final class Branch implements Serializable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("name", name)
- .add("revision", revision)
- .toString();
+ .add("name", name)
+ .add("revision", revision)
+ .toString();
//J+
}
@@ -162,6 +172,10 @@ public final class Branch implements Serializable
return revision;
}
+ public boolean isDefaultBranch() {
+ return defaultBranch;
+ }
+
//~--- fields ---------------------------------------------------------------
/** name of the branch */
@@ -169,4 +183,6 @@ public final class Branch implements Serializable
/** Field description */
private String revision;
+
+ private boolean defaultBranch;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Branches.java b/scm-core/src/main/java/sonia/scm/repository/Branches.java
index c0dc88943c..1eb679908e 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Branches.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Branches.java
@@ -150,8 +150,8 @@ public final class Branches implements Iterable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("branches", branches)
- .toString();
+ .add("branches", branches)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/BrowserResult.java b/scm-core/src/main/java/sonia/scm/repository/BrowserResult.java
index 7b7944b0d1..44c6b963ad 100644
--- a/scm-core/src/main/java/sonia/scm/repository/BrowserResult.java
+++ b/scm-core/src/main/java/sonia/scm/repository/BrowserResult.java
@@ -1,19 +1,19 @@
/**
* 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.
+ * 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.
+ * 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.
- *
+ * 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
@@ -24,13 +24,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* http://bitbucket.org/sdorra/scm-manager
- *
*/
-
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
@@ -38,10 +36,10 @@ package sonia.scm.repository;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
-import java.util.Iterator;
-import java.util.List;
//~--- JDK imports ------------------------------------------------------------
@@ -52,224 +50,66 @@ import java.util.List;
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "browser-result")
-public class BrowserResult implements Iterable, Serializable
-{
+public class BrowserResult implements Serializable {
- /** Field description */
- private static final long serialVersionUID = 2818662048045182761L;
+ private String revision;
+ private String requestedRevision;
+ private FileObject file;
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
- public BrowserResult() {}
-
- /**
- * Constructs ...
- *
- *
- * @param revision
- * @param tag
- * @param branch
- * @param files
- */
- public BrowserResult(String revision, String tag, String branch,
- List files)
- {
- this.revision = revision;
- this.tag = tag;
- this.branch = branch;
- this.files = files;
+ public BrowserResult() {
}
- //~--- methods --------------------------------------------------------------
+ public BrowserResult(String revision, FileObject file) {
+ this(revision, revision, file);
+ }
+
+ public BrowserResult(String revision, String requestedRevision, FileObject file) {
+ this.revision = revision;
+ this.requestedRevision = requestedRevision;
+ this.file = file;
+ }
+
+ public String getRevision() {
+ return revision;
+ }
+
+ public String getRequestedRevision() {
+ return requestedRevision;
+ }
+
+ public FileObject getFile() {
+ return file;
+ }
- /**
- * {@inheritDoc}
- *
- *
- * @param obj
- *
- * @return
- */
@Override
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
+ public boolean equals(Object obj) {
+ if (obj == null) {
return false;
}
- if (getClass() != obj.getClass())
- {
+ if (getClass() != obj.getClass()) {
return false;
}
final BrowserResult other = (BrowserResult) obj;
return Objects.equal(revision, other.revision)
- && Objects.equal(tag, other.tag)
- && Objects.equal(branch, other.branch)
- && Objects.equal(files, other.files);
+ && Objects.equal(file, other.file);
}
- /**
- * {@inheritDoc}
- *
- *
- * @return
- */
@Override
- public int hashCode()
- {
- return Objects.hashCode(revision, tag, branch, files);
+ public int hashCode() {
+ return Objects.hashCode(revision, file);
}
- /**
- * Method description
- *
- *
- * @return
- */
+
@Override
- public Iterator iterator()
- {
- Iterator it = null;
-
- if (files != null)
- {
- it = files.iterator();
- }
-
- return it;
- }
-
- /**
- * {@inheritDoc}
- *
- *
- * @return
- */
- @Override
- public String toString()
- {
- //J-
+ public String toString() {
return MoreObjects.toStringHelper(this)
- .add("revision", revision)
- .add("tag", tag)
- .add("branch", branch)
- .add("files", files)
- .toString();
- //J+
+ .add("revision", revision)
+ .add("files", file)
+ .toString();
}
- //~--- get methods ----------------------------------------------------------
- /**
- * Method description
- *
- *
- * @return
- */
- public String getBranch()
- {
- return branch;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public List getFiles()
- {
- return files;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getRevision()
- {
- return revision;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getTag()
- {
- return tag;
- }
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param branch
- */
- public void setBranch(String branch)
- {
- this.branch = branch;
- }
-
- /**
- * Method description
- *
- *
- * @param files
- */
- public void setFiles(List files)
- {
- this.files = files;
- }
-
- /**
- * Method description
- *
- *
- * @param revision
- */
- public void setRevision(String revision)
- {
- this.revision = revision;
- }
-
- /**
- * Method description
- *
- *
- * @param tag
- */
- public void setTag(String tag)
- {
- this.tag = tag;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String branch;
-
- /** Field description */
- @XmlElement(name = "file")
- @XmlElementWrapper(name = "files")
- private List files;
-
- /** Field description */
- private String revision;
-
- /** Field description */
- private String tag;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Changeset.java b/scm-core/src/main/java/sonia/scm/repository/Changeset.java
index ce3fb5424b..7397fecabe 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Changeset.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Changeset.java
@@ -33,27 +33,19 @@
package sonia.scm.repository;
-//~--- non-JDK imports --------------------------------------------------------
-
import com.google.common.base.Objects;
-
import sonia.scm.BasicPropertiesAware;
-import sonia.scm.Validateable;
+import sonia.scm.ModelObject;
import sonia.scm.util.Util;
import sonia.scm.util.ValidationUtil;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.Serializable;
-
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
/**
* Represents a changeset/commit of a repository.
@@ -62,43 +54,52 @@ import javax.xml.bind.annotation.XmlRootElement;
*/
@XmlRootElement(name = "changeset")
@XmlAccessorType(XmlAccessType.FIELD)
-public class Changeset extends BasicPropertiesAware
- implements Validateable, Serializable
-{
+public class Changeset extends BasicPropertiesAware implements ModelObject {
- /** Field description */
private static final long serialVersionUID = -8373308448928993039L;
- //~--- constructors ---------------------------------------------------------
+ /**
+ * The author of the changeset
+ */
+ private Person author;
/**
- * Constructs a new instance of changeset.
- *
+ * The name of the branches on which the changeset was committed.
*/
+ private List branches;
+
+ /**
+ * The date when the changeset was committed
+ */
+ private Long date;
+
+ /**
+ * The text of the changeset description
+ */
+ private String description;
+
+ /**
+ * The changeset identification string
+ */
+ private String id;
+
+ /**
+ * parent changeset ids
+ */
+ private List parents;
+
+ /**
+ * The tags associated with the changeset
+ */
+ private List tags;
+
public Changeset() {}
- /**
- * Constructs a new instance of changeset.
- *
- *
- * @param id id of the changeset
- * @param date date of the changeset
- * @param author author of the changeset
- */
public Changeset(String id, Long date, Person author)
{
this(id, date, author, null);
}
- /**
- * Constructs a new instance of changeset.
- *
- *
- * @param id id of the changeset
- * @param date date of the changeset
- * @param author author of the changeset
- * @param description description of the changeset
- */
public Changeset(String id, Long date, Person author, String description)
{
this.id = id;
@@ -107,16 +108,6 @@ public class Changeset extends BasicPropertiesAware
this.description = description;
}
- //~--- methods --------------------------------------------------------------
-
- /**
- * {@inheritDoc}
- *
- *
- * @param obj
- *
- * @return
- */
@Override
public boolean equals(Object obj)
{
@@ -125,22 +116,20 @@ public class Changeset extends BasicPropertiesAware
return false;
}
- if (getClass() != obj.getClass())
- {
+ if (getClass() != obj.getClass()) {
return false;
}
final Changeset other = (Changeset) obj;
//J-
- return Objects.equal(id, other.id)
+ return Objects.equal(id, other.id)
&& Objects.equal(date, other.date)
&& Objects.equal(author, other.author)
&& Objects.equal(description, other.description)
&& Objects.equal(parents, other.parents)
&& Objects.equal(tags, other.tags)
&& Objects.equal(branches, other.branches)
- && Objects.equal(modifications, other.modifications)
&& Objects.equal(properties, other.properties);
//J+
}
@@ -155,7 +144,7 @@ public class Changeset extends BasicPropertiesAware
public int hashCode()
{
return Objects.hashCode(id, date, author, description, parents, tags,
- branches, modifications, properties);
+ branches, properties);
}
/**
@@ -187,15 +176,24 @@ public class Changeset extends BasicPropertiesAware
out.append("branches: ").append(Util.toString(branches)).append("\n");
out.append("tags: ").append(Util.toString(tags)).append("\n");
- if (modifications != null)
- {
- out.append("modifications: \n").append(modifications);
- }
-
return out.toString();
}
- //~--- get methods ----------------------------------------------------------
+
+ /**
+ * Returns a timestamp of the creation date of the {@link Changeset}.
+ *
+ * @return a timestamp of the creation date of the {@link Changeset}
+ */
+ public Long getCreationDate() {
+ return getDate();
+ }
+
+ @Override
+ public void setCreationDate(Long timestamp) {
+ this.setDate(timestamp);
+ }
+
/**
* Returns the author of the changeset.
@@ -203,14 +201,13 @@ public class Changeset extends BasicPropertiesAware
*
* @return author of the changeset
*/
- public Person getAuthor()
- {
+ public Person getAuthor() {
return author;
}
/**
- * Returns the branches of the changeset. In the most cases a changeset is
- * only related to one branch, but in the case of receive hooks it is possible
+ * Returns the branches of the changeset. In the most cases a changeset is
+ * only related to one branch, but in the case of receive hooks it is possible
* that a changeset is related to more than a branch.
*
*
@@ -220,7 +217,7 @@ public class Changeset extends BasicPropertiesAware
{
if (branches == null)
{
- branches = new ArrayList<>();
+ branches = new ArrayList();
}
return branches;
@@ -254,27 +251,28 @@ public class Changeset extends BasicPropertiesAware
*
* @return id of the changeset
*/
- public String getId()
- {
+ @Override
+ public String getId() {
return id;
}
- /**
- * Returns the file modifications, which was done with this changeset.
- *
- *
- * @return file modifications
- */
- public Modifications getModifications()
- {
- if (modifications == null)
- {
- modifications = new Modifications();
- }
-
- return modifications;
+ @Override
+ public void setLastModified(Long timestamp) {
+ throw new UnsupportedOperationException("changesets are immutable");
}
+ @Override
+ public Long getLastModified() {
+ return null;
+ }
+
+ @Override
+ public String getType() {
+ return "Changeset";
+ }
+
+
+
/**
* Return the ids of the parent changesets.
*
@@ -286,7 +284,7 @@ public class Changeset extends BasicPropertiesAware
{
if (parents == null)
{
- parents = new ArrayList<>();
+ parents = new ArrayList();
}
return parents;
@@ -302,7 +300,7 @@ public class Changeset extends BasicPropertiesAware
{
if (tags == null)
{
- tags = new ArrayList<>();
+ tags = new ArrayList();
}
return tags;
@@ -321,8 +319,6 @@ public class Changeset extends BasicPropertiesAware
&& (date != null);
}
- //~--- set methods ----------------------------------------------------------
-
/**
* Sets the author of the changeset.
*
@@ -378,17 +374,6 @@ public class Changeset extends BasicPropertiesAware
this.id = id;
}
- /**
- * Sets the file modification of the changeset.
- *
- *
- * @param modifications file modifications
- */
- public void setModifications(Modifications modifications)
- {
- this.modifications = modifications;
- }
-
/**
* Sets the parents of the changeset.
*
@@ -412,30 +397,4 @@ public class Changeset extends BasicPropertiesAware
this.tags = tags;
}
- //~--- fields ---------------------------------------------------------------
-
- /** The author of the changeset */
- private Person author;
-
- /** The name of the branches on which the changeset was committed. */
- private List branches;
-
- /** The date when the changeset was committed */
- private Long date;
-
- /** The text of the changeset description */
- private String description;
-
- /** The changeset identification string */
- private String id;
-
- /** List of files changed by this changeset */
- @XmlElement(name = "modifications")
- private Modifications modifications;
-
- /** parent changeset ids */
- private List parents;
-
- /** The tags associated with the changeset */
- private List tags;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java b/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java
index df261fbd46..ca1018b7aa 100644
--- a/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java
+++ b/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java
@@ -38,7 +38,11 @@ package sonia.scm.repository;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
@@ -78,6 +82,22 @@ public class ChangesetPagingResult implements Iterable, Serializable
{
this.total = total;
this.changesets = changesets;
+ this.branchName = null;
+ }
+
+ /**
+ * Constructs a new changeset paging result for a specific branch.
+ *
+ *
+ * @param total total number of changesets
+ * @param changesets current list of fetched changesets
+ * @param branchName branch name this result was created for
+ */
+ public ChangesetPagingResult(int total, List changesets, String branchName)
+ {
+ this.total = total;
+ this.changesets = changesets;
+ this.branchName = branchName;
}
//~--- methods --------------------------------------------------------------
@@ -152,9 +172,10 @@ public class ChangesetPagingResult implements Iterable, Serializable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("changesets", changesets)
- .add("total", total)
- .toString();
+ .add("changesets", changesets)
+ .add("total", total)
+ .add("branch", branchName)
+ .toString();
//J+
}
@@ -182,37 +203,35 @@ public class ChangesetPagingResult implements Iterable, Serializable
return total;
}
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Sets the current list of changesets.
- *
- *
- * @param changesets current list of changesets
- */
- public void setChangesets(List changesets)
+ void setChangesets(List changesets)
{
this.changesets = changesets;
}
- /**
- * Sets the total number of changesets
- *
- *
- * @param total total number of changesets
- */
- public void setTotal(int total)
+ void setTotal(int total)
{
this.total = total;
}
+ void setBranchName(String branchName) {
+ this.branchName = branchName;
+ }
+
+ /**
+ * Returns the branch name this result was created for. This can either be an explicit branch ("give me all
+ * changesets for branch xyz") or an implicit one ("give me the changesets for the default").
+ */
+ public String getBranchName() {
+ return branchName;
+ }
+
//~--- fields ---------------------------------------------------------------
- /** current list of changesets */
@XmlElement(name = "changeset")
@XmlElementWrapper(name = "changesets")
private List changesets;
- /** total number of changesets */
private int total;
+
+ private String branchName;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/DirectoryHealthCheck.java b/scm-core/src/main/java/sonia/scm/repository/DirectoryHealthCheck.java
index 0f329d89b2..71f47f2022 100644
--- a/scm-core/src/main/java/sonia/scm/repository/DirectoryHealthCheck.java
+++ b/scm-core/src/main/java/sonia/scm/repository/DirectoryHealthCheck.java
@@ -178,7 +178,7 @@ public abstract class DirectoryHealthCheck implements HealthCheck
else if (handler instanceof RepositoryDirectoryHandler)
{
File directory =
- ((RepositoryDirectoryHandler) handler).getDirectory(repository);
+ ((RepositoryDirectoryHandler) handler).getDirectory(repository.getId());
if (directory == null)
{
diff --git a/scm-core/src/main/java/sonia/scm/repository/EscapeUtil.java b/scm-core/src/main/java/sonia/scm/repository/EscapeUtil.java
deleted file mode 100644
index a06472256d..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/EscapeUtil.java
+++ /dev/null
@@ -1,203 +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.repository;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import com.google.common.collect.Lists;
-
-import org.apache.commons.lang.StringEscapeUtils;
-
-import sonia.scm.util.Util;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.util.List;
-
-/**
- *
- * @author Sebastian Sdorra
- * @since 1.15
- */
-public final class EscapeUtil
-{
-
- /**
- * Constructs ...
- *
- */
- private EscapeUtil() {}
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param result
- */
- public static void escape(BrowserResult result)
- {
- result.setBranch(escape(result.getBranch()));
- result.setTag(escape(result.getTag()));
-
- for (FileObject fo : result)
- {
- escape(fo);
- }
- }
-
- /**
- * Method description
- *
- *
- * @param result
- * @since 1.17
- */
- public static void escape(BlameResult result)
- {
- for (BlameLine line : result.getBlameLines())
- {
- escape(line);
- }
- }
-
- /**
- * Method description
- *
- *
- * @param line
- * @since 1.17
- */
- public static void escape(BlameLine line)
- {
- line.setDescription(escape(line.getDescription()));
- escape(line.getAuthor());
- }
-
- /**
- * Method description
- *
- *
- * @param fo
- */
- public static void escape(FileObject fo)
- {
- fo.setDescription(escape(fo.getDescription()));
- fo.setName(fo.getName());
- fo.setPath(fo.getPath());
- }
-
- /**
- * Method description
- *
- *
- * @param changeset
- */
- public static void escape(Changeset changeset)
- {
- changeset.setDescription(escape(changeset.getDescription()));
- escape(changeset.getAuthor());
- changeset.setBranches(escapeList(changeset.getBranches()));
- changeset.setTags(escapeList(changeset.getTags()));
- }
-
- /**
- * Method description
- *
- *
- * @param person
- * @since 1.17
- */
- public static void escape(Person person)
- {
- if (person != null)
- {
- person.setName(escape(person.getName()));
- person.setMail(escape(person.getMail()));
- }
- }
-
- /**
- * Method description
- *
- *
- * @param result
- */
- public static void escape(ChangesetPagingResult result)
- {
- for (Changeset c : result)
- {
- escape(c);
- }
- }
-
- /**
- * Method description
- *
- *
- * @param value
- *
- * @return
- */
- public static String escape(String value)
- {
- return StringEscapeUtils.escapeHtml(value);
- }
-
- /**
- * Method description
- *
- *
- * @param values
- *
- * @return
- */
- public static List escapeList(List values)
- {
- if (Util.isNotEmpty(values))
- {
- List newList = Lists.newArrayList();
-
- for (String v : values)
- {
- newList.add(StringEscapeUtils.escapeHtml(v));
- }
-
- values = newList;
- }
-
- return values;
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Feature.java b/scm-core/src/main/java/sonia/scm/repository/Feature.java
index 1db351267d..1bcaef4de5 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Feature.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Feature.java
@@ -45,5 +45,10 @@ public enum Feature
* The default branch of the repository is a combined branch of all
* repository branches.
*/
- COMBINED_DEFAULT_BRANCH
+ COMBINED_DEFAULT_BRANCH,
+ /**
+ * The repository supports computation of incoming changes (either diff or list of changesets) of one branch
+ * in respect to another target branch.
+ */
+ INCOMING_REVISION
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/FileObject.java b/scm-core/src/main/java/sonia/scm/repository/FileObject.java
index 9e2e9e5ff1..7dedebb13a 100644
--- a/scm-core/src/main/java/sonia/scm/repository/FileObject.java
+++ b/scm-core/src/main/java/sonia/scm/repository/FileObject.java
@@ -33,10 +33,9 @@
package sonia.scm.repository;
-//~--- non-JDK imports --------------------------------------------------------
-
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
+import com.google.common.base.Strings;
import sonia.scm.LastModifiedAware;
import javax.xml.bind.annotation.XmlAccessType;
@@ -44,8 +43,11 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
-//~--- JDK imports ------------------------------------------------------------
+import static java.util.Collections.unmodifiableCollection;
/**
* The FileObject represents a file or a directory in a repository.
@@ -110,14 +112,14 @@ public class FileObject implements LastModifiedAware, Serializable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("name", name)
- .add("path", path)
- .add("directory", directory)
- .add("description", description)
- .add("length", length)
- .add("subRepository", subRepository)
- .add("lastModified", lastModified)
- .toString();
+ .add("name", name)
+ .add("path", path)
+ .add("directory", directory)
+ .add("description", description)
+ .add("length", length)
+ .add("subRepository", subRepository)
+ .add("lastModified", lastModified)
+ .toString();
//J+
}
@@ -181,6 +183,22 @@ public class FileObject implements LastModifiedAware, Serializable
return path;
}
+ /**
+ * Returns the parent path of the file.
+ *
+ * @return parent path
+ */
+ public String getParentPath() {
+ if (Strings.isNullOrEmpty(path)) {
+ return null;
+ }
+ int index = path.lastIndexOf('/');
+ if (index > 0) {
+ return path.substring(0, index);
+ }
+ return "";
+ }
+
/**
* Return sub repository informations or null if the file is not
* sub repository.
@@ -284,6 +302,22 @@ public class FileObject implements LastModifiedAware, Serializable
this.subRepository = subRepository;
}
+ public Collection getChildren() {
+ return unmodifiableCollection(children);
+ }
+
+ public void setChildren(List children) {
+ this.children = new ArrayList<>(children);
+ }
+
+ public void addChild(FileObject child) {
+ this.children.add(child);
+ }
+
+ public boolean hasChildren() {
+ return !children.isEmpty();
+ }
+
//~--- fields ---------------------------------------------------------------
/** file description */
@@ -307,4 +341,6 @@ public class FileObject implements LastModifiedAware, Serializable
/** sub repository informations */
@XmlElement(name = "subrepository")
private SubRepository subRepository;
+
+ private Collection children = new ArrayList<>();
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/HealthCheckFailure.java b/scm-core/src/main/java/sonia/scm/repository/HealthCheckFailure.java
index 8dc7e3ac54..55f1abbaa6 100644
--- a/scm-core/src/main/java/sonia/scm/repository/HealthCheckFailure.java
+++ b/scm-core/src/main/java/sonia/scm/repository/HealthCheckFailure.java
@@ -36,12 +36,12 @@ package sonia.scm.repository;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-//~--- JDK imports ------------------------------------------------------------
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* Single failure of a {@link HealthCheck}.
*
@@ -134,11 +134,11 @@ public final class HealthCheckFailure
{
//J-
return MoreObjects.toStringHelper(this)
- .add("id", id)
- .add("summary", summary)
- .add("url", url)
- .add("description", description)
- .toString();
+ .add("id", id)
+ .add("summary", summary)
+ .add("url", url)
+ .add("description", description)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/HealthCheckResult.java b/scm-core/src/main/java/sonia/scm/repository/HealthCheckResult.java
index 8d22e0fd63..9ff902e3cd 100644
--- a/scm-core/src/main/java/sonia/scm/repository/HealthCheckResult.java
+++ b/scm-core/src/main/java/sonia/scm/repository/HealthCheckResult.java
@@ -37,10 +37,10 @@ import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
-//~--- JDK imports ------------------------------------------------------------
-
import java.util.Set;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* Result of {@link HealthCheck}.
*
@@ -52,7 +52,7 @@ public final class HealthCheckResult
/** healthy result */
private static final HealthCheckResult HEALTHY =
- new HealthCheckResult(ImmutableSet.of());
+ new HealthCheckResult(ImmutableSet.of());
//~--- constructors ---------------------------------------------------------
diff --git a/scm-core/src/main/java/sonia/scm/repository/ImportHandler.java b/scm-core/src/main/java/sonia/scm/repository/ImportHandler.java
index a3c567c930..cee142b48e 100644
--- a/scm-core/src/main/java/sonia/scm/repository/ImportHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/ImportHandler.java
@@ -35,7 +35,6 @@ package sonia.scm.repository;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
-
import java.util.List;
/**
@@ -56,8 +55,6 @@ public interface ImportHandler
*
* @return a {@link List} names of imported repositories
* @throws IOException
- * @throws RepositoryException
*/
- public List importRepositories(RepositoryManager manager)
- throws IOException, RepositoryException;
+ public List importRepositories(RepositoryManager manager) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/ImportResult.java b/scm-core/src/main/java/sonia/scm/repository/ImportResult.java
index 47dc11fcfd..e834a7ec6c 100644
--- a/scm-core/src/main/java/sonia/scm/repository/ImportResult.java
+++ b/scm-core/src/main/java/sonia/scm/repository/ImportResult.java
@@ -132,9 +132,9 @@ public final class ImportResult
{
//J-
return MoreObjects.toStringHelper(this)
- .add("importedDirectories", importedDirectories)
- .add("failedDirectories", failedDirectories)
- .toString();
+ .add("importedDirectories", importedDirectories)
+ .add("failedDirectories", failedDirectories)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/InitialRepositoryLocationResolver.java b/scm-core/src/main/java/sonia/scm/repository/InitialRepositoryLocationResolver.java
new file mode 100644
index 0000000000..23dbf85f24
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/InitialRepositoryLocationResolver.java
@@ -0,0 +1,42 @@
+package sonia.scm.repository;
+
+import com.google.common.base.CharMatcher;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * A Location Resolver for File based Repository Storage.
+ *
+ * WARNING: The Locations provided with this class may not be used from the plugins to store any plugin specific files.
+ *
+ * Please use the {@link sonia.scm.store.DataStoreFactory } and the {@link sonia.scm.store.DataStore} classes to store data
+ * Please use the {@link sonia.scm.store.BlobStoreFactory } and the {@link sonia.scm.store.BlobStore} classes to store binary files
+ * Please use the {@link sonia.scm.store.ConfigurationStoreFactory} and the {@link sonia.scm.store.ConfigurationStore} classes to store configurations
+ *
+ * @author Mohamed Karray
+ * @since 2.0.0
+ */
+public class InitialRepositoryLocationResolver {
+
+ private static final String DEFAULT_REPOSITORY_PATH = "repositories";
+
+ private static final CharMatcher ID_MATCHER = CharMatcher.anyOf("/\\.");
+
+ /**
+ * Returns the initial path to repository.
+ *
+ * @param repositoryId id of the repository
+ *
+ * @return initial path of repository
+ */
+ @SuppressWarnings("squid:S2083") // path traversal is prevented with ID_MATCHER
+ public Path getPath(String repositoryId) {
+ // avoid path traversal attacks
+ checkArgument(ID_MATCHER.matchesNoneOf(repositoryId), "repository id contains invalid characters");
+ return Paths.get(DEFAULT_REPOSITORY_PATH, repositoryId);
+ }
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/InternalRepositoryException.java b/scm-core/src/main/java/sonia/scm/repository/InternalRepositoryException.java
new file mode 100644
index 0000000000..c53ae32750
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/InternalRepositoryException.java
@@ -0,0 +1,34 @@
+package sonia.scm.repository;
+
+import sonia.scm.ContextEntry;
+import sonia.scm.ExceptionWithContext;
+
+import java.util.List;
+
+public class InternalRepositoryException extends ExceptionWithContext {
+
+ public InternalRepositoryException(ContextEntry.ContextBuilder context, String message) {
+ this(context, message, null);
+ }
+
+ public InternalRepositoryException(ContextEntry.ContextBuilder context, String message, Exception cause) {
+ this(context.build(), message, cause);
+ }
+
+ public InternalRepositoryException(Repository repository, String message) {
+ this(ContextEntry.ContextBuilder.entity(repository), message, null);
+ }
+
+ public InternalRepositoryException(Repository repository, String message, Exception cause) {
+ this(ContextEntry.ContextBuilder.entity(repository), message, cause);
+ }
+
+ public InternalRepositoryException(List context, String message, Exception cause) {
+ super(context, message, cause);
+ }
+
+ @Override
+ public String getCode() {
+ return null;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Modifications.java b/scm-core/src/main/java/sonia/scm/repository/Modifications.java
index 88bdad679a..a679b0429f 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Modifications.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Modifications.java
@@ -37,20 +37,17 @@ package sonia.scm.repository;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
-
import sonia.scm.util.Util;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.Serializable;
-
-import java.util.List;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+
+//~--- JDK imports ------------------------------------------------------------
/**
*
@@ -70,7 +67,8 @@ public class Modifications implements Serializable
* Constructs ...
*
*/
- public Modifications() {}
+ public Modifications() {
+ }
/**
* Constructs ...
@@ -221,6 +219,10 @@ public class Modifications implements Serializable
return removed;
}
+ public String getRevision() {
+ return revision;
+ }
+
//~--- set methods ----------------------------------------------------------
/**
@@ -256,20 +258,26 @@ public class Modifications implements Serializable
this.removed = removed;
}
+ public void setRevision(String revision) {
+ this.revision = revision;
+ }
+
//~--- fields ---------------------------------------------------------------
+ private String revision;
+
/** list of added files */
- @XmlElement(name = "file")
+ @XmlElement(name = "added")
@XmlElementWrapper(name = "added")
private List added;
/** list of modified files */
- @XmlElement(name = "file")
+ @XmlElement(name = "modified")
@XmlElementWrapper(name = "modified")
private List modified;
/** list of removed files */
- @XmlElement(name = "file")
+ @XmlElement(name = "removed")
@XmlElementWrapper(name = "removed")
private List removed;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/ModificationsPreProcessor.java b/scm-core/src/main/java/sonia/scm/repository/ModificationsPreProcessor.java
new file mode 100644
index 0000000000..e5870e91aa
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/ModificationsPreProcessor.java
@@ -0,0 +1,23 @@
+package sonia.scm.repository;
+
+import sonia.scm.plugin.ExtensionPoint;
+
+
+/**
+ * A pre processor for {@link Modifications} objects. A pre processor is able to
+ * modify the object before it is delivered to the user interface.
+ *
+ * @author Mohamed Karray
+ * @since 2.0
+ */
+@ExtensionPoint
+public interface ModificationsPreProcessor extends PreProcessor {
+
+ /**
+ * Process the given modifications.
+ *
+ * @param modifications modifications to process
+ */
+ @Override
+ void process(Modifications modifications);
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/ModificationsPreProcessorFactory.java b/scm-core/src/main/java/sonia/scm/repository/ModificationsPreProcessorFactory.java
new file mode 100644
index 0000000000..71a6a38efa
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/ModificationsPreProcessorFactory.java
@@ -0,0 +1,26 @@
+package sonia.scm.repository;
+
+import sonia.scm.plugin.ExtensionPoint;
+
+
+/**
+ * This factory create a {@link ModificationsPreProcessor}
+ *
+ * @author Mohamed Karray
+ * @since 2.0
+ */
+@ExtensionPoint
+public interface ModificationsPreProcessorFactory extends PreProcessorFactory {
+
+ /**
+ * Create a new {@link ModificationsPreProcessor} for the given repository.
+ *
+ *
+ * @param repository repository
+ *
+ * @return {@link ModificationsPreProcessor} for the given repository
+ */
+ @Override
+ ModificationsPreProcessor createPreProcessor(Repository repository);
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/NamespaceAndName.java b/scm-core/src/main/java/sonia/scm/repository/NamespaceAndName.java
new file mode 100644
index 0000000000..fd0a72ad7c
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/NamespaceAndName.java
@@ -0,0 +1,63 @@
+package sonia.scm.repository;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+
+import java.util.Objects;
+
+public class NamespaceAndName implements Comparable {
+
+ private final String namespace;
+ private final String name;
+
+ public NamespaceAndName(String namespace, String name) {
+ Preconditions.checkArgument(!Strings.isNullOrEmpty(namespace), "a non empty namespace is required");
+ Preconditions.checkArgument(!Strings.isNullOrEmpty(name), "a non empty name is required");
+ this.namespace = namespace;
+ this.name = name;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String logString() {
+ return getNamespace() + "/" + getName();
+ }
+
+ @Override
+ public String toString() {
+ return logString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NamespaceAndName that = (NamespaceAndName) o;
+ return Objects.equals(namespace, that.namespace) &&
+ Objects.equals(name, that.name);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(namespace, name);
+ }
+
+ @Override
+ public int compareTo(NamespaceAndName o) {
+ int result = namespace.compareTo(o.namespace);
+ if (result == 0) {
+ return name.compareTo(o.name);
+ }
+ return result;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/NamespaceStrategy.java b/scm-core/src/main/java/sonia/scm/repository/NamespaceStrategy.java
new file mode 100644
index 0000000000..d3529294ed
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/NamespaceStrategy.java
@@ -0,0 +1,19 @@
+package sonia.scm.repository;
+
+import sonia.scm.plugin.ExtensionPoint;
+
+/**
+ * Strategy to create a namespace for the new repository. Namespaces are used to order and identify repositories.
+ */
+@ExtensionPoint
+public interface NamespaceStrategy {
+
+ /**
+ * Create new namespace for the given repository.
+ *
+ * @param repository repository
+ *
+ * @return namespace
+ */
+ String createNamespace(Repository repository);
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/NoCommonHistoryException.java b/scm-core/src/main/java/sonia/scm/repository/NoCommonHistoryException.java
new file mode 100644
index 0000000000..ddb7793d20
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/NoCommonHistoryException.java
@@ -0,0 +1,22 @@
+package sonia.scm.repository;
+
+import sonia.scm.BadRequestException;
+
+import static java.util.Collections.emptyList;
+
+@SuppressWarnings("squid:MaximumInheritanceDepth")
+public class NoCommonHistoryException extends BadRequestException {
+
+ public NoCommonHistoryException() {
+ this("no common history");
+ }
+
+ public NoCommonHistoryException(String message) {
+ super(emptyList(), message);
+ }
+
+ @Override
+ public String getCode() {
+ return "4iRct4avG1";
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/PathNotFoundException.java b/scm-core/src/main/java/sonia/scm/repository/PathNotFoundException.java
deleted file mode 100644
index 7048dc2cf7..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/PathNotFoundException.java
+++ /dev/null
@@ -1,83 +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.repository;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.Util;
-
-/**
- * Signals that the specified path could be found.
- *
- * @author Sebastian Sdorra
- */
-public class PathNotFoundException extends RepositoryException
-{
-
- /** Field description */
- private static final long serialVersionUID = 4629690181172951809L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs a new {@link PathNotFoundException}
- * with the specified path.
- *
- *
- * @param path path which could not be found
- */
- public PathNotFoundException(String path)
- {
- super("path \"".concat(Util.nonNull(path)).concat("\" not found"));
- this.path = Util.nonNull(path);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Return the path which could not be found.
- *
- *
- * @return path which could not be found
- */
- public String getPath()
- {
- return path;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String path;
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Permission.java b/scm-core/src/main/java/sonia/scm/repository/Permission.java
deleted file mode 100644
index 7ea2d701b4..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/Permission.java
+++ /dev/null
@@ -1,255 +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.repository;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import sonia.scm.security.PermissionObject;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-
-//~--- JDK imports ------------------------------------------------------------
-
-/**
- * Permissions controls the access to {@link Repository}.
- *
- * @author Sebastian Sdorra
- */
-@XmlRootElement(name = "permissions")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class Permission implements PermissionObject, Serializable
-{
-
- /** Field description */
- private static final long serialVersionUID = -2915175031430884040L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs a new {@link Permission}.
- * This constructor is used by JAXB.
- *
- */
- public Permission() {}
-
- /**
- * Constructs a new {@link Permission} with type = {@link PermissionType#READ}
- * for the specified user.
- *
- *
- * @param name name of the user
- */
- public Permission(String name)
- {
- this();
- this.name = name;
- }
-
- /**
- * Constructs a new {@link Permission} with the specified type for
- * the given user.
- *
- *
- * @param name name of the user
- * @param type type of the permission
- */
- public Permission(String name, PermissionType type)
- {
- this(name);
- this.type = type;
- }
-
- /**
- * Constructs a new {@link Permission} with the specified type for
- * the given user or group.
- *
- *
- * @param name name of the user or group
- * @param type type of the permission
- * @param groupPermission true if the permission is a permission for a group
- */
- public Permission(String name, PermissionType type, boolean groupPermission)
- {
- this(name, type);
- this.groupPermission = groupPermission;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Returns true if the {@link Permission} is the same as the obj argument.
- *
- *
- * @param obj the reference object with which to compare
- *
- * @return true if the {@link Permission} is the same as the obj argument
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
- return false;
- }
-
- if (getClass() != obj.getClass())
- {
- return false;
- }
-
- final Permission other = (Permission) obj;
-
- return Objects.equal(name, other.name)
- && Objects.equal(type, other.type)
- && Objects.equal(groupPermission, other.groupPermission);
- }
-
- /**
- * Returns the hash code value for the {@link Permission}.
- *
- *
- * @return the hash code value for the {@link Permission}
- */
- @Override
- public int hashCode()
- {
- return Objects.hashCode(name, type, groupPermission);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String toString()
- {
- //J-
- return MoreObjects.toStringHelper(this)
- .add("name", name)
- .add("type", type)
- .add("groupPermission", groupPermission)
- .toString();
- //J+
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Returns the name of the user or group.
- *
- *
- * @return name of the user or group
- */
- @Override
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns the {@link PermissionType} of the permission.
- *
- *
- * @return {@link PermissionType} of the permission
- */
- public PermissionType getType()
- {
- return type;
- }
-
- /**
- * Returns true if the permission is a permission which affects a group.
- *
- *
- * @return true if the permision is a group permission
- */
- @Override
- public boolean isGroupPermission()
- {
- return groupPermission;
- }
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Sets true if the permission is a group permission.
- *
- *
- * @param groupPermission true if the permission is a group permission
- */
- public void setGroupPermission(boolean groupPermission)
- {
- this.groupPermission = groupPermission;
- }
-
- /**
- * The name of the user or group.
- *
- *
- * @param name name of the user or group
- */
- public void setName(String name)
- {
- this.name = name;
- }
-
- /**
- * Sets the type of the permission.
- *
- *
- * @param type type of the permission
- */
- public void setType(PermissionType type)
- {
- this.type = type;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private boolean groupPermission = false;
-
- /** Field description */
- private String name;
-
- /** Field description */
- private PermissionType type = PermissionType.READ;
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/PermissionType.java b/scm-core/src/main/java/sonia/scm/repository/PermissionType.java
deleted file mode 100644
index bd4d773877..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/PermissionType.java
+++ /dev/null
@@ -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.repository;
-
-/**
- * Type of permissionPrefix for a {@link Repository}.
- *
- * @author Sebastian Sdorra
- */
-public enum PermissionType
-{
-
- /** read permision */
- READ(0, "repository:read:"),
-
- /** read and write permissionPrefix */
- WRITE(10, "repository:read,write:"),
-
- /**
- * read, write and
- * also the ability to manage the properties and permissions
- */
- OWNER(100, "repository:*:");
-
- /**
- * Constructs a new permissionPrefix type
- *
- *
- * @param value
- */
- private PermissionType(int value, String permissionPrefix)
- {
- this.value = value;
- this.permissionPrefix = permissionPrefix;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- *
- * @return
- *
- * @since 2.0.0
- */
- public String getPermissionPrefix()
- {
- return permissionPrefix;
- }
-
- /**
- * Returns the integer representation of the {@link PermissionType}
- *
- *
- * @return integer representation
- */
- public int getValue()
- {
- return value;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private final String permissionPrefix;
-
- /** Field description */
- private final int value;
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Person.java b/scm-core/src/main/java/sonia/scm/repository/Person.java
index b3bf15c49a..8b5e66f61a 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Person.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Person.java
@@ -36,18 +36,16 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
-
import sonia.scm.Validateable;
import sonia.scm.util.Util;
import sonia.scm.util.ValidationUtil;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.Serializable;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+//~--- JDK imports ------------------------------------------------------------
/**
* The {@link Person} (author) of a changeset.
@@ -251,9 +249,11 @@ public class Person implements Validateable, Serializable
//~--- fields ---------------------------------------------------------------
- /** name of the person */
+ /** mail address of the person */
private String mail;
- /** mail address of the person */
+ /**
+ * name of the person
+ */
private String name;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/PreProcessorUtil.java b/scm-core/src/main/java/sonia/scm/repository/PreProcessorUtil.java
index 72e4ed7d63..e64979dde6 100644
--- a/scm-core/src/main/java/sonia/scm/repository/PreProcessorUtil.java
+++ b/scm-core/src/main/java/sonia/scm/repository/PreProcessorUtil.java
@@ -36,17 +36,15 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Inject;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.util.Util;
-//~--- JDK imports ------------------------------------------------------------
-
import java.util.Collection;
import java.util.Set;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -73,14 +71,18 @@ public class PreProcessorUtil
* @param fileObjectPreProcessorFactorySet
* @param blameLinePreProcessorSet
* @param blameLinePreProcessorFactorySet
+ * @param modificationsPreProcessorFactorySet
+ * @param modificationsPreProcessorSet
*/
@Inject
public PreProcessorUtil(Set changesetPreProcessorSet,
- Set changesetPreProcessorFactorySet,
- Set fileObjectPreProcessorSet,
- Set fileObjectPreProcessorFactorySet,
- Set blameLinePreProcessorSet,
- Set blameLinePreProcessorFactorySet)
+ Set changesetPreProcessorFactorySet,
+ Set fileObjectPreProcessorSet,
+ Set fileObjectPreProcessorFactorySet,
+ Set blameLinePreProcessorSet,
+ Set blameLinePreProcessorFactorySet,
+ Set modificationsPreProcessorFactorySet,
+ Set modificationsPreProcessorSet)
{
this.changesetPreProcessorSet = changesetPreProcessorSet;
this.changesetPreProcessorFactorySet = changesetPreProcessorFactorySet;
@@ -88,6 +90,8 @@ public class PreProcessorUtil
this.fileObjectPreProcessorFactorySet = fileObjectPreProcessorFactorySet;
this.blameLinePreProcessorSet = blameLinePreProcessorSet;
this.blameLinePreProcessorFactorySet = blameLinePreProcessorFactorySet;
+ this.modificationsPreProcessorFactorySet = modificationsPreProcessorFactorySet;
+ this.modificationsPreProcessorSet = modificationsPreProcessorSet;
}
//~--- methods --------------------------------------------------------------
@@ -107,14 +111,7 @@ public class PreProcessorUtil
blameLine.getLineNumber(), repository.getName());
}
- EscapeUtil.escape(blameLine);
-
- PreProcessorHandler handler =
- new PreProcessorHandler<>(blameLinePreProcessorFactorySet,
- blameLinePreProcessorSet, repository);
-
- handler.callPreProcessors(blameLine);
- handler.callPreProcessorFactories(blameLine);
+ handlePreProcess(repository,blameLine,blameLinePreProcessorFactorySet, blameLinePreProcessorSet);
}
/**
@@ -125,22 +122,6 @@ public class PreProcessorUtil
* @param blameResult
*/
public void prepareForReturn(Repository repository, BlameResult blameResult)
- {
- prepareForReturn(repository, blameResult, true);
- }
-
- /**
- * Method description
- *
- *
- * @param repository
- * @param blameResult
- * @param escape
- *
- * @since 1.35
- */
- public void prepareForReturn(Repository repository, BlameResult blameResult,
- boolean escape)
{
if (logger.isTraceEnabled())
{
@@ -148,17 +129,7 @@ public class PreProcessorUtil
repository.getName());
}
- if (escape)
- {
- EscapeUtil.escape(blameResult);
- }
-
- PreProcessorHandler handler =
- new PreProcessorHandler<>(blameLinePreProcessorFactorySet,
- blameLinePreProcessorSet, repository);
-
- handler.callPreProcessors(blameResult.getBlameLines());
- handler.callPreProcessorFactories(blameResult.getBlameLines());
+ handlePreProcessForIterable(repository, blameResult.getBlameLines(),blameLinePreProcessorFactorySet, blameLinePreProcessorSet);
}
/**
@@ -170,39 +141,13 @@ public class PreProcessorUtil
*/
public void prepareForReturn(Repository repository, Changeset changeset)
{
- prepareForReturn(repository, changeset, true);
+ logger.trace("prepare changeset {} of repository {} for return", changeset.getId(), repository.getName());
+ handlePreProcess(repository, changeset, changesetPreProcessorFactorySet, changesetPreProcessorSet);
}
- /**
- * Method description
- *
- *
- * @param repository
- * @param changeset
- * @param escape
- *
- * @since 1.35
- */
- public void prepareForReturn(Repository repository, Changeset changeset,
- boolean escape)
- {
- if (logger.isTraceEnabled())
- {
- logger.trace("prepare changeset {} of repository {} for return",
- changeset.getId(), repository.getName());
- }
-
- if (escape)
- {
- EscapeUtil.escape(changeset);
- }
-
- PreProcessorHandler handler =
- new PreProcessorHandler<>(changesetPreProcessorFactorySet,
- changesetPreProcessorSet, repository);
-
- handler.callPreProcessors(changeset);
- handler.callPreProcessorFactories(changeset);
+ public void prepareForReturn(Repository repository, Modifications modifications) {
+ logger.trace("prepare modifications {} of repository {} for return", modifications, repository.getName());
+ handlePreProcess(repository, modifications, modificationsPreProcessorFactorySet, modificationsPreProcessorSet);
}
/**
@@ -213,40 +158,24 @@ public class PreProcessorUtil
* @param result
*/
public void prepareForReturn(Repository repository, BrowserResult result)
- {
- prepareForReturn(repository, result, true);
- }
-
- /**
- * Method description
- *
- *
- * @param repository
- * @param result
- * @param escape
- *
- * @since 1.35
- */
- public void prepareForReturn(Repository repository, BrowserResult result,
- boolean escape)
{
if (logger.isTraceEnabled())
{
- logger.trace("prepare browser result of repository {} for return",
- repository.getName());
+ logger.trace("prepare browser result of repository {} for return", repository.getName());
}
- if (escape)
- {
- EscapeUtil.escape(result);
+ PreProcessorHandler handler = new PreProcessorHandler<>(fileObjectPreProcessorFactorySet, fileObjectPreProcessorSet, repository);
+ handlePreProcessorForFileObject(handler, result.getFile());
+ }
+
+ private void handlePreProcessorForFileObject(PreProcessorHandler handler, FileObject fileObject) {
+ if (fileObject.isDirectory()) {
+ for (FileObject child : fileObject.getChildren()) {
+ handlePreProcessorForFileObject(handler, child);
+ }
}
-
- PreProcessorHandler handler =
- new PreProcessorHandler<>(fileObjectPreProcessorFactorySet,
- fileObjectPreProcessorSet, repository);
-
- handler.callPreProcessors(result);
- handler.callPreProcessorFactories(result);
+ handler.callPreProcessorFactories(fileObject);
+ handler.callPreProcessors(fileObject);
}
/**
@@ -255,12 +184,8 @@ public class PreProcessorUtil
*
* @param repository
* @param result
- * @param escape
- *
- * @since 1.35
*/
- public void prepareForReturn(Repository repository,
- ChangesetPagingResult result, boolean escape)
+ public void prepareForReturn(Repository repository, ChangesetPagingResult result)
{
if (logger.isTraceEnabled())
{
@@ -268,30 +193,23 @@ public class PreProcessorUtil
repository.getName());
}
- if (escape)
- {
- EscapeUtil.escape(result);
- }
-
- PreProcessorHandler handler =
- new PreProcessorHandler<>(changesetPreProcessorFactorySet,
- changesetPreProcessorSet, repository);
-
- handler.callPreProcessors(result);
- handler.callPreProcessorFactories(result);
+ handlePreProcessForIterable(repository,result,changesetPreProcessorFactorySet, changesetPreProcessorSet);
}
- /**
- * Method description
- *
- *
- * @param repository
- * @param result
- */
- public void prepareForReturn(Repository repository,
- ChangesetPagingResult result)
- {
- prepareForReturn(repository, result, true);
+ private , P extends PreProcessor> void handlePreProcess(Repository repository, T processedObject,
+ Collection factories,
+ Collection
preProcessors) {
+ PreProcessorHandler handler = new PreProcessorHandler(factories, preProcessors, repository);
+ handler.callPreProcessors(processedObject);
+ handler.callPreProcessorFactories(processedObject);
+ }
+
+ private , F extends PreProcessorFactory, P extends PreProcessor> void handlePreProcessForIterable(Repository repository, I processedObjects,
+ Collection factories,
+ Collection
preProcessors) {
+ PreProcessorHandler handler = new PreProcessorHandler(factories, preProcessors, repository);
+ handler.callPreProcessors(processedObjects);
+ handler.callPreProcessorFactories(processedObjects);
}
//~--- inner classes --------------------------------------------------------
@@ -454,6 +372,10 @@ public class PreProcessorUtil
/** Field description */
private final Collection changesetPreProcessorSet;
+ private final Collection modificationsPreProcessorFactorySet;
+
+ private final Collection modificationsPreProcessorSet;
+
/** Field description */
private final Collection fileObjectPreProcessorFactorySet;
diff --git a/scm-core/src/main/java/sonia/scm/repository/RemoveDeletedRepositoryRole.java b/scm-core/src/main/java/sonia/scm/repository/RemoveDeletedRepositoryRole.java
new file mode 100644
index 0000000000..25564dca83
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RemoveDeletedRepositoryRole.java
@@ -0,0 +1,48 @@
+package sonia.scm.repository;
+
+import com.github.legman.Subscribe;
+import sonia.scm.EagerSingleton;
+import sonia.scm.plugin.Extension;
+
+import javax.inject.Inject;
+
+import java.util.Optional;
+
+import static sonia.scm.HandlerEventType.DELETE;
+
+@EagerSingleton
+@Extension
+public class RemoveDeletedRepositoryRole {
+
+ private final RepositoryManager repositoryManager;
+
+ @Inject
+ public RemoveDeletedRepositoryRole(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ @Subscribe
+ void handle(RepositoryRoleEvent event) {
+ if (event.getEventType() == DELETE) {
+ repositoryManager.getAll()
+ .forEach(repository -> check(repository, event.getItem()));
+ }
+ }
+
+ private void check(Repository repository, RepositoryRole role) {
+ findPermission(repository, role)
+ .ifPresent(permission -> removeFromPermissions(repository, permission));
+ }
+
+ private Optional findPermission(Repository repository, RepositoryRole item) {
+ return repository.getPermissions()
+ .stream()
+ .filter(repositoryPermission -> item.getName().equals(repositoryPermission.getRole()))
+ .findFirst();
+ }
+
+ private void removeFromPermissions(Repository repository, RepositoryPermission permission) {
+ repository.removePermission(permission);
+ repositoryManager.modify(repository);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Repository.java b/scm-core/src/main/java/sonia/scm/repository/Repository.java
index b6916d64f3..e35e12bbb0 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Repository.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Repository.java
@@ -33,25 +33,27 @@
package sonia.scm.repository;
-//~--- non-JDK imports --------------------------------------------------------
-
import com.github.sdorra.ssp.PermissionObject;
import com.github.sdorra.ssp.StaticPermissions;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-import com.google.common.collect.Lists;
import sonia.scm.BasicPropertiesAware;
import sonia.scm.ModelObject;
-import sonia.scm.util.HttpUtil;
import sonia.scm.util.Util;
import sonia.scm.util.ValidationUtil;
-import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
-
-//~--- JDK imports ------------------------------------------------------------
+import java.util.Set;
/**
* Source code repository.
@@ -59,90 +61,243 @@ import java.util.List;
* @author Sebastian Sdorra
*/
@StaticPermissions(
- value = "repository",
- permissions = {"read", "write", "modify", "delete", "healthCheck"}
+ value = "repository",
+ permissions = {"read", "modify", "delete", "healthCheck", "pull", "push", "permissionRead", "permissionWrite"},
+ custom = true, customGlobal = true
)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "repositories")
-public class Repository extends BasicPropertiesAware implements ModelObject, PermissionObject
-{
+public class Repository extends BasicPropertiesAware implements ModelObject, PermissionObject{
- /** Field description */
private static final long serialVersionUID = 3486560714961909711L;
- //~--- constructors ---------------------------------------------------------
+ private String contact;
+ private Long creationDate;
+ private String description;
+ @XmlElement(name = "healthCheckFailure")
+ @XmlElementWrapper(name = "healthCheckFailures")
+ private List healthCheckFailures;
+ private String id;
+ private Long lastModified;
+ private String namespace;
+ private String name;
+ @XmlElement(name = "permission")
+ private Set permissions = new HashSet<>();
+ private String type;
+
/**
* Constructs a new {@link Repository}.
* This constructor is used by JAXB.
- *
*/
- public Repository() {}
+ public Repository() {
+ }
/**
* Constructs a new {@link Repository}.
*
- *
- *
- * @param id id of the {@link Repository}
+ * @param id id of the {@link Repository}
* @param type type of the {@link Repository}
* @param name name of the {@link Repository}
*/
- public Repository(String id, String type, String name)
- {
+ public Repository(String id, String type, String namespace, String name) {
this.id = id;
this.type = type;
+ this.namespace = namespace;
this.name = name;
}
/**
* Constructs a new {@link Repository}.
*
- *
- *
- * @param id id of the {@link Repository}
- * @param type type of the {@link Repository}
- * @param name name of the {@link Repository}
- * @param contact email address of a person who is responsible for
- * this repository.
+ * @param id id of the {@link Repository}
+ * @param type type of the {@link Repository}
+ * @param name name of the {@link Repository}
+ * @param namespace namespace of the {@link Repository}
+ * @param contact email address of a person who is responsible for
+ * this repository.
* @param description a short description of the repository
* @param permissions permissions for specific users and groups.
*/
- public Repository(String id, String type, String name, String contact,
- String description, Permission... permissions)
- {
+ public Repository(String id, String type, String namespace, String name, String contact,
+ String description, RepositoryPermission... permissions) {
this.id = id;
this.type = type;
+ this.namespace = namespace;
this.name = name;
this.contact = contact;
this.description = description;
- this.permissions = Lists.newArrayList();
- if (Util.isNotEmpty(permissions))
- {
+ if (Util.isNotEmpty(permissions)) {
this.permissions.addAll(Arrays.asList(permissions));
}
}
- //~--- methods --------------------------------------------------------------
+ /**
+ * Returns a contact email address of a person who is responsible for
+ * the {@link Repository}.
+ *
+ * @return contact email address
+ */
+ public String getContact() {
+ return contact;
+ }
/**
- * Create a clone of this {@link Repository} object.
+ * Returns a timestamp of the creation date of the {@link Repository}.
*
+ * @return a timestamp of the creation date of the {@link Repository}
+ */
+ public Long getCreationDate() {
+ return creationDate;
+ }
+
+ /**
+ * Returns a short description of the {@link Repository}.
*
- * @return clone of this {@link Repository}
+ * @return short description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Returns a {@link List} of {@link HealthCheckFailure}s. The {@link List}
+ * is empty if the repository is healthy.
+ *
+ * @return {@link List} of {@link HealthCheckFailure}s
+ * @since 1.36
+ */
+ @SuppressWarnings("unchecked")
+ public List getHealthCheckFailures() {
+ if (healthCheckFailures == null) {
+ healthCheckFailures = Collections.EMPTY_LIST;
+ }
+
+ return healthCheckFailures;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public Long getLastModified() {
+ return lastModified;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public String getNamespace() { return namespace; }
+
+ @XmlTransient
+ public NamespaceAndName getNamespaceAndName() {
+ return new NamespaceAndName(getNamespace(), getName());
+ }
+
+ public Collection getPermissions() {
+ return Collections.unmodifiableCollection(permissions);
+ }
+
+ /**
+ * Returns the type (hg, git, svn ...) of the {@link Repository}.
+ *
+ * @return type of the repository
*/
@Override
- public Repository clone()
- {
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Returns {@code true} if the repository is healthy.
+ *
+ * @return {@code true} if the repository is healthy
+ * @since 1.36
+ */
+ public boolean isHealthy() {
+ return Util.isEmpty(healthCheckFailures);
+ }
+
+ /**
+ * Returns true if the {@link Repository} is valid.
+ *
+ *
The namespace is valid
+ *
The name is valid
+ *
The type is not empty
+ *
The contact is empty or contains a valid email address
+ *
+ *
+ * @return true if the {@link Repository} is valid
+ */
+ @Override
+ public boolean isValid() {
+ return ValidationUtil.isRepositoryNameValid(namespace)
+ && ValidationUtil.isRepositoryNameValid(name)
+ && Util.isNotEmpty(type)
+ && ((Util.isEmpty(contact)) || ValidationUtil.isMailAddressValid(contact));
+ }
+
+ public void setContact(String contact) {
+ this.contact = contact;
+ }
+
+ public void setCreationDate(Long creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setLastModified(Long lastModified) {
+ this.lastModified = lastModified;
+ }
+
+ public void setNamespace(String namespace) { this.namespace = namespace; }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setPermissions(Collection permissions) {
+ this.permissions.clear();
+ this.permissions.addAll(permissions);
+ }
+
+ public void addPermission(RepositoryPermission newPermission) {
+ this.permissions.add(newPermission);
+ }
+
+ public boolean removePermission(RepositoryPermission permission) {
+ return this.permissions.remove(permission);
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setHealthCheckFailures(List healthCheckFailures) {
+ this.healthCheckFailures = healthCheckFailures;
+ }
+
+ @Override
+ public Repository clone() {
Repository repository = null;
- try
- {
+ try {
repository = (Repository) super.clone();
- }
- catch (CloneNotSupportedException ex)
- {
+ // fix permission reference on clone
+ repository.permissions = new HashSet<>(permissions);
+ } catch (CloneNotSupportedException ex) {
throw new RuntimeException(ex);
}
@@ -152,456 +307,72 @@ public class Repository extends BasicPropertiesAware implements ModelObject, Per
/**
* Copies all properties of the {@link Repository} to the given one.
*
- *
- * @param repository to copies all properties of this one
+ * @param repository the target {@link Repository}
*/
- public void copyProperties(Repository repository)
- {
+ public void copyProperties(Repository repository) {
+ repository.setNamespace(namespace);
repository.setName(name);
repository.setContact(contact);
repository.setCreationDate(creationDate);
repository.setLastModified(lastModified);
repository.setDescription(description);
repository.setPermissions(permissions);
- repository.setPublicReadable(publicReadable);
- repository.setArchived(archived);
// do not copy health check results
}
- /**
- * Creates the url of the repository.
- *
- *
- * @param baseUrl base url of the server including the context path
- *
- * @return url of the repository
- * @since 1.17
- */
- public String createUrl(String baseUrl)
- {
- String url = HttpUtil.append(baseUrl, type);
-
- return HttpUtil.append(url, name);
- }
-
/**
* Returns true if the {@link Repository} is the same as the obj argument.
*
- *
* @param obj the reference object with which to compare
- *
* @return true if the {@link Repository} is the same as the obj argument
*/
@Override
- public boolean equals(Object obj)
- {
- if (obj == null)
- {
+ public boolean equals(Object obj) {
+ if (obj == null) {
return false;
}
- if (getClass() != obj.getClass())
- {
+ if (getClass() != obj.getClass()) {
return false;
}
final Repository other = (Repository) obj;
- //J-
- return Objects.equal(id, other.id)
- && Objects.equal(name, other.name)
- && Objects.equal(contact, other.contact)
- && Objects.equal(description, other.description)
- && Objects.equal(publicReadable, other.publicReadable)
- && Objects.equal(archived, other.archived)
- && Objects.equal(permissions, other.permissions)
- && Objects.equal(type, other.type)
- && Objects.equal(creationDate, other.creationDate)
- && Objects.equal(lastModified, other.lastModified)
- && Objects.equal(properties, other.properties)
- && Objects.equal(healthCheckFailures, other.healthCheckFailures);
- //J+
+ return Objects.equal(id, other.id)
+ && Objects.equal(namespace, other.namespace)
+ && Objects.equal(name, other.name)
+ && Objects.equal(contact, other.contact)
+ && Objects.equal(description, other.description)
+ && Objects.equal(permissions, other.permissions)
+ && Objects.equal(type, other.type)
+ && Objects.equal(creationDate, other.creationDate)
+ && Objects.equal(lastModified, other.lastModified)
+ && Objects.equal(properties, other.properties)
+ && Objects.equal(healthCheckFailures, other.healthCheckFailures);
}
- /**
- * Returns the hash code value for the {@link Repository}.
- *
- *
- * @return the hash code value for the {@link Repository}
- */
@Override
- public int hashCode()
- {
- return Objects.hashCode(id, name, contact, description, publicReadable,
- archived, permissions, type, creationDate, lastModified, properties,
+ public int hashCode() {
+ return Objects.hashCode(id, namespace, name, contact, description,
+ permissions, type, creationDate, lastModified, properties,
healthCheckFailures);
}
- /**
- * Returns a {@link String} that represents the {@link Repository}.
- *
- *
- * @return {@link String} that represents the {@link Repository}
- */
@Override
- public String toString()
- {
- //J-
+ public String toString() {
return MoreObjects.toStringHelper(this)
- .add("id", id)
- .add("name", name)
- .add("contact", contact)
- .add("description", description)
- .add("publicReadable", publicReadable)
- .add("archived", archived)
- .add("permissions", permissions)
- .add("type", type)
- .add("lastModified", lastModified)
- .add("creationDate", creationDate)
- .add("properties", properties)
- .add("healthCheckFailures", healthCheckFailures)
- .toString();
- //J+
+ .add("id", id)
+ .add("namespace", namespace)
+ .add("name", name)
+ .add("contact", contact)
+ .add("description", description)
+ .add("permissions", permissions)
+ .add("type", type)
+ .add("lastModified", lastModified)
+ .add("creationDate", creationDate)
+ .add("properties", properties)
+ .add("healthCheckFailures", healthCheckFailures)
+ .toString();
}
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Returns a contact email address of a person who is responsible for
- * the {@link Repository}.
- *
- *
- * @return contact email address
- */
- public String getContact()
- {
- return contact;
- }
-
- /**
- * Returns a timestamp of the creation date of the {@link Repository}.
- *
- *
- * @return a timestamp of the creation date of the {@link Repository}
- */
- public Long getCreationDate()
- {
- return creationDate;
- }
-
- /**
- * Returns a short description of the {@link Repository}.
- *
- *
- * @return short description
- */
- public String getDescription()
- {
- return description;
- }
-
- /**
- * Returns a {@link List} of {@link HealthCheckFailure}s. The {@link List}
- * is empty if the repository is healthy.
- *
- *
- * @return {@link List} of {@link HealthCheckFailure}s
- * @since 1.36
- */
- @SuppressWarnings("unchecked")
- public List getHealthCheckFailures()
- {
- if (healthCheckFailures == null)
- {
- healthCheckFailures = Collections.EMPTY_LIST;
- }
-
- return healthCheckFailures;
- }
-
- /**
- * Returns the unique id of the {@link Repository}.
- *
- *
- * @return unique id
- */
- @Override
- public String getId()
- {
- return id;
- }
-
- /**
- * Returns the timestamp of the last modified date of the {@link Repository}.
- *
- *
- * @return timestamp of the last modified date
- */
- @Override
- public Long getLastModified()
- {
- return lastModified;
- }
-
- /**
- * Returns the name of the {@link Repository}.
- *
- *
- * @return name of the {@link Repository}
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns the access permissions of the {@link Repository}.
- *
- *
- * @return access permissions
- */
- public List getPermissions()
- {
- if (permissions == null)
- {
- permissions = Lists.newArrayList();
- }
-
- return permissions;
- }
-
- /**
- * Returns the type (hg, git, svn ...) of the {@link Repository}.
- *
- *
- * @return type of the repository
- */
- @Override
- public String getType()
- {
- return type;
- }
-
- /**
- * Returns true if the repository is archived.
- *
- *
- * @return true if the repository is archived
- * @since 1.14
- */
- public boolean isArchived()
- {
- return archived;
- }
-
- /**
- * Returns {@code true} if the repository is healthy.
- *
- *
- * @return {@code true} if the repository is healthy
- *
- * @since 1.36
- */
- public boolean isHealthy()
- {
- return Util.isEmpty(healthCheckFailures);
- }
-
- /**
- * Returns true if the {@link Repository} is public readable.
- *
- *
- * @return true if the {@link Repository} is public readable
- */
- public boolean isPublicReadable()
- {
- return publicReadable;
- }
-
- /**
- * Returns true if the {@link Repository} is valid.
- *
- *
The name is not empty and contains only A-z, 0-9, _, -, /
- *
The type is not empty
- *
The contact is empty or contains a valid email address
- *
- *
- *
- * @return true if the {@link Repository} is valid
- */
- @Override
- public boolean isValid()
- {
- return ValidationUtil.isRepositoryNameValid(name) && Util.isNotEmpty(type)
- && ((Util.isEmpty(contact))
- || ValidationUtil.isMailAddressValid(contact));
- }
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Archive or un archive this repository.
- *
- *
- * @param archived true to enable archive
- * @since 1.14
- */
- public void setArchived(boolean archived)
- {
- this.archived = archived;
- }
-
- /**
- * Sets the contact of the {@link Repository}. The contact address should be
- * a email address of a person who is responsible for the {@link Repository}.
- *
- *
- * @param contact email address of a person who is responsible for
- * the {@link Repository}
- */
- public void setContact(String contact)
- {
- this.contact = contact;
- }
-
- /**
- * Set the creation date of the {@link Repository}.
- *
- *
- * @param creationDate creation date of the {@link Repository}
- */
- public void setCreationDate(Long creationDate)
- {
- this.creationDate = creationDate;
- }
-
- /**
- * Sets a short description of the {@link Repository}.
- *
- *
- * @param description short description
- */
- public void setDescription(String description)
- {
- this.description = description;
- }
-
- /**
- * The unique id of the {@link Repository}.
- *
- *
- * @param id unique id
- */
- public void setId(String id)
- {
- this.id = id;
- }
-
- /**
- * Set the last modified timestamp of the {@link Repository}.
- *
- *
- * @param lastModified last modified timestamp
- */
- public void setLastModified(Long lastModified)
- {
- this.lastModified = lastModified;
- }
-
- /**
- * Set the name of the {@link Repository}.
- *
- *
- * @param name name of the {@link Repository}
- */
- public void setName(String name)
- {
- this.name = name;
- }
-
- /**
- * Set the access permissions for the {@link Repository}.
- *
- *
- * @param permissions list of access permissions
- */
- public void setPermissions(List permissions)
- {
- this.permissions = permissions;
- }
-
- /**
- * Sets true if the {@link Repository} is public readable.
- *
- *
- * @param publicReadable public readable
- */
- public void setPublicReadable(boolean publicReadable)
- {
- this.publicReadable = publicReadable;
- }
-
- /**
- * Sets the type (hg, svn, git ...) of the {@link Repository}.
- *
- *
- * @param type type of the {@link Repository}
- */
- public void setType(String type)
- {
- this.type = type;
- }
-
- /**
- * Sets {@link HealthCheckFailure} for a unhealthy repository.
- *
- * @param healthCheckFailures list of {@link HealthCheckFailure}s
- *
- * @since 1.36
- */
- public void setHealthCheckFailures(List healthCheckFailures)
- {
- this.healthCheckFailures = healthCheckFailures;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String contact;
-
- /** Field description */
- private Long creationDate;
-
- /** Field description */
- private String description;
-
- /**
- * @since 1.36
- */
- @XmlElement(name = "healthCheckFailure")
- @XmlElementWrapper(name = "healthCheckFailures")
- private List healthCheckFailures;
-
- /** Field description */
- private String id;
-
- /** Field description */
- private Long lastModified;
-
- /** Field description */
- private String name;
-
- /** Field description */
- private List permissions;
-
- /** Field description */
- @XmlElement(name = "public")
- private boolean publicReadable = false;
-
- /** Field description */
- private boolean archived = false;
-
- /** Field description */
- private String type;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryAlreadyExistsException.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryAlreadyExistsException.java
deleted file mode 100644
index c439b2d0f4..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryAlreadyExistsException.java
+++ /dev/null
@@ -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.repository;
-
-/**
- * This {@link Exception} is thrown when trying to create a repository with
- * the same name and type already exists.
- *
- * @author Sebastian Sdorra
- */
-public class RepositoryAlreadyExistsException extends RepositoryException
-{
- private static final long serialVersionUID = -774929917214137675L;
-
- /**
- * Creates a new instance.
- *
- * @param message exception message
- */
- public RepositoryAlreadyExistsException(String message) {
- super(message);
- }
-
- /**
- * Creates a new {@link RepositoryAlreadyExistsException} with an appropriate message.
- *
- * @param repository repository that already exists
- *
- * @return new exception with appropriate message
- */
- public static RepositoryAlreadyExistsException create(Repository repository){
- StringBuilder buffer = new StringBuilder("repository with name ");
- buffer.append(repository.getName()).append(" of type ");
- buffer.append(repository.getType()).append("already exists");
- return new RepositoryAlreadyExistsException(buffer.toString());
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryConfig.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryConfig.java
new file mode 100644
index 0000000000..909d95dce2
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryConfig.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of SCM-Manager; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ */
+
+
+package sonia.scm.repository;
+
+import sonia.scm.Validateable;
+import sonia.scm.config.Configuration;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+/**
+ * Basic {@link Repository} configuration class.
+ *
+ * @author Sebastian Sdorra
+ */
+@XmlRootElement
+public abstract class RepositoryConfig implements Validateable, Configuration {
+
+ /** true if the plugin is disabled */
+ private boolean disabled = false;
+ /**
+ * Returns true if the plugin is disabled.
+ *
+ *
+ * @return true if the plugin is disabled
+ * @since 1.13
+ */
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ /**
+ * Returns true if the configuration object is valid.
+ *
+ *
+ * @return true if the configuration object is valid
+ */
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+ //~--- set methods ----------------------------------------------------------
+
+ /**
+ * Enable or disable the plugin.
+ *
+ *
+ * @param disabled
+ * @since 1.13
+ */
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+
+
+ /**
+ * Specifies the identifier of the concrete {@link RepositoryConfig} when checking permissions of an object.
+ * The permission Strings will have the following format: "configuration:*:ID", where the ID part is defined by this
+ * method.
+ *
+ * For example: "configuration:read:git".
+ *
+ * No need to serialize this.
+ *
+ * @return identifier of this RepositoryConfig in permission strings
+ */
+ @Override
+ @XmlTransient // Only for permission checks, don't serialize to XML
+ public abstract String getId();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryDAO.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryDAO.java
index 9a2d4b5662..ce309ecee6 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryDAO.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryDAO.java
@@ -49,27 +49,22 @@ public interface RepositoryDAO extends GenericDAO
/**
* Returns true if a repository with specified
- * type and name exists in the backend.
+ * namespace and name exists in the backend.
*
*
- * @param type type of the repository
- * @param name name of the repository
+ * @param namespaceAndName namespace and name of the repository
*
* @return true if the repository exists
*/
- public boolean contains(String type, String name);
+ boolean contains(NamespaceAndName namespaceAndName);
//~--- get methods ----------------------------------------------------------
/**
- * Returns the repository with the specified type and name or null
+ * Returns the repository with the specified namespace and name or null
* if no such repository exists in the backend.
*
- *
- * @param type
- * @param name
- *
- * @return repository with the specified type and name or null
+ * @return repository with the specified namespace and name or null
*/
- public Repository get(String type, String name);
+ Repository get(NamespaceAndName namespaceAndName);
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryDirectoryHandler.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryDirectoryHandler.java
index 3fda4a76be..837aaa496b 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryDirectoryHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryDirectoryHandler.java
@@ -40,16 +40,13 @@ import java.io.File;
* @author Sebastian Sdorra
* @since 1.36
*/
-public interface RepositoryDirectoryHandler extends RepositoryHandler
-{
+public interface RepositoryDirectoryHandler extends RepositoryHandler {
+
+ String REPOSITORIES_NATIVE_DIRECTORY = "data";
/**
- * Method description
- *
- *
- * @param repository
- *
- * @return
+ * Get the current directory of the repository for the given id.
+ * @return the current directory of the given repository
*/
- public File getDirectory(Repository repository);
+ File getDirectory(String repositoryId);
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryException.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryException.java
deleted file mode 100644
index 63538d08e3..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryException.java
+++ /dev/null
@@ -1,95 +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.repository;
-
-/**
- * Base class for all repository exceptions.
- *
- * @author Sebastian Sdorra
- */
-public class RepositoryException extends Exception
-{
-
- /** Field description */
- private static final long serialVersionUID = -4939196278070910058L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs a new {@link RepositoryException} with null as its
- * error detail message.
- *
- */
- public RepositoryException()
- {
- super();
- }
-
- /**
- * Constructs a new {@link RepositoryException} with the specified
- * detail message.
- *
- *
- * @param message detail message
- */
- public RepositoryException(String message)
- {
- super(message);
- }
-
- /**
- * Constructs a new {@link RepositoryException} with the specified
- * detail message and cause.
- *
- *
- * @param cause the cause for the exception
- */
- public RepositoryException(Throwable cause)
- {
- super(cause);
- }
-
- /**
- * Constructs a new {@link RepositoryException} with the specified
- * detail message and cause.
- *
- *
- * @param message detail message
- * @param cause the cause for the exception
- */
- public RepositoryException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandler.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryHandler.java
index 8dc5f8418b..aaa090827a 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryHandler.java
@@ -36,7 +36,7 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.Handler;
-import sonia.scm.NotSupportedFeatuerException;
+import sonia.scm.FeatureNotSupportedException;
import sonia.scm.plugin.ExtensionPoint;
/**
@@ -47,20 +47,9 @@ import sonia.scm.plugin.ExtensionPoint;
*/
@ExtensionPoint
public interface RepositoryHandler
- extends Handler
+ extends Handler
{
- /**
- * Returns the resource path for the given {@link Repository}.
- * The resource path is part of the {@link Repository} url.
- *
- *
- *
- * @param repository given {@link Repository}
- * @return resource path of the {@link Repository}
- */
- public String createResourcePath(Repository repository);
-
//~--- get methods ----------------------------------------------------------
/**
@@ -70,9 +59,9 @@ public interface RepositoryHandler
* @return {@link ImportHandler} for the repository type of this handler
* @since 1.12
*
- * @throws NotSupportedFeatuerException
+ * @throws FeatureNotSupportedException
*/
- public ImportHandler getImportHandler() throws NotSupportedFeatuerException;
+ public ImportHandler getImportHandler() throws FeatureNotSupportedException;
/**
* Returns informations about the version of the RepositoryHandler.
@@ -82,4 +71,7 @@ public interface RepositoryHandler
* @since 1.15
*/
public String getVersionInformation();
+
+ @Override
+ RepositoryType getType();
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerConfigChangedEvent.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerConfigChangedEvent.java
index 844c4a78d6..645274e494 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerConfigChangedEvent.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerConfigChangedEvent.java
@@ -37,7 +37,7 @@ import sonia.scm.event.Event;
* @since 2.0.0
*/
@Event
-public class RepositoryHandlerConfigChangedEvent
+public class RepositoryHandlerConfigChangedEvent
{
private final C configuration;
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerNotFoundException.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerNotFoundException.java
deleted file mode 100644
index 4583902ef8..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerNotFoundException.java
+++ /dev/null
@@ -1,64 +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.repository;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class RepositoryHandlerNotFoundException extends RepositoryException
-{
-
- /** Field description */
- private static final long serialVersionUID = 5270463060802850944L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
- public RepositoryHandlerNotFoundException() {}
-
- /**
- * Constructs ...
- *
- *
- * @param message
- */
- public RepositoryHandlerNotFoundException(String message)
- {
- super(message);
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryIsNotArchivedException.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryIsNotArchivedException.java
deleted file mode 100644
index 775e4714d8..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryIsNotArchivedException.java
+++ /dev/null
@@ -1,88 +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.repository;
-
-/**
- *
- * @author Sebastian Sdorra
- *
- * @since 1.14
- */
-public class RepositoryIsNotArchivedException extends RepositoryException
-{
-
- /** Field description */
- private static final long serialVersionUID = 7728748133123987511L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
- public RepositoryIsNotArchivedException() {}
-
- /**
- * Constructs ...
- *
- *
- * @param message
- */
- public RepositoryIsNotArchivedException(String message)
- {
- super(message);
- }
-
- /**
- * Constructs ...
- *
- *
- * @param cause
- */
- public RepositoryIsNotArchivedException(Throwable cause)
- {
- super(cause);
- }
-
- /**
- * Constructs ...
- *
- *
- * @param message
- * @param cause
- */
- public RepositoryIsNotArchivedException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryLocationResolver.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryLocationResolver.java
new file mode 100644
index 0000000000..bdd7a03d62
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryLocationResolver.java
@@ -0,0 +1,48 @@
+package sonia.scm.repository;
+
+import java.util.function.BiConsumer;
+
+public abstract class RepositoryLocationResolver {
+
+ public abstract boolean supportsLocationType(Class> type);
+
+ protected abstract RepositoryLocationResolverInstance create(Class type);
+
+ public final RepositoryLocationResolverInstance forClass(Class type) {
+ if (!supportsLocationType(type)) {
+ throw new IllegalStateException("no support for location of class " + type);
+ }
+ return create(type);
+ }
+
+ public interface RepositoryLocationResolverInstance {
+
+ /**
+ * Get the existing location for the repository.
+ * @param repositoryId The id of the repository.
+ * @throws IllegalStateException when there is no known location for the given repository.
+ */
+ T getLocation(String repositoryId);
+
+ /**
+ * Create a new location for the new repository.
+ * @param repositoryId The id of the new repository.
+ * @throws IllegalStateException when there already is a location for the given repository registered.
+ */
+ T createLocation(String repositoryId);
+
+ /**
+ * Set the location of a new repository.
+ * @param repositoryId The id of the new repository.
+ * @throws IllegalStateException when there already is a location for the given repository registered.
+ */
+ void setLocation(String repositoryId, T location);
+
+ /**
+ * Iterates all repository locations known to this resolver instance and calls the consumer giving the repository id
+ * and its location for each repository.
+ * @param consumer This callback will be called for each repository with the repository id and its location.
+ */
+ void forAllLocations(BiConsumer consumer);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java
index 7cbac2b52e..7f4880c258 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java
@@ -35,16 +35,12 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
-import sonia.scm.Type;
import sonia.scm.TypeManager;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
-
import java.util.Collection;
-import javax.servlet.http.HttpServletRequest;
+//~--- JDK imports ------------------------------------------------------------
/**
* The central class for managing {@link Repository} objects.
@@ -55,7 +51,7 @@ import javax.servlet.http.HttpServletRequest;
* @apiviz.uses sonia.scm.repository.RepositoryHandler
*/
public interface RepositoryManager
- extends TypeManager
+ extends TypeManager
{
/**
@@ -75,26 +71,23 @@ public interface RepositoryManager
* @param repository {@link Repository} to import
*
* @throws IOException
- * @throws RepositoryException
*/
- public void importRepository(Repository repository)
- throws IOException, RepositoryException;
+ public void importRepository(Repository repository) throws IOException;
//~--- get methods ----------------------------------------------------------
/**
- * Returns a {@link Repository} by its type and name or
+ * Returns a {@link Repository} by its namespace and name or
* null if the {@link Repository} could not be found.
*
*
- * @param type type of the {@link Repository}
- * @param name name of the {@link Repository}
+ * @param namespaceAndName namespace and name of the {@link Repository}
*
*
- * @return {@link Repository} by its type and name or null
+ * @return {@link Repository} by its namespace and name or null
* if the {@link Repository} could not be found
*/
- public Repository get(String type, String name);
+ public Repository get(NamespaceAndName namespaceAndName);
/**
* Returns all configured repository types.
@@ -102,42 +95,7 @@ public interface RepositoryManager
*
* @return all configured repository types
*/
- public Collection getConfiguredTypes();
-
- /**
- * Returns the {@link Repository} associated to the request uri.
- *
- *
- * @param request the current http request
- *
- * @return associated to the request uri
- * @since 1.9
- */
- public Repository getFromRequest(HttpServletRequest request);
-
- /**
- * Returns the {@link Repository} associated to the given type and path.
- *
- *
- * @param type type of the repository (hg, git ...)
- * @param uri
- *
- * @return the {@link Repository} associated to the given type and path
- * @since 1.9
- */
- public Repository getFromTypeAndUri(String type, String uri);
-
- /**
- * Returns the {@link Repository} associated to the request uri.
- *
- *
- *
- * @param uri request uri without context path
- *
- * @return associated to the request uri
- * @since 1.9
- */
- public Repository getFromUri(String uri);
+ public Collection getConfiguredTypes();
/**
* Returns a {@link RepositoryHandler} by the given type (hg, git, svn ...).
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java
index 632b54b741..b7a819e5f9 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java
@@ -38,13 +38,10 @@ package sonia.scm.repository;
import sonia.scm.ManagerDecorator;
import sonia.scm.Type;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
-
import java.util.Collection;
-import javax.servlet.http.HttpServletRequest;
+//~--- JDK imports ------------------------------------------------------------
/**
* Decorator for {@link RepositoryManager}.
@@ -53,7 +50,7 @@ import javax.servlet.http.HttpServletRequest;
* @since 1.23
*/
public class RepositoryManagerDecorator
- extends ManagerDecorator
+ extends ManagerDecorator
implements RepositoryManager
{
@@ -84,27 +81,16 @@ public class RepositoryManagerDecorator
* {@inheritDoc}
*/
@Override
- public void importRepository(Repository repository)
- throws IOException, RepositoryException
- {
+ public void importRepository(Repository repository) throws IOException {
decorated.importRepository(repository);
}
//~--- get methods ----------------------------------------------------------
- /**
- * {@inheritDoc}
- *
- *
- * @param type
- * @param name
- *
- * @return
- */
@Override
- public Repository get(String type, String name)
+ public Repository get(NamespaceAndName namespaceAndName)
{
- return decorated.get(type, name);
+ return decorated.get(namespaceAndName);
}
/**
@@ -114,7 +100,7 @@ public class RepositoryManagerDecorator
* @return
*/
@Override
- public Collection getConfiguredTypes()
+ public Collection getConfiguredTypes()
{
return decorated.getConfiguredTypes();
}
@@ -132,49 +118,6 @@ public class RepositoryManagerDecorator
return decorated;
}
- /**
- * {@inheritDoc}
- *
- *
- * @param request
- *
- * @return
- */
- @Override
- public Repository getFromRequest(HttpServletRequest request)
- {
- return decorated.getFromRequest(request);
- }
-
- /**
- * {@inheritDoc}
- *
- *
- * @param type
- * @param uri
- *
- * @return
- */
- @Override
- public Repository getFromTypeAndUri(String type, String uri)
- {
- return decorated.getFromTypeAndUri(type, uri);
- }
-
- /**
- * {@inheritDoc}
- *
- *
- * @param uri
- *
- * @return
- */
- @Override
- public Repository getFromUri(String uri)
- {
- return decorated.getFromUri(uri);
- }
-
/**
* {@inheritDoc}
*
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryNotFoundException.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryNotFoundException.java
deleted file mode 100644
index f1649efb43..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryNotFoundException.java
+++ /dev/null
@@ -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.repository;
-
-/**
- * Signals that the specified {@link Repository} could be found.
- *
- * @author Sebastian Sdorra
- * @since 1.6
- */
-public class RepositoryNotFoundException extends RepositoryException
-{
-
- /** Field description */
- private static final long serialVersionUID = -6583078808900520166L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs a new {@link RepositoryNotFoundException} with null as its
- * error detail message.
- *
- */
- public RepositoryNotFoundException() {}
-
- /**
- * Constructs a new {@link RepositoryNotFoundException} with the specified
- * error detail message.
- *
- *
- * @param message error detail message
- */
- public RepositoryNotFoundException(String message)
- {
- super(message);
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryPathNotFoundException.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryPathNotFoundException.java
new file mode 100644
index 0000000000..96f76346b3
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryPathNotFoundException.java
@@ -0,0 +1,12 @@
+
+package sonia.scm.repository;
+
+public class RepositoryPathNotFoundException extends Exception {
+
+ public static final String REPOSITORY_PATH_NOT_FOUND = "Repository path not found";
+
+ public RepositoryPathNotFoundException() {
+ super(REPOSITORY_PATH_NOT_FOUND);
+ }
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryPermission.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryPermission.java
new file mode 100644
index 0000000000..3099c1f74b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryPermission.java
@@ -0,0 +1,278 @@
+/*
+ Copyright (c) 2010, Sebastian Sdorra
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ 3. Neither the name of SCM-Manager; nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ http://bitbucket.org/sdorra/scm-manager
+
+ */
+
+
+
+package sonia.scm.repository;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import sonia.scm.security.PermissionObject;
+
+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 java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import static java.util.Collections.emptyList;
+import static java.util.Collections.emptySet;
+import static java.util.Collections.unmodifiableSet;
+
+//~--- JDK imports ------------------------------------------------------------
+
+/**
+ * Permissions controls the access to {@link Repository}.
+ * This object should be immutable, but could not be due to mapstruct. Do not modify instances of this because this
+ * would change the hash code and therefor make it undeletable in a repository.
+ *
+ * @author Sebastian Sdorra
+ */
+@XmlRootElement(name = "permissions")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RepositoryPermission implements PermissionObject, Serializable
+{
+
+ private static final long serialVersionUID = -2915175031430884040L;
+ public static final String REPOSITORY_MODIFIED_EXCEPTION_TEXT = "repository permission must not be modified";
+
+ private Boolean groupPermission;
+ private String name;
+ @XmlElement(name = "verb")
+ private Set verbs;
+ private String role;
+
+ /**
+ * This constructor exists for mapstruct and JAXB, only -- do not use this in "normal" code.
+ *
+ * @deprecated Do not use this for "normal" code.
+ * Use {@link RepositoryPermission#RepositoryPermission(String, Collection, boolean)} instead.
+ */
+ @Deprecated
+ public RepositoryPermission() {}
+
+ public RepositoryPermission(String name, Collection verbs, boolean groupPermission)
+ {
+ this.name = name;
+ this.verbs = new LinkedHashSet<>(verbs);
+ this.role = null;
+ this.groupPermission = groupPermission;
+ }
+
+ public RepositoryPermission(String name, String role, boolean groupPermission)
+ {
+ this.name = name;
+ this.verbs = emptySet();
+ this.role = role;
+ this.groupPermission = groupPermission;
+ }
+
+ //~--- methods --------------------------------------------------------------
+
+ /**
+ * Returns true if the {@link RepositoryPermission} is the same as the obj argument.
+ *
+ *
+ * @param obj the reference object with which to compare
+ *
+ * @return true if the {@link RepositoryPermission} is the same as the obj argument
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ {
+ return false;
+ }
+
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+
+ final RepositoryPermission other = (RepositoryPermission) obj;
+
+ return Objects.equal(name, other.name)
+ && verbs.size() == other.verbs.size()
+ && verbs.containsAll(other.verbs)
+ && Objects.equal(role, other.role)
+ && Objects.equal(groupPermission, other.groupPermission);
+ }
+
+ /**
+ * Returns the hash code value for the {@link RepositoryPermission}.
+ *
+ *
+ * @return the hash code value for the {@link RepositoryPermission}
+ */
+ @Override
+ public int hashCode()
+ {
+ // Normally we do not have a log of repository permissions having the same size of verbs, but different content.
+ // Therefore we do not use the verbs themselves for the hash code but only the number of verbs.
+ return Objects.hashCode(name, verbs == null? -1: verbs.size(), role, groupPermission);
+ }
+
+
+ @Override
+ public String toString()
+ {
+ //J-
+ return MoreObjects.toStringHelper(this)
+ .add("name", name)
+ .add("role", role)
+ .add("verbs", verbs)
+ .add("groupPermission", groupPermission)
+ .toString();
+ //J+
+ }
+
+ //~--- get methods ----------------------------------------------------------
+
+ /**
+ * Returns the name of the user or group.
+ *
+ *
+ * @return name of the user or group
+ */
+ @Override
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the verb of the permission.
+ *
+ *
+ * @return verb of the permission
+ */
+ public Collection getVerbs()
+ {
+ return verbs == null ? emptyList() : Collections.unmodifiableSet(verbs);
+ }
+
+ /**
+ * Returns the role of the permission.
+ *
+ *
+ * @return role of the permission
+ */
+ public String getRole() {
+ return role;
+ }
+
+ /**
+ * Returns true if the permission is a permission which affects a group.
+ *
+ *
+ * @return true if the permision is a group permission
+ */
+ @Override
+ public boolean isGroupPermission()
+ {
+ return groupPermission;
+ }
+
+ //~--- set methods ----------------------------------------------------------
+
+ /**
+ * Use this for creation only. This will throw an {@link IllegalStateException} when modified.
+ * @throws IllegalStateException when modified after the value has been set once.
+ *
+ * @deprecated Do not use this for "normal" code.
+ * Use {@link RepositoryPermission#RepositoryPermission(String, Collection, boolean)}
+ * or {@link RepositoryPermission#RepositoryPermission(String, String, boolean)} instead.
+ */
+ @Deprecated
+ public void setGroupPermission(boolean groupPermission)
+ {
+ if (this.groupPermission != null) {
+ throw new IllegalStateException(REPOSITORY_MODIFIED_EXCEPTION_TEXT);
+ }
+ this.groupPermission = groupPermission;
+ }
+
+ /**
+ * Use this for creation only. This will throw an {@link IllegalStateException} when modified.
+ * @throws IllegalStateException when modified after the value has been set once.
+ *
+ * @deprecated Do not use this for "normal" code.
+ * Use {@link RepositoryPermission#RepositoryPermission(String, Collection, boolean)}
+ * or {@link RepositoryPermission#RepositoryPermission(String, String, boolean)} instead.
+ */
+ @Deprecated
+ public void setName(String name)
+ {
+ if (this.name != null) {
+ throw new IllegalStateException(REPOSITORY_MODIFIED_EXCEPTION_TEXT);
+ }
+ this.name = name;
+ }
+
+ /**
+ * Use this for creation only. This will throw an {@link IllegalStateException} when modified.
+ * @throws IllegalStateException when modified after the value has been set once.
+ *
+ * @deprecated Do not use this for "normal" code.
+ * Use {@link RepositoryPermission#RepositoryPermission(String, String, boolean)} instead.
+ */
+ @Deprecated
+ public void setRole(String role)
+ {
+ if (this.role != null) {
+ throw new IllegalStateException(REPOSITORY_MODIFIED_EXCEPTION_TEXT);
+ }
+ this.role = role;
+ }
+
+ /**
+ * Use this for creation only. This will throw an {@link IllegalStateException} when modified.
+ * @throws IllegalStateException when modified after the value has been set once.
+ *
+ * @deprecated Do not use this for "normal" code.
+ * Use {@link RepositoryPermission#RepositoryPermission(String, Collection, boolean)} instead.
+ */
+ @Deprecated
+ public void setVerbs(Collection verbs)
+ {
+ if (this.verbs != null) {
+ throw new IllegalStateException(REPOSITORY_MODIFIED_EXCEPTION_TEXT);
+ }
+ this.verbs = verbs == null? emptySet(): unmodifiableSet(new LinkedHashSet<>(verbs));
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryProvider.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryProvider.java
index 1a5300ad21..cea8574d14 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryProvider.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryProvider.java
@@ -6,13 +6,13 @@
* 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.
+ * 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.
+ * 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.
+ * 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
@@ -26,35 +26,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
- *
*/
-
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.throwingproviders.CheckedProvider;
-import sonia.scm.security.ScmSecurityException;
-
/**
*
* @author Sebastian Sdorra
* @since 1.10
*/
-public interface RepositoryProvider extends CheckedProvider
-{
-
- /**
- * Method description
- *
- *
- * @return
- *
- * @throws ScmSecurityException
- */
+public interface RepositoryProvider extends CheckedProvider {
@Override
- public Repository get() throws ScmSecurityException;
+ Repository get();
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryRequestListener.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryRequestListener.java
index 219aa9cee2..409052fe19 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryRequestListener.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryRequestListener.java
@@ -37,12 +37,11 @@ package sonia.scm.repository;
import sonia.scm.plugin.ExtensionPoint;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.IOException;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+//~--- JDK imports ------------------------------------------------------------
/**
* Listener before a repository request is executed. Repository request are
@@ -68,10 +67,6 @@ public interface RepositoryRequestListener
*
* @return false to abort the request
* @throws IOException
- * @throws RepositoryException
*/
- public boolean handleRequest(HttpServletRequest request,
- HttpServletResponse response,
- Repository repository)
- throws IOException, RepositoryException;
+ boolean handleRequest(HttpServletRequest request, HttpServletResponse response, Repository repository) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryRole.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryRole.java
new file mode 100644
index 0000000000..e5ca046aac
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryRole.java
@@ -0,0 +1,230 @@
+/*
+ Copyright (c) 2010, Sebastian Sdorra
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ 3. Neither the name of SCM-Manager; nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ http://bitbucket.org/sdorra/scm-manager
+
+ */
+
+
+
+package sonia.scm.repository;
+
+import com.github.sdorra.ssp.PermissionObject;
+import com.github.sdorra.ssp.StaticPermissions;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.base.Strings;
+import sonia.scm.ModelObject;
+
+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 java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import static java.util.Collections.emptyList;
+import static java.util.Collections.emptySet;
+import static java.util.Collections.unmodifiableSet;
+
+/**
+ * Custom role with specific permissions related to {@link Repository}.
+ * This object should be immutable, but could not be due to mapstruct.
+ */
+@StaticPermissions(value = "repositoryRole", permissions = {}, globalPermissions = {"write"})
+@XmlRootElement(name = "roles")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RepositoryRole implements ModelObject, PermissionObject {
+
+ private static final long serialVersionUID = -723588336073192740L;
+
+ private static final String REPOSITORY_MODIFIED_EXCEPTION_TEXT = "roles must not be modified";
+
+ private String name;
+ @XmlElement(name = "verb")
+ private Set verbs;
+
+ private Long creationDate;
+ private Long lastModified;
+ private String type;
+
+ /**
+ * This constructor exists for mapstruct and JAXB, only -- do not use this in "normal" code.
+ *
+ * @deprecated Do not use this for "normal" code.
+ * Use {@link RepositoryRole#RepositoryRole(String, Collection, String)} instead.
+ */
+ @Deprecated
+ public RepositoryRole() {}
+
+ public RepositoryRole(String name, Collection verbs, String type) {
+ this.name = name;
+ this.verbs = new LinkedHashSet<>(verbs);
+ this.type = type;
+ }
+
+ /**
+ * Returns true if the {@link RepositoryRole} is the same as the obj argument.
+ *
+ *
+ * @param obj the reference object with which to compare
+ *
+ * @return true if the {@link RepositoryRole} is the same as the obj argument
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ final RepositoryRole other = (RepositoryRole) obj;
+
+ return Objects.equal(name, other.name)
+ && verbs.size() == other.verbs.size()
+ && verbs.containsAll(other.verbs);
+ }
+
+ /**
+ * Returns the hash code value for the {@link RepositoryRole}.
+ *
+ *
+ * @return the hash code value for the {@link RepositoryRole}
+ */
+ @Override
+ public int hashCode()
+ {
+ // Normally we do not have a log of repository permissions having the same size of verbs, but different content.
+ // Therefore we do not use the verbs themselves for the hash code but only the number of verbs.
+ return Objects.hashCode(name, verbs == null? -1: verbs.size());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("name", name)
+ .add("verbs", verbs)
+ .toString();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the verb of the role.
+ */
+ public Collection getVerbs() {
+ return verbs == null ? emptyList() : Collections.unmodifiableSet(verbs);
+ }
+
+ @Override
+ public String getId() {
+ return name;
+ }
+
+ @Override
+ public void setLastModified(Long timestamp) {
+ this.lastModified = timestamp;
+ }
+
+ @Override
+ public Long getCreationDate() {
+ return creationDate;
+ }
+
+ @Override
+ public void setCreationDate(Long timestamp) {
+ this.creationDate = timestamp;
+ }
+
+ @Override
+ public Long getLastModified() {
+ return lastModified;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ if (this.type != null) {
+ throw new IllegalStateException(REPOSITORY_MODIFIED_EXCEPTION_TEXT);
+ }
+ this.type = type;
+ }
+
+ @Override
+ public boolean isValid() {
+ return !Strings.isNullOrEmpty(name) && !verbs.isEmpty();
+ }
+
+ /**
+ * Use this for creation only. This will throw an {@link IllegalStateException} when modified.
+ * @throws IllegalStateException when modified after the value has been set once.
+ *
+ * @deprecated Do not use this for "normal" code.
+ * Use {@link RepositoryRole#RepositoryRole(String, Collection, String)} instead.
+ */
+ @Deprecated
+ public void setName(String name) {
+ if (this.name != null) {
+ throw new IllegalStateException(REPOSITORY_MODIFIED_EXCEPTION_TEXT);
+ }
+ this.name = name;
+ }
+
+ /**
+ * Use this for creation only. This will throw an {@link IllegalStateException} when modified.
+ * @throws IllegalStateException when modified after the value has been set once.
+ *
+ * @deprecated Do not use this for "normal" code.
+ * Use {@link RepositoryRole#RepositoryRole(String, Collection, String)} instead.
+ */
+ @Deprecated
+ public void setVerbs(Collection verbs) {
+ if (this.verbs != null) {
+ throw new IllegalStateException(REPOSITORY_MODIFIED_EXCEPTION_TEXT);
+ }
+ this.verbs = verbs == null? emptySet(): unmodifiableSet(new LinkedHashSet<>(verbs));
+ }
+
+ @Override
+ public RepositoryRole clone() {
+ try {
+ return (RepositoryRole) super.clone();
+ } catch (CloneNotSupportedException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleDAO.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleDAO.java
new file mode 100644
index 0000000000..3d7e53b3a2
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleDAO.java
@@ -0,0 +1,10 @@
+package sonia.scm.repository;
+
+import sonia.scm.GenericDAO;
+
+import java.util.List;
+
+public interface RepositoryRoleDAO extends GenericDAO {
+ @Override
+ List getAll();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleEvent.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleEvent.java
new file mode 100644
index 0000000000..fcd21bfbcd
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleEvent.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of SCM-Manager; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+
+
+package sonia.scm.repository;
+
+import sonia.scm.HandlerEventType;
+import sonia.scm.event.AbstractHandlerEvent;
+import sonia.scm.event.Event;
+
+/**
+ * The RepositoryRoleEvent is fired if a repository role object changes.
+ * @since 2.0
+ */
+@Event
+public class RepositoryRoleEvent extends AbstractHandlerEvent {
+
+ /**
+ * Constructs a new repositoryRole event.
+ *
+ *
+ * @param eventType event type
+ * @param repositoryRole changed repositoryRole
+ */
+ public RepositoryRoleEvent(HandlerEventType eventType, RepositoryRole repositoryRole) {
+ super(eventType, repositoryRole);
+ }
+
+ /**
+ * Constructs a new repositoryRole event.
+ *
+ *
+ * @param eventType type of the event
+ * @param repositoryRole changed repositoryRole
+ * @param oldRepositoryRole old repositoryRole
+ */
+ public RepositoryRoleEvent(HandlerEventType eventType, RepositoryRole repositoryRole, RepositoryRole oldRepositoryRole) {
+ super(eventType, repositoryRole, oldRepositoryRole);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleManager.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleManager.java
new file mode 100644
index 0000000000..c7e1971110
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleManager.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of SCM-Manager; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+
+
+package sonia.scm.repository;
+
+import sonia.scm.Manager;
+import sonia.scm.search.Searchable;
+
+/**
+ * The central class for managing {@link RepositoryRole} objects.
+ * This class is a singleton and is available via injection.
+ */
+public interface RepositoryRoleManager extends Manager {
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleModificationEvent.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleModificationEvent.java
new file mode 100644
index 0000000000..eabeb26b2e
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryRoleModificationEvent.java
@@ -0,0 +1,67 @@
+/**
+ * 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.repository;
+
+import sonia.scm.HandlerEventType;
+import sonia.scm.ModificationHandlerEvent;
+import sonia.scm.event.Event;
+
+/**
+ * Event which is fired whenever a repository role is modified.
+ *
+ * @since 2.0
+ */
+@Event
+public class RepositoryRoleModificationEvent extends RepositoryRoleEvent implements ModificationHandlerEvent
+{
+
+ private final RepositoryRole itemBeforeModification;
+
+ /**
+ * Constructs a new {@link RepositoryRoleModificationEvent}.
+ *
+ * @param eventType type of event
+ * @param item changed repository role
+ * @param itemBeforeModification changed repository role before it was modified
+ */
+ public RepositoryRoleModificationEvent(HandlerEventType eventType, RepositoryRole item, RepositoryRole itemBeforeModification)
+ {
+ super(eventType, item);
+ this.itemBeforeModification = itemBeforeModification;
+ }
+
+ @Override
+ public RepositoryRole getItemBeforeModification()
+ {
+ return itemBeforeModification;
+ }
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryUtil.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryUtil.java
deleted file mode 100644
index fd955d27b7..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryUtil.java
+++ /dev/null
@@ -1,315 +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.repository;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import sonia.scm.io.DirectoryFileFilter;
-import sonia.scm.util.IOUtil;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-
-/**
- *
- * @author Sebastian Sdorra
- * @since 1.11
- */
-public final class RepositoryUtil
-{
-
- /** the logger for RepositoryUtil */
- private static final Logger logger =
- LoggerFactory.getLogger(RepositoryUtil.class);
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
- private RepositoryUtil() {}
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param directory
- * @param names
- *
- * @return
- */
- public static List searchRepositoryDirectories(File directory,
- String... names)
- {
- List repositories = new ArrayList<>();
-
- searchRepositoryDirectories(repositories, directory, Arrays.asList(names));
-
- return repositories;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- *
- * @param handler
- * @param directoryPath
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(AbstractRepositoryHandler handler,
- String directoryPath)
- throws IOException
- {
- return getRepositoryName(handler.getConfig().getRepositoryDirectory(),
- new File(directoryPath));
- }
-
- /**
- * Method description
- *
- *
- *
- * @param config
- * @param directoryPath
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(SimpleRepositoryConfig config,
- String directoryPath)
- throws IOException
- {
- return getRepositoryName(config.getRepositoryDirectory(),
- new File(directoryPath));
- }
-
- /**
- * Method description
- *
- *
- *
- * @param handler
- * @param directory
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(AbstractRepositoryHandler handler,
- File directory)
- throws IOException
- {
- return getRepositoryName(handler.getConfig().getRepositoryDirectory(),
- directory);
- }
-
- /**
- * Method description
- *
- *
- *
- * @param config
- * @param directory
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(SimpleRepositoryConfig config,
- File directory)
- throws IOException
- {
- return getRepositoryName(config.getRepositoryDirectory(), directory);
- }
-
- /**
- * Method description
- *
- *
- *
- * @param baseDirectory
- * @param directory
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(File baseDirectory, File directory)
- throws IOException
- {
- String name = null;
- String path = directory.getCanonicalPath();
- int directoryLength = baseDirectory.getCanonicalPath().length();
-
- if (directoryLength < path.length())
- {
- name = IOUtil.trimSeperatorChars(path.substring(directoryLength));
-
- // replace windows path seperator
- name = name.replaceAll("\\\\", "/");
- }
- else if (logger.isWarnEnabled())
- {
- logger.warn("path is shorter as the main repository path");
- }
-
- return name;
- }
-
- /**
- * Method description
- *
- *
- * @param handler
- * @param directoryNames
- *
- * @return
- *
- * @throws IOException
- */
- public static List getRepositoryNames(
- AbstractRepositoryHandler handler, String... directoryNames)
- throws IOException
- {
- return getRepositoryNames(handler.getConfig(), directoryNames);
- }
-
- /**
- * Method description
- *
- *
- * @param config
- * @param directoryNames
- *
- * @return
- *
- * @throws IOException
- */
- public static List getRepositoryNames(SimpleRepositoryConfig config,
- String... directoryNames)
- throws IOException
- {
- return getRepositoryNames(config.getRepositoryDirectory(), directoryNames);
- }
-
- /**
- * Method description
- *
- *
- * @param baseDirectory
- * @param directoryNames
- *
- * @return
- *
- * @throws IOException
- */
- public static List getRepositoryNames(File baseDirectory,
- String... directoryNames)
- throws IOException
- {
- List repositories = new ArrayList<>();
- List repositoryFiles = searchRepositoryDirectories(baseDirectory,
- directoryNames);
-
- for (File file : repositoryFiles)
- {
- String name = getRepositoryName(baseDirectory, file);
-
- if (name != null)
- {
- repositories.add(name);
- }
- }
-
- return repositories;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param repositories
- * @param directory
- * @param names
- */
- private static void searchRepositoryDirectories(List repositories,
- File directory, List names)
- {
- boolean found = false;
-
- for (String name : names)
- {
- if (new File(directory, name).exists())
- {
- found = true;
-
- break;
- }
- }
-
- if (found)
- {
- repositories.add(directory);
- }
- else
- {
- File[] directories = directory.listFiles(DirectoryFileFilter.instance);
-
- if (directories != null)
- {
- for (File d : directories)
- {
- searchRepositoryDirectories(repositories, d, names);
- }
- }
- }
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RevisionNotFoundException.java b/scm-core/src/main/java/sonia/scm/repository/RevisionNotFoundException.java
deleted file mode 100644
index a0fbd3f6a4..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/RevisionNotFoundException.java
+++ /dev/null
@@ -1,83 +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.repository;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.Util;
-
-/**
- * Signals that the specified revision could be found.
- *
- * @author Sebastian Sdorra
- */
-public class RevisionNotFoundException extends RepositoryException
-{
-
- /** Field description */
- private static final long serialVersionUID = -5594008535358811998L;
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs a new {@link RevisionNotFoundException}
- * with the specified revision.
- *
- *
- * @param revision revision which could not be found
- */
- public RevisionNotFoundException(String revision)
- {
- super("revision \"".concat(Util.nonNull(revision)).concat("\" not found"));
- this.revision = Util.nonNull(revision);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Return the revision which could not be found.
- *
- *
- * @return revision which could not be found
- */
- public String getRevision()
- {
- return revision;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String revision;
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/SimpleRepositoryConfig.java b/scm-core/src/main/java/sonia/scm/repository/SimpleRepositoryConfig.java
deleted file mode 100644
index 3654b9c8b4..0000000000
--- a/scm-core/src/main/java/sonia/scm/repository/SimpleRepositoryConfig.java
+++ /dev/null
@@ -1,122 +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.repository;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.Validateable;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Basic {@link Repository} configuration class.
- *
- * @author Sebastian Sdorra
- */
-@XmlRootElement
-public class SimpleRepositoryConfig implements Validateable
-{
-
- /**
- * Returns the directory for the repositories.
- *
- *
- * @return directory for the repositories
- */
- public File getRepositoryDirectory()
- {
- return repositoryDirectory;
- }
-
- /**
- * Returns true if the plugin is disabled.
- *
- *
- * @return true if the plugin is disabled
- * @since 1.13
- */
- public boolean isDisabled()
- {
- return disabled;
- }
-
- /**
- * Returns true if the configuration object is valid.
- *
- *
- * @return true if the configuration object is valid
- */
- @Override
- public boolean isValid()
- {
- return repositoryDirectory != null;
- }
-
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Enable or disable the plugin.
- *
- *
- * @param disabled
- * @since 1.13
- */
- public void setDisabled(boolean disabled)
- {
- this.disabled = disabled;
- }
-
- /**
- * Sets the directory for the repositories
- *
- *
- * @param repositoryDirectory directory for repositories
- */
- public void setRepositoryDirectory(File repositoryDirectory)
- {
- this.repositoryDirectory = repositoryDirectory;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** true if the plugin is disabled */
- private boolean disabled = false;
-
- /** directory for repositories */
- private File repositoryDirectory;
-}
diff --git a/scm-core/src/main/java/sonia/scm/repository/SubRepository.java b/scm-core/src/main/java/sonia/scm/repository/SubRepository.java
index 87e8b1f1e7..55ff0e2269 100644
--- a/scm-core/src/main/java/sonia/scm/repository/SubRepository.java
+++ b/scm-core/src/main/java/sonia/scm/repository/SubRepository.java
@@ -158,10 +158,10 @@ public class SubRepository implements Serializable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("repositoryUrl", repositoryUrl)
- .add("browserUrl", browserUrl)
- .add("revision", revision)
- .toString();
+ .add("repositoryUrl", repositoryUrl)
+ .add("browserUrl", browserUrl)
+ .add("revision", revision)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Tag.java b/scm-core/src/main/java/sonia/scm/repository/Tag.java
index b07c74ffa1..ae436c1a7a 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Tag.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Tag.java
@@ -37,12 +37,12 @@ package sonia.scm.repository;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-//~--- JDK imports ------------------------------------------------------------
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* Represents a tag in a repository.
*
@@ -126,9 +126,9 @@ public final class Tag
{
//J-
return MoreObjects.toStringHelper(this)
- .add("name", name)
- .add("revision", revision)
- .toString();
+ .add("name", name)
+ .add("revision", revision)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Tags.java b/scm-core/src/main/java/sonia/scm/repository/Tags.java
index 8126d8d106..e89ed314ea 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Tags.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Tags.java
@@ -139,8 +139,8 @@ public final class Tags implements Iterable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("tags", tags)
- .toString();
+ .add("tags", tags)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/AbstractBundleOrUnbundleCommandResponse.java b/scm-core/src/main/java/sonia/scm/repository/api/AbstractBundleOrUnbundleCommandResponse.java
index b9e8376fcd..d1d7ef5045 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/AbstractBundleOrUnbundleCommandResponse.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/AbstractBundleOrUnbundleCommandResponse.java
@@ -35,7 +35,6 @@ package sonia.scm.repository.api;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-
/**
* Abstract class for bundle or unbundle command.
*
@@ -97,8 +96,8 @@ public abstract class AbstractBundleOrUnbundleCommandResponse
{
//J-
return MoreObjects.toStringHelper(this)
- .add("changesetCount", changesetCount)
- .toString();
+ .add("changesetCount", changesetCount)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/AbstractDiffCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/AbstractDiffCommandBuilder.java
new file mode 100644
index 0000000000..b5b2f2a08b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/AbstractDiffCommandBuilder.java
@@ -0,0 +1,68 @@
+package sonia.scm.repository.api;
+
+import sonia.scm.FeatureNotSupportedException;
+import sonia.scm.repository.Feature;
+import sonia.scm.repository.spi.DiffCommandRequest;
+
+import java.util.Set;
+
+abstract class AbstractDiffCommandBuilder {
+
+
+ /** request for the diff command implementation */
+ final DiffCommandRequest request = new DiffCommandRequest();
+
+ private final Set supportedFeatures;
+
+ AbstractDiffCommandBuilder(Set supportedFeatures) {
+ this.supportedFeatures = supportedFeatures;
+ }
+
+ /**
+ * Compute the incoming changes of the branch set with {@link #setRevision(String)} in respect to the changeset given
+ * here. In other words: What changes would be new to the ancestor changeset given here when the branch would
+ * be merged into it. Requires feature {@link sonia.scm.repository.Feature#INCOMING_REVISION}!
+ *
+ * @return {@code this}
+ */
+ public T setAncestorChangeset(String revision)
+ {
+ if (!supportedFeatures.contains(Feature.INCOMING_REVISION)) {
+ throw new FeatureNotSupportedException(Feature.INCOMING_REVISION.name());
+ }
+ request.setAncestorChangeset(revision);
+
+ return self();
+ }
+
+ /**
+ * Show the difference only for the given path.
+ *
+ *
+ * @param path path for difference
+ *
+ * @return {@code this}
+ */
+ public T setPath(String path)
+ {
+ request.setPath(path);
+ return self();
+ }
+
+ /**
+ * Show the difference only for the given revision or (using {@link #setAncestorChangeset(String)}) between this
+ * and another revision.
+ *
+ *
+ * @param revision revision for difference
+ *
+ * @return {@code this}
+ */
+ public T setRevision(String revision)
+ {
+ request.setRevision(revision);
+ return self();
+ }
+
+ abstract T self();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BlameCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/BlameCommandBuilder.java
index 203a01b331..f55abd4598 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/BlameCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/BlameCommandBuilder.java
@@ -38,25 +38,22 @@ package sonia.scm.repository.api;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.BlameResult;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKey;
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.BlameCommand;
import sonia.scm.repository.spi.BlameCommandRequest;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
import java.io.Serializable;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* Shows changeset information by line for a given file.
* Blame is also known as annotate in some SCM systems.
@@ -138,10 +135,9 @@ public final class BlameCommandBuilder
* @throws IllegalArgumentException if the path is null or empty
*
* @throws IOException
- * @throws RepositoryException
*/
public BlameResult getBlameResult(String path)
- throws IOException, RepositoryException
+ throws IOException
{
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
"path is required");
@@ -189,7 +185,7 @@ public final class BlameCommandBuilder
if (!disablePreProcessors && (result != null))
{
- preProcessorUtil.prepareForReturn(repository, result, !disableEscaping);
+ preProcessorUtil.prepareForReturn(repository, result);
}
return result;
@@ -214,24 +210,6 @@ public final class BlameCommandBuilder
return this;
}
- /**
- * Disable html escaping for the returned blame lines. By default all
- * blame lines are html escaped.
- *
- *
- * @param disableEscaping true to disable the html escaping
- *
- * @return {@code this}
- *
- * @since 1.35
- */
- public BlameCommandBuilder setDisableEscaping(boolean disableEscaping)
- {
- this.disableEscaping = disableEscaping;
-
- return this;
- }
-
/**
* Disable the execution of pre processors.
*
@@ -366,9 +344,6 @@ public final class BlameCommandBuilder
/** the cache */
private final Cache cache;
- /** disable escaping */
- private boolean disableEscaping = false;
-
/** disable change */
private boolean disableCache = false;
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BranchCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/BranchCommandBuilder.java
new file mode 100644
index 0000000000..33f4a482ac
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/BranchCommandBuilder.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of SCM-Manager; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+
+package sonia.scm.repository.api;
+
+import sonia.scm.repository.Branch;
+import sonia.scm.repository.spi.BranchCommand;
+
+import java.io.IOException;
+
+/**
+ * @since 2.0
+ */
+public final class BranchCommandBuilder {
+
+ public BranchCommandBuilder(BranchCommand command) {
+ this.command = command;
+ }
+
+ /**
+ * Specifies the source branch, which the new branch should be based on.
+ *
+ * @param parentBranch The base branch for the new branch.
+ * @return This builder.
+ */
+ public BranchCommandBuilder from(String parentBranch) {
+ request.setParentBranch(parentBranch);
+ return this;
+ }
+
+ /**
+ * Execute the command and create a new branch with the given name.
+ * @param name The name of the new branch.
+ * @return The created branch.
+ * @throws IOException
+ */
+ public Branch branch(String name) {
+ request.setNewBranch(name);
+ return command.branch(request);
+ }
+
+ public void delete(String branchName) {
+ command.deleteOrClose(branchName);
+ }
+
+ private BranchCommand command;
+ private BranchRequest request = new BranchRequest();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BranchRequest.java b/scm-core/src/main/java/sonia/scm/repository/api/BranchRequest.java
new file mode 100644
index 0000000000..8473567156
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/BranchRequest.java
@@ -0,0 +1,22 @@
+package sonia.scm.repository.api;
+
+public class BranchRequest {
+ private String parentBranch;
+ private String newBranch;
+
+ public String getParentBranch() {
+ return parentBranch;
+ }
+
+ public void setParentBranch(String parentBranch) {
+ this.parentBranch = parentBranch;
+ }
+
+ public String getNewBranch() {
+ return newBranch;
+ }
+
+ public void setNewBranch(String newBranch) {
+ this.newBranch = newBranch;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BranchesCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/BranchesCommandBuilder.java
index 3deaf491d8..968f9ba39d 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/BranchesCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/BranchesCommandBuilder.java
@@ -29,30 +29,22 @@
*
*/
-
package sonia.scm.repository.api;
-//~--- non-JDK imports --------------------------------------------------------
-
import com.google.common.base.Objects;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.Branch;
import sonia.scm.repository.Branches;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKey;
-import sonia.scm.repository.RepositoryException;
-import sonia.scm.repository.spi.BlameCommand;
import sonia.scm.repository.spi.BranchesCommand;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
+
/**
* The branches command list all repository branches.
*
@@ -86,10 +78,8 @@ public final class BranchesCommandBuilder
* only be called from the {@link RepositoryService}.
*
* @param cacheManager cache manager
- * @param blameCommand implementation of the {@link BlameCommand}
- * @param branchesCommand
+ * @param branchesCommand implementation of the {@link BranchesCommand}
* @param repository repository to query
- * @param preProcessorUtil
*/
BranchesCommandBuilder(CacheManager cacheManager,
BranchesCommand branchesCommand, Repository repository)
@@ -108,9 +98,8 @@ public final class BranchesCommandBuilder
* @return branches from the repository
*
* @throws IOException
- * @throws RepositoryException
*/
- public Branches getBranches() throws RepositoryException, IOException
+ public Branches getBranches() throws IOException
{
Branches branches;
@@ -139,10 +128,7 @@ public final class BranchesCommandBuilder
branches = getBranchesFromCommand();
- if (branches != null)
- {
- cache.put(key, branches);
- }
+ cache.put(key, branches);
}
else if (logger.isDebugEnabled())
{
@@ -182,10 +168,9 @@ public final class BranchesCommandBuilder
* @return
*
* @throws IOException
- * @throws RepositoryException
*/
private Branches getBranchesFromCommand()
- throws RepositoryException, IOException
+ throws IOException
{
return new Branches(branchesCommand.getBranches());
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java
index f37677f37b..d482c04ea4 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java
@@ -36,29 +36,22 @@ package sonia.scm.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.FileObject;
-import sonia.scm.repository.FileObjectNameComparator;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKey;
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.BrowseCommand;
import sonia.scm.repository.spi.BrowseCommandRequest;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
import java.io.Serializable;
-import java.util.Collections;
-import java.util.List;
+//~--- JDK imports ------------------------------------------------------------
/**
* BrowseCommandBuilder is able to browse the files of a {@link Repository}.
@@ -100,7 +93,7 @@ public final class BrowseCommandBuilder
* only be called from the {@link RepositoryService}.
*
* @param cacheManager cache manager
- * @param logCommand implementation of the {@link LogCommand}
+ * @param browseCommand implementation of the {@link BrowseCommand}
* @param browseCommand
* @param repository repository to query
* @param preProcessorUtil
@@ -140,11 +133,8 @@ public final class BrowseCommandBuilder
* @return files for the given parameters
*
* @throws IOException
- * @throws RepositoryException
*/
- public BrowserResult getBrowserResult()
- throws IOException, RepositoryException
- {
+ public BrowserResult getBrowserResult() throws IOException {
BrowserResult result = null;
if (disableCache)
@@ -185,15 +175,7 @@ public final class BrowseCommandBuilder
if (!disablePreProcessors && (result != null))
{
- preProcessorUtil.prepareForReturn(repository, result, !disableEscaping);
-
- List fileObjects = result.getFiles();
-
- if (fileObjects != null)
- {
- fileObjects.sort(FileObjectNameComparator.instance);
- result.setFiles(fileObjects);
- }
+ preProcessorUtil.prepareForReturn(repository, result);
}
return result;
@@ -218,24 +200,6 @@ public final class BrowseCommandBuilder
return this;
}
- /**
- * Disable html escaping for the returned file objects. By default all
- * file objects are html escaped.
- *
- *
- * @param disableEscaping true to disable the html escaping
- *
- * @return {@code this}
- *
- * @since 1.35
- */
- public BrowseCommandBuilder setDisableEscaping(boolean disableEscaping)
- {
- this.disableEscaping = disableEscaping;
-
- return this;
- }
-
/**
* Disabling the last commit means that every call to
* {@link FileObject#getDescription()} and
@@ -439,9 +403,6 @@ public final class BrowseCommandBuilder
/** cache */
private final Cache cache;
- /** disable escaping */
- private boolean disableEscaping = false;
-
/** disables the cache */
private boolean disableCache = false;
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BundleCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/BundleCommandBuilder.java
index 4a25c0df50..1f4defbd8b 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/BundleCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/BundleCommandBuilder.java
@@ -37,23 +37,21 @@ package sonia.scm.repository.api;
import com.google.common.io.ByteSink;
import com.google.common.io.Files;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.BundleCommand;
import sonia.scm.repository.spi.BundleCommandRequest;
-import static com.google.common.base.Preconditions.*;
-
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+//~--- JDK imports ------------------------------------------------------------
+
/**
* The bundle command dumps a repository to a byte source such as a file. The
* created bundle can be restored to an empty repository with the
@@ -94,11 +92,8 @@ public final class BundleCommandBuilder
* @return bundle response
*
* @throws IOException
- * @throws RepositoryException
*/
- public BundleResponse bundle(File outputFile)
- throws IOException, RepositoryException
- {
+ public BundleResponse bundle(File outputFile) throws IOException {
checkArgument((outputFile != null) &&!outputFile.exists(),
"file is null or exists already");
@@ -120,10 +115,9 @@ public final class BundleCommandBuilder
* @return bundle response
*
* @throws IOException
- * @throws RepositoryException
*/
public BundleResponse bundle(OutputStream outputStream)
- throws IOException, RepositoryException
+ throws IOException
{
checkNotNull(outputStream, "output stream is required");
@@ -141,13 +135,12 @@ public final class BundleCommandBuilder
* @return bundle response
*
* @throws IOException
- * @throws RepositoryException
*/
public BundleResponse bundle(ByteSink sink)
- throws IOException, RepositoryException
+ throws IOException
{
checkNotNull(sink, "byte sink is required");
- logger.info("bundle {} to byte sink");
+ logger.info("bundle {} to byte sink", sink);
return bundleCommand.bundle(new BundleCommandRequest(sink));
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/CatCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/CatCommandBuilder.java
index f7b4d75fbd..d1e0cbc5f1 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/CatCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/CatCommandBuilder.java
@@ -33,24 +33,18 @@
package sonia.scm.repository.api;
-//~--- non-JDK imports --------------------------------------------------------
-
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.CatCommand;
import sonia.scm.repository.spi.CatCommandRequest;
import sonia.scm.util.IOUtil;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
/**
@@ -106,23 +100,31 @@ public final class CatCommandBuilder
}
/**
- * Passes the content of the given file to the outputstream.
+ * Passes the content of the given file to the output stream.
*
- * @param outputStream outputstream for the content
+ * @param outputStream output stream for the content
* @param path file path
- *
- * @return {@code this}
- *
- * @throws IOException
- * @throws RepositoryException
*/
- public CatCommandBuilder retriveContent(OutputStream outputStream,
- String path)
- throws IOException, RepositoryException
- {
+ public void retriveContent(OutputStream outputStream, String path) throws IOException {
getCatResult(outputStream, path);
+ }
- return this;
+ /**
+ * Returns an output stream with the file content.
+ *
+ * @param path file path
+ */
+ public InputStream getStream(String path) throws IOException {
+ Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
+ "path is required");
+
+ CatCommandRequest requestClone = request.clone();
+
+ requestClone.setPath(path);
+
+ logger.debug("create cat stream for {}", requestClone);
+
+ return catCommand.getCatResultStream(requestClone);
}
//~--- get methods ----------------------------------------------------------
@@ -134,10 +136,8 @@ public final class CatCommandBuilder
* @return content of the file
*
* @throws IOException
- * @throws RepositoryException
*/
- public String getContent(String path) throws IOException, RepositoryException
- {
+ public String getContent(String path) throws IOException {
String content = null;
ByteArrayOutputStream baos = null;
@@ -182,11 +182,9 @@ public final class CatCommandBuilder
* @param path path of the file
*
* @throws IOException
- * @throws RepositoryException
*/
private void getCatResult(OutputStream outputStream, String path)
- throws IOException, RepositoryException
- {
+ throws IOException {
Preconditions.checkNotNull(outputStream, "OutputStream is required");
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
"path is required");
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/Command.java b/scm-core/src/main/java/sonia/scm/repository/api/Command.java
index ccb0d8c2c0..8e95e314bb 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/Command.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/Command.java
@@ -61,5 +61,10 @@ public enum Command
/**
* @since 1.43
*/
- BUNDLE, UNBUNDLE;
+ BUNDLE, UNBUNDLE,
+
+ /**
+ * @since 2.0
+ */
+ MODIFICATIONS, MERGE, DIFF_RESULT, BRANCH, MODIFY;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/DiffCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/DiffCommandBuilder.java
index e1d7ba5f1a..03f4361083 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/DiffCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/DiffCommandBuilder.java
@@ -36,20 +36,17 @@ package sonia.scm.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Preconditions;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import sonia.scm.repository.RepositoryException;
+import sonia.scm.repository.Feature;
import sonia.scm.repository.spi.DiffCommand;
-import sonia.scm.repository.spi.DiffCommandRequest;
-import sonia.scm.util.IOUtil;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Set;
+
+//~--- JDK imports ------------------------------------------------------------
/**
* Shows differences between revisions for a specified file or
@@ -72,7 +69,7 @@ import java.io.OutputStream;
* @author Sebastian Sdorra
* @since 1.17
*/
-public final class DiffCommandBuilder
+public final class DiffCommandBuilder extends AbstractDiffCommandBuilder
{
/**
@@ -81,18 +78,21 @@ public final class DiffCommandBuilder
private static final Logger logger =
LoggerFactory.getLogger(DiffCommandBuilder.class);
+ /** implementation of the diff command */
+ private final DiffCommand diffCommand;
+
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new {@link DiffCommandBuilder}, this constructor should
* only be called from the {@link RepositoryService}.
*
- * @param implementation of {@link DiffCommand}
- *
- * @param diffCommand
+ * @param diffCommand implementation of {@link DiffCommand}
+ * @param supportedFeatures The supported features of the provider
*/
- DiffCommandBuilder(DiffCommand diffCommand)
+ DiffCommandBuilder(DiffCommand diffCommand, Set supportedFeatures)
{
+ super(supportedFeatures);
this.diffCommand = diffCommand;
}
@@ -102,19 +102,12 @@ public final class DiffCommandBuilder
* Passes the difference of the given parameter to the outputstream.
*
*
- * @param outputStream outputstream for the difference
- *
- * @return {@code this}
+ * @return A consumer that expects the output stream for the difference
*
* @throws IOException
- * @throws RepositoryException
*/
- public DiffCommandBuilder retriveContent(OutputStream outputStream)
- throws IOException, RepositoryException
- {
- getDiffResult(outputStream);
-
- return this;
+ public OutputStreamConsumer retrieveContent() throws IOException {
+ return getDiffResult();
}
//~--- get methods ----------------------------------------------------------
@@ -125,25 +118,12 @@ public final class DiffCommandBuilder
* @return content of the difference
*
* @throws IOException
- * @throws RepositoryException
*/
- public String getContent() throws IOException, RepositoryException
- {
- String content = null;
- ByteArrayOutputStream baos = null;
-
- try
- {
- baos = new ByteArrayOutputStream();
- getDiffResult(baos);
- content = baos.toString();
+ public String getContent() throws IOException {
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+ getDiffResult();
+ return baos.toString();
}
- finally
- {
- IOUtil.close(baos);
- }
-
- return content;
}
//~--- set methods ----------------------------------------------------------
@@ -167,69 +147,31 @@ public final class DiffCommandBuilder
return this;
}
-
- /**
- * Show the difference only for the given path.
- *
- *
- * @param path path for difference
- *
- * @return {@code this}
- */
- public DiffCommandBuilder setPath(String path)
- {
- request.setPath(path);
-
- return this;
- }
-
- /**
- * Show the difference only for the given revision.
- *
- *
- * @param revision revision for difference
- *
- * @return {@code this}
- */
- public DiffCommandBuilder setRevision(String revision)
- {
- request.setRevision(revision);
-
- return this;
- }
-
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
- * @param outputStream
- * @param path
- *
* @throws IOException
- * @throws RepositoryException
+ * @return
*/
- private void getDiffResult(OutputStream outputStream)
- throws IOException, RepositoryException
- {
- Preconditions.checkNotNull(outputStream, "OutputStream is required");
+ private OutputStreamConsumer getDiffResult() throws IOException {
Preconditions.checkArgument(request.isValid(),
"path and/or revision is required");
- if (logger.isDebugEnabled())
- {
- logger.debug("create diff for {}", request);
- }
+ logger.debug("create diff for {}", request);
- diffCommand.getDiffResult(request, outputStream);
+ return diffCommand.getDiffResult(request);
}
- //~--- fields ---------------------------------------------------------------
+ @Override
+ DiffCommandBuilder self() {
+ return this;
+ }
- /** implementation of the diff command */
- private final DiffCommand diffCommand;
-
- /** request for the diff command implementation */
- private final DiffCommandRequest request = new DiffCommandRequest();
+ @FunctionalInterface
+ public interface OutputStreamConsumer {
+ void accept(OutputStream outputStream) throws IOException;
+ }
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/DiffFile.java b/scm-core/src/main/java/sonia/scm/repository/api/DiffFile.java
new file mode 100644
index 0000000000..a3b1bafe0b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/DiffFile.java
@@ -0,0 +1,12 @@
+package sonia.scm.repository.api;
+
+public interface DiffFile extends Iterable {
+
+ String getOldRevision();
+
+ String getNewRevision();
+
+ String getOldPath();
+
+ String getNewPath();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/DiffLine.java b/scm-core/src/main/java/sonia/scm/repository/api/DiffLine.java
new file mode 100644
index 0000000000..193e5e75d5
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/DiffLine.java
@@ -0,0 +1,12 @@
+package sonia.scm.repository.api;
+
+import java.util.OptionalInt;
+
+public interface DiffLine {
+
+ OptionalInt getOldLineNumber();
+
+ OptionalInt getNewLineNumber();
+
+ String getContent();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/DiffResult.java b/scm-core/src/main/java/sonia/scm/repository/api/DiffResult.java
new file mode 100644
index 0000000000..b662db4e2d
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/DiffResult.java
@@ -0,0 +1,8 @@
+package sonia.scm.repository.api;
+
+public interface DiffResult extends Iterable {
+
+ String getOldRevision();
+
+ String getNewRevision();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/DiffResultCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/DiffResultCommandBuilder.java
new file mode 100644
index 0000000000..7e152f3d0f
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/DiffResultCommandBuilder.java
@@ -0,0 +1,41 @@
+package sonia.scm.repository.api;
+
+import com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import sonia.scm.repository.Feature;
+import sonia.scm.repository.spi.DiffResultCommand;
+
+import java.io.IOException;
+import java.util.Set;
+
+public class DiffResultCommandBuilder extends AbstractDiffCommandBuilder {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DiffResultCommandBuilder.class);
+
+ private final DiffResultCommand diffResultCommand;
+
+ DiffResultCommandBuilder(DiffResultCommand diffResultCommand, Set supportedFeatures) {
+ super(supportedFeatures);
+ this.diffResultCommand = diffResultCommand;
+ }
+
+ /**
+ * Returns the content of the difference as parsed objects.
+ *
+ * @return content of the difference
+ */
+ public DiffResult getDiffResult() throws IOException {
+ Preconditions.checkArgument(request.isValid(),
+ "path and/or revision is required");
+
+ LOG.debug("create diff result for {}", request);
+
+ return diffResultCommand.getDiffResult(request);
+ }
+
+ @Override
+ DiffResultCommandBuilder self() {
+ return this;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/HookChangesetBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/HookChangesetBuilder.java
index fb3900445e..7e016db430 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/HookChangesetBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/HookChangesetBuilder.java
@@ -33,24 +33,27 @@ package sonia.scm.repository.api;
//~--- non-JDK imports --------------------------------------------------------
+import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Streams;
+import com.google.common.collect.Iterables;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import sonia.scm.io.DeepCopy;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.spi.HookChangesetProvider;
import sonia.scm.repository.spi.HookChangesetRequest;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.function.Function;
-import java.util.stream.Collectors;
+import sonia.scm.repository.spi.HookChangesetResponse;
//~--- JDK imports ------------------------------------------------------------
+import java.io.IOException;
+
+import java.util.List;
+
/**
* The {@link HookChangesetBuilder} is able to return all {@link Changeset}s
* which are added during the current push/commit.
@@ -113,31 +116,39 @@ public final class HookChangesetBuilder
*/
public Iterable getChangesets()
{
- Iterable changesets =
- provider.handleRequest(request).getChangesets();
+ HookChangesetResponse hookChangesetResponse = provider.handleRequest(request);
+ Iterable changesets = hookChangesetResponse.getChangesets();
if (!disablePreProcessors)
{
- final Function changesetFunction = c -> {
- Changeset copy = null;
+ changesets = Iterables.transform(changesets,
+ new Function()
+ {
- try {
- copy = DeepCopy.copy(c);
- preProcessorUtil.prepareForReturn(repository, copy,
- !disableEscaping);
- } catch (IOException ex) {
- logger.error("could not create a copy of changeset", ex);
+ @Override
+ public Changeset apply(Changeset c)
+ {
+ Changeset copy = null;
+
+ try
+ {
+ copy = DeepCopy.copy(c);
+ preProcessorUtil.prepareForReturn(repository, copy);
+ }
+ catch (IOException ex)
+ {
+ logger.error("could not create a copy of changeset", ex);
+ }
+
+ if (copy == null)
+ {
+ copy = c;
+ }
+
+ return copy;
}
- if (copy == null) {
- copy = c;
- }
-
- return copy;
- };
- changesets = Streams.stream(changesets)
- .map(changesetFunction::apply)
- .collect(Collectors.toList());
+ });
}
return changesets;
@@ -145,24 +156,6 @@ public final class HookChangesetBuilder
//~--- set methods ----------------------------------------------------------
- /**
- * Disable html escaping for the returned changesets. By default all
- * changesets are html escaped.
- *
- *
- * @param disableEscaping true to disable the html escaping
- *
- * @return {@code this}
- *
- * @since 1.35
- */
- public HookChangesetBuilder setDisableEscaping(boolean disableEscaping)
- {
- this.disableEscaping = disableEscaping;
-
- return this;
- }
-
/**
* Disable the execution of pre processors.
*
@@ -181,9 +174,6 @@ public final class HookChangesetBuilder
//~--- fields ---------------------------------------------------------------
- /** disable escaping */
- private boolean disableEscaping = false;
-
/** disable pre processors marker */
private boolean disablePreProcessors = false;
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/Hunk.java b/scm-core/src/main/java/sonia/scm/repository/api/Hunk.java
new file mode 100644
index 0000000000..c8a3e1ebca
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/Hunk.java
@@ -0,0 +1,24 @@
+package sonia.scm.repository.api;
+
+public interface Hunk extends Iterable {
+
+ default String getRawHeader() {
+ return String.format("@@ -%s +%s @@", getLineMarker(getOldStart(), getOldLineCount()), getLineMarker(getNewStart(), getNewLineCount()));
+ }
+
+ default String getLineMarker(int start, int lineCount) {
+ if (lineCount == 1) {
+ return Integer.toString(start);
+ } else {
+ return String.format("%s,%s", start, lineCount);
+ }
+ }
+
+ int getOldStart();
+
+ int getOldLineCount();
+
+ int getNewStart();
+
+ int getNewLineCount();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/IncomingCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/IncomingCommandBuilder.java
index 747cb837a0..6098bdf92b 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/IncomingCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/IncomingCommandBuilder.java
@@ -36,22 +36,19 @@ package sonia.scm.repository.api;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
-
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
-import sonia.scm.repository.PermissionType;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryException;
+import sonia.scm.repository.RepositoryPermissions;
import sonia.scm.repository.spi.IncomingCommand;
import sonia.scm.repository.spi.IncomingCommandRequest;
-import sonia.scm.security.RepositoryPermission;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* The incoming command shows new {@link Changeset}s found in a different
* repository location.
@@ -66,8 +63,6 @@ public final class IncomingCommandBuilder
* Constructs a new {@link IncomingCommandBuilder}, this constructor should
* only be called from the {@link RepositoryService}.
*
- * @param cacheManager cache manager
- *
* @param cacheManger
* @param command implementation of the {@link IncomingCommand}
* @param repository repository to query
@@ -91,16 +86,14 @@ public final class IncomingCommandBuilder
* @return incoming changesets
*
* @throws IOException
- * @throws RepositoryException
*/
public ChangesetPagingResult getIncomingChangesets(
Repository remoteRepository)
- throws IOException, RepositoryException
+ throws IOException
{
Subject subject = SecurityUtils.getSubject();
- subject.checkPermission(new RepositoryPermission(remoteRepository,
- PermissionType.READ));
+ subject.isPermitted(RepositoryPermissions.pull(remoteRepository).asShiroString());
request.setRemoteRepository(remoteRepository);
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/LogCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/LogCommandBuilder.java
index de5e2b1b9f..2836fc537d 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/LogCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/LogCommandBuilder.java
@@ -37,25 +37,25 @@ package sonia.scm.repository.api;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+import sonia.scm.FeatureNotSupportedException;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
+import sonia.scm.repository.Feature;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKey;
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.LogCommand;
import sonia.scm.repository.spi.LogCommandRequest;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
import java.io.Serializable;
+import java.util.Set;
+
+//~--- JDK imports ------------------------------------------------------------
/**
* LogCommandBuilder is able to show the history of a file in a
@@ -107,19 +107,20 @@ public final class LogCommandBuilder
/**
* Constructs a new {@link LogCommandBuilder}, this constructor should
* only be called from the {@link RepositoryService}.
- *
- * @param cacheManager cache manager
+ * @param cacheManager cache manager
* @param logCommand implementation of the {@link LogCommand}
* @param repository repository to query
* @param preProcessorUtil
+ * @param supportedFeatures The supported features of the provider
*/
LogCommandBuilder(CacheManager cacheManager, LogCommand logCommand,
- Repository repository, PreProcessorUtil preProcessorUtil)
+ Repository repository, PreProcessorUtil preProcessorUtil, Set supportedFeatures)
{
this.cache = cacheManager.getCache(CACHE_NAME);
this.logCommand = logCommand;
this.repository = repository;
this.preProcessorUtil = preProcessorUtil;
+ this.supportedFeatures = supportedFeatures;
}
//~--- methods --------------------------------------------------------------
@@ -166,11 +167,8 @@ public final class LogCommandBuilder
* @return the {@link Changeset} with the given id or null
*
* @throws IOException
- * @throws RepositoryException
*/
- public Changeset getChangeset(String id)
- throws IOException, RepositoryException
- {
+ public Changeset getChangeset(String id) throws IOException {
Changeset changeset;
if (disableCache)
@@ -180,7 +178,7 @@ public final class LogCommandBuilder
logger.debug("get changeset for {} with disabled cache", id);
}
- changeset = logCommand.getChangeset(id);
+ changeset = logCommand.getChangeset(id, request);
}
else
{
@@ -194,7 +192,7 @@ public final class LogCommandBuilder
logger.debug("get changeset for {}", id);
}
- changeset = logCommand.getChangeset(id);
+ changeset = logCommand.getChangeset(id, request);
if (changeset != null)
{
@@ -228,11 +226,8 @@ public final class LogCommandBuilder
* @return all changesets with the given parameters
*
* @throws IOException
- * @throws RepositoryException
*/
- public ChangesetPagingResult getChangesets()
- throws IOException, RepositoryException
- {
+ public ChangesetPagingResult getChangesets() throws IOException {
ChangesetPagingResult cpr;
if (disableCache)
@@ -272,7 +267,7 @@ public final class LogCommandBuilder
if (!disablePreProcessors && (cpr != null))
{
- preProcessorUtil.prepareForReturn(repository, cpr, !disableEscaping);
+ preProcessorUtil.prepareForReturn(repository, cpr);
}
return cpr;
@@ -314,24 +309,6 @@ public final class LogCommandBuilder
return this;
}
- /**
- * Disable html escaping for the returned changesets. By default all
- * changesets are html escaped.
- *
- *
- * @param disableEscaping true to disable the html escaping
- *
- * @return {@code this}
- *
- * @since 1.35
- */
- public LogCommandBuilder setDisableEscaping(boolean disableEscaping)
- {
- this.disableEscaping = disableEscaping;
-
- return this;
- }
-
/**
* Disable the execution of pre processors.
*
@@ -424,6 +401,21 @@ public final class LogCommandBuilder
return this;
}
+ /**
+ * Compute the incoming changes of the branch set with {@link #setBranch(String)} in respect to the changeset given
+ * here. In other words: What changesets would be new to the ancestor changeset given here when the branch would
+ * be merged into it. Requires feature {@link sonia.scm.repository.Feature#INCOMING_REVISION}!
+ *
+ * @return {@code this}
+ */
+ public LogCommandBuilder setAncestorChangeset(String ancestorChangeset) {
+ if (!supportedFeatures.contains(Feature.INCOMING_REVISION)) {
+ throw new FeatureNotSupportedException(Feature.INCOMING_REVISION.name());
+ }
+ request.setAncestorChangeset(ancestorChangeset);
+ return this;
+ }
+
//~--- inner classes --------------------------------------------------------
/**
@@ -549,13 +541,11 @@ public final class LogCommandBuilder
/** Field description */
private final PreProcessorUtil preProcessorUtil;
+ private Set supportedFeatures;
/** repository to query */
private final Repository repository;
- /** disable escaping */
- private boolean disableEscaping = false;
-
/** disable cache */
private boolean disableCache = false;
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/MergeCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/MergeCommandBuilder.java
new file mode 100644
index 0000000000..6c4324c259
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/MergeCommandBuilder.java
@@ -0,0 +1,180 @@
+package sonia.scm.repository.api;
+
+import com.google.common.base.Preconditions;
+import sonia.scm.repository.Person;
+import sonia.scm.repository.spi.MergeCommand;
+import sonia.scm.repository.spi.MergeCommandRequest;
+import sonia.scm.repository.util.AuthorUtil;
+
+import java.util.Set;
+
+/**
+ * Use this {@link MergeCommandBuilder} to merge two branches of a repository ({@link #executeMerge()}) or to check if
+ * the branches could be merged without conflicts ({@link #dryRun()}). To do so, you have to specify the name of
+ * the target branch ({@link #setTargetBranch(String)}) and the name of the branch that should be merged
+ * ({@link #setBranchToMerge(String)}). Additionally you can specify an author that should be used for the commit
+ * ({@link #setAuthor(Person)}) and a message template ({@link #setMessageTemplate(String)}) if you are not doing a dry
+ * run only. If no author is specified, the logged in user and a default message will be used instead.
+ *
+ * To actually merge feature_branch into integration_branch do this:
+ *
+ *
+ * Keep in mind that you should always check the result of a merge even though you may have done a dry run
+ * beforehand, because the branches can change between the dry run and the actual merge.
+ *
+ * @since 2.0.0
+ */
+public class MergeCommandBuilder {
+
+ private final MergeCommand mergeCommand;
+ private final MergeCommandRequest request = new MergeCommandRequest();
+
+ MergeCommandBuilder(MergeCommand mergeCommand) {
+ this.mergeCommand = mergeCommand;
+ }
+
+ /**
+ * Use this to check if merge-strategy is supported by mergeCommand.
+ *
+ * @return boolean.
+ */
+ public boolean isSupported(MergeStrategy strategy) {
+ return mergeCommand.isSupported(strategy);
+ }
+
+ /**
+ * Use this to get a Set of all supported merge strategies by merge command.
+ *
+ * @return boolean.
+ */
+ public Set getSupportedMergeStrategies() {
+ return mergeCommand.getSupportedMergeStrategies();
+ }
+
+ /**
+ * Use this to set the branch that should be merged into the target branch.
+ *
+ * This is mandatory.
+ *
+ * @return This builder instance.
+ */
+ public MergeCommandBuilder setBranchToMerge(String branchToMerge) {
+ request.setBranchToMerge(branchToMerge);
+ return this;
+ }
+
+ /**
+ * Use this to set the target branch the other branch should be merged into.
+ *
+ * This is mandatory.
+ *
+ * @return This builder instance.
+ */
+ public MergeCommandBuilder setTargetBranch(String targetBranch) {
+ request.setTargetBranch(targetBranch);
+ return this;
+ }
+
+ /**
+ * Use this to set the author of the merge commit manually. If this is omitted, the currently logged in user will be
+ * used instead.
+ *
+ * This is optional and for {@link #executeMerge()} only.
+ *
+ * @return This builder instance.
+ */
+ public MergeCommandBuilder setAuthor(Person author) {
+ request.setAuthor(author);
+ return this;
+ }
+
+ /**
+ * Use this to set the strategy of the merge commit manually.
+ *
+ * This is optional and for {@link #executeMerge()} only.
+ *
+ * @return This builder instance.
+ */
+ public MergeCommandBuilder setMergeStrategy(MergeStrategy strategy) {
+ if (!mergeCommand.isSupported(strategy)) {
+ throw new IllegalArgumentException("merge strategy not supported: " + strategy);
+ }
+ request.setMergeStrategy(strategy);
+ return this;
+ }
+
+ /**
+ * Use this to set a template for the commit message. If no message is set, a default message will be used.
+ *
+ * You can use the placeholder {0} for the branch to be merged and {1} for the target
+ * branch, eg.:
+ *
+ *
+ * ...setMessageTemplate("Merge of {0} into {1}")...
+ *
+ *
+ * This is optional and for {@link #executeMerge()} only.
+ *
+ * @return This builder instance.
+ */
+ public MergeCommandBuilder setMessageTemplate(String messageTemplate) {
+ request.setMessageTemplate(messageTemplate);
+ return this;
+ }
+
+ /**
+ * Use this to reset the command.
+ * @return This builder instance.
+ */
+ public MergeCommandBuilder reset() {
+ request.reset();
+ return this;
+ }
+
+ /**
+ * Use this to actually do the merge. If an automatic merge is not possible, {@link MergeCommandResult#isSuccess()}
+ * will return false.
+ *
+ * @return The result of the merge.
+ */
+ public MergeCommandResult executeMerge() {
+ AuthorUtil.setAuthorIfNotAvailable(request);
+ Preconditions.checkArgument(request.isValid(), "revision to merge and target revision is required");
+ return mergeCommand.merge(request);
+ }
+
+ /**
+ * Use this to check whether the given branches can be merged autmatically. If this is possible,
+ * {@link MergeDryRunCommandResult#isMergeable()} will return true.
+ *
+ * @return The result whether the given branches can be merged automatically.
+ */
+ public MergeDryRunCommandResult dryRun() {
+ Preconditions.checkArgument(request.isValid(), "revision to merge and target revision is required");
+ return mergeCommand.dryRun(request);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/MergeCommandResult.java b/scm-core/src/main/java/sonia/scm/repository/api/MergeCommandResult.java
new file mode 100644
index 0000000000..53f712cddc
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/MergeCommandResult.java
@@ -0,0 +1,44 @@
+package sonia.scm.repository.api;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import static java.util.Collections.emptyList;
+import static java.util.Collections.unmodifiableCollection;
+
+/**
+ * This class keeps the result of a merge of branches. Use {@link #isSuccess()} to check whether the merge was
+ * sucessfully executed. If the result is false the merge could not be done without conflicts. In this
+ * case you can use {@link #getFilesWithConflict()} to get a list of files with merge conflicts.
+ */
+public class MergeCommandResult {
+ private final Collection filesWithConflict;
+
+ private MergeCommandResult(Collection filesWithConflict) {
+ this.filesWithConflict = filesWithConflict;
+ }
+
+ public static MergeCommandResult success() {
+ return new MergeCommandResult(emptyList());
+ }
+
+ public static MergeCommandResult failure(Collection filesWithConflict) {
+ return new MergeCommandResult(new HashSet<>(filesWithConflict));
+ }
+
+ /**
+ * If this returns true, the merge was successfull. If this returns false there were
+ * merge conflicts. In this case you can use {@link #getFilesWithConflict()} to check what files could not be merged.
+ */
+ public boolean isSuccess() {
+ return filesWithConflict.isEmpty();
+ }
+
+ /**
+ * If the merge was not successful ({@link #isSuccess()} returns false) this will give you a list of
+ * file paths that could not be merged automatically.
+ */
+ public Collection getFilesWithConflict() {
+ return unmodifiableCollection(filesWithConflict);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/MergeDryRunCommandResult.java b/scm-core/src/main/java/sonia/scm/repository/api/MergeDryRunCommandResult.java
new file mode 100644
index 0000000000..6ebb330aae
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/MergeDryRunCommandResult.java
@@ -0,0 +1,22 @@
+package sonia.scm.repository.api;
+
+/**
+ * This class keeps the result of a merge dry run. Use {@link #isMergeable()} to check whether an automatic merge is
+ * possible or not.
+ */
+public class MergeDryRunCommandResult {
+
+ private final boolean mergeable;
+
+ public MergeDryRunCommandResult(boolean mergeable) {
+ this.mergeable = mergeable;
+ }
+
+ /**
+ * This will return true, when an automatic merge is possible at the moment; false
+ * otherwise.
+ */
+ public boolean isMergeable() {
+ return mergeable;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/MergeStrategy.java b/scm-core/src/main/java/sonia/scm/repository/api/MergeStrategy.java
new file mode 100644
index 0000000000..4ccf1f706b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/MergeStrategy.java
@@ -0,0 +1,7 @@
+package sonia.scm.repository.api;
+
+public enum MergeStrategy {
+ MERGE_COMMIT,
+ FAST_FORWARD_IF_POSSIBLE,
+ SQUASH
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/MergeStrategyNotSupportedException.java b/scm-core/src/main/java/sonia/scm/repository/api/MergeStrategyNotSupportedException.java
new file mode 100644
index 0000000000..ae9fbb08b4
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/MergeStrategyNotSupportedException.java
@@ -0,0 +1,27 @@
+package sonia.scm.repository.api;
+
+import sonia.scm.BadRequestException;
+import sonia.scm.repository.Repository;
+
+import static sonia.scm.ContextEntry.ContextBuilder.entity;
+
+@SuppressWarnings("squid:MaximumInheritanceDepth") // exceptions have a deep inheritance depth themselves; therefore we accept this here
+public class MergeStrategyNotSupportedException extends BadRequestException {
+
+ private static final long serialVersionUID = 256498734456613496L;
+
+ private static final String CODE = "6eRhF9gU41";
+
+ public MergeStrategyNotSupportedException(Repository repository, MergeStrategy strategy) {
+ super(entity(repository).build(), createMessage(strategy));
+ }
+
+ @Override
+ public String getCode() {
+ return CODE;
+ }
+
+ private static String createMessage(MergeStrategy strategy) {
+ return "merge strategy " + strategy + " is not supported by this repository";
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/ModificationsCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/ModificationsCommandBuilder.java
new file mode 100644
index 0000000000..498746cc60
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/ModificationsCommandBuilder.java
@@ -0,0 +1,109 @@
+package sonia.scm.repository.api;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import lombok.extern.slf4j.Slf4j;
+import sonia.scm.cache.Cache;
+import sonia.scm.repository.Modifications;
+import sonia.scm.repository.PreProcessorUtil;
+import sonia.scm.repository.Repository;
+import sonia.scm.repository.RepositoryCacheKey;
+import sonia.scm.repository.spi.ModificationsCommand;
+import sonia.scm.repository.spi.ModificationsCommandRequest;
+
+import java.io.IOException;
+
+/**
+ * Get the modifications applied to files in a revision.
+ *
+ * Modifications are for example: Add, Update and Delete
+ *
+ * @author Mohamed Karray
+ * @since 2.0
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Accessors(fluent = true)
+public final class ModificationsCommandBuilder {
+ static final String CACHE_NAME = "sonia.cache.cmd.modifications";
+
+ private final ModificationsCommand modificationsCommand;
+
+ private final ModificationsCommandRequest request = new ModificationsCommandRequest();
+
+ private final Repository repository;
+
+ private final Cache cache;
+
+ private final PreProcessorUtil preProcessorUtil;
+
+ @Setter
+ private boolean disableCache = false;
+
+ @Setter
+ private boolean disablePreProcessors = false;
+
+ public ModificationsCommandBuilder revision(String revision){
+ request.setRevision(revision);
+ return this;
+ }
+
+ /**
+ * Reset each parameter to its default value.
+ *
+ *
+ * @return {@code this}
+ */
+ public ModificationsCommandBuilder reset() {
+ request.reset();
+ this.disableCache = false;
+ this.disablePreProcessors = false;
+ return this;
+ }
+
+ public Modifications getModifications() throws IOException {
+ Modifications modifications;
+ if (disableCache) {
+ log.info("Get modifications for {} with disabled cache", request);
+ modifications = modificationsCommand.getModifications(request);
+ } else {
+ ModificationsCommandBuilder.CacheKey key = new ModificationsCommandBuilder.CacheKey(repository.getId(), request);
+ if (cache.contains(key)) {
+ modifications = cache.get(key);
+ log.debug("Get modifications for {} from the cache", request);
+ } else {
+ log.info("Get modifications for {} with enabled cache", request);
+ modifications = modificationsCommand.getModifications(request);
+ if (modifications != null) {
+ cache.put(key, modifications);
+ log.debug("Modifications for {} added to the cache with key {}", request, key);
+ }
+ }
+ }
+ if (!disablePreProcessors && (modifications != null)) {
+ preProcessorUtil.prepareForReturn(repository, modifications);
+ }
+ return modifications;
+ }
+
+ @AllArgsConstructor
+ @Getter
+ @Setter
+ @EqualsAndHashCode
+ @ToString
+ class CacheKey implements RepositoryCacheKey {
+ private final String repositoryId;
+ private final ModificationsCommandRequest request;
+
+ @Override
+ public String getRepositoryId() {
+ return repositoryId;
+ }
+ }
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/ModifyCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/ModifyCommandBuilder.java
new file mode 100644
index 0000000000..05c1babe03
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/ModifyCommandBuilder.java
@@ -0,0 +1,243 @@
+package sonia.scm.repository.api;
+
+import com.google.common.base.Preconditions;
+import com.google.common.io.ByteSource;
+import com.google.common.io.ByteStreams;
+import com.google.common.io.Files;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import sonia.scm.repository.Person;
+import sonia.scm.repository.spi.ModifyCommand;
+import sonia.scm.repository.spi.ModifyCommandRequest;
+import sonia.scm.repository.util.AuthorUtil;
+import sonia.scm.repository.util.WorkdirProvider;
+import sonia.scm.util.IOUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+
+/**
+ * Use this {@link ModifyCommandBuilder} to make file changes to the head of a branch. You can
+ *
+ *
create new files ({@link #createFile(String)} (with the option to overwrite a file, if it already exists; by
+ * default a {@link sonia.scm.AlreadyExistsException} will be thrown)
+ */
+public class ModifyCommandBuilder {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ModifyCommandBuilder.class);
+
+ private final ModifyCommand command;
+ private final File workdir;
+
+ private final ModifyCommandRequest request = new ModifyCommandRequest();
+
+ ModifyCommandBuilder(ModifyCommand command, WorkdirProvider workdirProvider) {
+ this.command = command;
+ this.workdir = workdirProvider.createNewWorkdir();
+ }
+
+ /**
+ * Create a new file. The content of the file will be specified in a subsequent call to
+ * {@link ContentLoader#withData(ByteSource)} or {@link ContentLoader#withData(InputStream)}.
+ * By default, an {@link sonia.scm.AlreadyExistsException} will be thrown, when there already
+ * exists a file with the given path. You can disable this setting
+ * {@link WithOverwriteFlagContentLoader#setOverwrite(boolean)} to true.
+ * @param path The path and the name of the file that should be created.
+ * @return The loader to specify the content of the new file.
+ */
+ public WithOverwriteFlagContentLoader createFile(String path) {
+ return new WithOverwriteFlagContentLoader(
+ (content, overwrite) -> request.addRequest(new ModifyCommandRequest.CreateFileRequest(path, content, overwrite))
+ );
+ }
+
+ /**
+ * Modify an existing file. The new content of the file will be specified in a subsequent call to
+ * {@link ContentLoader#withData(ByteSource)} or {@link ContentLoader#withData(InputStream)}.
+ * @param path The path and the name of the file that should be modified.
+ * @return The loader to specify the new content of the file.
+ */
+ public SimpleContentLoader modifyFile(String path) {
+ return new SimpleContentLoader(
+ content -> request.addRequest(new ModifyCommandRequest.ModifyFileRequest(path, content))
+ );
+ }
+
+ /**
+ * Delete an existing file.
+ * @param path The path and the name of the file that should be deleted.
+ * @return This builder instance.
+ */
+ public ModifyCommandBuilder deleteFile(String path) {
+ request.addRequest(new ModifyCommandRequest.DeleteFileRequest(path));
+ return this;
+ }
+
+ /**
+ * Apply the changes and create a new commit with the given message and author.
+ * @return The revision of the new commit.
+ */
+ public String execute() {
+ AuthorUtil.setAuthorIfNotAvailable(request);
+ try {
+ Preconditions.checkArgument(request.isValid(), "commit message, branch and at least one request are required");
+ return command.execute(request);
+ } finally {
+ try {
+ IOUtil.delete(workdir);
+ } catch (IOException e) {
+ LOG.warn("could not delete temporary workdir '{}'", workdir, e);
+ }
+ }
+ }
+
+ /**
+ * Set the commit message for the new commit.
+ * @return This builder instance.
+ */
+ public ModifyCommandBuilder setCommitMessage(String message) {
+ request.setCommitMessage(message);
+ return this;
+ }
+
+ /**
+ * Set the author for the new commit.
+ * @return This builder instance.
+ */
+ public ModifyCommandBuilder setAuthor(Person author) {
+ request.setAuthor(author);
+ return this;
+ }
+
+ /**
+ * Set the branch the changes should be made upon.
+ * @return This builder instance.
+ */
+ public ModifyCommandBuilder setBranch(String branch) {
+ request.setBranch(branch);
+ return this;
+ }
+
+ /**
+ * Set the expected revision of the branch, before the changes are applied. If the branch does not have the
+ * expected revision, a concurrent modification exception will be thrown when the command is executed and no
+ * changes will be applied.
+ * @return This builder instance.
+ */
+ public ModifyCommandBuilder setExpectedRevision(String expectedRevision) {
+ request.setExpectedRevision(expectedRevision);
+ return this;
+ }
+
+ public interface ContentLoader {
+ /**
+ * Specify the data of the file using a {@link ByteSource}.
+ *
+ * @return The builder instance.
+ * @throws IOException If the data could not be read.
+ */
+ ModifyCommandBuilder withData(ByteSource data) throws IOException;
+
+ /**
+ * Specify the data of the file using an {@link InputStream}.
+ * @return The builder instance.
+ * @throws IOException If the data could not be read.
+ */
+ ModifyCommandBuilder withData(InputStream data) throws IOException;
+ }
+
+ public class SimpleContentLoader implements ContentLoader {
+
+ private final Consumer contentConsumer;
+
+ private SimpleContentLoader(Consumer contentConsumer) {
+ this.contentConsumer = contentConsumer;
+ }
+
+ @Override
+ public ModifyCommandBuilder withData(ByteSource data) throws IOException {
+ File content = loadData(data);
+ contentConsumer.accept(content);
+ return ModifyCommandBuilder.this;
+ }
+
+ @Override
+ public ModifyCommandBuilder withData(InputStream data) throws IOException {
+ File content = loadData(data);
+ contentConsumer.accept(content);
+ return ModifyCommandBuilder.this;
+ }
+ }
+
+ public class WithOverwriteFlagContentLoader implements ContentLoader {
+
+ private final ContentLoader contentLoader;
+ private boolean overwrite = false;
+
+ private WithOverwriteFlagContentLoader(BiConsumer contentConsumer) {
+ this.contentLoader = new SimpleContentLoader(file -> contentConsumer.accept(file, overwrite));
+ }
+
+ /**
+ * Set this to true to overwrite the file if it already exists. Otherwise an
+ * {@link sonia.scm.AlreadyExistsException} will be thrown.
+ * @return This loader instance.
+ */
+ public WithOverwriteFlagContentLoader setOverwrite(boolean overwrite) {
+ this.overwrite = overwrite;
+ return this;
+ }
+
+ @Override
+ public ModifyCommandBuilder withData(ByteSource data) throws IOException {
+ return contentLoader.withData(data);
+ }
+
+ @Override
+ public ModifyCommandBuilder withData(InputStream data) throws IOException {
+ return contentLoader.withData(data);
+ }
+ }
+
+ @SuppressWarnings("UnstableApiUsage") // Files only used internal
+ private File loadData(ByteSource data) throws IOException {
+ File file = createTemporaryFile();
+ data.copyTo(Files.asByteSink(file));
+ return file;
+ }
+
+ @SuppressWarnings("UnstableApiUsage") // Files and ByteStreams only used internal
+ private File loadData(InputStream data) throws IOException {
+ File file = createTemporaryFile();
+ try (OutputStream out = Files.asByteSink(file).openBufferedStream()) {
+ ByteStreams.copy(data, out);
+ }
+ return file;
+ }
+
+ private File createTemporaryFile() throws IOException {
+ return File.createTempFile("upload-", "", workdir);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/OutgoingCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/OutgoingCommandBuilder.java
index def8c3ae7f..d39c95e0e2 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/OutgoingCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/OutgoingCommandBuilder.java
@@ -30,18 +30,17 @@
*/
package sonia.scm.repository.api;
-import java.io.IOException;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.ChangesetPagingResult;
-import sonia.scm.repository.PermissionType;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryException;
+import sonia.scm.repository.RepositoryPermissions;
import sonia.scm.repository.spi.OutgoingCommand;
import sonia.scm.repository.spi.OutgoingCommandRequest;
-import sonia.scm.security.RepositoryPermission;
+
+import java.io.IOException;
/**
* Show changesets not found in a remote repository.
@@ -62,7 +61,7 @@ public final class OutgoingCommandBuilder
* @param repository repository to query
* @param preProcessorUtil pre processor util
*/
- OutgoingCommandBuilder(CacheManager cacheManger, OutgoingCommand command,
+ OutgoingCommandBuilder(CacheManager cacheManager, OutgoingCommand command,
Repository repository, PreProcessorUtil preProcessorUtil)
{
this.command = command;
@@ -80,12 +79,11 @@ public final class OutgoingCommandBuilder
* @return outgoing changesets
*/
public ChangesetPagingResult getOutgoingChangesets(
- Repository remoteRepository) throws IOException, RepositoryException
+ Repository remoteRepository) throws IOException
{
Subject subject = SecurityUtils.getSubject();
- subject.checkPermission(new RepositoryPermission(remoteRepository,
- PermissionType.READ));
+ subject.isPermitted(RepositoryPermissions.pull(remoteRepository).asShiroString());
request.setRemoteRepository(remoteRepository);
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/PullCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/PullCommandBuilder.java
index 528c93eef9..969ec6ef11 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/PullCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/PullCommandBuilder.java
@@ -36,22 +36,18 @@ package sonia.scm.repository.api;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import sonia.scm.repository.PermissionType;
import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryException;
+import sonia.scm.repository.RepositoryPermissions;
import sonia.scm.repository.spi.PullCommand;
import sonia.scm.repository.spi.PullCommandRequest;
-import sonia.scm.security.RepositoryPermission;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.net.URL;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* The pull command pull changes from a other repository.
*
@@ -93,18 +89,13 @@ public final class PullCommandBuilder
* @return informations over the executed pull command
*
* @throws IOException
- * @throws RepositoryException
- *
+ *
* @since 1.43
*/
- public PullResponse pull(String url)
- throws IOException, RepositoryException
- {
+ public PullResponse pull(String url) throws IOException {
Subject subject = SecurityUtils.getSubject();
//J-
- subject.checkPermission(
- new RepositoryPermission(localRepository, PermissionType.WRITE)
- );
+ subject.isPermitted(RepositoryPermissions.push(localRepository).asShiroString());
//J+
URL remoteUrl = new URL(url);
@@ -125,20 +116,13 @@ public final class PullCommandBuilder
* @return informations over the executed pull command
*
* @throws IOException
- * @throws RepositoryException
*/
- public PullResponse pull(Repository remoteRepository)
- throws IOException, RepositoryException
- {
+ public PullResponse pull(Repository remoteRepository) throws IOException {
Subject subject = SecurityUtils.getSubject();
//J-
- subject.checkPermission(
- new RepositoryPermission(localRepository, PermissionType.WRITE)
- );
- subject.checkPermission(
- new RepositoryPermission(remoteRepository, PermissionType.READ)
- );
+ subject.isPermitted(RepositoryPermissions.push(localRepository).asShiroString());
+ subject.isPermitted(RepositoryPermissions.push(remoteRepository).asShiroString());
//J+
request.reset();
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/PushCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/PushCommandBuilder.java
index fabe938ff7..a734225281 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/PushCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/PushCommandBuilder.java
@@ -37,23 +37,18 @@ package sonia.scm.repository.api;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import sonia.scm.repository.PermissionType;
import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryException;
+import sonia.scm.repository.RepositoryPermissions;
import sonia.scm.repository.spi.PushCommand;
import sonia.scm.repository.spi.PushCommandRequest;
-import sonia.scm.security.RepositoryPermission;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
-
import java.net.URL;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* The push command push changes to a other repository.
*
@@ -91,17 +86,12 @@ public final class PushCommandBuilder
* @return informations of the executed push command
*
* @throws IOException
- * @throws RepositoryException
*/
- public PushResponse push(Repository remoteRepository)
- throws IOException, RepositoryException
- {
+ public PushResponse push(Repository remoteRepository) throws IOException {
Subject subject = SecurityUtils.getSubject();
//J-
- subject.checkPermission(
- new RepositoryPermission(remoteRepository, PermissionType.WRITE)
- );
+ subject.isPermitted(RepositoryPermissions.push(remoteRepository).asShiroString());
//J+
logger.info("push changes to repository {}", remoteRepository.getId());
@@ -120,12 +110,10 @@ public final class PushCommandBuilder
* @return informations of the executed push command
*
* @throws IOException
- * @throws RepositoryException
*
* @since 1.43
*/
- public PushResponse push(String url) throws IOException, RepositoryException
- {
+ public PushResponse push(String url) throws IOException {
URL remoteUrl = new URL(url);
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java
index 5ae4b33c33..080d66ebf2 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java
@@ -1,19 +1,19 @@
/**
* 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.
+ * 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.
+ * 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.
- *
+ * 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
@@ -24,31 +24,28 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* http://bitbucket.org/sdorra/scm-manager
- *
*/
-
package sonia.scm.repository.api;
-//~--- non-JDK imports --------------------------------------------------------
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.Feature;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
+import sonia.scm.repository.RepositoryPermissions;
import sonia.scm.repository.spi.RepositoryServiceProvider;
-
-//~--- JDK imports ------------------------------------------------------------
+import sonia.scm.repository.util.WorkdirProvider;
import java.io.Closeable;
import java.io.IOException;
+import java.util.Set;
+import java.util.stream.Stream;
/**
* From the {@link RepositoryService} it is possible to access all commands for
@@ -68,8 +65,6 @@ import java.io.IOException;
* {@link #close()} method.
*
* @author Sebastian Sdorra
- * @since 1.17
- *
* @apiviz.uses sonia.scm.repository.Feature
* @apiviz.uses sonia.scm.repository.api.Command
* @apiviz.uses sonia.scm.repository.api.BlameCommandBuilder
@@ -85,39 +80,39 @@ import java.io.IOException;
* @apiviz.uses sonia.scm.repository.api.PushCommandBuilder
* @apiviz.uses sonia.scm.repository.api.BundleCommandBuilder
* @apiviz.uses sonia.scm.repository.api.UnbundleCommandBuilder
+ * @apiviz.uses sonia.scm.repository.api.MergeCommandBuilder
+ * @since 1.17
*/
-public final class RepositoryService implements Closeable
-{
+public final class RepositoryService implements Closeable {
- /**
- * the logger for RepositoryService
- */
- private static final Logger logger =
- LoggerFactory.getLogger(RepositoryService.class);
+ private static final Logger LOG = LoggerFactory.getLogger(RepositoryService.class);
- //~--- constructors ---------------------------------------------------------
+ private final CacheManager cacheManager;
+ private final PreProcessorUtil preProcessorUtil;
+ private final RepositoryServiceProvider provider;
+ private final Repository repository;
+ private final Set protocolProviders;
+ private final WorkdirProvider workdirProvider;
/**
* Constructs a new {@link RepositoryService}. This constructor should only
* be called from the {@link RepositoryServiceFactory}.
- *
- * @param cacheManager cache manager
- * @param provider implementation for {@link RepositoryServiceProvider}
- * @param repository the repository
- * @param preProcessorUtil
+ * @param cacheManager cache manager
+ * @param provider implementation for {@link RepositoryServiceProvider}
+ * @param repository the repository
+ * @param workdirProvider
*/
RepositoryService(CacheManager cacheManager,
- RepositoryServiceProvider provider, Repository repository,
- PreProcessorUtil preProcessorUtil)
- {
+ RepositoryServiceProvider provider, Repository repository,
+ PreProcessorUtil preProcessorUtil, Set protocolProviders, WorkdirProvider workdirProvider) {
this.cacheManager = cacheManager;
this.provider = provider;
this.repository = repository;
this.preProcessorUtil = preProcessorUtil;
+ this.protocolProviders = protocolProviders;
+ this.workdirProvider = workdirProvider;
}
- //~--- methods --------------------------------------------------------------
-
/**
* Closes the connection to the repository and releases all locks
* and resources. This method should be called in a finally block e.g.:
@@ -135,34 +130,24 @@ public final class RepositoryService implements Closeable
*
*/
@Override
- public void close()
- {
- try
- {
+ public void close() {
+ try {
provider.close();
- }
- catch (IOException ex)
- {
- logger.error("cound not close repository service provider", ex);
+ } catch (IOException ex) {
+ LOG.error("Could not close repository service provider", ex);
}
}
- //~--- get methods ----------------------------------------------------------
-
/**
* The blame command shows changeset information by line for a given file.
*
* @return instance of {@link BlameCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
*/
- public BlameCommandBuilder getBlameCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create blame command for repository {}",
- repository.getName());
- }
+ public BlameCommandBuilder getBlameCommand() {
+ LOG.debug("create blame command for repository {}",
+ repository.getNamespaceAndName());
return new BlameCommandBuilder(cacheManager, provider.getBlameCommand(),
repository, preProcessorUtil);
@@ -173,34 +158,41 @@ public final class RepositoryService implements Closeable
*
* @return instance of {@link BranchesCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
*/
- public BranchesCommandBuilder getBranchesCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create branches command for repository {}",
- repository.getName());
- }
+ public BranchesCommandBuilder getBranchesCommand() {
+ LOG.debug("create branches command for repository {}",
+ repository.getNamespaceAndName());
return new BranchesCommandBuilder(cacheManager,
provider.getBranchesCommand(), repository);
}
+ /**
+ * The branch command creates new branches.
+ *
+ * @return instance of {@link BranchCommandBuilder}
+ * @throws CommandNotSupportedException if the command is not supported
+ * by the implementation of the repository service provider.
+ */
+ public BranchCommandBuilder getBranchCommand() {
+ RepositoryPermissions.push(getRepository()).check();
+ LOG.debug("create branch command for repository {}",
+ repository.getNamespaceAndName());
+
+ return new BranchCommandBuilder(provider.getBranchCommand());
+ }
+
/**
* The browse command allows browsing of a repository.
*
* @return instance of {@link BrowseCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
*/
- public BrowseCommandBuilder getBrowseCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create browse command for repository {}",
- repository.getName());
- }
+ public BrowseCommandBuilder getBrowseCommand() {
+ LOG.debug("create browse command for repository {}",
+ repository.getNamespaceAndName());
return new BrowseCommandBuilder(cacheManager, provider.getBrowseCommand(),
repository, preProcessorUtil);
@@ -211,16 +203,12 @@ public final class RepositoryService implements Closeable
*
* @return instance of {@link BundleCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
* @since 1.43
*/
- public BundleCommandBuilder getBundleCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create bundle command for repository {}",
- repository.getName());
- }
+ public BundleCommandBuilder getBundleCommand() {
+ LOG.debug("create bundle command for repository {}",
+ repository.getNamespaceAndName());
return new BundleCommandBuilder(provider.getBundleCommand(), repository);
}
@@ -230,15 +218,11 @@ public final class RepositoryService implements Closeable
*
* @return instance of {@link CatCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
*/
- public CatCommandBuilder getCatCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create cat command for repository {}",
- repository.getName());
- }
+ public CatCommandBuilder getCatCommand() {
+ LOG.debug("create cat command for repository {}",
+ repository.getNamespaceAndName());
return new CatCommandBuilder(provider.getCatCommand());
}
@@ -249,36 +233,42 @@ public final class RepositoryService implements Closeable
*
* @return instance of {@link DiffCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
*/
- public DiffCommandBuilder getDiffCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create diff command for repository {}",
- repository.getName());
- }
+ public DiffCommandBuilder getDiffCommand() {
+ LOG.debug("create diff command for repository {}",
+ repository.getNamespaceAndName());
- return new DiffCommandBuilder(provider.getDiffCommand());
+ return new DiffCommandBuilder(provider.getDiffCommand(), provider.getSupportedFeatures());
+ }
+
+ /**
+ * The diff command shows differences between revisions for a specified file
+ * or the entire revision.
+ *
+ * @return instance of {@link DiffResultCommandBuilder}
+ * @throws CommandNotSupportedException if the command is not supported
+ * by the implementation of the repository service provider.
+ */
+ public DiffResultCommandBuilder getDiffResultCommand() {
+ LOG.debug("create diff result command for repository {}",
+ repository.getNamespaceAndName());
+
+ return new DiffResultCommandBuilder(provider.getDiffResultCommand(), provider.getSupportedFeatures());
}
/**
* The incoming command shows new {@link Changeset}s found in a different
* repository location.
*
- *
* @return instance of {@link IncomingCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
* @since 1.31
*/
- public IncomingCommandBuilder getIncomingCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create incoming command for repository {}",
- repository.getName());
- }
+ public IncomingCommandBuilder getIncomingCommand() {
+ LOG.debug("create incoming command for repository {}",
+ repository.getNamespaceAndName());
return new IncomingCommandBuilder(cacheManager,
provider.getIncomingCommand(), repository, preProcessorUtil);
@@ -289,36 +279,39 @@ public final class RepositoryService implements Closeable
*
* @return instance of {@link LogCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
*/
- public LogCommandBuilder getLogCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create log command for repository {}",
- repository.getName());
- }
+ public LogCommandBuilder getLogCommand() {
+ LOG.debug("create log command for repository {}",
+ repository.getNamespaceAndName());
return new LogCommandBuilder(cacheManager, provider.getLogCommand(),
- repository, preProcessorUtil);
+ repository, preProcessorUtil, provider.getSupportedFeatures());
}
/**
- * The outgoing command show changesets not found in a remote repository.
+ * The modification command shows file modifications in a revision.
*
+ * @return instance of {@link ModificationsCommandBuilder}
+ * @throws CommandNotSupportedException if the command is not supported
+ * by the implementation of the repository service provider.
+ */
+ public ModificationsCommandBuilder getModificationsCommand() {
+ LOG.debug("create modifications command for repository {}", repository.getNamespaceAndName());
+ return new ModificationsCommandBuilder(provider.getModificationsCommand(),repository, cacheManager.getCache(ModificationsCommandBuilder.CACHE_NAME), preProcessorUtil);
+ }
+
+ /**
+ * The outgoing command show {@link Changeset}s not found in a remote repository.
*
* @return instance of {@link OutgoingCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
* @since 1.31
*/
- public OutgoingCommandBuilder getOutgoingCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create outgoing command for repository {}",
- repository.getName());
- }
+ public OutgoingCommandBuilder getOutgoingCommand() {
+ LOG.debug("create outgoing command for repository {}",
+ repository.getNamespaceAndName());
return new OutgoingCommandBuilder(cacheManager,
provider.getOutgoingCommand(), repository, preProcessorUtil);
@@ -329,35 +322,27 @@ public final class RepositoryService implements Closeable
*
* @return instance of {@link PullCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
* @since 1.31
*/
- public PullCommandBuilder getPullCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create pull command for repository {}",
- repository.getName());
- }
+ public PullCommandBuilder getPullCommand() {
+ LOG.debug("create pull command for repository {}",
+ repository.getNamespaceAndName());
return new PullCommandBuilder(provider.getPullCommand(), repository);
}
/**
- * The push command push changes to a other repository.
+ * The push command pushes changes to a other repository.
*
* @return instance of {@link PushCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
* @since 1.31
*/
- public PushCommandBuilder getPushCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create push command for repository {}",
- repository.getName());
- }
+ public PushCommandBuilder getPushCommand() {
+ LOG.debug("create push command for repository {}",
+ repository.getNamespaceAndName());
return new PushCommandBuilder(provider.getPushCommand());
}
@@ -367,8 +352,7 @@ public final class RepositoryService implements Closeable
*
* @return repository of this service
*/
- public Repository getRepository()
- {
+ public Repository getRepository() {
return repository;
}
@@ -377,15 +361,11 @@ public final class RepositoryService implements Closeable
*
* @return instance of {@link TagsCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
*/
- public TagsCommandBuilder getTagsCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create tags command for repository {}",
- repository.getName());
- }
+ public TagsCommandBuilder getTagsCommand() {
+ LOG.debug("create tags command for repository {}",
+ repository.getNamespaceAndName());
return new TagsCommandBuilder(cacheManager, provider.getTagsCommand(),
repository);
@@ -396,60 +376,89 @@ public final class RepositoryService implements Closeable
*
* @return instance of {@link UnbundleCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
- * by the implementation of the repository service provider.
+ * by the implementation of the repository service provider.
* @since 1.43
*/
- public UnbundleCommandBuilder getUnbundleCommand()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("create bundle command for repository {}",
- repository.getName());
- }
+ public UnbundleCommandBuilder getUnbundleCommand() {
+ LOG.debug("create unbundle command for repository {}",
+ repository.getNamespaceAndName());
return new UnbundleCommandBuilder(provider.getUnbundleCommand(),
repository);
}
+ /**
+ * The merge command executes a merge of two branches. It is possible to do a dry run to check, whether the given
+ * branches can be merged without conflicts.
+ *
+ * @return instance of {@link MergeCommandBuilder}
+ * @throws CommandNotSupportedException if the command is not supported
+ * by the implementation of the repository service provider.
+ * @since 2.0.0
+ */
+ public MergeCommandBuilder getMergeCommand() {
+ LOG.debug("create merge command for repository {}",
+ repository.getNamespaceAndName());
+
+ return new MergeCommandBuilder(provider.getMergeCommand());
+ }
+
+ /**
+ * The modify command makes changes to the head of a branch. It is possible to
+ *
+ *
create new files
+ *
delete existing files
+ *
modify/replace files
+ *
move files
+ *
+ *
+ * @return instance of {@link ModifyCommandBuilder}
+ * @throws CommandNotSupportedException if the command is not supported
+ * by the implementation of the repository service provider.
+ * @since 2.0.0
+ */
+ public ModifyCommandBuilder getModifyCommand() {
+ LOG.debug("create modify command for repository {}",
+ repository.getNamespaceAndName());
+
+ return new ModifyCommandBuilder(provider.getModifyCommand(), workdirProvider);
+ }
+
/**
* Returns true if the command is supported by the repository service.
*
- *
* @param command command
- *
* @return true if the command is supported
*/
- public boolean isSupported(Command command)
- {
+ public boolean isSupported(Command command) {
return provider.getSupportedCommands().contains(command);
}
/**
* Returns true if the feature is supported by the repository service.
*
- *
* @param feature feature
- *
* @return true if the feature is supported
- *
* @since 1.25
*/
- public boolean isSupported(Feature feature)
- {
+ public boolean isSupported(Feature feature) {
return provider.getSupportedFeatures().contains(feature);
}
- //~--- fields ---------------------------------------------------------------
+ public Stream getSupportedProtocols() {
+ return protocolProviders.stream()
+ .filter(protocolProvider -> protocolProvider.getType().equals(getRepository().getType()))
+ .map(this::createProviderInstanceForRepository);
+ }
- /** cache manager */
- private CacheManager cacheManager;
+ private T createProviderInstanceForRepository(ScmProtocolProvider protocolProvider) {
+ return protocolProvider.get(repository);
+ }
- /** Field description */
- private PreProcessorUtil preProcessorUtil;
-
- /** implementation of the repository service provider */
- private RepositoryServiceProvider provider;
-
- /** the repository */
- private Repository repository;
+ public T getProtocol(Class clazz) {
+ return this.getSupportedProtocols()
+ .filter(scmProtocol -> clazz.isAssignableFrom(scmProtocol.getClass()))
+ .findFirst()
+ .orElseThrow(() -> new IllegalArgumentException(String.format("no implementation for %s and repository type %s", clazz.getName(),getRepository().getType())));
+ }
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java
index e07eee44f0..07c0b8fd47 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java
@@ -37,37 +37,39 @@ package sonia.scm.repository.api;
import com.github.legman.ReferenceType;
import com.github.legman.Subscribe;
-
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.HandlerEventType;
+import sonia.scm.NotFoundException;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.config.ScmConfiguration;
+import sonia.scm.event.ScmEventBus;
+import sonia.scm.repository.ClearRepositoryCacheEvent;
+import sonia.scm.repository.NamespaceAndName;
import sonia.scm.repository.PostReceiveRepositoryHookEvent;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKeyPredicate;
import sonia.scm.repository.RepositoryEvent;
import sonia.scm.repository.RepositoryManager;
-import sonia.scm.repository.RepositoryNotFoundException;
import sonia.scm.repository.RepositoryPermissions;
import sonia.scm.repository.spi.RepositoryServiceProvider;
import sonia.scm.repository.spi.RepositoryServiceResolver;
+import sonia.scm.repository.util.WorkdirProvider;
import sonia.scm.security.ScmSecurityException;
-//~--- JDK imports ------------------------------------------------------------
-
import java.util.Set;
-import sonia.scm.event.ScmEventBus;
-import sonia.scm.repository.ClearRepositoryCacheEvent;
+
+import static sonia.scm.ContextEntry.ContextBuilder.entity;
+import static sonia.scm.NotFoundException.notFound;
+
+//~--- JDK imports ------------------------------------------------------------
/**
* The {@link RepositoryServiceFactory} is the entrypoint of the repository api.
@@ -134,18 +136,22 @@ public final class RepositoryServiceFactory
* @param resolvers a set of {@link RepositoryServiceResolver}
* @param preProcessorUtil helper object for pre processor handling
*
+ * @param workdirProvider
* @since 1.21
*/
@Inject
public RepositoryServiceFactory(ScmConfiguration configuration,
- CacheManager cacheManager, RepositoryManager repositoryManager,
- Set resolvers, PreProcessorUtil preProcessorUtil)
+ CacheManager cacheManager, RepositoryManager repositoryManager,
+ Set resolvers, PreProcessorUtil preProcessorUtil,
+ Set protocolProviders, WorkdirProvider workdirProvider)
{
this.configuration = configuration;
this.cacheManager = cacheManager;
this.repositoryManager = repositoryManager;
this.resolvers = resolvers;
this.preProcessorUtil = preProcessorUtil;
+ this.protocolProviders = protocolProviders;
+ this.workdirProvider = workdirProvider;
ScmEventBus.getInstance().register(new CacheClearHook(cacheManager));
}
@@ -161,7 +167,7 @@ public final class RepositoryServiceFactory
* @return a implementation of RepositoryService
* for the given type of repository
*
- * @throws RepositoryNotFoundException if no repository
+ * @throws NotFoundException if no repository
* with the given id is available
* @throws RepositoryServiceNotFoundException if no repository service
* implementation for this kind of repository is available
@@ -169,9 +175,7 @@ public final class RepositoryServiceFactory
* @throws ScmSecurityException if current user has not read permissions
* for that repository
*/
- public RepositoryService create(String repositoryId)
- throws RepositoryNotFoundException
- {
+ public RepositoryService create(String repositoryId) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(repositoryId),
"a non empty repositoryId is required");
@@ -179,8 +183,7 @@ public final class RepositoryServiceFactory
if (repository == null)
{
- throw new RepositoryNotFoundException(
- "could not find a repository with id ".concat(repositoryId));
+ throw new NotFoundException(Repository.class, repositoryId);
}
return create(repository);
@@ -190,13 +193,12 @@ public final class RepositoryServiceFactory
* Creates a new RepositoryService for the given repository.
*
*
- * @param type type of the repository
- * @param name name of the repository
+ * @param namespaceAndName namespace and name of the repository
*
* @return a implementation of RepositoryService
* for the given type of repository
*
- * @throws RepositoryNotFoundException if no repository
+ * @throws NotFoundException if no repository
* with the given id is available
* @throws RepositoryServiceNotFoundException if no repository service
* implementation for this kind of repository is available
@@ -204,24 +206,16 @@ public final class RepositoryServiceFactory
* @throws ScmSecurityException if current user has not read permissions
* for that repository
*/
- public RepositoryService create(String type, String name)
- throws RepositoryNotFoundException
+ public RepositoryService create(NamespaceAndName namespaceAndName)
{
- Preconditions.checkArgument(!Strings.isNullOrEmpty(type),
- "a non empty type is required");
- Preconditions.checkArgument(!Strings.isNullOrEmpty(name),
- "a non empty name is required");
+ Preconditions.checkArgument(namespaceAndName != null,
+ "a non empty namespace and name is required");
- Repository repository = repositoryManager.get(type, name);
+ Repository repository = repositoryManager.get(namespaceAndName);
if (repository == null)
{
- StringBuilder msg =
- new StringBuilder("could not find a repository with type ");
-
- msg.append(type).append(" and name ").append(name);
-
- throw new RepositoryNotFoundException(msg.toString());
+ throw notFound(entity(namespaceAndName));
}
return create(repository);
@@ -253,7 +247,7 @@ public final class RepositoryServiceFactory
for (RepositoryServiceResolver resolver : resolvers)
{
- RepositoryServiceProvider provider = resolver.reslove(repository);
+ RepositoryServiceProvider provider = resolver.resolve(repository);
if (provider != null)
{
@@ -265,7 +259,7 @@ public final class RepositoryServiceFactory
}
service = new RepositoryService(cacheManager, provider, repository,
- preProcessorUtil);
+ preProcessorUtil, protocolProviders, workdirProvider);
break;
}
@@ -337,7 +331,6 @@ public final class RepositoryServiceFactory
/**
* Clear caches on repository delete event.
*
- * @param repository changed repository
* @param event repository event
*/
@Subscribe(referenceType = ReferenceType.STRONG)
@@ -381,4 +374,8 @@ public final class RepositoryServiceFactory
/** service resolvers */
private final Set resolvers;
+
+ private Set protocolProviders;
+
+ private final WorkdirProvider workdirProvider;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/ScmProtocol.java b/scm-core/src/main/java/sonia/scm/repository/api/ScmProtocol.java
new file mode 100644
index 0000000000..c987510491
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/ScmProtocol.java
@@ -0,0 +1,19 @@
+package sonia.scm.repository.api;
+
+/**
+ * An ScmProtocol represents a concrete protocol provided by the SCM-Manager instance
+ * to interact with a repository depending on its type. There may be multiple protocols
+ * available for a repository type (eg. http and ssh).
+ */
+public interface ScmProtocol {
+
+ /**
+ * The type of the concrete protocol, eg. "http" or "ssh".
+ */
+ String getType();
+
+ /**
+ * The URL to access the repository providing this protocol.
+ */
+ String getUrl();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/ScmProtocolProvider.java b/scm-core/src/main/java/sonia/scm/repository/api/ScmProtocolProvider.java
new file mode 100644
index 0000000000..591b8167e5
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/api/ScmProtocolProvider.java
@@ -0,0 +1,31 @@
+package sonia.scm.repository.api;
+
+import sonia.scm.plugin.ExtensionPoint;
+import sonia.scm.repository.Repository;
+
+/**
+ * Provider for scm native protocols.
+ *
+ * @param type of protocol
+ *
+ * @since 2.0.0
+ */
+@ExtensionPoint(multi = true)
+public interface ScmProtocolProvider {
+
+ /**
+ * Returns type of repository (e.g.: git, svn, hg, etc.)
+ *
+ * @return name of type
+ */
+ String getType();
+
+ /**
+ * Returns protocol for the given repository.
+ *
+ * @param repository repository
+ *
+ * @return protocol for repository
+ */
+ T get(Repository repository);
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/TagsCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/TagsCommandBuilder.java
index 65ceef0828..3a6ea16b10 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/TagsCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/TagsCommandBuilder.java
@@ -36,25 +36,21 @@ package sonia.scm.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKey;
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.Tag;
import sonia.scm.repository.Tags;
import sonia.scm.repository.spi.TagsCommand;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
-
import java.util.List;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* The tags command list all repository tags.
*
@@ -88,8 +84,7 @@ public final class TagsCommandBuilder
* only be called from the {@link RepositoryService}.
*
* @param cacheManager cache manager
- * @param logCommand implementation of the {@link TagsCommand}
- * @param command
+ * @param command implementation of the {@link TagsCommand}
* @param repository repository
*/
TagsCommandBuilder(CacheManager cacheManager, TagsCommand command,
@@ -109,10 +104,8 @@ public final class TagsCommandBuilder
* @return tags from the repository
*
* @throws IOException
- * @throws RepositoryException
*/
- public Tags getTags() throws RepositoryException, IOException
- {
+ public Tags getTags() throws IOException {
Tags tags;
if (disableCache)
@@ -183,9 +176,8 @@ public final class TagsCommandBuilder
* @return
*
* @throws IOException
- * @throws RepositoryException
*/
- private Tags getTagsFromCommand() throws RepositoryException, IOException
+ private Tags getTagsFromCommand() throws IOException
{
List tagList = command.getTags();
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/UnbundleCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/UnbundleCommandBuilder.java
index ff28e5c668..bfb998c6fe 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/UnbundleCommandBuilder.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/UnbundleCommandBuilder.java
@@ -37,25 +37,22 @@ package sonia.scm.repository.api;
import com.google.common.io.ByteSource;
import com.google.common.io.Files;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.UnbundleCommand;
import sonia.scm.repository.spi.UnbundleCommandRequest;
-import static com.google.common.base.Preconditions.*;
-
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-
import java.util.zip.GZIPInputStream;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+//~--- JDK imports ------------------------------------------------------------
+
/**
* The unbundle command can restore an empty repository from a bundle. The
* bundle can be created with the {@link BundleCommandBuilder}.
@@ -97,10 +94,9 @@ public final class UnbundleCommandBuilder
* @return unbundle response
*
* @throws IOException
- * @throws RepositoryException
*/
public UnbundleResponse unbundle(File inputFile)
- throws IOException, RepositoryException
+ throws IOException
{
checkArgument((inputFile != null) && inputFile.exists(),
"existing file is required");
@@ -122,10 +118,9 @@ public final class UnbundleCommandBuilder
* @return unbundle response
*
* @throws IOException
- * @throws RepositoryException
*/
public UnbundleResponse unbundle(InputStream inputStream)
- throws IOException, RepositoryException
+ throws IOException
{
checkNotNull(inputStream, "input stream is required");
logger.info("unbundle archive from stream");
@@ -142,10 +137,9 @@ public final class UnbundleCommandBuilder
* @return unbundle response
*
* @throws IOException
- * @throws RepositoryException
*/
public UnbundleResponse unbundle(ByteSource byteSource)
- throws IOException, RepositoryException
+ throws IOException
{
checkNotNull(byteSource, "byte source is required");
logger.info("unbundle from byte source");
@@ -186,7 +180,7 @@ public final class UnbundleCommandBuilder
{
@Override
- public InputStream openStream() throws IOException
+ public InputStream openStream()
{
return inputStream;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/BlameCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/BlameCommand.java
index 80c155a534..9953746fd1 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/BlameCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/BlameCommand.java
@@ -36,12 +36,11 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.BlameResult;
-import sonia.scm.repository.RepositoryException;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -59,8 +58,6 @@ public interface BlameCommand
* @return
*
* @throws IOException
- * @throws RepositoryException
*/
- public BlameResult getBlameResult(BlameCommandRequest request)
- throws IOException, RepositoryException;
+ BlameResult getBlameResult(BlameCommandRequest request) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/BranchCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/BranchCommand.java
new file mode 100644
index 0000000000..d5ba7f8dca
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/BranchCommand.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of SCM-Manager; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+
+package sonia.scm.repository.spi;
+
+
+import sonia.scm.repository.Branch;
+import sonia.scm.repository.api.BranchRequest;
+
+/**
+ * @since 2.0
+ */
+public interface BranchCommand {
+ Branch branch(BranchRequest name);
+
+ void deleteOrClose(String branchName);
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/BranchesCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/BranchesCommand.java
index a5659a8ffc..ba512ed4d2 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/BranchesCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/BranchesCommand.java
@@ -35,14 +35,12 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.Branch;
-import sonia.scm.repository.RepositoryException;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
-
import java.util.List;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -58,7 +56,6 @@ public interface BranchesCommand
* @return
*
* @throws IOException
- * @throws RepositoryException
*/
- public List getBranches() throws RepositoryException, IOException;
+ List getBranches() throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommand.java
index 4afc02b125..ee37d6243e 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommand.java
@@ -36,12 +36,11 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.BrowserResult;
-import sonia.scm.repository.RepositoryException;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -59,8 +58,6 @@ public interface BrowseCommand
* @return
*
* @throws IOException
- * @throws RepositoryException
*/
- public BrowserResult getBrowserResult(BrowseCommandRequest request)
- throws IOException, RepositoryException;
+ BrowserResult getBrowserResult(BrowseCommandRequest request) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommandRequest.java
index 445533455f..39da9a9ace 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommandRequest.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommandRequest.java
@@ -37,7 +37,6 @@ package sonia.scm.repository.spi;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-
/**
*
* @author Sebastian Sdorra
@@ -129,12 +128,12 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest
{
//J-
return MoreObjects.toStringHelper(this)
- .add("path", getPath())
- .add("revision", getRevision())
- .add("recursive", recursive)
- .add("disableLastCommit", disableLastCommit)
- .add("disableSubRepositoryDetection", disableSubRepositoryDetection)
- .toString();
+ .add("path", getPath())
+ .add("revision", getRevision())
+ .add("recursive", recursive)
+ .add("disableLastCommit", disableLastCommit)
+ .add("disableSubRepositoryDetection", disableSubRepositoryDetection)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/BundleCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/BundleCommand.java
index 8a0f21a714..7b6404c556 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/BundleCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/BundleCommand.java
@@ -35,13 +35,12 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.api.BundleResponse;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* Service provider implementation for the bundle command.
*
@@ -60,8 +59,7 @@ public interface BundleCommand
* @return bundle response
*
* @throws IOException
- * @throws RepositoryException
*/
public BundleResponse bundle(BundleCommandRequest request)
- throws IOException, RepositoryException;
+ throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/CannotDeleteDefaultBranchException.java b/scm-core/src/main/java/sonia/scm/repository/spi/CannotDeleteDefaultBranchException.java
new file mode 100644
index 0000000000..0053d5384a
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/CannotDeleteDefaultBranchException.java
@@ -0,0 +1,19 @@
+package sonia.scm.repository.spi;
+
+import sonia.scm.ContextEntry;
+import sonia.scm.ExceptionWithContext;
+import sonia.scm.repository.Repository;
+
+public class CannotDeleteDefaultBranchException extends ExceptionWithContext {
+
+ public static final String CODE = "78RhWxTIw1";
+
+ public CannotDeleteDefaultBranchException(Repository repository, String branchName) {
+ super(ContextEntry.ContextBuilder.entity("Branch", branchName).in(repository).build(), "default branch cannot be deleted");
+ }
+
+ @Override
+ public String getCode() {
+ return CODE;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/CatCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/CatCommand.java
index b9a6f52ab0..81600230db 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/CatCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/CatCommand.java
@@ -33,13 +33,8 @@
package sonia.scm.repository.spi;
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.repository.RepositoryException;
-
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
/**
@@ -47,19 +42,9 @@ import java.io.OutputStream;
* @author Sebastian Sdorra
* @since 1.17
*/
-public interface CatCommand
-{
+public interface CatCommand {
- /**
- * Method description
- *
- *
- * @param request
- * @param output
- *
- * @throws IOException
- * @throws RepositoryException
- */
- public void getCatResult(CatCommandRequest request, OutputStream output)
- throws IOException, RepositoryException;
+ void getCatResult(CatCommandRequest request, OutputStream output) throws IOException;
+
+ InputStream getCatResultStream(CatCommandRequest request) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/DiffCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/DiffCommand.java
index a4d0c24444..162c57cbc2 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/DiffCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/DiffCommand.java
@@ -33,14 +33,9 @@
package sonia.scm.repository.spi;
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.repository.RepositoryException;
-
-//~--- JDK imports ------------------------------------------------------------
+import sonia.scm.repository.api.DiffCommandBuilder;
import java.io.IOException;
-import java.io.OutputStream;
/**
*
@@ -55,12 +50,9 @@ public interface DiffCommand
*
*
* @param request
- * @param output
- *
* @throws IOException
* @throws RuntimeException
- * @throws RepositoryException
+ * @return
*/
- public void getDiffResult(DiffCommandRequest request, OutputStream output)
- throws IOException, RepositoryException;
+ DiffCommandBuilder.OutputStreamConsumer getDiffResult(DiffCommandRequest request) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/DiffCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/DiffCommandRequest.java
index 5cfd57f71b..e26b2eb5aa 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/DiffCommandRequest.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/DiffCommandRequest.java
@@ -109,7 +109,10 @@ public final class DiffCommandRequest extends FileBaseCommandRequest
this.format = format;
}
- //~--- get methods ----------------------------------------------------------
+ public void setAncestorChangeset(String ancestorChangeset) {
+ this.ancestorChangeset = ancestorChangeset;
+ }
+//~--- get methods ----------------------------------------------------------
/**
* Return the output format of the diff command.
@@ -124,8 +127,13 @@ public final class DiffCommandRequest extends FileBaseCommandRequest
return format;
}
- //~--- fields ---------------------------------------------------------------
+ public String getAncestorChangeset() {
+ return ancestorChangeset;
+ }
+//~--- fields ---------------------------------------------------------------
/** diff format */
private DiffFormat format = DiffFormat.NATIVE;
+
+ private String ancestorChangeset;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/DiffResultCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/DiffResultCommand.java
new file mode 100644
index 0000000000..ee50178d76
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/DiffResultCommand.java
@@ -0,0 +1,9 @@
+package sonia.scm.repository.spi;
+
+import sonia.scm.repository.api.DiffResult;
+
+import java.io.IOException;
+
+public interface DiffResultCommand {
+ DiffResult getDiffResult(DiffCommandRequest request) throws IOException;
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/FileBaseCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/FileBaseCommandRequest.java
index ad70315e5f..9f563345fd 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/FileBaseCommandRequest.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/FileBaseCommandRequest.java
@@ -38,10 +38,10 @@ package sonia.scm.repository.spi;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.Serializable;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -117,9 +117,9 @@ public abstract class FileBaseCommandRequest
{
//J-
return MoreObjects.toStringHelper(this)
- .add("path", path)
- .add("revision", revision)
- .toString();
+ .add("path", path)
+ .add("revision", revision)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/HookEventFacade.java b/scm-core/src/main/java/sonia/scm/repository/spi/HookEventFacade.java
index 899892a5b7..fd785e2138 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/HookEventFacade.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/HookEventFacade.java
@@ -35,16 +35,17 @@ package sonia.scm.repository.spi;
import com.google.inject.Inject;
import com.google.inject.Provider;
-
+import sonia.scm.repository.NamespaceAndName;
import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.RepositoryHookEvent;
import sonia.scm.repository.RepositoryHookType;
import sonia.scm.repository.RepositoryManager;
-import sonia.scm.repository.RepositoryNotFoundException;
import sonia.scm.repository.api.HookContext;
import sonia.scm.repository.api.HookContextFactory;
+import static sonia.scm.ContextEntry.ContextBuilder.entity;
+import static sonia.scm.NotFoundException.notFound;
+
/**
*
* @author Sebastian Sdorra
@@ -72,56 +73,25 @@ public final class HookEventFacade
//~--- methods --------------------------------------------------------------
- /**
- * Method description
- *
- *
- * @param id
- *
- * @return
- *
- * @throws RepositoryException
- */
- public HookEventHandler handle(String id) throws RepositoryException
- {
- return handle(repositoryManagerProvider.get().get(id));
- }
-
- /**
- * Method description
- *
- *
- * @param type
- * @param repositoryName
- *
- * @return
- *
- * @throws RepositoryException
- */
- public HookEventHandler handle(String type, String repositoryName)
- throws RepositoryException
- {
- return handle(repositoryManagerProvider.get().get(type, repositoryName));
- }
-
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @return
- *
- * @throws RepositoryException
- */
- public HookEventHandler handle(Repository repository)
- throws RepositoryException
- {
+ public HookEventHandler handle(String id) {
+ Repository repository = repositoryManagerProvider.get().get(id);
if (repository == null)
{
- throw new RepositoryNotFoundException("could not find repository");
+ throw notFound(entity("Repository", id));
}
+ return handle(repository);
+ }
+ public HookEventHandler handle(NamespaceAndName namespaceAndName) {
+ Repository repository = repositoryManagerProvider.get().get(namespaceAndName);
+ if (repository == null)
+ {
+ throw notFound(entity(namespaceAndName));
+ }
+ return handle(repository);
+ }
+
+ public HookEventHandler handle(Repository repository) {
return new HookEventHandler(repositoryManagerProvider.get(),
hookContextFactory, repository);
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/HttpScmProtocol.java b/scm-core/src/main/java/sonia/scm/repository/spi/HttpScmProtocol.java
new file mode 100644
index 0000000000..b933abf559
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/HttpScmProtocol.java
@@ -0,0 +1,38 @@
+package sonia.scm.repository.spi;
+
+import sonia.scm.repository.Repository;
+import sonia.scm.repository.api.ScmProtocol;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URI;
+
+public abstract class HttpScmProtocol implements ScmProtocol {
+
+ private final Repository repository;
+ private final String basePath;
+
+ public HttpScmProtocol(Repository repository, String basePath) {
+ this.repository = repository;
+ this.basePath = basePath;
+ }
+
+ @Override
+ public String getType() {
+ return "http";
+ }
+
+ @Override
+ public String getUrl() {
+ return URI.create(basePath + "/").resolve(String.format("repo/%s/%s", repository.getNamespace(), repository.getName())).toASCIIString();
+ }
+
+ public final void serve(HttpServletRequest request, HttpServletResponse response, ServletConfig config) throws ServletException, IOException {
+ serve(request, response, repository, config);
+ }
+
+ protected abstract void serve(HttpServletRequest request, HttpServletResponse response, Repository repository, ServletConfig config) throws ServletException, IOException;
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/IncomingCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/IncomingCommand.java
index 8b3341f77b..669f307acd 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/IncomingCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/IncomingCommand.java
@@ -35,12 +35,11 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.ChangesetPagingResult;
-import sonia.scm.repository.RepositoryException;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -49,18 +48,5 @@ import java.io.IOException;
public interface IncomingCommand
{
- /**
- * Method description
- *
- *
- * @param request
- *
- * @return
- *
- * @throws IOException
- * @throws RepositoryException
- */
- public ChangesetPagingResult getIncomingChangesets(
- IncomingCommandRequest request)
- throws IOException, RepositoryException;
+ ChangesetPagingResult getIncomingChangesets(IncomingCommandRequest request) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/InitializingHttpScmProtocolWrapper.java b/scm-core/src/main/java/sonia/scm/repository/spi/InitializingHttpScmProtocolWrapper.java
new file mode 100644
index 0000000000..c1b7229036
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/InitializingHttpScmProtocolWrapper.java
@@ -0,0 +1,91 @@
+package sonia.scm.repository.spi;
+
+import lombok.extern.slf4j.Slf4j;
+import sonia.scm.api.v2.resources.ScmPathInfoStore;
+import sonia.scm.config.ScmConfiguration;
+import sonia.scm.repository.Repository;
+import sonia.scm.repository.api.ScmProtocolProvider;
+
+import javax.inject.Provider;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Optional;
+
+import static java.util.Optional.empty;
+import static java.util.Optional.of;
+
+@Slf4j
+public abstract class InitializingHttpScmProtocolWrapper implements ScmProtocolProvider {
+
+ private final Provider extends ScmProviderHttpServlet> delegateProvider;
+ private final Provider pathInfoStore;
+ private final ScmConfiguration scmConfiguration;
+
+ private volatile boolean isInitialized = false;
+
+
+ protected InitializingHttpScmProtocolWrapper(Provider extends ScmProviderHttpServlet> delegateProvider, Provider pathInfoStore, ScmConfiguration scmConfiguration) {
+ this.delegateProvider = delegateProvider;
+ this.pathInfoStore = pathInfoStore;
+ this.scmConfiguration = scmConfiguration;
+ }
+
+ protected void initializeServlet(ServletConfig config, ScmProviderHttpServlet httpServlet) throws ServletException {
+ httpServlet.init(config);
+ }
+
+ @Override
+ public HttpScmProtocol get(Repository repository) {
+ if (!repository.getType().equals(getType())) {
+ throw new IllegalArgumentException(String.format("cannot handle repository with type %s with protocol for type %s", repository.getType(), getType()));
+ }
+ return new ProtocolWrapper(repository, computeBasePath());
+ }
+
+ private String computeBasePath() {
+ return getPathFromScmPathInfoIfAvailable().orElse(getPathFromConfiguration());
+ }
+
+ private Optional getPathFromScmPathInfoIfAvailable() {
+ try {
+ ScmPathInfoStore scmPathInfoStore = pathInfoStore.get();
+ if (scmPathInfoStore != null && scmPathInfoStore.get() != null) {
+ return of(scmPathInfoStore.get().getRootUri().toASCIIString());
+ }
+ } catch (Exception e) {
+ log.debug("could not get ScmPathInfoStore from context", e);
+ }
+ return empty();
+ }
+
+ private String getPathFromConfiguration() {
+ log.debug("using base path from configuration: {}", scmConfiguration.getBaseUrl());
+ return scmConfiguration.getBaseUrl();
+ }
+
+ private class ProtocolWrapper extends HttpScmProtocol {
+
+ public ProtocolWrapper(Repository repository, String basePath) {
+ super(repository, basePath);
+ }
+
+ @Override
+ protected void serve(HttpServletRequest request, HttpServletResponse response, Repository repository, ServletConfig config) throws ServletException, IOException {
+ if (!isInitialized) {
+ synchronized (InitializingHttpScmProtocolWrapper.this) {
+ if (!isInitialized) {
+ ScmProviderHttpServlet httpServlet = delegateProvider.get();
+ initializeServlet(config, httpServlet);
+ isInitialized = true;
+ }
+ }
+ }
+
+ delegateProvider.get().service(request, response, repository);
+ }
+
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/IntegrateChangesFromWorkdirException.java b/scm-core/src/main/java/sonia/scm/repository/spi/IntegrateChangesFromWorkdirException.java
new file mode 100644
index 0000000000..c7c378500b
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/IntegrateChangesFromWorkdirException.java
@@ -0,0 +1,23 @@
+package sonia.scm.repository.spi;
+
+import sonia.scm.ContextEntry;
+import sonia.scm.ExceptionWithContext;
+import sonia.scm.repository.Repository;
+
+public class IntegrateChangesFromWorkdirException extends ExceptionWithContext {
+
+ private static final String CODE = "CHRM7IQzo1";
+
+ public IntegrateChangesFromWorkdirException(Repository repository, String message) {
+ super(ContextEntry.ContextBuilder.entity(repository).build(), message);
+ }
+
+ public IntegrateChangesFromWorkdirException(Repository repository, String message, Exception cause) {
+ super(ContextEntry.ContextBuilder.entity(repository).build(), message, cause);
+ }
+
+ @Override
+ public String getCode() {
+ return CODE;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/LogCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/LogCommand.java
index 168c279c19..21d9ece4de 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/LogCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/LogCommand.java
@@ -37,45 +37,19 @@ package sonia.scm.repository.spi;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
-import sonia.scm.repository.RepositoryException;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
-public interface LogCommand
-{
+public interface LogCommand {
- /**
- * Method description
- *
- *
- * @param id
- *
- * @return
- *
- * @throws IOException
- * @throws RepositoryException
- */
- public Changeset getChangeset(String id)
- throws IOException, RepositoryException;
+ Changeset getChangeset(String id, LogCommandRequest request) throws IOException;
- /**
- * Method description
- *
- *
- * @param request
- *
- * @return
- *
- * @throws IOException
- * @throws RepositoryException
- */
- public ChangesetPagingResult getChangesets(LogCommandRequest request)
- throws IOException, RepositoryException;
+ ChangesetPagingResult getChangesets(LogCommandRequest request) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/LogCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/LogCommandRequest.java
index 4c7734667a..92cd41662b 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/LogCommandRequest.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/LogCommandRequest.java
@@ -38,10 +38,10 @@ package sonia.scm.repository.spi;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.Serializable;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -84,7 +84,8 @@ public final class LogCommandRequest implements Serializable, Resetable
&& Objects.equal(pagingStart, other.pagingStart)
&& Objects.equal(pagingLimit, other.pagingLimit)
&& Objects.equal(path, other.path)
- && Objects.equal(branch, other.branch);
+ && Objects.equal(branch, other.branch)
+ && Objects.equal(ancestorChangeset, other.ancestorChangeset);
//J+
}
@@ -98,7 +99,7 @@ public final class LogCommandRequest implements Serializable, Resetable
public int hashCode()
{
return Objects.hashCode(startChangeset, endChangeset, pagingStart,
- pagingLimit, path, branch);
+ pagingLimit, path, branch, ancestorChangeset);
}
/**
@@ -114,6 +115,7 @@ public final class LogCommandRequest implements Serializable, Resetable
pagingLimit = 20;
path = null;
branch = null;
+ ancestorChangeset = null;
}
/**
@@ -127,13 +129,14 @@ public final class LogCommandRequest implements Serializable, Resetable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("startChangeset", startChangeset)
- .add("endChangeset", endChangeset)
- .add("pagingStart", pagingStart)
- .add("pagingLimit", pagingLimit)
- .add("path", path)
- .add("branch", branch)
- .toString();
+ .add("startChangeset", startChangeset)
+ .add("endChangeset", endChangeset)
+ .add("pagingStart", pagingStart)
+ .add("pagingLimit", pagingLimit)
+ .add("path", path)
+ .add("branch", branch)
+ .add("ancestorChangeset", ancestorChangeset)
+ .toString();
//J+
}
@@ -205,6 +208,10 @@ public final class LogCommandRequest implements Serializable, Resetable
this.startChangeset = startChangeset;
}
+ public void setAncestorChangeset(String ancestorChangeset) {
+ this.ancestorChangeset = ancestorChangeset;
+ }
+
//~--- get methods ----------------------------------------------------------
/**
@@ -284,6 +291,10 @@ public final class LogCommandRequest implements Serializable, Resetable
return pagingLimit < 0;
}
+ public String getAncestorChangeset() {
+ return ancestorChangeset;
+ }
+
//~--- fields ---------------------------------------------------------------
/** Field description */
@@ -303,4 +314,6 @@ public final class LogCommandRequest implements Serializable, Resetable
/** Field description */
private String startChangeset;
+
+ private String ancestorChangeset;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/MergeCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/MergeCommand.java
new file mode 100644
index 0000000000..a62e373dca
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/MergeCommand.java
@@ -0,0 +1,17 @@
+package sonia.scm.repository.spi;
+
+import sonia.scm.repository.api.MergeCommandResult;
+import sonia.scm.repository.api.MergeDryRunCommandResult;
+import sonia.scm.repository.api.MergeStrategy;
+
+import java.util.Set;
+
+public interface MergeCommand {
+ MergeCommandResult merge(MergeCommandRequest request);
+
+ MergeDryRunCommandResult dryRun(MergeCommandRequest request);
+
+ boolean isSupported(MergeStrategy strategy);
+
+ Set getSupportedMergeStrategies();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/MergeCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/MergeCommandRequest.java
new file mode 100644
index 0000000000..0751920d01
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/MergeCommandRequest.java
@@ -0,0 +1,105 @@
+package sonia.scm.repository.spi;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.base.Strings;
+import sonia.scm.Validateable;
+import sonia.scm.repository.Person;
+import sonia.scm.repository.api.MergeStrategy;
+import sonia.scm.repository.util.AuthorUtil.CommandWithAuthor;
+
+import java.io.Serializable;
+
+public class MergeCommandRequest implements Validateable, Resetable, Serializable, Cloneable, CommandWithAuthor {
+
+ private static final long serialVersionUID = -2650236557922431528L;
+
+ private String branchToMerge;
+ private String targetBranch;
+ private Person author;
+ private String messageTemplate;
+ private MergeStrategy mergeStrategy;
+
+ public String getBranchToMerge() {
+ return branchToMerge;
+ }
+
+ public void setBranchToMerge(String branchToMerge) {
+ this.branchToMerge = branchToMerge;
+ }
+
+ public String getTargetBranch() {
+ return targetBranch;
+ }
+
+ public void setTargetBranch(String targetBranch) {
+ this.targetBranch = targetBranch;
+ }
+
+ public Person getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(Person author) {
+ this.author = author;
+ }
+
+ public String getMessageTemplate() {
+ return messageTemplate;
+ }
+
+ public void setMessageTemplate(String messageTemplate) {
+ this.messageTemplate = messageTemplate;
+ }
+
+ public MergeStrategy getMergeStrategy() {
+ return mergeStrategy;
+ }
+
+ public void setMergeStrategy(MergeStrategy mergeStrategy) {
+ this.mergeStrategy = mergeStrategy;
+ }
+
+ public boolean isValid() {
+ return !Strings.isNullOrEmpty(getBranchToMerge())
+ && !Strings.isNullOrEmpty(getTargetBranch());
+ }
+
+ public void reset() {
+ this.setBranchToMerge(null);
+ this.setTargetBranch(null);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ final MergeCommandRequest other = (MergeCommandRequest) obj;
+
+ return Objects.equal(branchToMerge, other.branchToMerge)
+ && Objects.equal(targetBranch, other.targetBranch)
+ && Objects.equal(author, other.author)
+ && Objects.equal(mergeStrategy, other.mergeStrategy);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(branchToMerge, targetBranch, author, mergeStrategy);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("branchToMerge", branchToMerge)
+ .add("targetBranch", targetBranch)
+ .add("author", author)
+ .add("mergeStrategy", mergeStrategy)
+ .toString();
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/ModificationsCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/ModificationsCommand.java
new file mode 100644
index 0000000000..322468f827
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/ModificationsCommand.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, Sebastian Sdorra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of SCM-Manager; nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://bitbucket.org/sdorra/scm-manager
+ *
+ */
+
+package sonia.scm.repository.spi;
+
+import sonia.scm.repository.Modifications;
+
+import java.io.IOException;
+
+/**
+ * Command to get the modifications applied to files in a revision.
+ *
+ * Modifications are for example: Add, Update, Delete
+ *
+ * @author Mohamed Karray
+ * @since 2.0
+ */
+public interface ModificationsCommand {
+
+ Modifications getModifications(String revision) throws IOException;
+
+ Modifications getModifications(ModificationsCommandRequest request) throws IOException;
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/ModificationsCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/ModificationsCommandRequest.java
new file mode 100644
index 0000000000..8a910a3396
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/ModificationsCommandRequest.java
@@ -0,0 +1,24 @@
+package sonia.scm.repository.spi;
+
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+
+@ToString
+@EqualsAndHashCode
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class ModificationsCommandRequest implements Resetable {
+ private String revision;
+
+ @Override
+ public void reset() {
+ revision = null;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/ModifyCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/ModifyCommand.java
new file mode 100644
index 0000000000..1bc64e0e08
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/ModifyCommand.java
@@ -0,0 +1,17 @@
+package sonia.scm.repository.spi;
+
+import java.io.File;
+import java.io.IOException;
+
+public interface ModifyCommand {
+
+ String execute(ModifyCommandRequest request);
+
+ interface Worker {
+ void delete(String toBeDeleted) throws IOException;
+
+ void create(String toBeCreated, File file, boolean overwrite) throws IOException;
+
+ void modify(String path, File file) throws IOException;
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/ModifyCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/ModifyCommandRequest.java
new file mode 100644
index 0000000000..43814f8729
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/ModifyCommandRequest.java
@@ -0,0 +1,154 @@
+package sonia.scm.repository.spi;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import sonia.scm.Validateable;
+import sonia.scm.repository.Person;
+import sonia.scm.repository.util.AuthorUtil.CommandWithAuthor;
+import sonia.scm.util.IOUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class ModifyCommandRequest implements Resetable, Validateable, CommandWithAuthor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ModifyCommandRequest.class);
+
+ private final List requests = new ArrayList<>();
+
+ private Person author;
+ private String commitMessage;
+ private String branch;
+ private String expectedRevision;
+
+ @Override
+ public void reset() {
+ requests.clear();
+ author = null;
+ commitMessage = null;
+ branch = null;
+ }
+
+ public void addRequest(PartialRequest request) {
+ this.requests.add(request);
+ }
+
+ public void setAuthor(Person author) {
+ this.author = author;
+ }
+
+ public void setCommitMessage(String commitMessage) {
+ this.commitMessage = commitMessage;
+ }
+
+ public void setBranch(String branch) {
+ this.branch = branch;
+ }
+
+ public List getRequests() {
+ return Collections.unmodifiableList(requests);
+ }
+
+ public Person getAuthor() {
+ return author;
+ }
+
+ public String getCommitMessage() {
+ return commitMessage;
+ }
+
+ public String getBranch() {
+ return branch;
+ }
+
+ public String getExpectedRevision() {
+ return expectedRevision;
+ }
+
+ @Override
+ public boolean isValid() {
+ return StringUtils.isNotEmpty(commitMessage) && !requests.isEmpty();
+ }
+
+ public void setExpectedRevision(String expectedRevision) {
+ this.expectedRevision = expectedRevision;
+ }
+
+ public interface PartialRequest {
+ void execute(ModifyCommand.Worker worker) throws IOException;
+ }
+
+ public static class DeleteFileRequest implements PartialRequest {
+ private final String path;
+
+ public DeleteFileRequest(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public void execute(ModifyCommand.Worker worker) throws IOException {
+ worker.delete(path);
+ }
+ }
+
+ private abstract static class ContentModificationRequest implements PartialRequest {
+
+ private final File content;
+
+ ContentModificationRequest(File content) {
+ this.content = content;
+ }
+
+ File getContent() {
+ return content;
+ }
+
+ void cleanup() {
+ if (content.exists()) {
+ try {
+ IOUtil.delete(content);
+ } catch (IOException e) {
+ LOG.warn("could not delete temporary file {}", content, e);
+ }
+ }
+ }
+ }
+
+ public static class CreateFileRequest extends ContentModificationRequest {
+
+ private final String path;
+ private final boolean overwrite;
+
+ public CreateFileRequest(String path, File content, boolean overwrite) {
+ super(content);
+ this.path = path;
+ this.overwrite = overwrite;
+ }
+
+ @Override
+ public void execute(ModifyCommand.Worker worker) throws IOException {
+ worker.create(path, getContent(), overwrite);
+ cleanup();
+ }
+ }
+
+ public static class ModifyFileRequest extends ContentModificationRequest {
+
+ private final String path;
+
+ public ModifyFileRequest(String path, File content) {
+ super(content);
+ this.path = path;
+ }
+
+ @Override
+ public void execute(ModifyCommand.Worker worker) throws IOException {
+ worker.modify(path, getContent());
+ cleanup();
+ }
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/ModifyWorkerHelper.java b/scm-core/src/main/java/sonia/scm/repository/spi/ModifyWorkerHelper.java
new file mode 100644
index 0000000000..a1ff6b0eb3
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/ModifyWorkerHelper.java
@@ -0,0 +1,88 @@
+package sonia.scm.repository.spi;
+
+import org.apache.commons.lang.StringUtils;
+import sonia.scm.ContextEntry;
+import sonia.scm.repository.Repository;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Path;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+import static sonia.scm.AlreadyExistsException.alreadyExists;
+import static sonia.scm.ContextEntry.ContextBuilder.entity;
+import static sonia.scm.NotFoundException.notFound;
+
+/**
+ * This "interface" is not really intended to be used as an interface but rather as
+ * a base class to reduce code redundancy in Worker instances.
+ */
+public interface ModifyWorkerHelper extends ModifyCommand.Worker {
+
+ @Override
+ default void delete(String toBeDeleted) throws IOException {
+ Path fileToBeDeleted = new File(getWorkDir(), toBeDeleted).toPath();
+ try {
+ Files.delete(fileToBeDeleted);
+ } catch (NoSuchFileException e) {
+ throw notFound(createFileContext(toBeDeleted));
+ }
+ doScmDelete(toBeDeleted);
+ }
+
+ void doScmDelete(String toBeDeleted);
+
+ @Override
+ default void create(String toBeCreated, File file, boolean overwrite) throws IOException {
+ Path targetFile = new File(getWorkDir(), toBeCreated).toPath();
+ createDirectories(targetFile);
+ if (overwrite) {
+ Files.move(file.toPath(), targetFile, REPLACE_EXISTING);
+ } else {
+ try {
+ Files.move(file.toPath(), targetFile);
+ } catch (FileAlreadyExistsException e) {
+ throw alreadyExists(createFileContext(toBeCreated));
+ }
+ }
+ addFileToScm(toBeCreated, targetFile);
+ }
+
+ default void modify(String path, File file) throws IOException {
+ Path targetFile = new File(getWorkDir(), path).toPath();
+ createDirectories(targetFile);
+ if (!targetFile.toFile().exists()) {
+ throw notFound(createFileContext(path));
+ }
+ Files.move(file.toPath(), targetFile, REPLACE_EXISTING);
+ addFileToScm(path, targetFile);
+ }
+
+ void addFileToScm(String name, Path file);
+
+ default ContextEntry.ContextBuilder createFileContext(String path) {
+ ContextEntry.ContextBuilder contextBuilder = entity("file", path);
+ if (!StringUtils.isEmpty(getBranch())) {
+ contextBuilder.in("branch", getBranch());
+ }
+ contextBuilder.in(getRepository());
+ return contextBuilder;
+ }
+
+ default void createDirectories(Path targetFile) throws IOException {
+ try {
+ Files.createDirectories(targetFile.getParent());
+ } catch (FileAlreadyExistsException e) {
+ throw alreadyExists(createFileContext(targetFile.toString()));
+ }
+ }
+
+ File getWorkDir();
+
+ Repository getRepository();
+
+ String getBranch();
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/OutgoingCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/OutgoingCommand.java
index 9e5509e945..c37950abe2 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/OutgoingCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/OutgoingCommand.java
@@ -35,12 +35,11 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.ChangesetPagingResult;
-import sonia.scm.repository.RepositoryException;
-
-//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -58,9 +57,6 @@ public interface OutgoingCommand
* @return
*
* @throws IOException
- * @throws RepositoryException
*/
- public ChangesetPagingResult getOutgoingChangesets(
- OutgoingCommandRequest request)
- throws IOException, RepositoryException;
+ ChangesetPagingResult getOutgoingChangesets(OutgoingCommandRequest request) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/PagedRemoteCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/PagedRemoteCommandRequest.java
index b1e15a0389..b6545bdc4d 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/PagedRemoteCommandRequest.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/PagedRemoteCommandRequest.java
@@ -36,7 +36,6 @@ package sonia.scm.repository.spi;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-
/**
*
* @author Sebastian Sdorra
@@ -86,10 +85,10 @@ public abstract class PagedRemoteCommandRequest extends RemoteCommandRequest
//J-
return MoreObjects.toStringHelper(this)
- .add("remoteURL", remoteRepository)
- .add("pagingStart", pagingStart)
- .add("pagingLimit", pagingLimit)
- .toString();
+ .add("remoteURL", remoteRepository)
+ .add("pagingStart", pagingStart)
+ .add("pagingLimit", pagingLimit)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/PullCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/PullCommand.java
index 533f8e1351..e7aa044353 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/PullCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/PullCommand.java
@@ -34,13 +34,12 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.api.PullResponse;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -58,8 +57,6 @@ public interface PullCommand
* @return
*
* @throws IOException
- * @throws RepositoryException
*/
- public PullResponse pull(PullCommandRequest request)
- throws IOException, RepositoryException;
+ PullResponse pull(PullCommandRequest request) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/PushCommand.java b/scm-core/src/main/java/sonia/scm/repository/spi/PushCommand.java
index c77947937a..9530add4f8 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/PushCommand.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/PushCommand.java
@@ -34,13 +34,12 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
-import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.api.PushResponse;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.IOException;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -58,8 +57,6 @@ public interface PushCommand
* @return
*
* @throws IOException
- * @throws RepositoryException
*/
- public PushResponse push(PushCommandRequest request)
- throws IOException, RepositoryException;
+ PushResponse push(PushCommandRequest request) throws IOException;
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/RemoteCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/RemoteCommandRequest.java
index 1994afd29c..bbc902cd2a 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/RemoteCommandRequest.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/RemoteCommandRequest.java
@@ -37,13 +37,12 @@ package sonia.scm.repository.spi;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-
import sonia.scm.repository.Repository;
-//~--- JDK imports ------------------------------------------------------------
-
import java.net.URL;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -103,9 +102,9 @@ public abstract class RemoteCommandRequest implements Resetable
{
//J-
return MoreObjects.toStringHelper(this)
- .add("remoteRepository", remoteRepository)
- .add("remoteUrl", remoteUrl)
- .toString();
+ .add("remoteRepository", remoteRepository)
+ .add("remoteUrl", remoteUrl)
+ .toString();
//J+
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceProvider.java b/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceProvider.java
index 976f38fffb..cdd0417cf7 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceProvider.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceProvider.java
@@ -33,20 +33,17 @@
package sonia.scm.repository.spi;
-//~--- non-JDK imports --------------------------------------------------------
-
import sonia.scm.repository.Feature;
import sonia.scm.repository.api.Command;
import sonia.scm.repository.api.CommandNotSupportedException;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.Closeable;
import java.io.IOException;
-
import java.util.Collections;
import java.util.Set;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -104,6 +101,17 @@ public abstract class RepositoryServiceProvider implements Closeable
throw new CommandNotSupportedException(Command.BRANCHES);
}
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ public BranchCommand getBranchCommand()
+ {
+ throw new CommandNotSupportedException(Command.BRANCH);
+ }
+
/**
* Method description
*
@@ -150,6 +158,11 @@ public abstract class RepositoryServiceProvider implements Closeable
throw new CommandNotSupportedException(Command.DIFF);
}
+ public DiffResultCommand getDiffResultCommand()
+ {
+ throw new CommandNotSupportedException(Command.DIFF_RESULT);
+ }
+
/**
* Method description
*
@@ -173,6 +186,16 @@ public abstract class RepositoryServiceProvider implements Closeable
throw new CommandNotSupportedException(Command.LOG);
}
+ /**
+ * Get the corresponding {@link ModificationsCommand} implemented from the Plugins
+ *
+ * @return the corresponding {@link ModificationsCommand} implemented from the Plugins
+ * @throws CommandNotSupportedException if there is no Implementation
+ */
+ public ModificationsCommand getModificationsCommand() {
+ throw new CommandNotSupportedException(Command.MODIFICATIONS);
+ }
+
/**
* Method description
*
@@ -244,4 +267,20 @@ public abstract class RepositoryServiceProvider implements Closeable
{
throw new CommandNotSupportedException(Command.UNBUNDLE);
}
+
+ /**
+ * @since 2.0
+ */
+ public MergeCommand getMergeCommand()
+ {
+ throw new CommandNotSupportedException(Command.MERGE);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public ModifyCommand getModifyCommand()
+ {
+ throw new CommandNotSupportedException(Command.MODIFY);
+ }
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceResolver.java b/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceResolver.java
index f0ed4c0814..d747bbdce0 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceResolver.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/RepositoryServiceResolver.java
@@ -33,8 +33,6 @@
package sonia.scm.repository.spi;
-//~--- non-JDK imports --------------------------------------------------------
-
import sonia.scm.plugin.ExtensionPoint;
import sonia.scm.repository.Repository;
@@ -55,5 +53,5 @@ public interface RepositoryServiceResolver
*
* @return
*/
- public RepositoryServiceProvider reslove(Repository repository);
+ public RepositoryServiceProvider resolve(Repository repository);
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/ScmProviderHttpServlet.java b/scm-core/src/main/java/sonia/scm/repository/spi/ScmProviderHttpServlet.java
new file mode 100644
index 0000000000..3a9dad52d6
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/ScmProviderHttpServlet.java
@@ -0,0 +1,16 @@
+package sonia.scm.repository.spi;
+
+import sonia.scm.repository.Repository;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public interface ScmProviderHttpServlet {
+
+ void service(HttpServletRequest request, HttpServletResponse response, Repository repository) throws ServletException, IOException;
+
+ void init(ServletConfig config) throws ServletException;
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/ScmProviderHttpServletDecorator.java b/scm-core/src/main/java/sonia/scm/repository/spi/ScmProviderHttpServletDecorator.java
new file mode 100644
index 0000000000..c5dd55d277
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/ScmProviderHttpServletDecorator.java
@@ -0,0 +1,28 @@
+package sonia.scm.repository.spi;
+
+import sonia.scm.repository.Repository;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class ScmProviderHttpServletDecorator implements ScmProviderHttpServlet {
+
+ private final ScmProviderHttpServlet object;
+
+ public ScmProviderHttpServletDecorator(ScmProviderHttpServlet object) {
+ this.object = object;
+ }
+
+ @Override
+ public void service(HttpServletRequest request, HttpServletResponse response, Repository repository) throws ServletException, IOException {
+ object.service(request, response, repository);
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ object.init(config);
+ }
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/ScmProviderHttpServletDecoratorFactory.java b/scm-core/src/main/java/sonia/scm/repository/spi/ScmProviderHttpServletDecoratorFactory.java
new file mode 100644
index 0000000000..531a25e91d
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/ScmProviderHttpServletDecoratorFactory.java
@@ -0,0 +1,15 @@
+package sonia.scm.repository.spi;
+
+import sonia.scm.DecoratorFactory;
+import sonia.scm.plugin.ExtensionPoint;
+
+@ExtensionPoint
+public interface ScmProviderHttpServletDecoratorFactory extends DecoratorFactory