Compare commits
1 Commits
master
...
xservices-
Author | SHA1 | Date |
---|---|---|
Brian Rosenberger | ef43d6e840 |
132
build.gradle
132
build.gradle
|
@ -1,132 +0,0 @@
|
|||
apply plugin: 'war'
|
||||
apply plugin: "maven-publish"
|
||||
apply plugin: "signing"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(8)
|
||||
}
|
||||
}
|
||||
|
||||
project.version "2.0.2-SNAPSHOT"
|
||||
group "net.brutex.xservices"
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
|
||||
maven {
|
||||
name = 'LocalRemote'
|
||||
def releasesRepoUrl = 'https://archiva.brutex.net/repository/internal/'
|
||||
def snapshotsRepoUrl = 'https://archiva.brutex.net/repository/snapshots/'
|
||||
url = project.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||
allowInsecureProtocol = false
|
||||
credentials {
|
||||
username = mavenuser
|
||||
password = mavenpass
|
||||
}
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'OSSRH'
|
||||
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
|
||||
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
|
||||
url = project.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||
credentials {
|
||||
username = ossrhUsername
|
||||
password = ossrhPassword
|
||||
}
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'brutexGitea'
|
||||
def releasesRepoUrl = 'https://source.brutex.net/api/packages/brutex/maven'
|
||||
def snapshotsRepoUrl = 'https://source.brutex.net/api/packages/brutex/maven'
|
||||
url = project.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||
allowInsecureProtocol = false
|
||||
credentials {
|
||||
username = mavenuser
|
||||
password = mavenpass
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('createDist', Zip) {Zip t ->
|
||||
archiveBaseName = project.name
|
||||
archiveVersion = version
|
||||
archiveExtension = "zip"
|
||||
destinationDirectory = new File(project.buildDir, "/distribution/")
|
||||
from war.outputs.files
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "javax.servlet:javax.servlet-api:4.0.1"
|
||||
compileOnly "javax.ws.rs:javax.ws.rs-api:2.1.1"
|
||||
|
||||
implementation "org.apache.commons:commons-configuration2:2.9.0"
|
||||
implementation "org.apache.commons:commons-lang3:3.12.0"
|
||||
implementation "commons-net:commons-net:3.9.0"
|
||||
implementation "commons-beanutils:commons-beanutils:1.9.4"
|
||||
implementation "org.apache.httpcomponents:httpclient:4.5.14"
|
||||
implementation "org.apache.httpcomponents:fluent-hc:4.5.14"
|
||||
implementation "commons-io:commons-io:2.11.0"
|
||||
|
||||
implementation "org.apache.ant:ant:1.10.13"
|
||||
implementation "org.apache.ant:ant-nodeps:1.8.1"
|
||||
implementation "org.apache.ant:ant-jsch:1.10.13"
|
||||
implementation "org.apache.ant:ant-commons-net:1.10.13"
|
||||
implementation "org.apache.ant:ant-javamail:1.10.13"
|
||||
implementation "org.apache.ant:ant-launcher:1.10.13"
|
||||
|
||||
implementation "org.apache.commons:commons-jcs-core:2.2.1"
|
||||
|
||||
implementation "org.quartz-scheduler:quartz:2.3.2"
|
||||
|
||||
implementation "org.slf4j:slf4j-api:2.0.7"
|
||||
runtimeOnly "ch.qos.logback:logback-core:1.3.8"
|
||||
runtimeOnly "ch.qos.logback:logback-classic:1.3.8"
|
||||
//runtimeOnly "org.slf4j:slf4j-simple:2.0.7"
|
||||
|
||||
implementation "org.apache.ws.commons.axiom:axiom:1.2.22"
|
||||
implementation "org.apache.ws.commons.axiom:axiom-impl:1.2.22"
|
||||
|
||||
implementation "org.apache.shiro:shiro-core:1.12.0"
|
||||
implementation "org.apache.shiro:shiro-root:1.12.0"
|
||||
implementation "org.apache.shiro:shiro-web:1.12.0"
|
||||
|
||||
implementation "org.apache.cxf:cxf:3.4.10"
|
||||
implementation "org.apache.cxf:cxf-rt-databinding-aegis:3.2.14"
|
||||
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-transports-http:3.2.14"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-frontend-jaxrs:3.2.14"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-frontend-jaxws:3.2.14"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-security:3.2.14"
|
||||
|
||||
|
||||
implementation "rhino:js:1.7R2"
|
||||
|
||||
implementation "org.springframework:spring-core:5.3.29"
|
||||
implementation "org.springframework:spring-context:5.3.29"
|
||||
implementation "org.springframework:spring-web:5.3.29"
|
||||
|
||||
implementation "com.h2database:h2:2.2.222"
|
||||
|
||||
implementation "com.sun.xml.bind:jaxb-impl:2.3.0.1"
|
||||
implementation "com.sun.xml.bind:jaxb-core:2.3.0.1"
|
||||
|
||||
implementation fileTree(dir: "lib/", includes: ["*.jar"], excludes: ["serena.*.jar"])
|
||||
compileOnly fileTree(dir: "lib/", includes: ["serena.*.jar"])
|
||||
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.28"
|
||||
compileOnly "org.projectlombok:lombok:1.18.28"
|
||||
|
||||
}
|
44
build.xml
44
build.xml
|
@ -1,14 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<project default="create-doc" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
|
||||
|
||||
<property name="toolsdir" location="C:/JAVA-DEV/" />
|
||||
|
||||
|
||||
<!-- C:\JAVA-DEV\apache-fop-1.1 -->
|
||||
|
||||
<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
|
||||
<classpath>
|
||||
<fileset dir="${toolsdir}/fop-2.2/fop">
|
||||
<fileset dir="C:\\JAVA-DEV\\apache-fop-1.1">
|
||||
<include name="build/*.jar" />
|
||||
<include name="lib/*.jar" />
|
||||
</fileset>
|
||||
|
@ -17,20 +14,19 @@
|
|||
|
||||
<!-- External Syntax Higlighter for docbook xsl -->
|
||||
<path id="xslthl.path">
|
||||
<pathelement location="${toolsdir}/xslthl-2.1.3/xslthl-2.1.3.jar" />
|
||||
<pathelement location="C:\\JAVA-DEV\\xslthl-2.1.0\\xslthl-2.1.0.jar" />
|
||||
</path>
|
||||
|
||||
|
||||
<property name="current-loc" location="." />
|
||||
<property name="workspace" location=".." />
|
||||
|
||||
<property name="htmldir" value="${current-loc}/doc/html" />
|
||||
<property name="docbookdir" value="${toolsdir}/docbook-xsl-1.79.1/" />
|
||||
<property name="docbookdir" value="D:/DATA/JAVA-DEV/docbook-xsl-1.78.1/" />
|
||||
|
||||
<property name="fo.stylesheet" value="${docbookdir}/fo/docbook.xsl" />
|
||||
<property name="fo.stylesheet.hl" value="${docbookdir}/fo/docbook.xsl" />
|
||||
<property name="html.stylesheet.hl" value="${docbookdir}/html/docbook.xsl" />
|
||||
<property name="html.chunked.stylesheet.hl" value="${docbookdir}/html/docbook.xsl" />
|
||||
<property name="html.stylesheet.hl" value="${docbookdir}/html/docbook-with-highlighting.xsl" />
|
||||
<property name="html.chunked.stylesheet.hl" value="${docbookdir}/html/docbook-chunked-with-highlighting.xsl" />
|
||||
<property name="eclipse.stylesheet" value="${docbookdir}/eclipse/eclipse.xsl" />
|
||||
<property name="html.stylesheet" value="${docbookdir}/html/docbook.xsl" />
|
||||
<property name="javahelp.stylesheet" value="${docbookdir}/javahelp/javahelp.xsl" />
|
||||
|
@ -39,9 +35,8 @@
|
|||
<property name="docbooksource" value="${current-loc}/doc" />
|
||||
<property name="xalan" value="org.apache.xalan.processor.TransformerFactoryImpl" />
|
||||
<property name="web.dir" value="${current-loc}/web" />
|
||||
<property name="build.dir" value="${current-loc}/build/classes" />
|
||||
<property name="bin.dir" value="${current-loc}/bin" />
|
||||
<property name="delivery.dir" value="c:/TEMP/_DELIVERY_AREA" />
|
||||
<property name="build.dir" value="${current-loc}/bin" />
|
||||
<property name="delivery.dir" value="c:\\TEMP\\_DELIVERY_AREA" />
|
||||
<property name="name" value="XServices" />
|
||||
|
||||
|
||||
|
@ -66,7 +61,7 @@
|
|||
<xslt force="true" style="${html.stylesheet.hl}" in="${docbooksource}/BruteXServices_User_Guide.dbk" out="${htmldir}/index.html">
|
||||
<factory name="${xalan}" />
|
||||
<classpath refid="xslthl.path" />
|
||||
<param name="highlight.xslthl.config" expression="file:///${docbookdir}/highlighting/xslthl-config.xml" />
|
||||
<param name="highlight.xslthl.config" expression="file:///C:/JAVA-DEV/docbook-xsl-1.78.1/highlighting/xslthl-config.xml" />
|
||||
<param name="highlight.source" expression="1" />
|
||||
<param name="html.stylesheet" expression="style.css" />
|
||||
</xslt>
|
||||
|
@ -90,7 +85,7 @@
|
|||
<param name="html.cleanup" expression="1" />
|
||||
<param name="chunk.first.selection" expression="1" />
|
||||
<param name="navig.showtitles" expression="1" />
|
||||
<param name="highlight.xslthl.config" expression="file:///${docbookdir}/highlighting/xslthl-config.xml" />
|
||||
<param name="highlight.xslthl.config" expression="file:///C:/JAVA-DEV/docbook-xsl-1.78.1/highlighting/xslthl-config.xml" />
|
||||
<param name="highlight.source" expression="1" />
|
||||
</xslt>
|
||||
<copy file="${docbooksource}/style.css" overwrite="true" tofile="${htmldir}/style.css" />
|
||||
|
@ -107,7 +102,7 @@
|
|||
<param name="chapter.autolabel" expression="1" />
|
||||
<param name="appendix.autolabel" expression="1" />
|
||||
<param name="section.label.includes.component.label" expression="1" />
|
||||
<param name="highlight.xslthl.config" expression="file:///${docbookdir}/highlighting/xslthl-config.xml" />
|
||||
<param name="highlight.xslthl.config" expression="file:///C:/JAVA-DEV/docbook-xsl-1.78.1/highlighting/xslthl-config.xml" />
|
||||
<param name="highlight.source" expression="1" />
|
||||
<param name="paper.type" expression="A4" />
|
||||
</xslt>
|
||||
|
@ -163,12 +158,7 @@
|
|||
</target>
|
||||
|
||||
<target name="build-war">
|
||||
<ivy:retrieve pattern="c://TEMP/lib/default/[artifact]-[revision].[ext]" conf="master" />
|
||||
<jar destfile="${bin.dir}/XServices.jar"
|
||||
basedir="${build.dir}"
|
||||
includes="net/**/*"/>
|
||||
|
||||
|
||||
<ivy:retrieve pattern="c://TEMP/lib/default/[artifact]-[revision].[ext]" conf="default" />
|
||||
<war destfile="${delivery.dir}\\${name}.war" webxml="${web.dir}/WEB-INF/web.xml">
|
||||
<fileset dir="${web.dir}/">
|
||||
<include name="**/*.*" />
|
||||
|
@ -176,14 +166,7 @@
|
|||
<lib dir="c://TEMP/lib/default">
|
||||
<!--<exclude name="portlet.jar"/>-->
|
||||
</lib>
|
||||
<lib dir="${bin.dir}" />
|
||||
<classes dir="${build.dir}">
|
||||
<!--We already packed all classes into a jar,
|
||||
so put only remaining config files into
|
||||
classes
|
||||
-->
|
||||
<exclude name="net/**/*"/>
|
||||
</classes>
|
||||
<classes dir="${build.dir}" />
|
||||
</war>
|
||||
<tstamp>
|
||||
<format property="build.version" pattern="yyyyMMddhhmmss" />
|
||||
|
@ -197,7 +180,4 @@
|
|||
<echo>Distribution: ${delivery.dir}\\${name}\\${name}-${build.version} </echo>
|
||||
</target>
|
||||
|
||||
<target name="hot-deploy" depends="build-war">
|
||||
<copy file="${delivery.dir}\\${name}\\${name}-${build.version}\\${name}.war" toFile="C://JAVA-DEV//Tomcat//apache-tomcat-8.5.30 -localtest//webapps//XServices.war" />
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
<title>Installation</title>
|
||||
<para>As of February 2013, XServices require Java 7. Older builds run against Java 5.</para>
|
||||
<para>As of April 2018, XServices require Java 8 and Tomcat 8.5.</para>
|
||||
|
||||
<para>Apache Tomcat 7</para>
|
||||
<para>tbd.</para>
|
||||
<para>In short: Deploy .WAR file to Apache Tomcat</para>
|
||||
<section>
|
||||
|
|
Binary file not shown.
|
@ -1,7 +0,0 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
|
@ -1,248 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed 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
|
||||
#
|
||||
# https://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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
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
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
|
@ -1,92 +0,0 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -0,0 +1,119 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!-- 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. -->
|
||||
<ivy-module version="2.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
|
||||
<info organisation="Brutex Network" module="XServices" status="integration">
|
||||
</info>
|
||||
|
||||
<configurations>
|
||||
<conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
|
||||
<conf name="master" visibility="public" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
|
||||
<conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths." extends="master"/>
|
||||
<conf name="provided" visibility="public" description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive."/>
|
||||
<conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath." extends="compile"/>
|
||||
<conf name="test" visibility="private" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases." extends="runtime"/>
|
||||
<conf name="system" visibility="public" description="this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository."/>
|
||||
<conf name="sources" visibility="public" description="this configuration contains the source artifact of this module, if any."/>
|
||||
<conf name="javadoc" visibility="public" description="this configuration contains the javadoc artifact of this module, if any."/>
|
||||
<conf name="optional" visibility="public" description="contains all optional dependencies"/>
|
||||
</configurations>
|
||||
|
||||
|
||||
<dependencies defaultconf="*->#(master),master(*)">
|
||||
|
||||
<dependency org="com.sun.xml.bind" name="jaxb-impl" rev="2.2.7"/>
|
||||
|
||||
<dependency org="org.apache.commons" name="commons-lang3" rev="3.1"/>
|
||||
<dependency org="commons-configuration" name="commons-configuration" rev="1.10"/>
|
||||
<dependency org="commons-net" name="commons-net" rev="3.2"/>
|
||||
|
||||
<dependency org="org.apache.ant" name="ant" rev="1.8.4"/>
|
||||
<dependency org="org.apache.ant" name="ant-nodeps" rev="1.8.1"/>
|
||||
<dependency org="org.apache.ant" name="ant-jsch" rev="1.8.4"/>
|
||||
<!--<dependency org="ant-contrib" name="ant-contrib" rev="20020829"/>-->
|
||||
<dependency org="org.apache.ant" name="ant-commons-net" rev="1.8.4"/>
|
||||
|
||||
<!-- JCS does not define scopes in its pom.xml, thus map any configuration to default -->
|
||||
<dependency org="org.apache.jcs" name="jcs" rev="1.3"/>
|
||||
|
||||
<!--<dependency org="concurrent" name="concurrent" rev="1.3.4"/> --><!-- needed for JCS -->
|
||||
|
||||
|
||||
<dependency org="org.quartz-scheduler" name="quartz" rev="2.2.0"/>
|
||||
|
||||
<dependency org="log4j" name="log4j" rev="1.2.17"/>
|
||||
|
||||
<dependency org="org.apache.ws.commons.axiom" name="axiom-api" rev="1.2.14"/>
|
||||
<dependency org="org.apache.ws.commons.axiom" name="axiom-impl" rev="1.2.14"/>
|
||||
|
||||
<dependency org="jaxen" name="jaxen" rev="1.1.4"/>
|
||||
|
||||
<dependency org="org.apache.shiro" name="shiro-core" rev="1.2.2"/>
|
||||
<dependency org="org.apache.shiro" name="shiro-web" rev="1.2.2"/>
|
||||
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.6"/> <!-- Binding to Log4J -->
|
||||
|
||||
<dependency org="org.apache.cxf" name="cxf-rt-core" rev="2.7.0"/>
|
||||
<dependency org="org.apache.cxf" name="cxf-rt-transports-http" rev="2.7.0"/>
|
||||
<dependency org="org.apache.cxf" name="cxf-rt-databinding-aegis" rev="2.7.0"/>
|
||||
<dependency org="org.apache.cxf" name="cxf-rt-frontend-jaxrs" rev="2.7.0"/>
|
||||
<dependency org="org.apache.cxf" name="cxf-rt-frontend-jaxws" rev="2.7.0"/>
|
||||
<dependency org="org.apache.cxf" name="cxf-rt-rs-security-sso-saml" rev="2.7.0"/>
|
||||
|
||||
|
||||
<dependency org="rhino" name="js" rev="1.7R2"/>
|
||||
|
||||
|
||||
<!--
|
||||
<dependency org="org.apache.cxf" name="cxf-rt-bindings-soap" rev="2.7.0"/>
|
||||
<dependency org="org.apache.cxf" name="cxf-rt-databinding-jaxb" rev="2.7.0"/>
|
||||
-->
|
||||
|
||||
<dependency org="org.springframework" name="spring-web" rev="3.0.7.RELEASE"/>
|
||||
|
||||
<!--
|
||||
<dependency org="javax.transaction" name="jta" rev="1.0.1B" />
|
||||
<dependency org="javax.sql" name="jdbc-stdext" rev="2.0" />
|
||||
-->
|
||||
|
||||
<!--
|
||||
Locally managed libraries
|
||||
-->
|
||||
<dependency org="lib" name="java-unrar" rev="0.3" conf="*->*">
|
||||
<artifact name="java-unrar" type="jar" />
|
||||
</dependency>
|
||||
<dependency org="lib" name="lib.cvsclient" rev="20131001" conf="*->*">
|
||||
<artifact name="lib.cvsclient" type="jar" />
|
||||
</dependency>
|
||||
<dependency org="lib" name="lib.xservices-scmtypes" rev="20131001" conf="*">
|
||||
<artifact name="lib.xservices-scmtypes" type="jar" />
|
||||
</dependency>
|
||||
|
||||
<!-- Serena Dimensions CM 14.1 -->
|
||||
<dependency org="serena" name="serena.darius" rev="14.1" conf="*">
|
||||
<artifact name="serena.darius" type="jar" />
|
||||
</dependency>
|
||||
<dependency org="serena" name="serena.dmclient" rev="14.1" conf="*">
|
||||
<artifact name="serena.dmclient" type="jar" />
|
||||
</dependency>
|
||||
<dependency org="serena" name="serena.dmfile" rev="14.1" conf="*">
|
||||
<artifact name="serena.dmfile" type="jar" />
|
||||
</dependency>
|
||||
<dependency org="serena" name="serena.dmnet" rev="14.1" conf="*">
|
||||
<artifact name="serena.dmnet" type="jar" />
|
||||
</dependency>
|
||||
<dependency org="serena" name="serena.dmtpi" rev="14.1" conf="*">
|
||||
<artifact name="serena.dmtpi" type="jar" />
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</ivy-module>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ivysettings>
|
||||
<settings defaultResolver="defaultchain" />
|
||||
<resolvers>
|
||||
<ibiblio name="apache-maven" m2compatible="true" usepoms="true" root="http://repo.maven.apache.org/maven2/" />
|
||||
<ibiblio name="java" m2compatible="true" usepoms="true" root="http://download.java.net/maven/2/" />
|
||||
|
||||
<filesystem name="local-filesystem">
|
||||
<!-- <ivy pattern="${ivy.settings.dir}/1/[organisation]/[module]/ivys/ivy-[revision].xml"/> -->
|
||||
<artifact pattern="${ivy.settings.dir}/lib/[artifact]-[revision].[ext]" />
|
||||
</filesystem>
|
||||
|
||||
<chain name="defaultchain">
|
||||
<resolver ref="local-filesystem" />
|
||||
<resolver ref="apache-maven" />
|
||||
<resolver ref="java" />
|
||||
|
||||
</chain>
|
||||
</resolvers>
|
||||
|
||||
<modules>
|
||||
<module organisation="javax.transaction" resolver="java" />
|
||||
<module organisation="javax.sql" resolver="java" />
|
||||
</modules>
|
||||
</ivysettings>
|
||||
|
Binary file not shown.
|
@ -0,0 +1,61 @@
|
|||
# DEFAULT CACHE REGION
|
||||
jcs.default=DC
|
||||
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
|
||||
jcs.default.cacheattributes.MaxObjects=1000
|
||||
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
|
||||
jcs.default.cacheattributes.UseMemoryShrinker=false
|
||||
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
|
||||
jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
|
||||
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
|
||||
jcs.default.elementattributes.IsEternal=false
|
||||
jcs.default.elementattributes.MaxLifeSeconds=21600
|
||||
jcs.default.elementattributes.IdleTime=1800
|
||||
jcs.default.elementattributes.IsSpool=true
|
||||
jcs.default.elementattributes.IsRemote=true
|
||||
jcs.default.elementattributes.IsLateral=true
|
||||
|
||||
# PRE-DEFINED CACHE REGIONS
|
||||
jcs.region.FileCache=DC
|
||||
jcs.region.FileCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
|
||||
jcs.region.FileCache.cacheattributes.MaxObjects=1000
|
||||
jcs.region.FileCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
|
||||
jcs.region.FileCache.cacheattributes.UseMemoryShrinker=false
|
||||
jcs.region.FileCache.cacheattributes.MaxMemoryIdleTimeSeconds=3600
|
||||
jcs.region.FileCache.cacheattributes.ShrinkerIntervalSeconds=60
|
||||
jcs.region.FileCache.cacheattributes.MaxSpoolPerRun=500
|
||||
jcs.region.FileCache.elementattributes=org.apache.jcs.engine.ElementAttributes
|
||||
jcs.region.FileCache.elementattributes.IsEternal=false
|
||||
|
||||
jcs.region.CVSCache=DC
|
||||
jcs.region.CVSCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
|
||||
jcs.region.CVSCache.cacheattributes.MaxObjects=50
|
||||
jcs.region.CVSCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
|
||||
jcs.region.CVSCache.cacheattributes.UseMemoryShrinker=true
|
||||
jcs.region.CVSCache.cacheattributes.MaxMemoryIdleTimeSeconds=3600
|
||||
jcs.region.CVSCache.cacheattributes.ShrinkerIntervalSeconds=60
|
||||
jcs.region.CVSCache.cacheattributes.MaxSpoolPerRun=5
|
||||
jcs.region.CVSCache.elementattributes=org.apache.jcs.engine.ElementAttributes
|
||||
jcs.region.CVSCache.elementattributes.IsEternal=false
|
||||
|
||||
jcs.region.DIMCM=DC
|
||||
jcs.region.DIMCM.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
|
||||
jcs.region.DIMCM.cacheattributes.MaxObjects=50
|
||||
jcs.region.DIMCM.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
|
||||
jcs.region.DIMCM.cacheattributes.UseMemoryShrinker=true
|
||||
jcs.region.DIMCM.cacheattributes.MaxMemoryIdleTimeSeconds=3600
|
||||
jcs.region.DIMCM.cacheattributes.ShrinkerIntervalSeconds=60
|
||||
jcs.region.DIMCM.cacheattributes.MaxSpoolPerRun=5
|
||||
jcs.region.DIMCM.elementattributes=org.apache.jcs.engine.ElementAttributes
|
||||
jcs.region.DIMCM.elementattributes.IsEternal=false
|
||||
|
||||
|
||||
|
||||
# AVAILABLE AUXILIARY CACHES
|
||||
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
|
||||
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
|
||||
jcs.auxiliary.DC.attributes.DiskPath=${user.dir}/jcs_swap
|
||||
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000000
|
||||
jcs.auxiliary.DC.attributes.MaxKeySize=1000000
|
||||
jcs.auxiliary.DC.attributes.MaxRecycleBinSize=5000
|
||||
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
|
||||
jcs.auxiliary.DC.attributes.ShutdownSpoolTimeLimit=60
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
log4j.rootLogger=INFO, A1
|
||||
log4j.appender.A1=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
# Print the date in ISO 8601 format
|
||||
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c{2} - %m%n
|
||||
|
||||
# Print only messages of level WARN or above in the package com.foo.
|
||||
log4j.logger.net.brutex.xservices=INFO
|
||||
log4j.logger.net.brutex.xservices.ws.rs=DEBUG
|
||||
log4j.logger.net.brutex.xservices.security=DEBUG
|
||||
|
||||
log4j.logger.org.springframework=INFO
|
||||
|
||||
log4j.logger.org.apache.jcs=INFO
|
||||
|
||||
log4j.logger.org.apache.commons=INFO
|
||||
|
||||
log4j.logger.org.apache.axiom=INFO
|
||||
|
||||
log4j.logger.org.apache.shiro=INFO
|
||||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package net.brutex.xservices.security;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.shiro.authz.Permission;
|
||||
import org.apache.shiro.util.AntPathMatcher;
|
||||
|
||||
|
@ -25,13 +24,13 @@ import org.apache.shiro.util.AntPathMatcher;
|
|||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class DirectoryPermission implements Permission {
|
||||
|
||||
private final Logger logger = Logger.getLogger(DirectoryPermission.class);
|
||||
private final String path;
|
||||
|
||||
public DirectoryPermission(String antlikepath) {
|
||||
log.debug(String.format("Creating permission for path '{}'", antlikepath));
|
||||
logger.debug(String.format("Creating permission for path '%s'", antlikepath));
|
||||
path = antlikepath;
|
||||
}
|
||||
|
||||
|
@ -41,13 +40,13 @@ public class DirectoryPermission implements Permission {
|
|||
|
||||
/* is of same type */
|
||||
if(! (p instanceof DirectoryPermission)) {
|
||||
log.debug(String.format("Testing if permission of type '{}' implies permission of type '{}'. Result was '{}'" , this.getClass(), p.getClass(), result));
|
||||
logger.debug(String.format("Testing if permission of type '%s' implies permission of type '%s'. Result was '%s'" , this.getClass(), p.getClass(), result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/* comparing to non null directory */
|
||||
if( ((DirectoryPermission)p).getPath() == null) {
|
||||
log.debug(String.format("Testing if DirectoryPermission '{}' implies permission to 'null'. Result was '{}'" , this.getPath(), result));
|
||||
logger.debug(String.format("Testing if DirectoryPermission '%s' implies permission to 'null'. Result was '%s'" , this.getPath(), result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,7 @@ public class DirectoryPermission implements Permission {
|
|||
if( (new AntPathMatcher()).matches(path, ((DirectoryPermission)p).getPath()) ) {
|
||||
result = true;
|
||||
}
|
||||
log.debug(String.format("Testing if DirectoryPermission '{}' implies permission to '{}'. Result was '{}'" , this.getPath(), ((DirectoryPermission) p).getPath(), result));
|
||||
logger.debug(String.format("Testing if DirectoryPermission '%s' implies permission to '%s'. Result was '%s'" , this.getPath(), ((DirectoryPermission) p).getPath(), result));
|
||||
|
||||
return result;
|
||||
}
|
|
@ -16,11 +16,10 @@
|
|||
|
||||
package net.brutex.xservices.security;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.ws.XmlService;
|
||||
import net.brutex.xservices.ws.rs.FileInfo;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.shiro.authz.Permission;
|
||||
import org.apache.shiro.authz.permission.InvalidPermissionStringException;
|
||||
|
||||
|
@ -28,33 +27,33 @@ import org.apache.shiro.authz.permission.InvalidPermissionStringException;
|
|||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class PermissionResolver implements org.apache.shiro.authz.permission.PermissionResolver {
|
||||
|
||||
final Logger logger = Logger.getLogger(PermissionResolver.class);
|
||||
private final String DELIMITER = "||";
|
||||
|
||||
@Override
|
||||
public Permission resolvePermission(String permissionString) {
|
||||
log.debug(String.format("Trying to examine new Permission '{}'", permissionString));
|
||||
logger.debug(String.format("Trying to examine new Permission '%s'", permissionString));
|
||||
if(! permissionString.contains(DELIMITER)) {
|
||||
log.error(String.format("Permission '{}' is missing permission class.", permissionString));
|
||||
throw new InvalidPermissionStringException(String.format("Permission '{}' is missing permission class.", permissionString), permissionString);
|
||||
logger.error(String.format("Permission '%s' is missing permission class.", permissionString));
|
||||
throw new InvalidPermissionStringException(String.format("Permission '%s' is missing permission class.", permissionString), permissionString);
|
||||
}
|
||||
int delimiterIndex = permissionString.indexOf(DELIMITER);
|
||||
String value = permissionString.substring(0, delimiterIndex);
|
||||
delimiterIndex = delimiterIndex + DELIMITER.length();
|
||||
switch (value) {
|
||||
case XmlService.SERVICE_NAME:
|
||||
log.debug(String.format("Found '{}' as permission class.", value));
|
||||
logger.debug(String.format("Found '%s' as permission class.", value));
|
||||
return new XmlServicePermission(permissionString.substring( delimiterIndex ));
|
||||
|
||||
case FileInfo.SERVICE_NAME:
|
||||
log.debug(String.format("Found '{}' as permission class.", value));
|
||||
logger.debug(String.format("Found '%s' as permission class.", value));
|
||||
return new DirectoryPermission(permissionString.substring( delimiterIndex ));
|
||||
|
||||
|
||||
default:
|
||||
log.warn(String.format("Permission class '{}' is not defined.", value));
|
||||
logger.warn(String.format("Permission class '%s' is not defined.", value));
|
||||
throw new InvalidPermissionStringException(String.format("Permission class '%s' is not defined.", value), permissionString);
|
||||
}
|
||||
}
|
|
@ -17,14 +17,24 @@
|
|||
|
||||
package net.brutex.xservices.security;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.AuthenticationInfo;
|
||||
import org.apache.shiro.authc.AuthenticationToken;
|
||||
import org.apache.shiro.authz.AuthorizationInfo;
|
||||
import org.apache.shiro.authz.Permission;
|
||||
import org.apache.shiro.authz.permission.PermissionResolver;
|
||||
import org.apache.shiro.config.Ini;
|
||||
import org.apache.shiro.io.ResourceUtils;
|
||||
import org.apache.shiro.realm.AuthorizingRealm;
|
||||
import org.apache.shiro.realm.text.IniRealm;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.apache.shiro.util.Nameable;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import org.apache.shiro.util.PermissionUtils;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/*
|
||||
|
@ -38,9 +48,10 @@ import java.net.URISyntaxException;
|
|||
/**
|
||||
* The Class XServicesRealm.
|
||||
*/
|
||||
@Slf4j
|
||||
public class XServicesRealm extends IniRealm implements Nameable {
|
||||
|
||||
/** The logger. */
|
||||
private static Logger logger = Logger.getLogger(XServicesRealm.class);
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
@ -59,25 +70,11 @@ public class XServicesRealm extends IniRealm implements Nameable {
|
|||
* 'shiro.ini' in classpath and {@link net.brutex.xservices.security.PermissionResolver PermissionResolver}.
|
||||
*
|
||||
*/
|
||||
|
||||
public XServicesRealm() {
|
||||
super();
|
||||
/* needs review */
|
||||
URI classesRootDir;
|
||||
try {
|
||||
classesRootDir = getClass().getProtectionDomain().getCodeSource().getLocation().toURI();
|
||||
String dir = classesRootDir.toString().replaceAll("%20", " ");
|
||||
dir = dir.substring(0, dir.lastIndexOf("WEB-INF"));
|
||||
this.setIni(Ini.fromResourcePath(dir+"/WEB-INF/shiro.ini"));
|
||||
} catch (URISyntaxException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
this.setIni(Ini.fromResourcePath(ResourceUtils.CLASSPATH_PREFIX+"shiro.ini"));
|
||||
this.setPermissionResolver(new net.brutex.xservices.security.PermissionResolver());
|
||||
//this.setRolePermissionResolver(new RolePermissionResolver());
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -16,20 +16,21 @@
|
|||
|
||||
package net.brutex.xservices.security;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.shiro.authz.Permission;
|
||||
import org.apache.shiro.util.AntPathMatcher;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class XmlServicePermission implements Permission {
|
||||
|
||||
private final Logger logger = Logger.getLogger(XmlServicePermission.class);
|
||||
private final String permissionString;
|
||||
|
||||
public XmlServicePermission(String permissionString) {
|
||||
log.debug(String.format("Creating permission for '{}'", permissionString));
|
||||
logger.debug(String.format("Creating permission for '%s'", permissionString));
|
||||
this.permissionString = permissionString;
|
||||
}
|
||||
|
||||
|
@ -39,13 +40,13 @@ public class XmlServicePermission implements Permission {
|
|||
|
||||
/* is of same type */
|
||||
if(! (p instanceof XmlServicePermission)) {
|
||||
log.debug(String.format("Testing if permission of type '{}' implies permission of type '{}'. Result was '{}'" , this.getClass(), p.getClass(), result));
|
||||
logger.debug(String.format("Testing if permission of type '%s' implies permission of type '%s'. Result was '%s'" , this.getClass(), p.getClass(), result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/* comparing to non null directory */
|
||||
if( ((XmlServicePermission)p).getPermissionString() == null) {
|
||||
log.debug(String.format("Testing if DirectoryPermission '{}' implies permission to 'null'. Result was '{}'" , permissionString, result));
|
||||
logger.debug(String.format("Testing if DirectoryPermission '%s' implies permission to 'null'. Result was '%s'" , permissionString, result));
|
||||
return result;
|
||||
}
|
||||
|
|
@ -41,6 +41,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.sun.xml.bind.XmlAccessorFactory;
|
||||
/**
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
|
@ -29,7 +29,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
@XmlType
|
||||
public class StringMatchType
|
||||
{
|
||||
public final List<StringMatchDetails> stringlist = new ArrayList<StringMatchDetails>();
|
||||
public final List<StringMatchDetails> stringlist = new ArrayList();
|
||||
public int size = 0;
|
||||
|
||||
public synchronized void addStringMatch(StringMatchDetails match)
|
|
@ -18,7 +18,6 @@ package net.brutex.xservices.types.ant;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
@ -45,13 +44,13 @@ public class AntProperty {
|
|||
/**
|
||||
* Converts a Map<String, String> into a list of
|
||||
* AntProperties.
|
||||
* @param newMap The map to convert
|
||||
* @param map The map to convert
|
||||
* @return A list of key/value pairs
|
||||
*/
|
||||
public static List<AntProperty> createAntPropertyList(Map<String, Object> newMap) {
|
||||
public static List<AntProperty> createAntPropertyList(Map<String, String> map) {
|
||||
List<AntProperty> list = new ArrayList<AntProperty>();
|
||||
for(Map.Entry<String, Object> e : newMap.entrySet()) {
|
||||
list.add(new AntProperty(e.getKey(), (String)e.getValue()));
|
||||
for(Map.Entry<String, String> e : map.entrySet()) {
|
||||
list.add(new AntProperty(e.getKey(), e.getValue()));
|
||||
}
|
||||
return list;
|
||||
}
|
|
@ -31,23 +31,23 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.quartz.utils.ConnectionProvider;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
||||
|
||||
private Connection conn = null;
|
||||
|
||||
private final Logger logger = Logger.getLogger(this.getClass().getCanonicalName());
|
||||
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
if( conn!= null ) { // Todo: && conn.conn.isValid(5)) {
|
||||
log.debug("Checking tables on pre-exisiting database connection.");
|
||||
logger.debug("Checking tables on pre-exisiting database connection.");
|
||||
checkTables();
|
||||
return conn;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
// Class.forName("org.hsqldb.jdbc.JDBCDriver" );
|
||||
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to load Derby JDBC driver.");
|
||||
logger.fatal("Failed to load Derby JDBC driver.");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -87,11 +87,6 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws SQLException {
|
||||
|
||||
}
|
||||
|
||||
private synchronized void recursiveDelete(File dbDir) {
|
||||
File[] files = dbDir.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
|
@ -106,9 +101,9 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
|
||||
private synchronized void checkTables() throws SQLException {
|
||||
log.debug("Checking QUARTZ database schema.");
|
||||
logger.debug("Checking QUARTZ database schema.");
|
||||
if(!isConnected(false)) {
|
||||
log.error("Failed to validate QUARTZ database schema.");
|
||||
logger.error("Failed to validate QUARTZ database schema.");
|
||||
return;
|
||||
}
|
||||
List<String> ddl_list = new ArrayList<String>(11);
|
||||
|
@ -131,7 +126,7 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
for (String tbl : ddl_list) {
|
||||
ResultSet rs = dmd.getTables(null, "APP", tbl, null);
|
||||
if (!rs.next()) {
|
||||
log.debug("Adding DDL for table {}", tbl);
|
||||
logger.log(Level.INFO, "Adding DDL for table "+ tbl);
|
||||
Statement st = conn.createStatement();
|
||||
File ddlFile = new File(ddl + tbl + ".ddl");
|
||||
String create = "";
|
||||
|
@ -142,15 +137,18 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
create.trim();
|
||||
if( st.execute(create)) {
|
||||
log.debug("Table {} created.", tbl);
|
||||
logger.log(Level.INFO, "Table " + tbl + " created.");
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (SQLException ex) {
|
||||
log.error("Error executing statement {}.",create, ex );
|
||||
logger.log(Level.ERROR, "Error executing statement "+ create );
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.trace("Table {} exists.", tbl);
|
||||
logger.trace("Table "+tbl+" exists.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,15 +159,15 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
} else {
|
||||
String t = this.getClass().getClassLoader().getResource("/").toString().substring(6); // WEB-INF/classes
|
||||
t += "../data/db";
|
||||
log.debug("Database directory is set to '{}", t);
|
||||
logger.debug("Database directory is set to '" + t + "'");
|
||||
try {
|
||||
this.conn = DriverManager.getConnection("jdbc:derby:" + t + ";create=true;");
|
||||
} catch (SQLException ex) {
|
||||
log.error(ex.getMessage(), ex);
|
||||
logger.error(ex.getMessage(), ex);
|
||||
if(!fail) {
|
||||
log.warn("Deleting database directory.");
|
||||
logger.warn("Deleting database directory.");
|
||||
recursiveDelete(new File(t));
|
||||
log.warn("Retrying to connect to database.");
|
||||
logger.warn("Retrying to connect to database.");
|
||||
return isConnected(true);
|
||||
} else {
|
||||
return false;
|
||||
|
@ -179,7 +177,11 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws SQLException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -31,22 +31,23 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.quartz.utils.ConnectionProvider;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
||||
|
||||
private Connection conn = null;
|
||||
private final Logger logger = Logger.getLogger(this.getClass().getCanonicalName());
|
||||
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
if( conn!= null) { // Todo: && conn.conn.isValid(5)) {) {
|
||||
log.debug("Checking tables on pre-exisiting database connection.");
|
||||
logger.debug("Checking tables on pre-exisiting database connection.");
|
||||
checkTables();
|
||||
return conn;
|
||||
}
|
||||
|
@ -54,7 +55,7 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
// Class.forName("org.hsqldb.jdbc.JDBCDriver" );
|
||||
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to load Derby JDBC driver.");
|
||||
logger.fatal("Failed to load Derby JDBC driver.");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -86,11 +87,6 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws SQLException {
|
||||
|
||||
}
|
||||
|
||||
private synchronized void recursiveDelete(File dbDir) {
|
||||
File[] files = dbDir.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
|
@ -105,9 +101,9 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
|
||||
private synchronized void checkTables() throws SQLException {
|
||||
log.debug("Checking QUARTZ database schema.");
|
||||
logger.debug("Checking QUARTZ database schema.");
|
||||
if(!isConnected(false)) {
|
||||
log.error("Failed to validate QUARTZ database schema.");
|
||||
logger.error("Failed to validate QUARTZ database schema.");
|
||||
return;
|
||||
}
|
||||
List<String> ddl_list = new ArrayList<String>(11);
|
||||
|
@ -130,7 +126,7 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
for (String tbl : ddl_list) {
|
||||
ResultSet rs = dmd.getTables(null, "APP", tbl, null);
|
||||
if (!rs.next()) {
|
||||
log.debug("Adding DDL for table {}.", tbl);
|
||||
logger.log(Level.INFO, "Adding DDL for table "+ tbl);
|
||||
Statement st = conn.createStatement();
|
||||
File ddlFile = new File(ddl + tbl + ".ddl");
|
||||
String create = "";
|
||||
|
@ -141,16 +137,18 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
create.trim();
|
||||
if( st.execute(create)) {
|
||||
log.debug("Table {} created.", tbl);
|
||||
logger.log(Level.INFO, "Table " + tbl + " created.");
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (SQLException ex) {
|
||||
log.error("Error executing statement {}", create, ex );
|
||||
logger.log(Level.ERROR, "Error executing statement "+ create );
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.trace("Table {} exists.", tbl);
|
||||
logger.trace("Table "+tbl+" exists.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,15 +159,15 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
} else {
|
||||
String t = this.getClass().getClassLoader().getResource("/").toString().substring(6); // WEB-INF/classes
|
||||
t += "../data/db";
|
||||
log.debug("Database directory is set to '{}'", t);
|
||||
logger.debug("Database directory is set to '" + t + "'");
|
||||
try {
|
||||
this.conn = DriverManager.getConnection("jdbc:derby:" + t + ";create=true;");
|
||||
} catch (SQLException ex) {
|
||||
log.error(ex.getMessage(), ex);
|
||||
logger.error(ex.getMessage(), ex);
|
||||
if(!fail) {
|
||||
log.warn("Deleting database directory.");
|
||||
logger.warn("Deleting database directory.");
|
||||
recursiveDelete(new File(t));
|
||||
log.warn("Retrying to connect to database.");
|
||||
logger.warn("Retrying to connect to database.");
|
||||
return isConnected(true);
|
||||
} else {
|
||||
return false;
|
||||
|
@ -178,6 +176,12 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws SQLException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
/* */ package net.brutex.xservices.util;
|
||||
/* */
|
||||
/* */ import java.io.File;
|
||||
/* */ import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.types.scm.ItemType;
|
||||
import net.brutex.xservices.util.CVSRoot;
|
||||
|
||||
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||
import org.apache.commons.configuration2.builder.fluent.Configurations;
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
|
||||
/* */ import net.brutex.xservices.types.scm.ItemType;
|
||||
/* */ import net.brutex.xservices.ws.rs.CVSInfoImpl;
|
||||
/* */ import org.apache.commons.configuration.Configuration;
|
||||
/* */ import org.apache.commons.configuration.ConfigurationException;
|
||||
/* */ import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
/* */ import org.apache.log4j.Logger;
|
||||
/* */ import org.netbeans.lib.cvsclient.Client;
|
||||
/* */ import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
|
||||
/* */ import org.netbeans.lib.cvsclient.command.CommandAbortedException;
|
||||
|
@ -16,13 +14,13 @@ import org.apache.commons.configuration2.ex.ConfigurationException;
|
|||
/* */ import org.netbeans.lib.cvsclient.connection.AuthenticationException;
|
||||
/* */ import org.netbeans.lib.cvsclient.connection.PServerConnection;
|
||||
/* */
|
||||
@Slf4j
|
||||
/* */ public class CVSClient
|
||||
/* */ {
|
||||
/* */ private final File configfile;
|
||||
/* */ private final PServerConnection connection;
|
||||
/* */ private final CVSRoot root;
|
||||
/* */ private final GlobalOptions globalOptions;
|
||||
/* 41 */ final Logger logger = Logger.getLogger(CVSInfoImpl.class);
|
||||
/* */ public final Client client;
|
||||
/* */
|
||||
/* */ public Client getClient()
|
||||
|
@ -36,9 +34,7 @@ import org.apache.commons.configuration2.ex.ConfigurationException;
|
|||
/* 55 */ throw new ConfigurationException("Config file not found");
|
||||
/* */ }
|
||||
/* 57 */ this.configfile = config;
|
||||
Configurations configs = new Configurations();
|
||||
|
||||
/* 58 */ PropertiesConfiguration configuration = configs.properties(this.configfile);
|
||||
/* 58 */ Configuration configuration = new PropertiesConfiguration(this.configfile);
|
||||
/* */
|
||||
/* 60 */ String cvsroot = configuration.getString("CVSROOT");
|
||||
/* 61 */ String workdir = configuration.getString("WORKDIR");
|
||||
|
@ -61,7 +57,7 @@ import org.apache.commons.configuration2.ex.ConfigurationException;
|
|||
/* */ try {
|
||||
/* 79 */ this.connection.open();
|
||||
/* */ } catch (AuthenticationException ex) {
|
||||
/* 81 */ log.error(ex.getMessage());
|
||||
/* 81 */ this.logger.error(ex.getMessage());
|
||||
/* */ }
|
||||
/* */
|
||||
/* 84 */ this.client = new Client(this.connection, new StandardAdminHandler());
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
package net.brutex.xservices.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.FileVisitResult;
|
||||
|
@ -27,7 +25,9 @@ import java.nio.file.attribute.BasicFileAttributes;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import net.brutex.xservices.types.FileInfoType;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
|
@ -35,7 +35,6 @@ import java.util.List;
|
|||
*
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*/
|
||||
@Slf4j
|
||||
public class FileWalker extends SimpleFileVisitor<Path> {
|
||||
|
||||
/** The matcher. */
|
||||
|
@ -50,6 +49,9 @@ public class FileWalker extends SimpleFileVisitor<Path> {
|
|||
/** The pattern. */
|
||||
private final String pattern;
|
||||
|
||||
/** The logger. */
|
||||
final Logger logger = Logger.getLogger(FileWalker.class);
|
||||
|
||||
List<Path> list;
|
||||
|
||||
/**
|
||||
|
@ -74,11 +76,11 @@ public class FileWalker extends SimpleFileVisitor<Path> {
|
|||
*/
|
||||
void find(Path file) {
|
||||
Path name = file.getFileName();
|
||||
log.debug("Compare file '{}' against pattern '{}'.", file, pattern);
|
||||
logger.trace("Compare file " + file.toString() + " against pattern '"+pattern+"'.");
|
||||
total++;
|
||||
if (name != null && matcher.matches(name)) {
|
||||
list.add(file);
|
||||
log.debug("Added file '{}' to the result set.", file);
|
||||
logger.debug("Added file " + file.toString() + " to the result set.");
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +116,7 @@ public class FileWalker extends SimpleFileVisitor<Path> {
|
|||
@Override
|
||||
public FileVisitResult visitFileFailed(Path file,
|
||||
IOException exc) {
|
||||
log.warn("Failed to include file '{}'.", file);
|
||||
logger.warn(String.format("Failed to include file '%s'.", file.toString()));
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
|
@ -19,7 +19,6 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.PrintStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.brutex.xservices.types.ReturnCode;
|
||||
import net.brutex.xservices.types.ant.AntProperty;
|
||||
|
||||
|
@ -81,14 +80,14 @@ public class RunTask {
|
|||
*/
|
||||
public ReturnCode postTask() throws BuildException {
|
||||
int returnCode = 0;
|
||||
Map<String, Object> origMap = new HashMap<String, Object>();
|
||||
Map<String, Object> newMap = null;
|
||||
Map<String, String> origMap = new HashMap<String, String>();
|
||||
Map<String, String> newMap = null;
|
||||
origMap.putAll(antproject.getProperties());
|
||||
antproject.executeTarget(anttarget.getName());
|
||||
newMap = antproject.getProperties();
|
||||
newMap.putAll(antproject.getUserProperties());
|
||||
|
||||
for (Map.Entry<String, Object> e : origMap.entrySet()) {
|
||||
for (Map.Entry<String, String> e : origMap.entrySet()) {
|
||||
newMap.remove(e.getKey());
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright 2013 Brian Rosenberger (Brutex Network)
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
package net.brutex.xservices.util.cache;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public class CacheExecutorService
|
||||
implements ServletContextListener
|
||||
{
|
||||
static final String EXECUTOR_NAME = "CACHE_EXECUTOR";
|
||||
private ExecutorService executor;
|
||||
|
||||
public void contextInitialized(ServletContextEvent arg0)
|
||||
{
|
||||
ServletContext context = arg0.getServletContext();
|
||||
int nr_executors = 5;
|
||||
ThreadFactory daemonFactory = new DaemonThreadFactory();
|
||||
try {
|
||||
nr_executors = Integer.parseInt(context.getInitParameter("cache:thread-count"));
|
||||
} catch (NumberFormatException localNumberFormatException) {
|
||||
}
|
||||
if (nr_executors <= 1)
|
||||
this.executor = Executors.newSingleThreadExecutor(daemonFactory);
|
||||
else {
|
||||
this.executor = Executors.newFixedThreadPool(nr_executors, daemonFactory);
|
||||
}
|
||||
context.setAttribute("CACHE_EXECUTOR", this.executor);
|
||||
}
|
||||
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
ServletContext context = arg0.getServletContext();
|
||||
this.executor.shutdownNow();
|
||||
}
|
||||
}
|
|
@ -21,22 +21,22 @@ import java.util.ArrayList;
|
|||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.types.scm.ObjectFactory;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
|
||||
public class CacheServlet extends HttpServlet
|
||||
{
|
||||
List<File> configfiles = new ArrayList<File>();
|
||||
private final Logger logger = Logger.getLogger(CacheServlet.class);
|
||||
List<File> configfiles = new ArrayList();
|
||||
int cacheinterval;
|
||||
private final ObjectFactory FACTORY = new ObjectFactory();
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class CacheServlet extends HttpServlet
|
|||
if (name.startsWith("cvs-config-")) {
|
||||
String configfile = getServletContext()
|
||||
.getInitParameter(name);
|
||||
log.info("CVS configuration file: {}", configfile);
|
||||
this.logger.info("CVS configuration file: " + configfile);
|
||||
this.configfiles.add(new File(configfile));
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ public class CacheServlet extends HttpServlet
|
|||
this.cacheinterval = Integer.parseInt(getServletContext()
|
||||
.getInitParameter("cvs-cache-interval"));
|
||||
} catch (NumberFormatException e) {
|
||||
log.debug("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '{}' minutes", this.cacheinterval );
|
||||
this.logger.debug("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '" + this.cacheinterval + "' minutes");
|
||||
}
|
||||
log.info("CacheServlet set to '{}' minutes interval.", this.cacheinterval);
|
||||
this.logger.info("CacheServlet set to " + this.cacheinterval + " minutes interval.");
|
||||
}
|
||||
}
|
|
@ -23,15 +23,12 @@ import java.util.Enumeration;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.types.scm.ItemListType;
|
||||
import net.brutex.xservices.types.scm.ItemType;
|
||||
import net.brutex.xservices.types.scmfindings.FindingDetailsType;
|
||||
|
@ -40,29 +37,29 @@ import net.brutex.xservices.types.scmfindings.FindingsListType;
|
|||
import net.brutex.xservices.types.scmfindings.GroupMatchListType;
|
||||
import net.brutex.xservices.types.scmfindings.ObjectFactory;
|
||||
import net.brutex.xservices.ws.rs.CVSInfoImpl;
|
||||
|
||||
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||
import org.apache.commons.configuration2.builder.fluent.Configurations;
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
import org.apache.commons.jcs.access.exception.CacheException;
|
||||
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
import org.apache.jcs.JCS;
|
||||
import org.apache.jcs.access.exception.CacheException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
|
||||
public class FindingsCacheServlet extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 4041338473949999960L;
|
||||
private final static Logger logger = Logger
|
||||
.getLogger(FindingsCacheServlet.class);
|
||||
private final List<File> configfiles = new ArrayList<File>();
|
||||
private final ObjectFactory FACTORY = new ObjectFactory();
|
||||
private ExecutorService executor;
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
super.init();
|
||||
executor = (ExecutorService) getServletContext()
|
||||
ExecutorService executor = (ExecutorService) getServletContext()
|
||||
.getAttribute("CACHE_EXECUTOR");
|
||||
|
||||
if(! this.initConfigList()) return;
|
||||
|
@ -71,7 +68,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
int i = 1;
|
||||
for(File f: configfiles) {
|
||||
//Initialise configuration bean using default values
|
||||
FindingsConfigBean cbean = new FindingsConfigBean(i);
|
||||
FindingsConfigBean cbean = new FindingsConfigBean(i, Logger.getLogger("worker-"+i+ "." + this.getClass().getName()));
|
||||
i++;
|
||||
|
||||
|
||||
|
@ -81,38 +78,37 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
int cacheinterval = Integer.parseInt(getServletContext()
|
||||
.getInitParameter("cvs-cache-interval"));
|
||||
cbean.setCacheinterval(cacheinterval);
|
||||
log.info("FindingsCacheServlet set to "+ cacheinterval + " minutes interval.");
|
||||
logger.info("FindingsCacheServlet set to "+ cacheinterval + " minutes interval.");
|
||||
} catch (NumberFormatException e) {
|
||||
log.warn("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '"
|
||||
logger.warn("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '"
|
||||
+ cbean.getCacheinterval()+ "' minutes");
|
||||
}
|
||||
|
||||
Configurations configs = new Configurations();
|
||||
PropertiesConfiguration config = null;
|
||||
try {
|
||||
config = configs.properties(f);
|
||||
config = new PropertiesConfiguration(f);
|
||||
} catch (ConfigurationException e) {
|
||||
log.error("Could not read parameter file at '"+f.getAbsolutePath()+"'");
|
||||
logger.error("Could not read parameter file at '"+f.getAbsolutePath()+"'");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
File cvsconfig = new File(config.getString("CVSROOTCONFIGFILE"));
|
||||
cbean.setCvsconfig(cvsconfig);
|
||||
FindingsCacheServlet.log.debug("Fetching list of files using '"
|
||||
FindingsCacheServlet.logger.debug("Fetching list of files using '"
|
||||
+ cvsconfig.getAbsolutePath() + "' config file");
|
||||
|
||||
|
||||
List<Object> filepatterns = config.getList("FILESEARCH");
|
||||
cbean.setFilepatterns(filepatterns);
|
||||
FindingsCacheServlet.log.debug("Checking '"
|
||||
FindingsCacheServlet.logger.debug("Checking '"
|
||||
+ filepatterns.size()
|
||||
+ "' patterns for file name and path matching.");
|
||||
|
||||
|
||||
List<Object> contentpatterns = config.getList("CONTENTSEARCH");
|
||||
cbean.setContentpatterns(contentpatterns);
|
||||
FindingsCacheServlet.log.debug("Checking '"
|
||||
FindingsCacheServlet.logger.debug("Checking '"
|
||||
+ contentpatterns.size()
|
||||
+ "' patterns for content matching");
|
||||
|
||||
|
@ -120,9 +116,8 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
|
||||
|
||||
executor.submit(new ThisRunnable(cbean));
|
||||
|
||||
}
|
||||
log.info("FindingsCacheServlet has been initialized.");
|
||||
logger.info("FindingsCacheServlet has been initialized.");
|
||||
|
||||
}
|
||||
|
||||
|
@ -133,14 +128,14 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
String filename = getServletContext().getInitParameter(
|
||||
"cvs-findings-configuration");
|
||||
if (filename == null) {
|
||||
log.warn("'cvs-findings-configuration' init parameter is not specified.");
|
||||
logger.warn("'cvs-findings-configuration' init parameter is not specified.");
|
||||
return false;
|
||||
}
|
||||
final File findingsconfig = new File(filename);
|
||||
log.info("CVS findings configuration file found at '"
|
||||
logger.info("CVS findings configuration file found at '"
|
||||
+ findingsconfig.getAbsolutePath() + "'");
|
||||
if ((!findingsconfig.canRead()) || (findingsconfig.isDirectory())) {
|
||||
log.info("CVS findings configuration file '"
|
||||
logger.info("CVS findings configuration file '"
|
||||
+ findingsconfig.getAbsolutePath() + "' does not exist.");
|
||||
return false;
|
||||
}
|
||||
|
@ -158,7 +153,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
String name = (String) attributes.nextElement();
|
||||
if (name.startsWith("cvs-config-")) {
|
||||
String configfile = getServletContext().getInitParameter(name);
|
||||
log.info("Adding CVS configuration file: " + configfile);
|
||||
logger.info("Adding CVS configuration file: " + configfile);
|
||||
this.configfiles.add(new File(configfile));
|
||||
}
|
||||
}
|
||||
|
@ -168,12 +163,12 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
List<File> removelist = new ArrayList<File>();
|
||||
for (File f : configfiles) {
|
||||
if (!f.exists()) {
|
||||
log.warn("CVS configuration file '"
|
||||
logger.warn("CVS configuration file '"
|
||||
+ f.getAbsolutePath()
|
||||
+ "' is specified, but does not exist. Removing from list.");
|
||||
removelist.add(f);
|
||||
} else if (!f.canRead()) {
|
||||
log.warn("CVS configuration file '"
|
||||
logger.warn("CVS configuration file '"
|
||||
+ f.getAbsolutePath()
|
||||
+ "' does exist, but is not readable. Removing from list.");
|
||||
removelist.add(f);
|
||||
|
@ -203,7 +198,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
ObjectFactory FACTORY = new ObjectFactory();
|
||||
FindingsListType findingsList = FACTORY.createFindingsListType();
|
||||
|
||||
FindingsCacheServlet.log.info("Processing '"
|
||||
FindingsCacheServlet.logger.info("Processing '"
|
||||
+ fileslist.getItems().size() + "' files and directories.");
|
||||
|
||||
while (!this.isInterrupted) {
|
||||
|
@ -216,7 +211,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
Object o = iterF.next();
|
||||
if (this.isInterrupted)
|
||||
break;
|
||||
FindingsCacheServlet.log.debug("Scanning filename '"
|
||||
FindingsCacheServlet.logger.debug("Scanning filename '"
|
||||
+ i.getFullname() + "' for pattern '"
|
||||
+ (String) o + "'");
|
||||
p = Pattern.compile((String) o);
|
||||
|
@ -231,17 +226,17 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
finding.setData(it.getData());
|
||||
finding = copyDetails(finding, i);
|
||||
findingsList.getFindings().add(finding);
|
||||
FindingsCacheServlet.log
|
||||
FindingsCacheServlet.logger
|
||||
.debug("Match found for '"
|
||||
+ i.getFullname() + "'");
|
||||
break;
|
||||
}
|
||||
FindingsCacheServlet.log
|
||||
FindingsCacheServlet.logger
|
||||
.debug("No match found for '" + i.getFullname()
|
||||
+ "'");
|
||||
}
|
||||
}
|
||||
FindingsCacheServlet.log
|
||||
FindingsCacheServlet.logger
|
||||
.debug("Processing file content for '"
|
||||
+ findingsList.getFindings().size()
|
||||
+ "' entries in the list.");
|
||||
|
@ -257,7 +252,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
Object o = iter.next();
|
||||
if (this.isInterrupted)
|
||||
break;
|
||||
FindingsCacheServlet.log
|
||||
FindingsCacheServlet.logger
|
||||
.debug("Scanning file content for file '"
|
||||
+ t.getFullname() + "' for pattern '"
|
||||
+ (String) o + "'");
|
||||
|
@ -293,7 +288,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
fd.getMatchLists().add(gmg);
|
||||
}
|
||||
t.getFindingLists().add(fd);
|
||||
FindingsCacheServlet.log
|
||||
FindingsCacheServlet.logger
|
||||
.debug("Found matching content at index '" + s
|
||||
+ "' in file '" + t.getFullname()
|
||||
+ "' with pattern '" + p1.toString()
|
||||
|
@ -302,7 +297,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
|
||||
if (!isFound) {
|
||||
findingsList.getFindings().remove(t);
|
||||
FindingsCacheServlet.log
|
||||
FindingsCacheServlet.logger
|
||||
.debug("Found matching filename for '"
|
||||
+ t.getFullname()
|
||||
+ "' but content didn't match. Removing.");
|
||||
|
@ -311,24 +306,24 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
try {
|
||||
instance.getCacheInstance().put(
|
||||
"FINDINGS-" + t.getROOT(), findingsList);
|
||||
FindingsCacheServlet.log
|
||||
FindingsCacheServlet.logger
|
||||
.info("FINDINGS for CVSROOT '" + t.getROOT()
|
||||
+ "' have been updated in cache.");
|
||||
} catch (CacheException e) {
|
||||
FindingsCacheServlet.log.error(e.getMessage(), e);
|
||||
FindingsCacheServlet.logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
int cacheinterval = configuration.getCacheinterval();
|
||||
FindingsCacheServlet.log.debug("Now sleeping for '"
|
||||
FindingsCacheServlet.logger.debug("Now sleeping for '"
|
||||
+ cacheinterval + "' minutes");
|
||||
Thread.currentThread();
|
||||
Thread.sleep(cacheinterval * 60000);
|
||||
FindingsCacheServlet.log.debug("Waking up after '"
|
||||
FindingsCacheServlet.logger.debug("Waking up after '"
|
||||
+ cacheinterval + "' minutes of sleep");
|
||||
} catch (InterruptedException e) {
|
||||
this.isInterrupted = true;
|
||||
FindingsCacheServlet.log
|
||||
FindingsCacheServlet.logger
|
||||
.warn("FindingsCacheServlet cache was interrupted. Shutting down.");
|
||||
}
|
||||
}
|
||||
|
@ -348,24 +343,4 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.GenericServlet#destroy()
|
||||
*/
|
||||
@Override
|
||||
public void destroy() {
|
||||
// TODO Auto-generated method stub
|
||||
executor.shutdown();
|
||||
try {
|
||||
executor.awaitTermination(3, TimeUnit.SECONDS);
|
||||
log.info("Cache Worker Threads have shut down.");
|
||||
} catch (InterruptedException e) {
|
||||
log.error("Cache Worker Threads did not terminate within timeout.", e);
|
||||
}
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
}
|
|
@ -16,21 +16,19 @@
|
|||
|
||||
package net.brutex.xservices.util.cache;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class FindingsConfigBean {
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
private final int instanceid;
|
||||
|
||||
|
@ -39,10 +37,10 @@ public class FindingsConfigBean {
|
|||
private List<Object> filepatterns;
|
||||
private List<Object> contentpatterns;
|
||||
|
||||
public FindingsConfigBean(int instanceid) {
|
||||
public FindingsConfigBean(int instanceid, Logger logger) {
|
||||
this.instanceid = instanceid;
|
||||
|
||||
log.debug("Initialise FindingsConfigBean instance '" + instanceid + "'");
|
||||
this.logger = logger;
|
||||
logger.debug("Initialise FindingsConfigBean instance '"+instanceid+"'");
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,8 +52,7 @@ public class FindingsConfigBean {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param cacheinterval
|
||||
* the cache interval to set
|
||||
* @param cacheinterval the cache interval to set
|
||||
*/
|
||||
public void setCacheinterval(int cacheinterval) {
|
||||
this.cacheinterval = cacheinterval;
|
||||
|
@ -69,8 +66,7 @@ public class FindingsConfigBean {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param cvsconfig
|
||||
* the cvsconfig to set
|
||||
* @param cvsconfig the cvsconfig to set
|
||||
*/
|
||||
public void setCvsconfig(File cvsconfig) {
|
||||
this.cvsconfig = cvsconfig;
|
||||
|
@ -84,8 +80,7 @@ public class FindingsConfigBean {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param filepatterns
|
||||
* the filepatterns to set
|
||||
* @param filepatterns the filepatterns to set
|
||||
*/
|
||||
public void setFilepatterns(List<Object> filepatterns) {
|
||||
this.filepatterns = filepatterns;
|
||||
|
@ -99,8 +94,7 @@ public class FindingsConfigBean {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param contentpatterns
|
||||
* the contentpatterns to set
|
||||
* @param contentpatterns the contentpatterns to set
|
||||
*/
|
||||
public void setContentpatterns(List<Object> contentpatterns) {
|
||||
this.contentpatterns = contentpatterns;
|
|
@ -18,23 +18,16 @@ package net.brutex.xservices.ws;
|
|||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebService;
|
||||
import javax.jws.soap.SOAPBinding;
|
||||
|
||||
import net.brutex.xservices.types.HostConnection;
|
||||
import net.brutex.xservices.types.HostinfoType;
|
||||
import net.brutex.xservices.types.MailMimeType;
|
||||
import net.brutex.xservices.types.ReturnCode;
|
||||
import net.brutex.xservices.types.RuntimeInfoType;
|
||||
import net.brutex.xservices.types.alfevent.ALFEventResponseType;
|
||||
import net.brutex.xservices.types.alfevent.ALFEventType;
|
||||
import net.brutex.xservices.types.ant.FileSetResource;
|
||||
|
||||
import org.apache.cxf.aegis.type.java5.XmlElement;
|
||||
import org.apache.cxf.aegis.type.java5.XmlReturnType;
|
||||
import org.apache.cxf.annotations.WSDLDocumentation;
|
||||
import org.h2.jdbcx.JdbcConnectionPool;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Bundles various methods
|
||||
|
@ -43,7 +36,6 @@ import java.math.BigInteger;
|
|||
* @since 0.4.0
|
||||
*/
|
||||
@WebService(targetNamespace = net.brutex.xservices.util.BrutexNamespaces.WS_XSERVICES)
|
||||
//@SOAPBinding(style = SOAPBinding.Style.RPC)
|
||||
@WSDLDocumentation("Various service operations.")
|
||||
public interface MiscService {
|
||||
|
||||
|
@ -68,20 +60,4 @@ public interface MiscService {
|
|||
@WebMethod(operationName="getMemory")
|
||||
@WSDLDocumentation("Get memory and processor information")
|
||||
public abstract RuntimeInfoType getMemory();
|
||||
|
||||
@WebMethod(operationName="lock")
|
||||
@WSDLDocumentation("Get a lock.")
|
||||
public abstract BigInteger lock(@WebParam(name="id") @XmlElement(nillable = false) String id,
|
||||
@WebParam(name="objectId") @XmlElement(nillable = false) String objectId,
|
||||
@WebParam(name="validity") BigInteger validity) throws XServicesFault;
|
||||
|
||||
@WebMethod(operationName="unlock")
|
||||
@WSDLDocumentation("Remove a lock.")
|
||||
public abstract Boolean unlock( @WebParam(name="id") @XmlElement(nillable = false) String id,
|
||||
@WebParam(name="objectId") @XmlElement(nillable = false) String objectId)
|
||||
throws XServicesFault;
|
||||
|
||||
@WebMethod(operationName="", action = "EventNotice")
|
||||
@SOAPBinding(use = SOAPBinding.Use.LITERAL, style = SOAPBinding.Style.DOCUMENT, parameterStyle = SOAPBinding.ParameterStyle.BARE)
|
||||
public abstract ALFEventResponseType mergeALFEvent(@WebParam(name="ALFEventNoticeDoc", targetNamespace = "http://www.eclipse.org/alf/schema/EventBase/1") ALFEventType event) throws XServicesFault;
|
||||
}
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package net.brutex.xservices.ws;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebService;
|
||||
|
@ -79,13 +81,4 @@ public abstract interface StringService
|
|||
@WebParam(name="string") @XmlElement(required=true) String paramString)
|
||||
throws XServicesFault;
|
||||
|
||||
@WebMethod(operationName="handleStringLists")
|
||||
@WSDLDocumentation("Tokenizes all strings and then adds/removes tokens to/ from basestring")
|
||||
public abstract String handleStringLists(
|
||||
@WebParam(name="basestring") @XmlElement(required=true) String paramBaseString,
|
||||
@WebParam(name="addstring") @XmlElement(required=true) String paramAddString,
|
||||
@WebParam(name="removestring") @XmlElement(required=true) String paramRemoveString,
|
||||
@WebParam(name="delimiter") @XmlElement(required=true) String delimiter)
|
||||
throws XServicesFault;
|
||||
|
||||
}
|
|
@ -26,7 +26,15 @@ import java.util.UUID;
|
|||
|
||||
import javax.jws.WebService;
|
||||
|
||||
import org.quartz.*;
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.SimpleTrigger;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
import org.quartz.impl.matchers.GroupMatcher;
|
||||
|
||||
|
@ -140,5 +148,4 @@ public class JobServiceImpl implements JobService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -78,7 +78,7 @@ public class MailServiceImpl implements MailService {
|
|||
mail.setBccList(bcclist);
|
||||
mail.setSubject(subject);
|
||||
mail.setMessage(message);
|
||||
//mail.setMessageMimeType(messagemimetype);
|
||||
mail.setMessageMimeType(messagemimetype);
|
||||
if (attachments != null) {
|
||||
mail.addFileset(attachments.getAntResource(mail.getProject()));
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* Copyright 2013 Brian Rosenberger (Brutex Network)
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
package net.brutex.xservices.ws.impl;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import net.brutex.xservices.types.HostConnection;
|
||||
import net.brutex.xservices.types.HostinfoType;
|
||||
import net.brutex.xservices.types.MailMimeType;
|
||||
import net.brutex.xservices.types.ReturnCode;
|
||||
import net.brutex.xservices.types.RuntimeInfoType;
|
||||
import net.brutex.xservices.types.ant.FileSetResource;
|
||||
import net.brutex.xservices.util.BrutexNamespaces;
|
||||
import net.brutex.xservices.util.RunTask;
|
||||
import net.brutex.xservices.ws.MiscService;
|
||||
|
||||
import org.apache.cxf.annotations.WSDLDocumentation;
|
||||
import org.apache.cxf.annotations.WSDLDocumentationCollection;
|
||||
import org.apache.tools.ant.taskdefs.HostInfo;
|
||||
import org.apache.tools.ant.taskdefs.Sleep;
|
||||
import org.apache.tools.ant.taskdefs.email.EmailTask;
|
||||
|
||||
/**
|
||||
* Implements the web service
|
||||
*
|
||||
* @author Brian Rosenberger, bru@brutex.de
|
||||
*/
|
||||
@WebService(targetNamespace="http://ws.xservices.brutex.net", endpointInterface="net.brutex.xservices.ws.MiscService", serviceName="MiscService")
|
||||
public class MiscServiceImpl
|
||||
implements MiscService
|
||||
{
|
||||
public HostinfoType getHostinfo(String hostname)
|
||||
{
|
||||
HostInfo info = new HostInfo();
|
||||
info.setTaskName("HostInfo");
|
||||
RunTask runner = new RunTask(info);
|
||||
info.setHost(hostname);
|
||||
|
||||
ReturnCode ret = runner.postTask();
|
||||
HostinfoType infotype = new HostinfoType(
|
||||
ret.getProperty("NAME"),
|
||||
ret.getProperty("DOMAIN"),
|
||||
ret.getProperty("ADDR4"),
|
||||
ret.getProperty("ADDR6"));
|
||||
return infotype;
|
||||
}
|
||||
|
||||
public ReturnCode getInfo() {
|
||||
ReturnCode r = new ReturnCode();
|
||||
r.returnCode = 0;
|
||||
|
||||
Properties props = System.getProperties();
|
||||
|
||||
Enumeration e = props.propertyNames();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
String propName = (String)e.nextElement();
|
||||
|
||||
String propValue = (String)props.get(propName);
|
||||
r.stdOut = (r.stdOut + propName + ": " + propValue + "\n");
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public ReturnCode sendMailSimple(HostConnection mailhost, String from, String tolist, String subject, String message)
|
||||
{
|
||||
return sendMail(from, from, tolist, "", "", subject, message,
|
||||
"text/plain", null, mailhost.hostname, mailhost.port,
|
||||
mailhost.user, mailhost.password, "utf-8", false, false);
|
||||
}
|
||||
|
||||
public ReturnCode sendMailSimpleWithAttachment(HostConnection mailhost, String from, String tolist, String subject, String message, FileSetResource res)
|
||||
{
|
||||
return sendMail(from, from, tolist, "", "", subject, message,
|
||||
"text/plain", res, mailhost.hostname, mailhost.port,
|
||||
mailhost.user, mailhost.password, "utf-8", false, false);
|
||||
}
|
||||
|
||||
public ReturnCode sendMail(HostConnection mailhost, String from, String tolist, String cclist, String bcclist, String subject, MailMimeType mimetype, String charset, String message, FileSetResource res, boolean ssl, boolean tls)
|
||||
{
|
||||
return sendMail(from, from, tolist, cclist, bcclist, subject, message,
|
||||
mimetype.value(), res, mailhost.hostname, mailhost.port,
|
||||
mailhost.user, mailhost.password, charset, tls, ssl);
|
||||
}
|
||||
|
||||
public ReturnCode sleep(int minutes, int seconds) {
|
||||
return sleep(0, minutes, seconds, 0);
|
||||
}
|
||||
|
||||
public String generateUUID() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
private ReturnCode sendMail(String from, String replyto, String tolist, String cclist, String bcclist, String subject, String message, String messagemimetype, FileSetResource attachments, String mailhost, int mailport, String user, String password, String charset, boolean tls, boolean ssl)
|
||||
{
|
||||
EmailTask mail = new EmailTask();
|
||||
mail.setTaskName("Mail");
|
||||
RunTask runner = new RunTask(mail);
|
||||
mail.setFrom(from);
|
||||
mail.setReplyTo(replyto);
|
||||
mail.setToList(tolist);
|
||||
mail.setCcList(cclist);
|
||||
mail.setBccList(bcclist);
|
||||
mail.setSubject(subject);
|
||||
mail.setMessage(message);
|
||||
mail.setMessageMimeType(messagemimetype);
|
||||
if (attachments != null) {
|
||||
mail.addFileset(attachments.getAntResource(mail.getProject()));
|
||||
}
|
||||
mail.setMailhost(mailhost);
|
||||
mail.setMailport(mailport);
|
||||
mail.setUser(user);
|
||||
mail.setPassword(password);
|
||||
mail.setCharset(charset);
|
||||
mail.setSSL(ssl);
|
||||
mail.setEnableStartTLS(tls);
|
||||
return runner.postTask();
|
||||
}
|
||||
|
||||
private ReturnCode sleep(int hours, int minutes, int seconds, int milliseconds)
|
||||
{
|
||||
Sleep sleep = new Sleep();
|
||||
sleep.setTaskName("Sleep");
|
||||
RunTask runner = new RunTask(sleep);
|
||||
sleep.setHours(hours);
|
||||
sleep.setMinutes(minutes);
|
||||
sleep.setSeconds(seconds);
|
||||
sleep.setMilliseconds(milliseconds);
|
||||
return runner.postTask();
|
||||
}
|
||||
|
||||
public RuntimeInfoType getMemory() {
|
||||
return new RuntimeInfoType();
|
||||
}
|
||||
}
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package net.brutex.xservices.ws.impl;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -107,30 +106,6 @@ public class StringServiceImpl
|
|||
return value;
|
||||
}
|
||||
|
||||
public String handleStringLists(String basestring, String addstring, String removestring, String delimiter) throws XServicesFault {
|
||||
StringTokenizer base = new StringTokenizer(basestring, delimiter);
|
||||
StringTokenizer add = new StringTokenizer(addstring, delimiter);
|
||||
StringTokenizer remove = new StringTokenizer(removestring, delimiter);
|
||||
HashSet<String> hset = new HashSet<String>();
|
||||
String result = new String();
|
||||
|
||||
while(base.hasMoreTokens()) {
|
||||
hset.add(base.nextToken().toString() );
|
||||
}
|
||||
while(add.hasMoreTokens()) {
|
||||
hset.add(add.nextToken().toString() );
|
||||
}
|
||||
while(remove.hasMoreTokens()) {
|
||||
hset.remove(remove.nextToken().toString() );
|
||||
}
|
||||
Iterator<String> hsetit = hset.iterator();
|
||||
while(hsetit.hasNext()) {
|
||||
result = result.concat(hsetit.next().toString() + delimiter);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private int getFlags(String flags) {
|
||||
int allflags = 0;
|
||||
if (flags.contains("i")) {
|
|
@ -26,13 +26,17 @@ import java.nio.charset.Charset;
|
|||
import java.nio.charset.IllegalCharsetNameException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.ws.rs.NotAuthorizedException;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.security.DirectoryPermission;
|
||||
import net.brutex.xservices.types.AttributeType;
|
||||
import net.brutex.xservices.types.NamespaceListType;
|
||||
import net.brutex.xservices.types.NamespaceType;
|
||||
|
@ -54,8 +58,9 @@ import org.apache.axiom.om.OMProcessingInstruction;
|
|||
import org.apache.axiom.om.OMText;
|
||||
import org.apache.axiom.om.OMXMLBuilderFactory;
|
||||
import org.apache.axiom.om.xpath.AXIOMXPath;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.UnauthorizedException;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jaxen.JaxenException;
|
||||
import org.jaxen.SimpleNamespaceContext;
|
||||
|
@ -64,20 +69,20 @@ import org.jaxen.SimpleNamespaceContext;
|
|||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@WebService(targetNamespace = "http://ws.xservices.brutex.net", endpointInterface = "net.brutex.xservices.ws.XmlService", serviceName = "XmlService")
|
||||
public class XmlServiceImpl implements XmlService {
|
||||
final Logger logger = Logger.getLogger(XmlServiceImpl.class);
|
||||
|
||||
|
||||
public String insertNodesFromFile(FileResource res, NamespaceListType nsList, String xpath, String xmlFragment)
|
||||
throws XServicesFault {
|
||||
public String insertNodesFromFile(FileResource res, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault {
|
||||
try {
|
||||
AXIOMXPath axp = new AXIOMXPath(xpath);
|
||||
InputStream is = res.getAntResource(null).getInputStream();
|
||||
OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument();
|
||||
OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is)
|
||||
.getDocument();
|
||||
OMDocument fragdoc = null;
|
||||
if ((xmlFragment != null) && (new String(xmlFragment).length() > 0)) {
|
||||
fragdoc = OMXMLBuilderFactory.createOMBuilder(new StringReader("<XS>" + xmlFragment + "</XS>"))
|
||||
fragdoc = OMXMLBuilderFactory.createOMBuilder(
|
||||
new StringReader("<XS>" + xmlFragment + "</XS>"))
|
||||
.getDocument();
|
||||
} else {
|
||||
throw new XServicesFault("No xmldata to insert.");
|
||||
|
@ -95,7 +100,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
XMLStreamWriter writer = xof.createXMLStreamWriter(sw);
|
||||
document.serialize(writer);
|
||||
|
||||
log.debug(sw.getBuffer().toString());
|
||||
this.logger.trace(sw.getBuffer().toString());
|
||||
return sw.getBuffer().toString();
|
||||
} catch (JaxenException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -109,15 +114,15 @@ public class XmlServiceImpl implements XmlService {
|
|||
}
|
||||
}
|
||||
|
||||
public String replaceNodesFromFile(FileResource res, NamespaceListType nsList, String xpath, String xmlFragment)
|
||||
throws XServicesFault {
|
||||
public String replaceNodesFromFile(FileResource res, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault {
|
||||
try {
|
||||
AXIOMXPath axp = new AXIOMXPath(xpath);
|
||||
InputStream is = res.getAntResource(null).getInputStream();
|
||||
OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument();
|
||||
OMDocument fragdoc = null;
|
||||
if ((xmlFragment != null) && (new String(xmlFragment).length() > 0)) {
|
||||
fragdoc = OMXMLBuilderFactory.createOMBuilder(new StringReader("<XS>" + xmlFragment + "</XS>"))
|
||||
fragdoc = OMXMLBuilderFactory.createOMBuilder(
|
||||
new StringReader("<XS>" + xmlFragment + "</XS>"))
|
||||
.getDocument();
|
||||
} else {
|
||||
throw new XServicesFault("No xmldata to insert.");
|
||||
|
@ -135,7 +140,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
XMLStreamWriter writer = xof.createXMLStreamWriter(sw);
|
||||
document.serialize(writer);
|
||||
|
||||
log.debug(sw.getBuffer().toString());
|
||||
this.logger.trace(sw.getBuffer().toString());
|
||||
return sw.getBuffer().toString();
|
||||
} catch (JaxenException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -149,16 +154,17 @@ public class XmlServiceImpl implements XmlService {
|
|||
}
|
||||
}
|
||||
|
||||
public String replaceNodes(String source, String encoding, NamespaceListType nsList, String xpath,
|
||||
String xmlFragment) throws XServicesFault {
|
||||
public String replaceNodes(String source, String encoding, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault {
|
||||
encoding = validateEncoding(encoding);
|
||||
try {
|
||||
AXIOMXPath axp = new AXIOMXPath(xpath);
|
||||
InputStream is = new ByteArrayInputStream(source.getBytes(encoding));
|
||||
OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument();
|
||||
OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is)
|
||||
.getDocument();
|
||||
OMDocument fragdoc = null;
|
||||
if ((xmlFragment != null) && (new String(xmlFragment).length() > 0)) {
|
||||
fragdoc = OMXMLBuilderFactory.createOMBuilder(new StringReader("<XS>" + xmlFragment + "</XS>"))
|
||||
fragdoc = OMXMLBuilderFactory.createOMBuilder(
|
||||
new StringReader("<XS>" + xmlFragment + "</XS>"))
|
||||
.getDocument();
|
||||
} else {
|
||||
throw new XServicesFault("No xmldata to insert.");
|
||||
|
@ -176,7 +182,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
XMLStreamWriter writer = xof.createXMLStreamWriter(sw);
|
||||
document.serialize(writer);
|
||||
|
||||
log.debug(sw.getBuffer().toString());
|
||||
this.logger.trace(sw.getBuffer().toString());
|
||||
return sw.getBuffer().toString();
|
||||
} catch (JaxenException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -190,16 +196,17 @@ public class XmlServiceImpl implements XmlService {
|
|||
}
|
||||
|
||||
@RequiresPermissions("insertNodes")
|
||||
public String insertNodes(String source, String encoding, NamespaceListType nsList, String xpath,
|
||||
String xmlFragment) throws XServicesFault {
|
||||
public String insertNodes(String source, String encoding, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault {
|
||||
encoding = validateEncoding(encoding);
|
||||
try {
|
||||
AXIOMXPath axp = new AXIOMXPath(xpath);
|
||||
InputStream is = new ByteArrayInputStream(source.getBytes(encoding));
|
||||
OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument();
|
||||
OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is)
|
||||
.getDocument();
|
||||
OMDocument fragdoc = null;
|
||||
if ((xmlFragment != null) && (new String(xmlFragment).length() > 0)) {
|
||||
fragdoc = OMXMLBuilderFactory.createOMBuilder(new StringReader("<XS>" + xmlFragment + "</XS>"))
|
||||
fragdoc = OMXMLBuilderFactory.createOMBuilder(
|
||||
new StringReader("<XS>" + xmlFragment + "</XS>"))
|
||||
.getDocument();
|
||||
} else {
|
||||
throw new XServicesFault("No xmldata to insert.");
|
||||
|
@ -217,7 +224,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
XMLStreamWriter writer = xof.createXMLStreamWriter(sw);
|
||||
document.serialize(writer);
|
||||
|
||||
log.debug(sw.getBuffer().toString());
|
||||
this.logger.trace(sw.getBuffer().toString());
|
||||
return sw.getBuffer().toString();
|
||||
} catch (JaxenException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -231,21 +238,19 @@ public class XmlServiceImpl implements XmlService {
|
|||
}
|
||||
|
||||
public String wrapInCDATA(String data) throws XServicesFault {
|
||||
String result = "";
|
||||
String result ="";
|
||||
String[] tokens = data.split("\\]\\]>", -1);
|
||||
|
||||
for (int i = 0; i < tokens.length; i++) {
|
||||
for(int i=0; i<tokens.length; i++) {
|
||||
result += tokens[i];
|
||||
if (i + 1 < tokens.length)
|
||||
result += "]]]]><![CDATA[>";
|
||||
if (i+1 < tokens.length ) result += "]]]]><![CDATA[>";
|
||||
}
|
||||
|
||||
result = "<![CDATA[" + result + "]]>";
|
||||
return result;
|
||||
}
|
||||
|
||||
public StringSplitType selectXPath(String source, String encoding, NamespaceListType nsList, String xpath)
|
||||
throws XServicesFault {
|
||||
public StringSplitType selectXPath(String source, String encoding, NamespaceListType nsList, String xpath) throws XServicesFault {
|
||||
encoding = validateEncoding(encoding);
|
||||
try {
|
||||
StringSplitType rarray = new StringSplitType();
|
||||
|
@ -258,36 +263,37 @@ public class XmlServiceImpl implements XmlService {
|
|||
|
||||
axp.setNamespaceContext(context);
|
||||
List results = axp.selectNodes(sourcedoc);
|
||||
for (Object o : results) {
|
||||
for(Object o : results) {
|
||||
String text = null;
|
||||
|
||||
if (o instanceof OMNode) {
|
||||
switch (((OMNode) o).getType()) {
|
||||
if(o instanceof OMNode) {
|
||||
switch (((OMNode)o).getType()) {
|
||||
case OMNode.TEXT_NODE:
|
||||
text = ((OMText) o).getText();
|
||||
text = ((OMText)o).getText();
|
||||
break;
|
||||
case OMNode.COMMENT_NODE:
|
||||
text = ((OMComment) o).getValue();
|
||||
text = ((OMComment)o).getValue();
|
||||
break;
|
||||
case OMNode.PI_NODE:
|
||||
text = ((OMProcessingInstruction) o).getValue();
|
||||
text = ((OMProcessingInstruction)o).getValue();
|
||||
break;
|
||||
default:
|
||||
StringWriter sw = new StringWriter();
|
||||
XMLOutputFactory xof = XMLOutputFactory.newInstance();
|
||||
XMLStreamWriter writer = xof.createXMLStreamWriter(sw);
|
||||
((OMNode) o).serialize(writer);
|
||||
((OMNode)o).serialize(writer);
|
||||
writer.flush();
|
||||
text = sw.toString();
|
||||
}
|
||||
} else if (o instanceof OMAttribute) {
|
||||
text = ((OMAttribute) o).getAttributeValue();
|
||||
} else if(o instanceof OMAttribute) {
|
||||
text = ((OMAttribute)o).getAttributeValue();
|
||||
} else {
|
||||
text = String.valueOf(o);
|
||||
}
|
||||
rarray.addStringMatch(text);
|
||||
}
|
||||
|
||||
|
||||
return rarray;
|
||||
} catch (JaxenException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -300,8 +306,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
}
|
||||
}
|
||||
|
||||
public String setAttribute(String source, String encoding, NamespaceListType nsList, String xpath,
|
||||
AttributeType attr) throws XServicesFault {
|
||||
public String setAttribute(String source, String encoding, NamespaceListType nsList, String xpath, AttributeType attr) throws XServicesFault {
|
||||
encoding = validateEncoding(encoding);
|
||||
try {
|
||||
StringSplitType rarray = new StringSplitType();
|
||||
|
@ -315,15 +320,15 @@ public class XmlServiceImpl implements XmlService {
|
|||
|
||||
axp.setNamespaceContext(context);
|
||||
List results = axp.selectNodes(sourcedoc);
|
||||
for (Object o : results) {
|
||||
for(Object o : results) {
|
||||
String text = null;
|
||||
|
||||
if (o instanceof OMNode) {
|
||||
switch (((OMNode) o).getType()) {
|
||||
if(o instanceof OMNode) {
|
||||
switch (((OMNode)o).getType()) {
|
||||
case OMNode.ELEMENT_NODE:
|
||||
OMElement node = ((OMElement) o);
|
||||
if (attr.value == null) {
|
||||
node.removeAttribute(node.getAttribute(new QName(attr.name)));
|
||||
OMElement node = ((OMElement)o);
|
||||
if(attr.value == null) {
|
||||
node.removeAttribute( node.getAttribute(new QName(attr.name)));
|
||||
} else {
|
||||
node.addAttribute(attr.name, attr.value, node.getNamespace());
|
||||
}
|
||||
|
@ -353,18 +358,20 @@ public class XmlServiceImpl implements XmlService {
|
|||
}
|
||||
}
|
||||
|
||||
private OMDocument insertNodes(OMDocument xmldocument, AXIOMXPath axp, OMDocument xmlfragment)
|
||||
throws XServicesFault {
|
||||
private OMDocument insertNodes(OMDocument xmldocument, AXIOMXPath axp,OMDocument xmlfragment) throws XServicesFault {
|
||||
List<?> olist = null;
|
||||
try {
|
||||
olist = axp.selectNodes(xmldocument.getOMDocumentElement());
|
||||
log.debug("XPath '" + axp.toString() + "' has " + olist.size() + " matches.");
|
||||
log.debug("XPath root expression is: '" + axp.debug() + "'.");
|
||||
this.logger.debug("XPath '" + axp.toString() + "' has "
|
||||
+ olist.size() + " matches.");
|
||||
this.logger.trace("XPath root expression is: '" + axp.debug()
|
||||
+ "'.");
|
||||
} catch (JaxenException e) {
|
||||
throw new XServicesFault(e.getMessage(), e);
|
||||
}
|
||||
if (olist.size() == 0)
|
||||
throw new XServicesFault(Messages.getString("XmlService.no_match", new Object[] { axp.toString() }));
|
||||
throw new XServicesFault(Messages.getString("XmlService.no_match",
|
||||
new Object[] { axp.toString() }));
|
||||
|
||||
// Prepare children to insert
|
||||
xmlfragment.build();
|
||||
|
@ -372,7 +379,8 @@ public class XmlServiceImpl implements XmlService {
|
|||
// Determine what has been matched
|
||||
OMContainer match = null;
|
||||
for (Object o : olist) {
|
||||
Iterator<?> children = xmlfragment.getOMDocumentElement().getChildren();
|
||||
Iterator<?> children = xmlfragment.getOMDocumentElement()
|
||||
.getChildren();
|
||||
if ((o instanceof OMNode)) {
|
||||
OMNode node = (OMNode) o;
|
||||
switch (node.getType()) {
|
||||
|
@ -381,25 +389,29 @@ public class XmlServiceImpl implements XmlService {
|
|||
match = (OMElement) o;
|
||||
if ((o instanceof OMDocument))
|
||||
match = ((OMDocument) o).getOMDocumentElement();
|
||||
log.debug(Messages.getString("XmlService.8"));
|
||||
this.logger.debug(Messages.getString("XmlService.8"));
|
||||
break;
|
||||
case OMNode.TEXT_NODE:
|
||||
match = ((OMText) o).getParent();
|
||||
log.debug(Messages.getString("XmlService.9"));
|
||||
this.logger.debug(Messages.getString("XmlService.9"));
|
||||
break;
|
||||
case OMNode.COMMENT_NODE:
|
||||
// match = node.getParent();
|
||||
match = (OMContainer) node;
|
||||
log.debug(Messages.getString("XmlService.10"));
|
||||
this.logger.debug(Messages.getString("XmlService.10"));
|
||||
break;
|
||||
default:
|
||||
log.error("XPath matched " + o.getClass().getCanonicalName() + " Node Type:" + node.getType());
|
||||
log.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(Messages.getString("XmlService.12"));
|
||||
this.logger.error("XPath matched "
|
||||
+ o.getClass().getCanonicalName() + " Node Type:"
|
||||
+ node.getType());
|
||||
this.logger.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(
|
||||
Messages.getString("XmlService.12"));
|
||||
}
|
||||
} else {
|
||||
log.error("XPath matched " + o.getClass().getCanonicalName());
|
||||
log.error(Messages.getString("XmlService.11"));
|
||||
this.logger.error("XPath matched "
|
||||
+ o.getClass().getCanonicalName());
|
||||
this.logger.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(Messages.getString("XmlService.12"));
|
||||
}
|
||||
|
||||
|
@ -413,19 +425,22 @@ public class XmlServiceImpl implements XmlService {
|
|||
return xmldocument;
|
||||
}
|
||||
|
||||
private OMDocument replaceNodes(OMDocument xmldocument, AXIOMXPath axp, OMDocument xmlfragment)
|
||||
throws XServicesFault {
|
||||
|
||||
private OMDocument replaceNodes(OMDocument xmldocument, AXIOMXPath axp, OMDocument xmlfragment) throws XServicesFault {
|
||||
|
||||
List<?> olist = null;
|
||||
try {
|
||||
olist = axp.selectNodes(xmldocument.getOMDocumentElement());
|
||||
log.debug("XPath '" + axp.toString() + "' has " + olist.size() + " matches.");
|
||||
log.debug("XPath root expression is: '" + axp.debug() + "'.");
|
||||
this.logger.debug("XPath '" + axp.toString() + "' has "
|
||||
+ olist.size() + " matches.");
|
||||
this.logger.trace("XPath root expression is: '" + axp.debug()
|
||||
+ "'.");
|
||||
} catch (JaxenException e) {
|
||||
throw new XServicesFault(e.getMessage(), e);
|
||||
}
|
||||
if (olist.size() == 0)
|
||||
throw new XServicesFault(Messages.getString("XmlService.no_match", new Object[] { axp.toString() }));
|
||||
throw new XServicesFault(Messages.getString("XmlService.no_match",
|
||||
new Object[] { axp.toString() }));
|
||||
|
||||
// Prepare children to insert
|
||||
xmlfragment.build();
|
||||
|
@ -433,7 +448,8 @@ public class XmlServiceImpl implements XmlService {
|
|||
// Determine what has been matched
|
||||
OMNode match = null;
|
||||
for (Object o : olist) {
|
||||
Iterator<?> children = xmlfragment.getOMDocumentElement().getChildren();
|
||||
Iterator<?> children = xmlfragment.getOMDocumentElement()
|
||||
.getChildren();
|
||||
if ((o instanceof OMNode)) {
|
||||
OMNode node = (OMNode) o;
|
||||
switch (node.getType()) {
|
||||
|
@ -442,16 +458,20 @@ public class XmlServiceImpl implements XmlService {
|
|||
match = (OMElement) o;
|
||||
if ((o instanceof OMDocument))
|
||||
match = ((OMDocument) o).getOMDocumentElement();
|
||||
log.debug(Messages.getString("XmlService.8"));
|
||||
this.logger.debug(Messages.getString("XmlService.8"));
|
||||
break;
|
||||
default:
|
||||
log.error("XPath matched " + o.getClass().getCanonicalName() + " Node Type:" + node.getType());
|
||||
log.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(Messages.getString("XmlService.12"));
|
||||
this.logger.error("XPath matched "
|
||||
+ o.getClass().getCanonicalName() + " Node Type:"
|
||||
+ node.getType());
|
||||
this.logger.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(
|
||||
Messages.getString("XmlService.12"));
|
||||
}
|
||||
} else {
|
||||
log.error("XPath matched " + o.getClass().getCanonicalName());
|
||||
log.error(Messages.getString("XmlService.11"));
|
||||
this.logger.error("XPath matched "
|
||||
+ o.getClass().getCanonicalName());
|
||||
this.logger.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(Messages.getString("XmlService.12"));
|
||||
}
|
||||
|
||||
|
@ -468,29 +488,29 @@ public class XmlServiceImpl implements XmlService {
|
|||
private SimpleNamespaceContext createContext(NamespaceListType nsList) {
|
||||
// Initialize XPath context
|
||||
SimpleNamespaceContext context = new SimpleNamespaceContext();
|
||||
if (nsList != null) {
|
||||
if(nsList != null) {
|
||||
for (NamespaceType ns : nsList.getNamespaces()) {
|
||||
context.addNamespace(ns.getPrefix(), ns.getUri().toString());
|
||||
log.debug(
|
||||
Messages.getString("XmlService.0") + ns.getPrefix() + "=\"" + ns.getUri().toString() + "\"'");
|
||||
this.logger.debug(Messages.getString("XmlService.0")
|
||||
+ ns.getPrefix() + "=\"" + ns.getUri().toString()
|
||||
+ "\"'");
|
||||
}
|
||||
} else {
|
||||
log.debug("No namespaces defined.");
|
||||
logger.debug("No namespaces defined.");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
private String validateEncoding(String encoding) throws XServicesFault {
|
||||
if (encoding == null || encoding.equals("")) {
|
||||
encoding = Charset.defaultCharset().displayName();
|
||||
}
|
||||
if(encoding == null || encoding.equals("")) { encoding=Charset.defaultCharset().displayName(); }
|
||||
try {
|
||||
Charset.isSupported(encoding);
|
||||
} catch (IllegalCharsetNameException e) {
|
||||
throw new XServicesFault("Endcoding '" + encoding + "' is not supported by this JRE.");
|
||||
throw new XServicesFault("Endcoding '"+encoding+"' is not supported by this JRE.");
|
||||
}
|
||||
log.debug("Setting source xml string encoding to '" + encoding + "'");
|
||||
logger.debug("Setting source xml string encoding to '"+encoding+"'");
|
||||
return encoding;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -8,11 +8,9 @@ import java.io.PrintStream;
|
|||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import net.brutex.xservices.types.scm.AttributeType;
|
||||
import net.brutex.xservices.types.scm.ItemListType;
|
||||
import net.brutex.xservices.types.scm.ItemType;
|
||||
|
@ -25,11 +23,10 @@ import net.brutex.xservices.types.scmfindings.FindingsListType;
|
|||
import net.brutex.xservices.util.BasicCVSListener;
|
||||
import net.brutex.xservices.util.CVSClient;
|
||||
import net.brutex.xservices.util.CVSRoot;
|
||||
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
import org.apache.commons.jcs.JCS;
|
||||
import org.apache.commons.jcs.access.CacheAccess;
|
||||
import org.apache.commons.jcs.access.exception.CacheException;
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.apache.jcs.JCS;
|
||||
import org.apache.jcs.access.exception.CacheException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.netbeans.lib.cvsclient.Client;
|
||||
import org.netbeans.lib.cvsclient.command.CommandAbortedException;
|
||||
import org.netbeans.lib.cvsclient.command.CommandException;
|
||||
|
@ -44,16 +41,15 @@ import org.netbeans.lib.cvsclient.connection.AuthenticationException;
|
|||
import org.netbeans.lib.cvsclient.event.EventManager;
|
||||
import org.netbeans.lib.cvsclient.event.FileInfoEvent;
|
||||
|
||||
@Slf4j
|
||||
public class CVSInfoImpl implements CVSInfo {
|
||||
|
||||
final Logger logger = Logger.getLogger(CVSInfoImpl.class);
|
||||
final ObjectFactory FACTORY = new ObjectFactory();
|
||||
final ItemListType list = this.FACTORY.createItemListType();
|
||||
|
||||
public Response getRepositoryFiles(HttpHeaders h, File f, String modules,
|
||||
boolean isRecursive, boolean showRevisions, boolean forceNoCache) {
|
||||
String cachekey = "getFiles" + f.toURI().toString();
|
||||
log.debug("forceNoCache=" + forceNoCache);
|
||||
this.logger.debug("forceNoCache=" + forceNoCache);
|
||||
ItemListType cacheresult = (ItemListType) getCacheInstance().get(
|
||||
cachekey);
|
||||
|
||||
|
@ -121,7 +117,7 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
try {
|
||||
CVSInfoImpl.this.getCacheInstance().put(key, cvsfile);
|
||||
} catch (CacheException e) {
|
||||
log.error("Could not cache item '"
|
||||
CVSInfoImpl.this.logger.error("Could not cache item '"
|
||||
+ key + "'", e);
|
||||
}
|
||||
}
|
||||
|
@ -142,14 +138,14 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
|
||||
rlog.setRecursive(isRecursive);
|
||||
|
||||
log.info("Executing CVS command '" + rlog.getCVSCommand()
|
||||
this.logger.info("Executing CVS command '" + rlog.getCVSCommand()
|
||||
+ "' against '" + cvsclient.getRoot().host + "@"
|
||||
+ cvsclient.getRoot().repository + "'");
|
||||
client.executeCommand(rlog, cvsclient.getGlobalOptions());
|
||||
|
||||
getCacheInstance().put(cachekey, this.list);
|
||||
} catch (ConfigurationException e) {
|
||||
log.error("CVS Configuration File '" + f.getAbsolutePath()
|
||||
this.logger.error("CVS Configuration File '" + f.getAbsolutePath()
|
||||
+ f.getName() + "'not found.", e);
|
||||
} catch (CommandAbortedException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -172,7 +168,7 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
|
||||
public Response getModules(HttpHeaders h, File f, boolean forceNoCache) {
|
||||
String cachekey = "Modules" + f.toURI().toString();
|
||||
log.debug("forceNoCache=" + forceNoCache);
|
||||
this.logger.debug("forceNoCache=" + forceNoCache);
|
||||
|
||||
ModuleListType response = (ModuleListType) getCacheInstance().get(
|
||||
cachekey);
|
||||
|
@ -200,12 +196,12 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
CheckoutCommand co = new CheckoutCommand();
|
||||
co.setShowModulesWithStatus(true);
|
||||
|
||||
log.info("Executing CVS command '" + co.getCVSCommand()
|
||||
this.logger.info("Executing CVS command '" + co.getCVSCommand()
|
||||
+ "' against '" + cvsclient.getRoot().host + "@"
|
||||
+ cvsclient.getRoot().repository + "'");
|
||||
client.executeCommand(co, cvsclient.getGlobalOptions());
|
||||
if (list.getModules().size() == 0) {
|
||||
log.warn("Repository '"
|
||||
this.logger.warn("Repository '"
|
||||
+ cvsclient.getRoot().repository
|
||||
+ "' does not have modules");
|
||||
}
|
||||
|
@ -220,14 +216,14 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
|
||||
public Response getTags(HttpHeaders h, File f, boolean withFiles) {
|
||||
String cachekey = f.toURI().toString() + ":taglist";
|
||||
log.debug("Retrieving Tags from cache using key '" + cachekey
|
||||
this.logger.debug("Retrieving Tags from cache using key '" + cachekey
|
||||
+ "'");
|
||||
TagListType tags = (TagListType) getCacheInstance().get(cachekey);
|
||||
if (tags != null) {
|
||||
log.debug("Delivering Tags from cache.");
|
||||
this.logger.debug("Delivering Tags from cache.");
|
||||
return Response.ok(tags).build();
|
||||
}
|
||||
log.warn("Taglist not found in cache.");
|
||||
this.logger.warn("Taglist not found in cache.");
|
||||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
|
@ -239,17 +235,17 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
ItemListType list = null;
|
||||
|
||||
if (!forceNoCache) {
|
||||
log.debug("Retrieving file content from cache using key '"
|
||||
this.logger.debug("Retrieving file content from cache using key '"
|
||||
+ cachekey + "'");
|
||||
list = (ItemListType) getCacheInstance().get(cachekey);
|
||||
}
|
||||
|
||||
if (list != null) {
|
||||
log.debug("Delivering file content from cache.");
|
||||
this.logger.debug("Delivering file content from cache.");
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
|
||||
log.warn("File content not found in cache.");
|
||||
this.logger.warn("File content not found in cache.");
|
||||
list = this.FACTORY.createItemListType();
|
||||
try {
|
||||
CVSClient cvsclient = new CVSClient(f);
|
||||
|
@ -306,7 +302,7 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
checkout.setModule(filestring);
|
||||
checkout.setPipeToOutput(true);
|
||||
|
||||
log.info("Execute CVS command '" + checkout.getCVSCommand()
|
||||
this.logger.info("Execute CVS command '" + checkout.getCVSCommand()
|
||||
+ "' against '" + cvsclient.getRoot().host + "@"
|
||||
+ cvsclient.getRoot().repository + "'");
|
||||
client.executeCommand(checkout, cvsclient.getGlobalOptions());
|
||||
|
@ -326,14 +322,14 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
public CacheAccess<Object, Object> getCacheInstance() {
|
||||
CacheAccess<Object, Object> jcs = null;
|
||||
public JCS getCacheInstance() {
|
||||
JCS jcs = null;
|
||||
String cacheinstance = "CVSCache";
|
||||
try {
|
||||
log.trace("Getting cache instance named 'CVSCache'");
|
||||
this.logger.trace("Getting cache instance named 'CVSCache'");
|
||||
jcs = JCS.getInstance("CVSCache");
|
||||
} catch (CacheException e) {
|
||||
log.error("Failed to get cache instance", e);
|
||||
this.logger.error("Failed to get cache instance", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jcs;
|
||||
|
@ -347,21 +343,26 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
+ client.getRoot().repository;
|
||||
|
||||
String cachestring = "FINDINGS-" + cvsroot;
|
||||
log.debug("Fetch searchFileContent response from cache using cachekey '"
|
||||
this.logger
|
||||
.debug("Fetch searchFileContent response from cache using cachekey '"
|
||||
+ cachestring + "'");
|
||||
FindingsListType result = (FindingsListType) getCacheInstance()
|
||||
.get(cachestring);
|
||||
if (result != null)
|
||||
log.debug("Found object for key '" + cachestring
|
||||
this.logger.debug("Found object for key '" + cachestring
|
||||
+ "' in cache.");
|
||||
else {
|
||||
log.debug("Found no object for key '" + cachestring
|
||||
this.logger.debug("Found no object for key '" + cachestring
|
||||
+ "' in cache.");
|
||||
}
|
||||
|
||||
if (result != null)
|
||||
return Response.ok(result).build();
|
||||
} catch (CommandAbortedException | AuthenticationException | ConfigurationException e) {
|
||||
} catch (CommandAbortedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AuthenticationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Response.noContent().build();
|
|
@ -28,7 +28,7 @@ import javax.ws.rs.core.HttpHeaders;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.jcs.access.exception.CacheException;
|
||||
import org.apache.jcs.access.exception.CacheException;
|
||||
|
||||
import net.brutex.xservices.ws.XServicesFault;
|
||||
|
|
@ -33,20 +33,16 @@ import javax.ws.rs.core.HttpHeaders;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||
import org.apache.commons.configuration2.builder.fluent.Configurations;
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
import org.apache.commons.jcs.JCS;
|
||||
import org.apache.commons.jcs.access.CacheAccess;
|
||||
import org.apache.commons.jcs.access.exception.CacheException;
|
||||
|
||||
|
||||
import net.brutex.xservices.cmtypes.ItemType;
|
||||
import net.brutex.xservices.cmtypes.ItemTypeList;
|
||||
import net.brutex.xservices.types.FileInfoType;
|
||||
import net.brutex.xservices.util.FileWalker;
|
||||
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
import org.apache.jcs.JCS;
|
||||
import org.apache.jcs.access.exception.CacheException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -78,9 +74,9 @@ import com.serena.dmclient.api.SystemAttributes;
|
|||
*
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*/
|
||||
@Slf4j
|
||||
public class DIMCMInfoImpl implements DIMCMInfo {
|
||||
|
||||
Logger logger = Logger.getLogger(DIMCMInfoImpl.class);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -97,7 +93,7 @@ public class DIMCMInfoImpl implements DIMCMInfo {
|
|||
/*
|
||||
* try to hit cache first
|
||||
*/
|
||||
CacheAccess<Object, Object> cache = JCS.getInstance("DIMCM");
|
||||
JCS cache = JCS.getInstance("DIMCM");
|
||||
String cachekey = projSpec + directory + String.valueOf(recursive);
|
||||
if(useCache) {
|
||||
ItemTypeList cacheresult = (ItemTypeList) cache.get(cachekey);
|
||||
|
@ -238,14 +234,14 @@ public class DIMCMInfoImpl implements DIMCMInfo {
|
|||
|
||||
if (search == null || search.equals("")) {
|
||||
search = "*";
|
||||
log.info("No search pattern supplied, using default '*'.");
|
||||
logger.info("No search pattern supplied, using default '*'.");
|
||||
}
|
||||
|
||||
FileWalker finder = new FileWalker(search);
|
||||
try {
|
||||
Files.walkFileTree(dir.toPath(),
|
||||
EnumSet.of(FileVisitOption.FOLLOW_LINKS), depth, finder);
|
||||
log.info("FileWalker returned '" + finder.getCount()
|
||||
logger.info("FileWalker returned '" + finder.getCount()
|
||||
+ "' hits. '" + finder.getTotal()
|
||||
+ "' files have been scanned.");
|
||||
List<Path> result = finder.getResult();
|
||||
|
@ -261,7 +257,7 @@ public class DIMCMInfoImpl implements DIMCMInfo {
|
|||
list.add(new FileInfoType(f, baseuri));
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
log.error(e2.getMessage(), e2);
|
||||
logger.error(e2.getMessage(), e2);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +320,7 @@ public class DIMCMInfoImpl implements DIMCMInfo {
|
|||
if (conn != null)
|
||||
return conn;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -332,8 +328,7 @@ public class DIMCMInfoImpl implements DIMCMInfo {
|
|||
*/
|
||||
PropertiesConfiguration props;
|
||||
try {
|
||||
|
||||
props = new Configurations().properties(this.getClass()
|
||||
props = new PropertiesConfiguration(this.getClass()
|
||||
.getClassLoader().getResource("/../dimcm.properties"));
|
||||
} catch (ConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -354,13 +349,11 @@ public class DIMCMInfoImpl implements DIMCMInfo {
|
|||
private String getBaseURL() {
|
||||
final String CACHE_BASEURL = "DIMCM.conf.baseurl";
|
||||
try {
|
||||
CacheAccess<Object, Object> cache = JCS.getInstance("DIMCM");
|
||||
JCS cache = JCS.getInstance("DIMCM");
|
||||
String baseurl = (String) cache.get(CACHE_BASEURL);
|
||||
if(baseurl != null) return baseurl;
|
||||
|
||||
Configurations configs = new Configurations();
|
||||
|
||||
PropertiesConfiguration props = configs.properties((this.getClass().getClassLoader().getResource("/../dimcm.properties")));
|
||||
PropertiesConfiguration props = new PropertiesConfiguration(this.getClass().getClassLoader().getResource("/../dimcm.properties"));
|
||||
baseurl = props.getString("baseurl");
|
||||
cache.put(CACHE_BASEURL, baseurl);
|
||||
return baseurl;
|
|
@ -47,14 +47,13 @@ import javax.ws.rs.core.Response;
|
|||
import javax.ws.rs.core.StreamingOutput;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.security.DirectoryPermission;
|
||||
import net.brutex.xservices.types.FileInfoType;
|
||||
import net.brutex.xservices.util.FileWalker;
|
||||
|
||||
import org.apache.commons.jcs.JCS;
|
||||
import org.apache.commons.jcs.access.CacheAccess;
|
||||
import org.apache.commons.jcs.access.exception.CacheException;
|
||||
import org.apache.jcs.JCS;
|
||||
import org.apache.jcs.access.exception.CacheException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.UnauthorizedException;
|
||||
|
||||
|
@ -63,10 +62,10 @@ import org.apache.shiro.authz.UnauthorizedException;
|
|||
*
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*/
|
||||
@Slf4j
|
||||
public class FileInfoImpl implements FileInfo {
|
||||
|
||||
|
||||
Logger logger = Logger.getLogger(FileInfoImpl.class);
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -76,20 +75,20 @@ public class FileInfoImpl implements FileInfo {
|
|||
{
|
||||
if(dir==null) {
|
||||
dir = "c:/";
|
||||
log.warn("No directory specified. Default is 'c:/'.");
|
||||
logger.warn("No directory specified. Default is 'c:/'.");
|
||||
}
|
||||
isPermitted(dir);
|
||||
|
||||
URI baseuri = URI.create(uriInfo.getBaseUri()+FileInfo.BASE_PATH+"getFile?file=");
|
||||
|
||||
log.info(String.format("Listing directory '%s'.", dir));
|
||||
logger.info(String.format("Listing directory '%s'.", dir));
|
||||
if (level <= 0) level = 1;
|
||||
|
||||
if ((!withDir) && (!withFiles)) withFiles = true;
|
||||
String cachekey = level + "||" + withFiles + "||" + withDir + "||" + search + "||" + dir;
|
||||
try {
|
||||
log.debug(String.format("Hitting cache with cachekey '%s'", cachekey));
|
||||
CacheAccess<Object, Object> jcs = JCS.getInstance("FileCache");
|
||||
logger.debug(String.format("Hitting cache with cachekey '%s'", cachekey));
|
||||
JCS jcs = JCS.getInstance("FileCache");
|
||||
|
||||
/*Try to retrieve the file list from the cache*/
|
||||
List<FileInfoType> list = (List<FileInfoType>)jcs.get(cachekey);
|
||||
|
@ -97,9 +96,9 @@ public class FileInfoImpl implements FileInfo {
|
|||
if (list == null || !useCache) {
|
||||
list = setDirectory(baseuri, dir, withDir, withFiles, level, search);
|
||||
jcs.put(cachekey, list);
|
||||
log.debug("Stored in Cache: " + list.toString());
|
||||
logger.debug("Stored in Cache: " + list.toString());
|
||||
} else {
|
||||
log.debug("Got from Cache: " + list.toString());
|
||||
logger.debug("Got from Cache: " + list.toString());
|
||||
}
|
||||
|
||||
int fromIndex = 0;
|
||||
|
@ -109,7 +108,7 @@ public class FileInfoImpl implements FileInfo {
|
|||
if (toIndex > list.size()) toIndex = list.size();
|
||||
if (fromIndex > toIndex) fromIndex = toIndex;
|
||||
GenericEntity<List<FileInfoType>> sublist = new GenericEntity<List<FileInfoType>>(list.subList(fromIndex, toIndex)) {};
|
||||
log.info(String.format("Returning items %s to %s from total of %s items in the list.", fromIndex, toIndex, list.size()));
|
||||
logger.info(String.format("Returning items %s to %s from total of %s items in the list.", fromIndex, toIndex, list.size()));
|
||||
return Response.ok(sublist).build();
|
||||
} catch (CacheException e) {
|
||||
return Response.serverError().build();
|
||||
|
@ -132,13 +131,13 @@ public class FileInfoImpl implements FileInfo {
|
|||
|
||||
if(search==null || search.equals("") ) {
|
||||
search = "*";
|
||||
log.info("No search pattern supplied, using default '*'.");
|
||||
logger.info("No search pattern supplied, using default '*'.");
|
||||
}
|
||||
|
||||
FileWalker finder = new FileWalker(search);
|
||||
try {
|
||||
Files.walkFileTree(dir.toPath(), EnumSet.of(FileVisitOption.FOLLOW_LINKS), depth, finder);
|
||||
log.info("FileWalker returned '"+finder.getCount()+"' hits. '" + finder.getTotal() + "' files have been scanned.");
|
||||
logger.info("FileWalker returned '"+finder.getCount()+"' hits. '" + finder.getTotal() + "' files have been scanned.");
|
||||
List<Path> result = finder.getResult();
|
||||
for(Path f : result) {
|
||||
if(! withDirectories) {
|
||||
|
@ -150,7 +149,7 @@ public class FileInfoImpl implements FileInfo {
|
|||
list.add(new FileInfoType(f, baseuri));
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
log.error(e2.getMessage(), e2);;
|
||||
logger.error(e2.getMessage(), e2);;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,7 +194,7 @@ public Response getFile(HttpHeaders paramHttpHeaders, String file) {
|
|||
//In case we can not find the media type for some reason
|
||||
//the default assignment is taken, so we can
|
||||
//ignore this error.
|
||||
log.debug(String.format("Could not probe media type for file '%s'. Default is '%s'", path.toString(), mime.getType()), e);
|
||||
logger.debug(String.format("Could not probe media type for file '%s'. Default is '%s'", path.toString(), mime.getType()), e);
|
||||
}
|
||||
Response r = Response.ok(path.toFile(), mime).build();
|
||||
String fileName = path.getFileName().toString();
|
||||
|
@ -203,7 +202,7 @@ public Response getFile(HttpHeaders paramHttpHeaders, String file) {
|
|||
return r;
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
log.error(e1.getMessage(), e1);
|
||||
logger.error(e1.getMessage(), e1);
|
||||
return Response.serverError().build();
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +250,7 @@ private Response getDirectoryAsZip(final Path path) {
|
|||
|
||||
private boolean isPermitted(String dir) {
|
||||
if(! SecurityUtils.getSubject().isPermitted( new DirectoryPermission(dir))) {
|
||||
log.warn(String.format("User '%s' does not have permission to access '%s'.",SecurityUtils.getSubject().getPrincipal(), dir ));
|
||||
logger.warn(String.format("User '%s' does not have permission to access '%s'.",SecurityUtils.getSubject().getPrincipal(), dir ));
|
||||
throw new NotAuthorizedException(new UnauthorizedException("User does not have permission to access "+ dir));
|
||||
}
|
||||
return true;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue