diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 378b937..0000000 --- a/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -target -bin -.classpath -.project -d: \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..858dcee --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +bin/ +target/ + +# Gradle +.gradle +build + +# Eclipse +.classpath +.project +.settings diff --git a/build-libs/gradle-wrapper.jar b/build-libs/gradle-wrapper.jar deleted file mode 100644 index 6a7162a..0000000 Binary files a/build-libs/gradle-wrapper.jar and /dev/null differ diff --git a/build-libs/jetty-6.1.14.zip b/build-libs/jetty-6.1.14.zip deleted file mode 100644 index 2c24049..0000000 Binary files a/build-libs/jetty-6.1.14.zip and /dev/null differ diff --git a/build.gradle b/build.gradle index c03f1e7..727c881 100644 --- a/build.gradle +++ b/build.gradle @@ -13,55 +13,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -archivesBaseName = 'webdav-servlet' -project.group = 'net.sf.webdav-servlet' -project.version = '2.1-dev' +apply plugin: 'java' +apply plugin: 'maven' +apply plugin: 'eclipse' -usePlugin('war') -usePlugin('jetty') +archivesBaseName = 'webdav-servlet' +group = 'net.sf.webdav-servlet' +version = '2.0.2.JACKGENE-SNAPSHOT' sourceCompatibility = 1.5 targetCompatibility = 1.5 -dependencies { - addMavenRepo() +repositories { + if (rootProject.hasProperty('repositories.MAVEN_CENTRAL_MIRROR_URL')) { + maven { + url getProperty('repositories.MAVEN_CENTRAL_MIRROR_URL') + } + } else { + mavenCentral() + } +} - providedCompile "javax.servlet:servlet-api:2.4" +dependencies { + compile "javax.servlet:servlet-api:2.4" compile "org.slf4j:slf4j-api:1.4.3" - compile "org.slf4j:slf4j-log4j12:1.4.3" - compile "log4j:log4j:1.2.12" testCompile "junit:junit:4.4" testCompile "org.jmock:jmock:2.4.0" testCompile "org.springframework:spring-webmvc:2.5.2" testCompile "org.springframework:spring-mock:2.0.7" - - addConfiguration("jettyRuntime") - jettyRuntime "org.mortbay.jetty:jsp-2.1:6.1.14", "org.mortbay.jetty:jetty-annotations:6.1.14" -} - -defaultTasks "help" - -createTask ('help') { - println " " - println "available goals:" - println " clean \t\tcleans the build folder" - println " test \t\t\truns the test suite" - println " eclipse \t\tcreates eclipse project files" - println " jettyRun \t\tstarts with jetty webserver" - println " " - println "useful flags :" - println " -Dskip.test \t\tskip execution of tests" - println " " - println "examples" - println " ./gradlew clean dists -Dskip.test \tbuilds the distribution and skip the tests" -} - -createTask('wrapper', type: Wrapper).configure { - urlRoot = 'http://dist.codehaus.org/gradle/' - gradleVersion = '0.5' - jarPath = 'build-libs' + testRuntime "org.slf4j:slf4j-log4j12:1.4.3" } test { @@ -69,101 +50,34 @@ test { exclude '**/net/sf/webdav/testutil/**/*Test.class' } -String jettyArtifactVersion = 'jetty-6.1.14' -File jettyDistribution = new File(buildDir, jettyArtifactVersion) - -libs { - archive_jar.enabled=true - - jar(classifier: 'sources') { - fileSet(dir: 'src/main/java') - } - - jar(classifier: 'javadoc') { - fileSet(dir: new File(buildDir, "docs/javadoc")) - } +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource } - -archive_javadoc_jar.dependsOn('javadoc') - -dists { - zip() { - String zipRoot = "$archivesBaseName-${project.version}" - zipFileSet(dir: new File(buildDir, jettyArtifactVersion), prefix: zipRoot) - } +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir } - -archive_zip.doFirst() { - ant.unzip(src: new File("build-libs", jettyArtifactVersion+".zip"), dest: buildDir) - - ant.delete(dir: new File(jettyDistribution, 'patches')) - ant.delete(dir: new File(jettyDistribution, 'modules')) - ant.delete(dir: new File(jettyDistribution, 'jxr')) - ant.delete(dir: new File(jettyDistribution, 'javadoc')) - ant.delete(dir: new File(jettyDistribution, 'extras')) - ant.delete(dir: new File(jettyDistribution, 'distribution')) - ant.delete(dir: new File(jettyDistribution, 'contrib')) - ant.delete(dir: new File(jettyDistribution, 'examples')) - ant.delete(dir: new File(jettyDistribution, 'contexts')) - ant.delete(dir: new File(jettyDistribution, 'webapps')) - ant.delete(file: new File(jettyDistribution, 'pom.xml')) - ant.delete(file: new File(jettyDistribution, 'README.txt')) - ant.delete(file: new File(jettyDistribution, 'VERSION.txt')) - - ant.mkdir(dir: new File(jettyDistribution, 'contexts')) - ant.mkdir(dir: new File(jettyDistribution, 'webapps')) - - ant.unzip(src: archive_war.archivePath, dest: new File(jettyDistribution, 'webapps/ROOT')) - - ant.copy(file: 'src/main/scripts/start.sh', todir: jettyDistribution) +artifacts { + archives sourcesJar + archives javadocJar } - -jettyRun { - contextPath = '/' - scanIntervalSeconds = 2 - useTestClasspath = true - connectors = configure(new org.mortbay.jetty.nio.SelectChannelConnector()) { - port = 8088 - maxIdleTime = 60000 +if (rootProject.hasProperty('uploadArchives.my.edu.clhs.baseRepositoryUrl')) { + uploadArchives { + ext.BASE_REPOSITORY_URL = getProperty('uploadArchives.my.edu.clhs.baseRepositoryUrl') + repositories { + mavenDeployer { + repository(url: "${BASE_REPOSITORY_URL}/release") + snapshotRepository(url: "${BASE_REPOSITORY_URL}/snapshot") + pom.whenConfigured { pom -> + pom.dependencies.removeAll { dep -> + dep.groupId == 'javax.servlet' && dep.artifactId == 'servlet-api' + } + } + } + } + } } -}.doFirst { jettyRun -> - jettyRun.additionalRuntimeJars = dependencies.jettyRuntime.resolve() as List -} - -createTask('android-webapp', dependsOn:'compile') { - File generatedClasses = new File(buildDir, 'generated-classes') - def webappClassPath = dependencies.resolve("compile"); - def excludeArtifacts = ['servlet-api']; - webappClassPath.each {jarFile -> - excludeArtifacts.each {excludeArtifact -> - if (jarFile.toString().indexOf(excludeArtifact) == -1) { - ant.unzip(src: jarFile, dest: generatedClasses) - } - } - } - - File androidWebapp = new File(buildDir, 'android-webapp/exploded') - androidWebapp.mkdirs(); - File androidWebAppLib = new File(androidWebapp, "WEB-INF/lib"); - androidWebAppLib.mkdirs(); - - String dxPath = System.getProperty("dxTool"); - String argument1 = '--dex' - String argument2 = '--core-library' - String argument3 = '--output='+new File(androidWebAppLib, "classes.zip").getAbsolutePath(); - String argument4 = '--positions=lines' - String argument5 = new File(buildDir, "classes").getAbsolutePath(); - String argument6 = new File(buildDir, "generated-classes").getAbsolutePath(); - - def command = """${dxPath} ${argument1} ${argument2} ${argument3} ${argument4} ${argument5} ${argument6}"""// Create the String - println command - def proc = command.execute() - proc.waitFor() - - ant.copy(file: 'src/main/webapp/WEB-INF/web.xml', todir: new File(androidWebapp, "WEB-INF")) - ant.war(destfile: new File(buildDir, "android-webapp/webdav-servlet.war"), basedir: androidWebapp, webxml: 'src/main/webapp/WEB-INF/web.xml') - - -} \ No newline at end of file +task wrapper(type: Wrapper) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..a7634b0 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..c9d4f0c --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Feb 03 21:09:06 PST 2014 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip diff --git a/gradlew b/gradlew index 2828a6a..91a7e26 100755 --- a/gradlew +++ b/gradlew @@ -1,24 +1,31 @@ -#!/bin/bash +#!/usr/bin/env bash ############################################################################## -## ## -## Gradle wrapper script for UN*X ## -## ## +## +## Gradle start up script for UN*X +## ############################################################################## -# Uncomment this line to set JVM_OPTS -# GRADLE_OPTS="$GRADLE_OPTS -Xmx512" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" warn ( ) { - echo "${PROGNAME}: $*" + echo "$*" } die ( ) { - warn "$*" + echo + echo "$*" + echo exit 1 } - # OS specific support (must be 'true' or 'false'). cygwin=false msys=false @@ -35,56 +42,77 @@ case "`uname`" in ;; esac -# Attempt to set JAVA_HOME if it's not already set. -if [ -z "$JAVA_HOME" ] ; then - if $darwin ; then - [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home" - [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" - else - javaExecutable="`which javac`" - [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME." - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME." - javaExecutable="`readlink -f \"$javaExecutable\"`" - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - export JAVA_HOME="$javaHome" - fi -fi - # For Cygwin, ensure paths are in UNIX format before anything is touched. if $cygwin ; then - [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` fi -STARTER_MAIN_CLASS=org.gradle.wrapper.WrapperMain -CLASSPATH=`dirname "$0"`/build-libs/gradle-wrapper.jar +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi +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" + 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" + which java >/dev/null 2>&1 || 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 -if [ ! -x "$JAVACMD" ] ; then - die "JAVA_HOME is not defined correctly, can not execute: $JAVACMD" + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi fi -if [ -z "$JAVA_HOME" ] ; then - warn "JAVA_HOME environment variable is not set" + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then - JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"` - TOOLS_JAR=`cygpath --path --mixed "$TOOLS_JAR"` + APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` # We build the pattern for arguments to be converted via cygpath @@ -111,7 +139,7 @@ if $cygwin ; then eval `echo args$i`="\"$arg\"" fi i=$((i+1)) - done + done case $i in (0) set -- ;; (1) set -- "$args0" ;; @@ -126,8 +154,11 @@ if $cygwin ; then esac fi -"$JAVACMD" $GRADLE_OPTS \ - -classpath "$CLASSPATH" \ - -Dtools.jar="$TOOLS_JAR" \ - $STARTER_MAIN_CLASS \ - "$@" +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat index 85dc20b..aec9973 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,85 +1,55 @@ @if "%DEBUG%" == "" @echo off @rem ########################################################################## -@rem ## -@rem Gradle startup script for Windows ## -@rem ## -@rem ########################################################################## - @rem -@rem $Revision: 10602 $ $Date: 2008-01-25 02:49:54 +0100 (ven., 25 janv. 2008) $ +@rem Gradle startup script for Windows @rem +@rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Uncomment this line to set JVM_OPTS -@rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512 +@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= set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=.\ +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% -@rem Determine the command interpreter to execute the "CD" later -set COMMAND_COM="cmd.exe" -if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe" -if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com" +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome -@rem Use explicit find.exe to prevent cygwin and others find.exe from being used -set FIND_EXE="find.exe" -if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe" -if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe" - -:check_JAVA_HOME -@rem Make sure we have a valid JAVA_HOME -if not "%JAVA_HOME%" == "" goto have_JAVA_HOME +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init echo. -echo ERROR: Environment variable JAVA_HOME has not been set. +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. -echo. -goto end -:have_JAVA_HOME -@rem Validate JAVA_HOME -%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul -if not errorlevel 1 goto init +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init echo. -echo ERROR: JAVA_HOME might be set to an invalid directory: %JAVA_HOME% +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 if there are problems. -echo. +echo location of your Java installation. + +goto fail :init -@rem get name of script to launch with full path @rem Get command-line arguments, handling Windowz variants -SET _marker=%JAVA_HOME: =% -@rem IF NOT "%_marker%" == "%JAVA_HOME%" ECHO JAVA_HOME "%JAVA_HOME%" contains spaces. Please change to a location without spaces if this causes problems. if not "%OS%" == "Windows_NT" goto win9xME_args -if "%eval[2+2]" == "4" goto 4NT_args - -IF "%_marker%" == "%JAVA_HOME%" goto :win9xME_args - -set _FIXPATH= -call :fixpath "%JAVA_HOME%" -set JAVA_HOME=%_FIXPATH:~1% - -goto win9xME_args - -:fixpath -if not %1.==. ( -for /f "tokens=1* delims=;" %%a in (%1) do ( -call :shortfilename "%%a" & call :fixpath "%%b" -) -) -goto :EOF -:shortfilename -for %%i in (%1) do set _FIXPATH=%_FIXPATH%;%%~fsi -goto :EOF - +if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -99,28 +69,22 @@ set CMD_LINE_ARGS=%$ :execute @rem Setup the command line -set STARTER_MAIN_CLASS=org.gradle.wrapper.WrapperMain -set CLASSPATH=%DIRNAME%\build-libs\gradle-wrapper.jar -set JAVA_EXE=%JAVA_HOME%\bin\java.exe -set TOOLS_JAR=%JAVA_HOME%\lib\tools.jar +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar -if "%GRADLE_OPTS%" == "" set GRADLE_OPTS="-Xmx128m" -set GRADLE_OPTS=%GRADLE_OPTS% -Dtools.jar="%TOOLS_JAR%" - -"%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS% +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd -if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1 - +:fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit "%ERRORLEVEL%" -exit /b "%ERRORLEVEL%" +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal -:omega \ No newline at end of file +:omega diff --git a/src/main/java/net/sf/webdav/WebDavServletBean.java b/src/main/java/net/sf/webdav/WebDavServletBean.java index 4863bf5..d83bfc5 100644 --- a/src/main/java/net/sf/webdav/WebDavServletBean.java +++ b/src/main/java/net/sf/webdav/WebDavServletBean.java @@ -31,6 +31,7 @@ import net.sf.webdav.methods.DoUnlock; public class WebDavServletBean extends HttpServlet { + private static final long serialVersionUID = 1L; private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory .getLogger(WebDavServletBean.class); diff --git a/src/main/java/net/sf/webdav/WebdavServlet.java b/src/main/java/net/sf/webdav/WebdavServlet.java index c9540be..c960171 100644 --- a/src/main/java/net/sf/webdav/WebdavServlet.java +++ b/src/main/java/net/sf/webdav/WebdavServlet.java @@ -33,6 +33,7 @@ */ public class WebdavServlet extends WebDavServletBean { + private static final long serialVersionUID = 1L; private static final String ROOTPATH_PARAMETER = "rootpath"; diff --git a/src/main/java/net/sf/webdav/exceptions/AccessDeniedException.java b/src/main/java/net/sf/webdav/exceptions/AccessDeniedException.java index 667a528..c30e662 100644 --- a/src/main/java/net/sf/webdav/exceptions/AccessDeniedException.java +++ b/src/main/java/net/sf/webdav/exceptions/AccessDeniedException.java @@ -17,6 +17,7 @@ package net.sf.webdav.exceptions; public class AccessDeniedException extends WebdavException { + private static final long serialVersionUID = 1L; public AccessDeniedException() { super(); diff --git a/src/main/java/net/sf/webdav/exceptions/LockFailedException.java b/src/main/java/net/sf/webdav/exceptions/LockFailedException.java index b6e4c0f..b7e0384 100644 --- a/src/main/java/net/sf/webdav/exceptions/LockFailedException.java +++ b/src/main/java/net/sf/webdav/exceptions/LockFailedException.java @@ -1,6 +1,7 @@ package net.sf.webdav.exceptions; public class LockFailedException extends WebdavException { + private static final long serialVersionUID = 1L; public LockFailedException() { super(); diff --git a/src/main/java/net/sf/webdav/exceptions/ObjectAlreadyExistsException.java b/src/main/java/net/sf/webdav/exceptions/ObjectAlreadyExistsException.java index d093800..8b18668 100644 --- a/src/main/java/net/sf/webdav/exceptions/ObjectAlreadyExistsException.java +++ b/src/main/java/net/sf/webdav/exceptions/ObjectAlreadyExistsException.java @@ -17,6 +17,7 @@ package net.sf.webdav.exceptions; public class ObjectAlreadyExistsException extends WebdavException { + private static final long serialVersionUID = 1L; public ObjectAlreadyExistsException() { super(); diff --git a/src/main/java/net/sf/webdav/exceptions/ObjectNotFoundException.java b/src/main/java/net/sf/webdav/exceptions/ObjectNotFoundException.java index ae0a736..c3233f8 100644 --- a/src/main/java/net/sf/webdav/exceptions/ObjectNotFoundException.java +++ b/src/main/java/net/sf/webdav/exceptions/ObjectNotFoundException.java @@ -17,6 +17,7 @@ package net.sf.webdav.exceptions; public class ObjectNotFoundException extends WebdavException { + private static final long serialVersionUID = 1L; public ObjectNotFoundException() { super(); diff --git a/src/main/java/net/sf/webdav/exceptions/UnauthenticatedException.java b/src/main/java/net/sf/webdav/exceptions/UnauthenticatedException.java index b0100f4..e16368e 100644 --- a/src/main/java/net/sf/webdav/exceptions/UnauthenticatedException.java +++ b/src/main/java/net/sf/webdav/exceptions/UnauthenticatedException.java @@ -17,6 +17,7 @@ package net.sf.webdav.exceptions; public class UnauthenticatedException extends WebdavException { + private static final long serialVersionUID = 1L; public UnauthenticatedException() { super(); diff --git a/src/main/java/net/sf/webdav/exceptions/WebdavException.java b/src/main/java/net/sf/webdav/exceptions/WebdavException.java index 6d8a620..8403d41 100644 --- a/src/main/java/net/sf/webdav/exceptions/WebdavException.java +++ b/src/main/java/net/sf/webdav/exceptions/WebdavException.java @@ -17,6 +17,7 @@ package net.sf.webdav.exceptions; public class WebdavException extends RuntimeException { + private static final long serialVersionUID = 1L; public WebdavException() { super(); diff --git a/src/main/java/net/sf/webdav/fromcatalina/RequestUtil.java b/src/main/java/net/sf/webdav/fromcatalina/RequestUtil.java index d247e4d..453ffaa 100644 --- a/src/main/java/net/sf/webdav/fromcatalina/RequestUtil.java +++ b/src/main/java/net/sf/webdav/fromcatalina/RequestUtil.java @@ -19,7 +19,6 @@ import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Map; -import java.util.TimeZone; import javax.servlet.http.Cookie; diff --git a/src/main/java/net/sf/webdav/locking/LockedObject.java b/src/main/java/net/sf/webdav/locking/LockedObject.java index 2dda386..e65bd21 100644 --- a/src/main/java/net/sf/webdav/locking/LockedObject.java +++ b/src/main/java/net/sf/webdav/locking/LockedObject.java @@ -2,6 +2,7 @@ import java.util.UUID; + /** * a helper class for ResourceLocks, represents the Locks * @@ -10,47 +11,50 @@ */ public class LockedObject { - private ResourceLocks _resourceLocks; + private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory + .getLogger(LockedObject.class); + + private final ResourceLocks _resourceLocks; - private String _path; + private final String _path; - private String _id; + private final String _id; /** * Describing the depth of a locked collection. If the locked resource is * not a collection, depth is 0 / doesn't matter. */ - protected int _lockDepth; + volatile int _lockDepth; /** * Describing the timeout of a locked object (ms) */ - protected long _expiresAt; + volatile long _expiresAt; /** * owner of the lock. shared locks can have multiple owners. is null if no * owner is present */ // protected String[] _owner = null; - protected String[] _owner = null; + volatile String[] _owner = null; /** * children of that lock */ - protected LockedObject[] _children = null; + volatile LockedObject[] _children = null; - protected LockedObject _parent = null; + volatile LockedObject _parent = null; /** * weather the lock is exclusive or not. if owner=null the exclusive value * doesn't matter */ - protected boolean _exclusive = false; + volatile boolean _exclusive = false; /** * weather the lock is a write or read lock */ - protected String _type = null; + volatile String _type = null; /** * @param _resourceLocks @@ -82,7 +86,7 @@ public LockedObject(ResourceLocks resLocks, String path, boolean temporary) { * string that represents the owner * @return true if the owner was added, false otherwise */ - public boolean addLockedObjectOwner(String owner) { + public synchronized boolean addLockedObjectOwner(String owner) { if (_owner == null) { _owner = new String[1]; @@ -113,7 +117,7 @@ public boolean addLockedObjectOwner(String owner) { * @param owner * string that represents the owner */ - public void removeLockedObjectOwner(String owner) { + public synchronized void removeLockedObjectOwner(String owner) { try { if (_owner != null) { @@ -140,8 +144,7 @@ public void removeLockedObjectOwner(String owner) { } } } catch (ArrayIndexOutOfBoundsException e) { - System.out.println("LockedObject.removeLockedObjectOwner()"); - System.out.println(e.toString()); + LOG.error("LockedObject.removeLockedObjectOwner()", e); } } @@ -151,7 +154,7 @@ public void removeLockedObjectOwner(String owner) { * @param newChild * new child */ - public void addChild(LockedObject newChild) { + void addChild(LockedObject newChild) { if (_children == null) { _children = new LockedObject[0]; } @@ -167,7 +170,7 @@ public void addChild(LockedObject newChild) { * (does not check this itself) * */ - public void removeLockedObject() { + void removeLockedObject() { if (this != _resourceLocks._root && !this.getPath().equals("/")) { int size = _parent._children.length; @@ -203,7 +206,7 @@ public void removeLockedObject() { * (does not check this itself) * */ - public void removeTempLockedObject() { + void removeTempLockedObject() { if (this != _resourceLocks._tempRoot) { // removing from tree if (_parent != null && _parent._children != null) { @@ -246,7 +249,7 @@ public void removeTempLockedObject() { * the depth to which should be checked * @return true if the lock can be placed */ - public boolean checkLocks(boolean exclusive, int depth) { + boolean checkLocks(boolean exclusive, int depth) { if (checkParents(exclusive) && checkChildren(exclusive, depth)) { return true; } diff --git a/src/main/java/net/sf/webdav/locking/ResourceLocks.java b/src/main/java/net/sf/webdav/locking/ResourceLocks.java index 1463403..d243696 100644 --- a/src/main/java/net/sf/webdav/locking/ResourceLocks.java +++ b/src/main/java/net/sf/webdav/locking/ResourceLocks.java @@ -32,7 +32,7 @@ */ public class ResourceLocks implements IResourceLocks { - private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory + private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory .getLogger(ResourceLocks.class); /** @@ -41,35 +41,35 @@ public class ResourceLocks implements IResourceLocks { */ private final int _cleanupLimit = 100000; - protected int _cleanupCounter = 0; + volatile int _cleanupCounter = 0; /** * keys: path value: LockedObject from that path */ - protected Hashtable _locks = new Hashtable(); + final Hashtable _locks = new Hashtable(); /** * keys: id value: LockedObject from that id */ - protected Hashtable _locksByID = new Hashtable(); + final Hashtable _locksByID = new Hashtable(); /** * keys: path value: Temporary LockedObject from that path */ - protected Hashtable _tempLocks = new Hashtable(); + final Hashtable _tempLocks = new Hashtable(); /** * keys: id value: Temporary LockedObject from that id */ - protected Hashtable _tempLocksByID = new Hashtable(); + final Hashtable _tempLocksByID = new Hashtable(); // REMEMBER TO REMOVE UNUSED LOCKS FROM THE HASHTABLE AS WELL - protected LockedObject _root = null; + final LockedObject _root; - protected LockedObject _tempRoot = null; + final LockedObject _tempRoot; - private boolean _temporary = true; + private final boolean _temporary = true; public ResourceLocks() { _root = new LockedObject(this, "/", true); @@ -177,7 +177,7 @@ public synchronized void unlockTemporaryLockedObjects( } - public void checkTimeouts(ITransaction transaction, boolean temporary) { + public synchronized void checkTimeouts(ITransaction transaction, boolean temporary) { if (!temporary) { Enumeration lockedObjects = _locks.elements(); while (lockedObjects.hasMoreElements()) { diff --git a/src/main/java/net/sf/webdav/methods/DoGet.java b/src/main/java/net/sf/webdav/methods/DoGet.java index dd75a9c..76c8a0e 100644 --- a/src/main/java/net/sf/webdav/methods/DoGet.java +++ b/src/main/java/net/sf/webdav/methods/DoGet.java @@ -66,6 +66,7 @@ protected void doBody(ITransaction transaction, HttpServletResponse resp, while ((read = in.read(copyBuffer, 0, copyBuffer.length)) != -1) { out.write(copyBuffer, 0, read); + out.flush(); } } finally { // flushing causes a IOE if a file is opened on the webserver @@ -110,7 +111,6 @@ protected void folderBody(ITransaction transaction, String path, if (so.isFolder()) { // TODO some folder response (for browsers, DAV tools // use propfind) in html? - Locale locale = req.getLocale(); DateFormat shortDF= getDateTimeFormat(req.getLocale()); resp.setContentType("text/html"); resp.setCharacterEncoding("UTF8"); diff --git a/src/main/java/net/sf/webdav/methods/DoLock.java b/src/main/java/net/sf/webdav/methods/DoLock.java index d5af92f..c2079ba 100644 --- a/src/main/java/net/sf/webdav/methods/DoLock.java +++ b/src/main/java/net/sf/webdav/methods/DoLock.java @@ -44,12 +44,12 @@ public class DoLock extends AbstractMethod { - private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory + private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory .getLogger(DoLock.class); - private IWebdavStore _store; - private IResourceLocks _resourceLocks; - private boolean _readOnly; + private final IWebdavStore _store; + private final IResourceLocks _resourceLocks; + private final boolean _readOnly; private boolean _macLockRequest = false; @@ -69,8 +69,9 @@ public DoLock(IWebdavStore store, IResourceLocks resourceLocks, _readOnly = readOnly; } - public void execute(ITransaction transaction, HttpServletRequest req, - HttpServletResponse resp) throws IOException, LockFailedException { + public synchronized void execute(ITransaction transaction, + HttpServletRequest req, HttpServletResponse resp) + throws IOException, LockFailedException { LOG.trace("-- " + this.getClass().getName()); if (_readOnly) { @@ -80,8 +81,6 @@ public void execute(ITransaction transaction, HttpServletRequest req, _path = getRelativePath(req); _parentPath = getParentPath(getCleanPath(_path)); - Hashtable errorList = new Hashtable(); - if (!checkLocks(transaction, req, resp, _resourceLocks, _path)) { resp.setStatus(WebdavStatus.SC_LOCKED); return; // resource is locked @@ -275,6 +274,7 @@ private void executeLock(ITransaction transaction, HttpServletRequest req, + _userAgent + "'"); doMacLockRequestWorkaround(transaction, req, resp); + _macLockRequest = false; } else { // Getting LockInformation from request if (getLockInformation(transaction, req, resp)) { diff --git a/src/main/java/net/sf/webdav/methods/DoPropfind.java b/src/main/java/net/sf/webdav/methods/DoPropfind.java index f64e9f8..d439994 100644 --- a/src/main/java/net/sf/webdav/methods/DoPropfind.java +++ b/src/main/java/net/sf/webdav/methods/DoPropfind.java @@ -253,10 +253,10 @@ private void parseProperties(ITransaction transaction, StoredObject so = _store.getStoredObject(transaction, path); - boolean isFolder = so.isFolder(); + final boolean isFolder = so.isFolder(); final String creationdate = creationDateFormat(so.getCreationDate()); final String lastModified = lastModifiedDateFormat(so.getLastModified()); - String resourceLength = String.valueOf(so.getResourceLength()); + final String resourceLength = String.valueOf(so.getResourceLength()); // ResourceInfo resourceInfo = new ResourceInfo(path, resources); @@ -302,9 +302,8 @@ private void parseProperties(ITransaction transaction, generatedXML.writeElement("DAV::displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement("DAV::displayname", XMLWriter.CLOSING); + generatedXML.writeProperty("DAV::getlastmodified", lastModified); if (!isFolder) { - generatedXML - .writeProperty("DAV::getlastmodified", lastModified); generatedXML.writeProperty("DAV::getcontentlength", resourceLength); String contentType = mimeType; @@ -345,6 +344,8 @@ private void parseProperties(ITransaction transaction, generatedXML .writeElement("DAV::creationdate", XMLWriter.NO_CONTENT); generatedXML.writeElement("DAV::displayname", XMLWriter.NO_CONTENT); + generatedXML. + writeElement("DAV::getlastmodified", XMLWriter.NO_CONTENT); if (!isFolder) { generatedXML.writeElement("DAV::getcontentlanguage", XMLWriter.NO_CONTENT); @@ -353,8 +354,6 @@ private void parseProperties(ITransaction transaction, generatedXML.writeElement("DAV::getcontenttype", XMLWriter.NO_CONTENT); generatedXML.writeElement("DAV::getetag", XMLWriter.NO_CONTENT); - generatedXML.writeElement("DAV::getlastmodified", - XMLWriter.NO_CONTENT); } generatedXML .writeElement("DAV::resourcetype", XMLWriter.NO_CONTENT); @@ -422,12 +421,8 @@ private void parseProperties(ITransaction transaction, generatedXML.writeProperty("DAV::getetag", getETag(so)); } } else if (property.equals("DAV::getlastmodified")) { - if (isFolder) { - propertiesNotFound.addElement(property); - } else { - generatedXML.writeProperty("DAV::getlastmodified", - lastModified); - } + generatedXML.writeProperty("DAV::getlastmodified", + lastModified); } else if (property.equals("DAV::resourcetype")) { if (isFolder) { generatedXML.writeElement("DAV::resourcetype", diff --git a/src/main/java/net/sf/webdav/methods/DoUnlock.java b/src/main/java/net/sf/webdav/methods/DoUnlock.java index a5fe3c9..487049f 100644 --- a/src/main/java/net/sf/webdav/methods/DoUnlock.java +++ b/src/main/java/net/sf/webdav/methods/DoUnlock.java @@ -15,12 +15,12 @@ public class DoUnlock extends DeterminableMethod { - private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory + private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory .getLogger(DoUnlock.class); - private IWebdavStore _store; - private IResourceLocks _resourceLocks; - private boolean _readOnly; + private final IWebdavStore _store; + private final IResourceLocks _resourceLocks; + private final boolean _readOnly; public DoUnlock(IWebdavStore store, IResourceLocks resourceLocks, boolean readOnly) { @@ -87,7 +87,7 @@ public void execute(ITransaction transaction, HttpServletRequest req, } } } catch (LockFailedException e) { - e.printStackTrace(); + LOG.error("Lockfailed exception", e); } finally { _resourceLocks.unlockTemporaryLockedObjects(transaction, path, tempLockOwner); diff --git a/src/test/java/net/sf/webdav/methods/DoCopyTest.java b/src/test/java/net/sf/webdav/methods/DoCopyTest.java index c27c5a5..57ee803 100644 --- a/src/test/java/net/sf/webdav/methods/DoCopyTest.java +++ b/src/test/java/net/sf/webdav/methods/DoCopyTest.java @@ -1,7 +1,6 @@ package net.sf.webdav.methods; import java.io.ByteArrayInputStream; -import java.io.PrintWriter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -137,8 +136,6 @@ public void testDoCopyIfParentIsLockedWithWrongLockToken() throws Exception { final String wrongLockToken = "()"; - final PrintWriter pw = new PrintWriter("/tmp/XMLTestFile"); - _mockery.checking(new Expectations() { { one(mockReq).getAttribute("javax.servlet.include.request_uri"); @@ -171,13 +168,7 @@ public void testDoCopyIfParentIsLockedWithWrongLockToken() throws Exception { one(mockReq).getHeader("If"); will(returnValue(wrongLockToken)); - one(mockRes).setStatus(WebdavStatus.SC_MULTI_STATUS); - - one(mockReq).getRequestURI(); - will(returnValue("http://foo.bar".concat(destCollectionPath))); - - one(mockRes).getWriter(); - will(returnValue(pw)); + one(mockRes).setStatus(WebdavStatus.SC_LOCKED); } }); @@ -412,11 +403,9 @@ public void testDoCopyFolderIfNoLocks() throws Exception { one(mockReq).getHeader("Depth"); will(returnValue("-1")); - sourceChildren = new String[] { "sourceFile" }; - one(mockStore).getChildrenNames(mockTransaction, sourceCollectionPath); - will(returnValue(sourceChildren)); + will(returnValue(getSourceChildren())); StoredObject sourceFileSo = initFileStoredObject(resourceContent); diff --git a/src/test/java/net/sf/webdav/methods/DoDeleteTest.java b/src/test/java/net/sf/webdav/methods/DoDeleteTest.java index 63c04ec..1d16a9d 100644 --- a/src/test/java/net/sf/webdav/methods/DoDeleteTest.java +++ b/src/test/java/net/sf/webdav/methods/DoDeleteTest.java @@ -1,7 +1,5 @@ package net.sf.webdav.methods; -import java.io.PrintWriter; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -254,8 +252,6 @@ public void testDeleteFileInLockedFolderWithWrongLockToken() final String wrongLockToken = "()"; - final PrintWriter pw = new PrintWriter("/tmp/XMLTestFile"); - _mockery.checking(new Expectations() { { one(mockReq).getAttribute("javax.servlet.include.request_uri"); @@ -267,13 +263,7 @@ public void testDeleteFileInLockedFolderWithWrongLockToken() one(mockReq).getHeader("If"); will(returnValue(wrongLockToken)); - one(mockRes).setStatus(WebdavStatus.SC_MULTI_STATUS); - - one(mockReq).getRequestURI(); - will(returnValue("http://foo.bar".concat(lockedFolderPath))); - - one(mockRes).getWriter(); - will(returnValue(pw)); + one(mockRes).setStatus(WebdavStatus.SC_LOCKED); } }); diff --git a/src/test/java/net/sf/webdav/methods/DoGetTest.java b/src/test/java/net/sf/webdav/methods/DoGetTest.java index 70f12ac..00e492f 100644 --- a/src/test/java/net/sf/webdav/methods/DoGetTest.java +++ b/src/test/java/net/sf/webdav/methods/DoGetTest.java @@ -102,7 +102,7 @@ public void testAccessOfaPageResultsInPage() throws Exception { one(mockRes).addHeader(with(any(String.class)), with(any(String.class))); - one(mockMimeTyper).getMimeType("/index.html"); + one(mockMimeTyper).getMimeType(mockTransaction, "/index.html"); will(returnValue("text/foo")); one(mockRes).setContentType("text/foo"); @@ -156,7 +156,7 @@ public void testAccessOfaDirectoryResultsInRudimentaryChildList() one(mockStore).getStoredObject(mockTransaction, "/foo/"); will(returnValue(fooSo)); - one(mockReq).getLocale(); + atLeast(1).of(mockReq).getLocale(); will(returnValue(Locale.GERMAN)); one(mockRes).setContentType("text/html"); @@ -254,7 +254,7 @@ public void testAccessOfaMissingPageResultsInPossibleAlternatveTo404() one(mockRes).addHeader(with(any(String.class)), with(any(String.class))); - one(mockMimeTyper).getMimeType("/alternative"); + one(mockMimeTyper).getMimeType(mockTransaction, "/alternative"); will(returnValue("text/foo")); one(mockRes).setContentType("text/foo"); diff --git a/src/test/java/net/sf/webdav/methods/DoHeadTest.java b/src/test/java/net/sf/webdav/methods/DoHeadTest.java index 7575102..620892e 100644 --- a/src/test/java/net/sf/webdav/methods/DoHeadTest.java +++ b/src/test/java/net/sf/webdav/methods/DoHeadTest.java @@ -88,7 +88,7 @@ public void testAccessOfaPageResultsInPage() throws Exception { one(mockRes).addHeader(with(any(String.class)), with(any(String.class))); - one(mockMimeTyper).getMimeType("/index.html"); + one(mockMimeTyper).getMimeType(mockTransaction, "/index.html"); will(returnValue("text/foo")); one(mockRes).setContentType("text/foo"); diff --git a/src/test/java/net/sf/webdav/methods/DoMoveTest.java b/src/test/java/net/sf/webdav/methods/DoMoveTest.java index d79d365..38411d9 100644 --- a/src/test/java/net/sf/webdav/methods/DoMoveTest.java +++ b/src/test/java/net/sf/webdav/methods/DoMoveTest.java @@ -408,7 +408,6 @@ public void testMovingIfSourcePathEqualsDestinationPath() throws Exception { @Test public void testMovingOfaCollectionIfDestinationIsNotPresent() throws Exception { - _mockery.checking(new Expectations() { { one(mockReq).getAttribute("javax.servlet.include.request_uri"); @@ -465,11 +464,9 @@ public void testMovingOfaCollectionIfDestinationIsNotPresent() one(mockReq).getHeader("Depth"); will(returnValue(null)); - String[] sourceChildren = new String[] { "sourceFile" }; - one(mockStore).getChildrenNames(mockTransaction, sourceCollectionPath); - will(returnValue(sourceChildren)); + will(returnValue(getSourceChildren())); StoredObject sourceFileSo = initFileStoredObject(resourceContent); @@ -500,11 +497,9 @@ public void testMovingOfaCollectionIfDestinationIsNotPresent() sourceCollectionPath); will(returnValue(sourceCollectionSo)); - sourceChildren = new String[] { "sourceFile" }; - one(mockStore).getChildrenNames(mockTransaction, sourceCollectionPath); - will(returnValue(sourceChildren)); + will(returnValue(getSourceChildren())); one(mockStore).getStoredObject(mockTransaction, sourceFilePath); will(returnValue(sourceFileSo)); @@ -643,7 +638,7 @@ public void testMovingOfaCollectionIfDestinationIsPresentAndOverwriteTrue() will(returnValue(destCollectionSo)); one(mockStore).getChildrenNames(mockTransaction, overwritePath); - will(returnValue(destChildren)); + will(returnValue(getDestChildren())); StoredObject destFileSo = initFileStoredObject(resourceContent); @@ -667,7 +662,7 @@ public void testMovingOfaCollectionIfDestinationIsPresentAndOverwriteTrue() one(mockStore).getChildrenNames(mockTransaction, sourceCollectionPath); - will(returnValue(sourceChildren)); + will(returnValue(getSourceChildren())); StoredObject sourceFileSo = initFileStoredObject(resourceContent); @@ -696,11 +691,10 @@ public void testMovingOfaCollectionIfDestinationIsPresentAndOverwriteTrue() sourceCollectionPath); will(returnValue(sourceCollectionSo)); - sourceChildren = new String[] { "sourceFile" }; - - one(mockStore).getChildrenNames(mockTransaction, - sourceCollectionPath); - will(returnValue(sourceChildren)); + one(mockStore).getChildrenNames( + mockTransaction, sourceCollectionPath + ); + will(returnValue(getSourceChildren())); one(mockStore).getStoredObject(mockTransaction, sourceFilePath); will(returnValue(sourceFileSo)); diff --git a/src/test/java/net/sf/webdav/methods/DoPropfindTest.java b/src/test/java/net/sf/webdav/methods/DoPropfindTest.java index 8654d94..5b9113d 100644 --- a/src/test/java/net/sf/webdav/methods/DoPropfindTest.java +++ b/src/test/java/net/sf/webdav/methods/DoPropfindTest.java @@ -73,7 +73,7 @@ public void doPropFindOnDirectory() throws Exception { one(mockRes).getWriter(); will(returnValue(printWriter)); - one(mockMimeTyper).getMimeType(path); + one(mockMimeTyper).getMimeType(mockTransaction, path); will(returnValue("text/xml; charset=UTF-8")); one(mockStore).getStoredObject(mockTransaction, path); @@ -164,7 +164,7 @@ public void doPropFindOnFile() throws Exception { one(mockRes).getWriter(); will(returnValue(printWriter)); - one(mockMimeTyper).getMimeType(path); + one(mockMimeTyper).getMimeType(mockTransaction, path); will(returnValue("text/xml; charset=UTF-8")); one(mockStore).getStoredObject(mockTransaction, path); diff --git a/src/test/java/net/sf/webdav/methods/DoProppatchTest.java b/src/test/java/net/sf/webdav/methods/DoProppatchTest.java index e01b6fe..53625b2 100644 --- a/src/test/java/net/sf/webdav/methods/DoProppatchTest.java +++ b/src/test/java/net/sf/webdav/methods/DoProppatchTest.java @@ -105,6 +105,9 @@ public void doProppatchOnRequestWithNoContent() throws Exception { one(mockStore).getStoredObject(mockTransaction, path); will(returnValue(testFileSo)); + one(mockReq).getHeader("If"); + will(returnValue(null)); + one(mockReq).getAttribute("javax.servlet.include.request_uri"); will(returnValue(null)); @@ -145,6 +148,9 @@ public void doProppatchOnResource() throws Exception { one(mockStore).getStoredObject(mockTransaction, path); will(returnValue(testFileSo)); + one(mockReq).getHeader("If"); + will(returnValue(null)); + one(mockReq).getAttribute("javax.servlet.include.request_uri"); will(returnValue(null)); diff --git a/src/test/java/net/sf/webdav/methods/DoPutTest.java b/src/test/java/net/sf/webdav/methods/DoPutTest.java index 4a718d1..67ad900 100644 --- a/src/test/java/net/sf/webdav/methods/DoPutTest.java +++ b/src/test/java/net/sf/webdav/methods/DoPutTest.java @@ -110,8 +110,6 @@ public void testDoPutIfReadOnlyFalse() throws Exception { @Test public void testDoPutIfLazyFolderCreationOnPutIsFalse() throws Exception { - final PrintWriter pw = new PrintWriter("/tmp/XMLTestFile"); - _mockery.checking(new Expectations() { { one(mockReq).getAttribute("javax.servlet.include.request_uri"); @@ -128,13 +126,9 @@ public void testDoPutIfLazyFolderCreationOnPutIsFalse() throws Exception { one(mockStore).getStoredObject(mockTransaction, parentPath); will(returnValue(parentSo)); - one(mockRes).setStatus(WebdavStatus.SC_MULTI_STATUS); - - one(mockReq).getRequestURI(); - will(returnValue("http://foo.bar".concat(path))); - - one(mockRes).getWriter(); - will(returnValue(pw)); + one(mockRes).sendError( + WebdavStatus.SC_NOT_FOUND, WebdavStatus.getStatusText(WebdavStatus.SC_NOT_FOUND) + ); } }); diff --git a/src/test/java/net/sf/webdav/testutil/MockTest.java b/src/test/java/net/sf/webdav/testutil/MockTest.java index eeefcbc..d2ed259 100644 --- a/src/test/java/net/sf/webdav/testutil/MockTest.java +++ b/src/test/java/net/sf/webdav/testutil/MockTest.java @@ -1,6 +1,7 @@ package net.sf.webdav.testutil; import java.io.ByteArrayInputStream; +import java.util.Arrays; import java.util.Date; import junit.framework.Assert; @@ -70,8 +71,8 @@ public abstract class MockTest extends Assert { protected static String overwritePath = destCollectionPath + "/sourceFolder"; - protected static String[] sourceChildren = new String[] { "sourceFile" }; - protected static String[] destChildren = new String[] { "destFile" }; + private static final String[] sourceChildren = new String[] { "sourceFile" }; + private static final String[] destChildren = new String[] { "destFile" }; @After public final void assertSatisfiedMockery() throws Exception { @@ -136,4 +137,12 @@ public static LockedObject initLockNullLockedObject(ResourceLocks resLocks, return lo; } + + protected static String[] getSourceChildren() { + return Arrays.copyOf(sourceChildren, sourceChildren.length); + } + + protected static String[] getDestChildren() { + return Arrays.copyOf(destChildren, destChildren.length); + } }