Skip to content

Commit

Permalink
3.1.2208
Browse files Browse the repository at this point in the history
  • Loading branch information
ITHitBuild committed Dec 14, 2017
1 parent b25f7f0 commit add2876
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 64 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ WebDAV server with file system back-end storage is a fully functional Class 2 se
## WebDAV Server with Versioning Example
This example demonstrates how you can implement file versioning support in your WebDAV server. It is using auto-versioning and each time you save a file the new version is created. Your client application does not need to know anything about versioning support on a server side. While capable of handling any WebDAV clients, this DeltaV sample is optimized to work with Microsoft Office. It is using Lock/Unlock commands to minimize an amount of versions created. [more...](https://www.webdavsystem.com/javaserver/server_examples/deltav_storage/)

## Android WebDAV Server on NanoHTTPD Example
A modified NanoHTTPD mobile WebDAV server that runs on Android. It stores all files in mobile device file system while locks and properties in SQLite. This sample provides access to the documents inside a mobile app folder. To see the documents a user opens a sample web page served by this server in a web browser on any machine in the local network. A user can open, edit and save documents back to the mobile device as well as can upload, download and manage documents using any WebDAV client. The sample requires license.
## Android WebDAV Server Example
A mobile WebDAV server that runs on Android on modified NanoHTTPD server. It stores all files in mobile device file system while locks and properties in SQLite. This sample provides access to the documents inside a mobile app folder. To see the documents a user opens a sample web page served by this server in a web browser on any machine in the local network. A user can open, edit and save documents back to the mobile device as well as can upload, download and manage documents using any WebDAV client. The sample requires license.
Its text should be added to the **webdavsettings.json** file (see **assets** folder) in the **License** section. Please change all double quotes to single quotes in the license text or remove **xml** header.
To build example execute **buildAndroid.bat** or **buildAndroid** in the root folder.
To build example execute **buildAndroid.bat** or **buildAndroid** in the root folder. [more...](https://www.webdavsystem.com/javaserver/server_examples/android/)
6 changes: 3 additions & 3 deletions androidfsstorage/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
jarJar {
rules = [
'stax-api-1.0.1.jar': 'javax.xml.** com.ithit.webdav.xml.@1',
'webdav-server-3.0.2101.jar': 'javax.xml.stream.** com.ithit.webdav.xml.stream.@1'
'webdav-server-3.1.2208.jar': 'javax.xml.stream.** com.ithit.webdav.xml.stream.@1'
]
}

Expand All @@ -38,11 +38,11 @@ dependencies {
compile 'commons-io:commons-io:2.4'
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support:appcompat-v7:26.+'
compile ('com.ithit.webdav.integration:android-integration:3.0.2101', {
compile ('com.ithit.webdav.integration:android-integration:3.1.2208', {
exclude group: 'org.nanohttpd', module: 'nanohttpd'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
jarJar 'stax:stax-api:1.0.1'
jarJar 'com.ithit.webdav:webdav-server:3.0.2101'
jarJar 'com.ithit.webdav:webdav-server:3.1.2208'
testCompile 'junit:junit:4.12'
}
4 changes: 2 additions & 2 deletions androidfsstorage/app/src/main/assets/MyCustomHandlerPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,13 @@ <h3>Connect with WebDAV Client</h3>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.11.1/typeahead.jquery.min.js"></script>
<script>
function OpenAjaxFileBrowserWindow() {
window.open("afb/AjaxFileBrowser.html", "", "menubar=1,location=1,status=1,scrollbars=1,resizable=1,width=900,height=600");
window.open("wwwroot/AjaxFileBrowser.html", "", "menubar=1,location=1,status=1,scrollbars=1,resizable=1,width=900,height=600");
}

function OpenTestsWindow() {
var width = Math.round(screen.width * 0.5);
var height = Math.round(screen.height * 0.8);
window.open("afb/AjaxIntegrationTests.html", "", "menubar=1,location=1,status=1,scrollbars=1,resizable=1,width=" + width + ",height=" + height);
window.open("wwwroot/AjaxIntegrationTests.html", "", "menubar=1,location=1,status=1,scrollbars=1,resizable=1,width=" + width + ",height=" + height);
}

(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import android.app.Service;
import android.content.Intent;

import com.ithit.webdav.integration.android.AndroidLoggingContext;
import com.ithit.webdav.samples.androidfsstorage.android.NanoBroadcastReceiver;
import com.ithit.webdav.server.Logger;

/**
* Represents logging messages to the application view on devices, running Android.
*/
public class AndroidLogContext extends AndroidLoggingContext {
public class AndroidNanoLogger implements Logger {

/**
* Logging intent service.
Expand All @@ -20,7 +20,7 @@ public class AndroidLogContext extends AndroidLoggingContext {
* Creates new instance of this class.
* @param intentService Logging intent service.
*/
public AndroidLogContext(Service intentService) {
public AndroidNanoLogger(Service intentService) {
this.intentService = intentService;
}

Expand All @@ -29,7 +29,7 @@ public AndroidLogContext(Service intentService) {
* @param message Text message.
*/
@Override
public void log(String message) {
public void logDebug(String message) {
Intent broadcastIntent = new Intent(NanoBroadcastReceiver.LOG_OUTPUT);
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
broadcastIntent.putExtra("message", message);
Expand All @@ -42,7 +42,7 @@ public void log(String message) {
* @param throwable Error.
*/
@Override
public void log(String message, Throwable throwable) {
public void logError(String message, Throwable throwable) {
Intent broadcastIntent = new Intent(NanoBroadcastReceiver.LOG_OUTPUT);
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
StringBuilder trace = new StringBuilder();
Expand All @@ -52,4 +52,9 @@ public void log(String message, Throwable throwable) {
broadcastIntent.putExtra("message", message + "\n\n" + trace);
intentService.sendBroadcast(broadcastIntent);
}

@Override
public boolean isDebugEnabled() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public void processRequest(DavRequest request, DavResponse response, HierarchyIt
}
stream.flush();
} else {
if (request.getRequestURI().contains("afb/AjaxIntegrationTests.html")) {
if (request.getRequestURI().contains("wwwroot/AjaxIntegrationTests.html")) {
PrintStream stream = new PrintStream(response.getOutputStream(), true, charset);
response.setCharacterEncoding(charset);
response.setContentType("text/html");
for (String line: testPage) {
stream.println(line);
}
stream.flush();
} else if (request.getRequestURI().contains("afb/AjaxFileBrowser.html")) {
} else if (request.getRequestURI().contains("wwwroot/AjaxFileBrowser.html")) {
PrintStream stream = new PrintStream(response.getOutputStream(), true, charset);
response.setCharacterEncoding(charset);
response.setContentType("text/html");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ithit.webdav.samples.androidfsstorage;

import com.ithit.webdav.samples.androidfsstorage.extendedattributes.ExtendedAttributesExtension;
import com.ithit.webdav.server.Engine;
import com.ithit.webdav.server.Folder;
import com.ithit.webdav.server.HierarchyItem;
import com.ithit.webdav.server.Lock;
Expand Down Expand Up @@ -279,7 +278,7 @@ private boolean clientHasToken() throws ServerException {
if (activeLocks.size() == 0) {
return true;
}
List<String> clientLockTokens = Engine.getClientLockTokens(getEngine().getRequest());
List<String> clientLockTokens = getEngine().getRequest().getClientLockTokens();
for (LockInfo lockInfo: activeLocks) {
if (clientLockTokens.contains(lockInfo.getToken())) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ private void fillConfigMap(String jsonString) {
}

private String readConfig(AssetManager assetManager, String jsonFileName) {
String jsonString = "";
StringBuilder jsonString = new StringBuilder();
try {
List<String> jsonLines = IOUtils.readLines(assetManager.open(jsonFileName));

for (String s: jsonLines) {
jsonString += s;
jsonString.append(s);
}
} catch (IOException ignored) {
}
return jsonString;
return jsonString.toString();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import android.os.IBinder;
import android.util.Log;

import com.ithit.webdav.samples.androidfsstorage.AndroidLogContext;
import com.ithit.webdav.samples.androidfsstorage.AndroidNanoLogger;
import com.ithit.webdav.samples.androidfsstorage.AndroidWebDavServer;
import com.ithit.webdav.samples.androidfsstorage.Config;
import com.ithit.webdav.server.DefaultLoggerImpl;
import com.ithit.webdav.server.Logger;

import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -40,7 +39,7 @@ public NanoIntentService() {}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Logger logger = new DefaultLoggerImpl(new AndroidLogContext(this));
Logger logger = new AndroidNanoLogger(this);

InputStream getPage = null;
InputStream errorPage = null;
Expand All @@ -49,8 +48,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
try {
getPage = getApplicationContext().getAssets().open("MyCustomHandlerPage.html");
errorPage = getApplicationContext().getAssets().open("attributesErrorPage.html");
testPage = getApplicationContext().getAssets().open("afb/AjaxIntegrationTests.html");
browserPage = getApplicationContext().getAssets().open("afb/AjaxFileBrowser.html");
testPage = getApplicationContext().getAssets().open("wwwroot/AjaxIntegrationTests.html");
browserPage = getApplicationContext().getAssets().open("wwwroot/AjaxFileBrowser.html");
List<String> getPageLines = IOUtils.readLines(getPage, StandardCharsets.UTF_8);
List<String> errorPageLines = IOUtils.readLines(errorPage, StandardCharsets.UTF_8);
List<String> testPageLines = IOUtils.readLines(testPage, StandardCharsets.UTF_8);
Expand Down
4 changes: 3 additions & 1 deletion androidfsstorage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

buildscript {
repositories {
mavenLocal()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'ru.tinkoff.gradle:jarjar:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,6 +16,7 @@ buildscript {

allprojects {
repositories {
mavenLocal()
jcenter()
}
}
Expand Down
15 changes: 8 additions & 7 deletions deltav/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ithit.webdav.samples</groupId>
<artifactId>deltav</artifactId>
<version>3.0.2114</version>
<version>3.1.2208</version>
<packaging>war</packaging>

<properties>
Expand All @@ -23,7 +23,7 @@
<dependency>
<groupId>com.ithit.webdav.integration</groupId>
<artifactId>servlet-integration</artifactId>
<version>3.0.2114</version>
<version>3.1.2208</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
Expand Down Expand Up @@ -93,7 +93,7 @@
<dependency>
<groupId>com.ithit.webdav</groupId>
<artifactId>webdav-server</artifactId>
<version>3.0.2114</version>
<version>3.1.2208</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -133,7 +133,7 @@
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/deltav-3.0.2114/META-INF</outputDirectory>
<outputDirectory>${project.build.directory}/deltav-3.1.2208/META-INF</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
Expand Down Expand Up @@ -212,7 +212,7 @@
<server>filesystem</server>
<port>11021</port>
<path>/</path>
<warSourceDirectory>target/deltav-3.0.2114</warSourceDirectory>
<warSourceDirectory>target/deltav-3.1.2208</warSourceDirectory>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -251,7 +251,6 @@
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<escapeString>\</escapeString>
<installDirectory>${java.io.tmpdir}</installDirectory>
<nodeVersion>v4.6.0</nodeVersion>
</configuration>
Expand All @@ -263,13 +262,15 @@
</goals>
<phase>generate-resources</phase>
<configuration>
<escapeString>\</escapeString>
<arguments>install</arguments>
<workingDirectory>src/main/webapp/WEB-INF/wwwroot</workingDirectory>
<installDirectory>${java.io.tmpdir}</installDirectory>
</configuration>
</execution>
</executions>
<configuration>
<escapeString>\</escapeString>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ boolean clientHasToken() throws ServerException {
List<LockInfo> itemLocks = getActiveLocks();
if (itemLocks.size() == 0)
return true;
List<String> clientLockTokens = Engine.getClientLockTokens(getEngine().getRequest());
List<String> clientLockTokens = getEngine().getRequest().getClientLockTokens();
for (String clientLockToken : clientLockTokens)
for (LockInfo itemLock : itemLocks)
if (clientLockToken.equals(itemLock.getToken()))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.ithit.webdav.samples.deltavservlet;

import com.ithit.webdav.integration.servlet.HttpDavLoggingContext;
import com.ithit.webdav.integration.servlet.HttpServletDavRequest;
import com.ithit.webdav.integration.servlet.HttpServletDavResponse;
import com.ithit.webdav.server.DefaultLoggerImpl;
import com.ithit.webdav.integration.servlet.HttpServletLoggerImpl;
import com.ithit.webdav.server.Engine;
import com.ithit.webdav.server.Logger;
import com.ithit.webdav.server.MimeType;
import com.ithit.webdav.server.deltav.AutoVersion;
Expand Down Expand Up @@ -89,7 +89,7 @@ static String getContext() {
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);

logger = new DefaultLoggerImpl(new HttpDavLoggingContext(servletConfig.getServletContext()));
logger = new HttpServletLoggerImpl(servletConfig.getServletContext());

String licenseFile = servletConfig.getInitParameter("license");
resourcePath = servletConfig.getInitParameter("resources");
Expand Down Expand Up @@ -148,8 +148,8 @@ protected void service(HttpServletRequest httpServletRequest, HttpServletRespons
}
HttpServletDavRequest davRequest = new HttpServletDavRequest(httpServletRequest);
HttpServletDavResponse davResponse = new HttpServletDavResponse(httpServletResponse);
CustomFolderGetHandler handler = new CustomFolderGetHandler(engine.getResponseCharacterEncoding(), engine.getVersion());
CustomFolderGetHandler handlerHead = new CustomFolderGetHandler(engine.getResponseCharacterEncoding(), engine.getVersion());
CustomFolderGetHandler handler = new CustomFolderGetHandler(engine.getResponseCharacterEncoding(), Engine.getVersion());
CustomFolderGetHandler handlerHead = new CustomFolderGetHandler(engine.getResponseCharacterEncoding(), Engine.getVersion());
handler.setPreviousHandler(engine.registerMethodHandler("GET", handler));
handlerHead.setPreviousHandler(engine.registerMethodHandler("HEAD", handlerHead));

Expand Down
13 changes: 7 additions & 6 deletions filesystemstorage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ithit.webdav.samples</groupId>
<artifactId>filesystemstorage</artifactId>
<version>3.0.2114</version>
<version>3.1.2208</version>
<packaging>war</packaging>

<properties>
Expand Down Expand Up @@ -36,7 +36,7 @@
<dependency>
<groupId>com.ithit.webdav.integration</groupId>
<artifactId>servlet-integration</artifactId>
<version>3.0.2114</version>
<version>3.1.2208</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down Expand Up @@ -112,7 +112,7 @@
<dependency>
<groupId>com.ithit.webdav</groupId>
<artifactId>webdav-server</artifactId>
<version>3.0.2114</version>
<version>3.1.2208</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
Expand Down Expand Up @@ -198,7 +198,7 @@
<server>filesystem</server>
<port>11021</port>
<path>/</path>
<warSourceDirectory>target/filesystemstorage-3.0.2114</warSourceDirectory>
<warSourceDirectory>target/filesystemstorage-3.1.2208</warSourceDirectory>
</configuration>
</plugin>
<plugin>
Expand All @@ -212,7 +212,6 @@
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<escapeString>\</escapeString>
<installDirectory>${java.io.tmpdir}</installDirectory>
<nodeVersion>v4.6.0</nodeVersion>
</configuration>
Expand All @@ -224,13 +223,15 @@
</goals>
<phase>generate-resources</phase>
<configuration>
<escapeString>\</escapeString>
<arguments>install</arguments>
<workingDirectory>src/main/webapp/WEB-INF/wwwroot</workingDirectory>
<installDirectory>${java.io.tmpdir}</installDirectory>
</configuration>
</execution>
</executions>
<configuration>
<escapeString>\</escapeString>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private boolean clientHasToken() throws ServerException {
if (activeLocks.size() == 0) {
return true;
}
List<String> clientLockTokens = Engine.getClientLockTokens(getEngine().getRequest());
List<String> clientLockTokens = getEngine().getRequest().getClientLockTokens();
return !activeLocks.stream().filter(x -> clientLockTokens.contains(x.getToken())).collect(Collectors.toList()).isEmpty();
}

Expand Down
Loading

0 comments on commit add2876

Please sign in to comment.