Skip to content

Commit add2876

Browse files
committed
3.1.2208
1 parent b25f7f0 commit add2876

File tree

20 files changed

+72
-64
lines changed

20 files changed

+72
-64
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ WebDAV server with file system back-end storage is a fully functional Class 2 se
3030
## WebDAV Server with Versioning Example
3131
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/)
3232

33-
## Android WebDAV Server on NanoHTTPD Example
34-
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.
33+
## Android WebDAV Server Example
34+
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.
3535
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.
36-
To build example execute **buildAndroid.bat** or **buildAndroid** in the root folder.
36+
To build example execute **buildAndroid.bat** or **buildAndroid** in the root folder. [more...](https://www.webdavsystem.com/javaserver/server_examples/android/)

androidfsstorage/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ android {
2323
jarJar {
2424
rules = [
2525
'stax-api-1.0.1.jar': 'javax.xml.** com.ithit.webdav.xml.@1',
26-
'webdav-server-3.0.2101.jar': 'javax.xml.stream.** com.ithit.webdav.xml.stream.@1'
26+
'webdav-server-3.1.2208.jar': 'javax.xml.stream.** com.ithit.webdav.xml.stream.@1'
2727
]
2828
}
2929

@@ -38,11 +38,11 @@ dependencies {
3838
compile 'commons-io:commons-io:2.4'
3939
compile 'com.google.code.gson:gson:2.7'
4040
compile 'com.android.support:appcompat-v7:26.+'
41-
compile ('com.ithit.webdav.integration:android-integration:3.0.2101', {
41+
compile ('com.ithit.webdav.integration:android-integration:3.1.2208', {
4242
exclude group: 'org.nanohttpd', module: 'nanohttpd'
4343
})
4444
compile 'com.android.support.constraint:constraint-layout:1.0.2'
4545
jarJar 'stax:stax-api:1.0.1'
46-
jarJar 'com.ithit.webdav:webdav-server:3.0.2101'
46+
jarJar 'com.ithit.webdav:webdav-server:3.1.2208'
4747
testCompile 'junit:junit:4.12'
4848
}

androidfsstorage/app/src/main/assets/MyCustomHandlerPage.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,13 @@ <h3>Connect with WebDAV Client</h3>
326326
<script src="https://cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.11.1/typeahead.jquery.min.js"></script>
327327
<script>
328328
function OpenAjaxFileBrowserWindow() {
329-
window.open("afb/AjaxFileBrowser.html", "", "menubar=1,location=1,status=1,scrollbars=1,resizable=1,width=900,height=600");
329+
window.open("wwwroot/AjaxFileBrowser.html", "", "menubar=1,location=1,status=1,scrollbars=1,resizable=1,width=900,height=600");
330330
}
331331

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

338338
(function () {
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import android.app.Service;
44
import android.content.Intent;
55

6-
import com.ithit.webdav.integration.android.AndroidLoggingContext;
76
import com.ithit.webdav.samples.androidfsstorage.android.NanoBroadcastReceiver;
7+
import com.ithit.webdav.server.Logger;
88

99
/**
1010
* Represents logging messages to the application view on devices, running Android.
1111
*/
12-
public class AndroidLogContext extends AndroidLoggingContext {
12+
public class AndroidNanoLogger implements Logger {
1313

1414
/**
1515
* Logging intent service.
@@ -20,7 +20,7 @@ public class AndroidLogContext extends AndroidLoggingContext {
2020
* Creates new instance of this class.
2121
* @param intentService Logging intent service.
2222
*/
23-
public AndroidLogContext(Service intentService) {
23+
public AndroidNanoLogger(Service intentService) {
2424
this.intentService = intentService;
2525
}
2626

@@ -29,7 +29,7 @@ public AndroidLogContext(Service intentService) {
2929
* @param message Text message.
3030
*/
3131
@Override
32-
public void log(String message) {
32+
public void logDebug(String message) {
3333
Intent broadcastIntent = new Intent(NanoBroadcastReceiver.LOG_OUTPUT);
3434
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
3535
broadcastIntent.putExtra("message", message);
@@ -42,7 +42,7 @@ public void log(String message) {
4242
* @param throwable Error.
4343
*/
4444
@Override
45-
public void log(String message, Throwable throwable) {
45+
public void logError(String message, Throwable throwable) {
4646
Intent broadcastIntent = new Intent(NanoBroadcastReceiver.LOG_OUTPUT);
4747
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
4848
StringBuilder trace = new StringBuilder();
@@ -52,4 +52,9 @@ public void log(String message, Throwable throwable) {
5252
broadcastIntent.putExtra("message", message + "\n\n" + trace);
5353
intentService.sendBroadcast(broadcastIntent);
5454
}
55+
56+
@Override
57+
public boolean isDebugEnabled() {
58+
return true;
59+
}
5560
}

androidfsstorage/app/src/main/java/com/ithit/webdav/samples/androidfsstorage/CustomFolderGetHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public void processRequest(DavRequest request, DavResponse response, HierarchyIt
5555
}
5656
stream.flush();
5757
} else {
58-
if (request.getRequestURI().contains("afb/AjaxIntegrationTests.html")) {
58+
if (request.getRequestURI().contains("wwwroot/AjaxIntegrationTests.html")) {
5959
PrintStream stream = new PrintStream(response.getOutputStream(), true, charset);
6060
response.setCharacterEncoding(charset);
6161
response.setContentType("text/html");
6262
for (String line: testPage) {
6363
stream.println(line);
6464
}
6565
stream.flush();
66-
} else if (request.getRequestURI().contains("afb/AjaxFileBrowser.html")) {
66+
} else if (request.getRequestURI().contains("wwwroot/AjaxFileBrowser.html")) {
6767
PrintStream stream = new PrintStream(response.getOutputStream(), true, charset);
6868
response.setCharacterEncoding(charset);
6969
response.setContentType("text/html");

androidfsstorage/app/src/main/java/com/ithit/webdav/samples/androidfsstorage/HierarchyItemImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.ithit.webdav.samples.androidfsstorage;
22

33
import com.ithit.webdav.samples.androidfsstorage.extendedattributes.ExtendedAttributesExtension;
4-
import com.ithit.webdav.server.Engine;
54
import com.ithit.webdav.server.Folder;
65
import com.ithit.webdav.server.HierarchyItem;
76
import com.ithit.webdav.server.Lock;
@@ -279,7 +278,7 @@ private boolean clientHasToken() throws ServerException {
279278
if (activeLocks.size() == 0) {
280279
return true;
281280
}
282-
List<String> clientLockTokens = Engine.getClientLockTokens(getEngine().getRequest());
281+
List<String> clientLockTokens = getEngine().getRequest().getClientLockTokens();
283282
for (LockInfo lockInfo: activeLocks) {
284283
if (clientLockTokens.contains(lockInfo.getToken())) {
285284
return true;

androidfsstorage/app/src/main/java/com/ithit/webdav/samples/androidfsstorage/android/AndroidConfigurationHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ private void fillConfigMap(String jsonString) {
3838
}
3939

4040
private String readConfig(AssetManager assetManager, String jsonFileName) {
41-
String jsonString = "";
41+
StringBuilder jsonString = new StringBuilder();
4242
try {
4343
List<String> jsonLines = IOUtils.readLines(assetManager.open(jsonFileName));
4444

4545
for (String s: jsonLines) {
46-
jsonString += s;
46+
jsonString.append(s);
4747
}
4848
} catch (IOException ignored) {
4949
}
50-
return jsonString;
50+
return jsonString.toString();
5151
}
5252

5353

androidfsstorage/app/src/main/java/com/ithit/webdav/samples/androidfsstorage/android/NanoIntentService.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
import android.os.IBinder;
88
import android.util.Log;
99

10-
import com.ithit.webdav.samples.androidfsstorage.AndroidLogContext;
10+
import com.ithit.webdav.samples.androidfsstorage.AndroidNanoLogger;
1111
import com.ithit.webdav.samples.androidfsstorage.AndroidWebDavServer;
1212
import com.ithit.webdav.samples.androidfsstorage.Config;
13-
import com.ithit.webdav.server.DefaultLoggerImpl;
1413
import com.ithit.webdav.server.Logger;
1514

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

4140
@Override
4241
public int onStartCommand(Intent intent, int flags, int startId) {
43-
Logger logger = new DefaultLoggerImpl(new AndroidLogContext(this));
42+
Logger logger = new AndroidNanoLogger(this);
4443

4544
InputStream getPage = null;
4645
InputStream errorPage = null;
@@ -49,8 +48,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
4948
try {
5049
getPage = getApplicationContext().getAssets().open("MyCustomHandlerPage.html");
5150
errorPage = getApplicationContext().getAssets().open("attributesErrorPage.html");
52-
testPage = getApplicationContext().getAssets().open("afb/AjaxIntegrationTests.html");
53-
browserPage = getApplicationContext().getAssets().open("afb/AjaxFileBrowser.html");
51+
testPage = getApplicationContext().getAssets().open("wwwroot/AjaxIntegrationTests.html");
52+
browserPage = getApplicationContext().getAssets().open("wwwroot/AjaxFileBrowser.html");
5453
List<String> getPageLines = IOUtils.readLines(getPage, StandardCharsets.UTF_8);
5554
List<String> errorPageLines = IOUtils.readLines(errorPage, StandardCharsets.UTF_8);
5655
List<String> testPageLines = IOUtils.readLines(testPage, StandardCharsets.UTF_8);

0 commit comments

Comments
 (0)