Skip to content

Commit 88f9e4c

Browse files
committed
6.2.9080-Beta
1 parent 5056681 commit 88f9e4c

37 files changed

Lines changed: 826 additions & 186 deletions

File tree

Java/androidfsstorage/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ android {
3434
jarJar {
3535
rules = [
3636
'stax-api-1.0.1.jar' : 'javax.xml.** com.ithit.webdav.xml.@1',
37-
'webdav-server-6.1.7907-Beta.jar': 'javax.xml.stream.** com.ithit.webdav.xml.stream.@1'
37+
'webdav-server-6.2.9080-Beta.jar': 'javax.xml.stream.** com.ithit.webdav.xml.stream.@1'
3838
]
3939
}
4040

@@ -75,11 +75,11 @@ dependencies {
7575
implementation 'commons-io:commons-io:2.7'
7676
implementation 'com.google.code.gson:gson:2.8.9'
7777
implementation 'com.android.support:appcompat-v7:27.1.1'
78-
implementation('com.ithit.webdav.integration:android-integration:6.1.7907-Beta', {
78+
implementation('com.ithit.webdav.integration:android-integration:6.2.9080-Beta', {
7979
exclude group: 'org.nanohttpd', module: 'nanohttpd'
8080
})
8181
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
8282
jarJar 'stax:stax-api:1.0.1'
83-
jarJar 'com.ithit.webdav:webdav-server:6.1.7907-Beta'
83+
jarJar 'com.ithit.webdav:webdav-server:6.2.9080-Beta'
8484
testImplementation 'junit:junit:4.12'
8585
}

Java/androidfsstorage/app/src/main/java/com/ithit/webdav/samples/androidfsstorage/FolderImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,20 @@ public FileImpl createFile(String name) throws LockedException, ServerException
103103
* Creates new {@link FolderImpl} folder with the specified name in this folder.
104104
*
105105
* @param name Name of the folder to create.
106+
* @return Instance of newly created Folder.
106107
* @throws LockedException This folder was locked. Client did not provide the lock token.
107108
* @throws ServerException In case of an error.
108109
*/
109110
@Override
110-
public void createFolder(String name) throws LockedException,
111+
public Folder createFolder(String name) throws LockedException,
111112
ServerException {
112113
ensureHasToken();
113114

114115
File fullPath = FileUtils.getFile(this.getFullPath(), name);
115116
if (!fullPath.exists()) {
116117
fullPath.mkdir();
117118
}
119+
return FolderImpl.getFolder(getPath() + encode(name), getEngine());
118120
}
119121

120122
/**

Java/collectionsync/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
<h1 class="d-xl-block d-none">WebDAV Server Example with Collection Synchronization support</h1>
3+
<p><span>This sample&nbsp;is a fully functional Class 2 WebDAV server that stores all data in the file system. It supports collection synchronization as per RFC 6578. The&nbsp;<a title="AJAX Library" href="https://www.webdavsystem.com/ajax/">IT Hit WebDAV Ajax Library</a>&nbsp;is used to display and browse server content on a default web page as well as to open documents for editing from a web page and save back directly to the server. It is provided in Java and Kotlin, with identical functionality.</span></p>
4+
<h2>Requirements</h2>
5+
<ul>
6+
<li>Java 1.8.</li>
7+
<li>Apache Tomcat 7.0+ or GlassFish v4.1.1+ or&nbsp;WebLogic 12c+ or JBoss WildFly 9+ or WebSphere&nbsp;16.0.0.2+.</li>
8+
<li>Windows OS</li>
9+
<li>NTFS</li>
10+
</ul>
11+
<p>You will also need the&nbsp;<a title="AJAX Library" href="https://www.webdavsystem.com/ajax/">IT Hit WebDAV Ajax Library</a>&nbsp;to display JavaScript UI on a default web page. You can install it from NPM using NPM command line tool, see below. Node.js is <strong>ONLY</strong> required to download the JavaScript files used in the project. Node.js is <strong>NOT</strong> required to run the server.</p>
12+
<h2>Running the sample</h2>
13+
<ol>
14+
<li><strong>Set license.</strong>&nbsp;Download your license file&nbsp;<a href="https://www.webdavsystem.com/javaserver/download/">here</a>. To set the license, edit the 'license' section in \collectionsync<em>\WEB-INF\web.xml</em>&nbsp;and specify the path to the&nbsp;<em>license.lic</em>&nbsp;file. <br>
15+
<pre class="brush:xml;auto-links:false;toolbar:false">&lt;init-param&gt;
16+
&lt;param-name&gt;license&lt;/param-name&gt;
17+
&lt;param-value&gt;C:\License.lic&lt;/param-value&gt;
18+
&lt;/init-param&gt;</pre>
19+
The IT Hit Java WebDAV Server Library is fully functional and does not have any limitations. However, the trial period is limited to 1 month. After the trial period expires the Java WebDAV Server will stop working.</li>
20+
<li><strong>Download the IT Hit WebDAV Ajax Library.</strong>&nbsp;You can do this with NPM command-line tool, which is included with Node.js.&nbsp;Install the&nbsp;<a href="https://nodejs.org/en/download/">Node.js</a>&nbsp;and navigate to&nbsp;<code class="code">\collectionsync\WEB-INF\wwwroot\js\</code>&nbsp;folder. Run:&nbsp;
21+
<pre class="brush:html;auto-links:false;toolbar:false">npm install&nbsp;webdav.client</pre>
22+
This will download IT Hit WebDAV Ajax Library files into your project. Note that Node.js itself is <strong>NOT</strong> required to run the server, it is used <strong>ONLY</strong> to install the required JavaScript files.</li>
23+
<li><strong>Configure the storage folder.</strong> By default, this sample publishes documents from the <code class="code">WEB-INF/Storage</code>&nbsp;folder. For the sake of configuration simplicity, documents are extracted from project resources during the first run. You can publish documents from any other folder specifying a path in the 'root' section in&nbsp;<code class="code">web.xml</code>:<br>
24+
<pre class="brush:xml;auto-links:false;toolbar:false">&lt;init-param&gt;
25+
&lt;param-name&gt;root&lt;/param-name&gt;
26+
&lt;param-value&gt;C:\Storage\&lt;/param-value&gt;
27+
&lt;/init-param&gt;</pre>
28+
</li>
29+
<li><strong>Configure the application server.</strong>&nbsp;Here we will configure WebDAV server to run on the website root (<code class="code">http://server.com/</code>). <span class="warn"><strong>Note:</strong> While you can configure WebDAV server to run on site non-root (for instance on&nbsp;<code class="code">http://server.com/webdavroot/</code>) some WebDAV clients (such as some old versions or Mini-redirector, Microsoft Web Folders and MS Office 2007 and earlier) will fail to connect to non-root server. They submit configuration requests to server root and if they do not get the response they will not be able to connect.&nbsp;See also&nbsp;<a title="Working with MS Office" href="https://www.webdavsystem.com/javaserver/doc/ms_office_read_only/">Making Microsoft Office to Work with WebDAV Server</a> and&nbsp;<a title="Opening Docs" href="https://www.webdavsystem.com/ajax/programming/open-doc-webpage/opening_ms_office_docs/">Opening Microsoft Office Documents and Other Types of Files for Editing From a Web Page</a>.</span>
30+
<ul>
31+
<li><strong>In the case of Tomcat:</strong><br>Copy&nbsp;<em>\collectionsync</em>&nbsp;folder to&nbsp;<em>&lt;Your Tomcat location&gt;\Tomcat x.x\webapps</em>&nbsp;folder. Add the following lines under the &lt;Host&gt; tag in&nbsp;<em>&lt;Your Tomcat location&gt;</em><em>\Tomcat x.x\conf\server.xml</em>:<br>
32+
<pre class="brush:csharp;auto-links:false;toolbar:false">&lt;Context path="" debug="0" docBase="collectionsync"&gt;
33+
&lt;/Context&gt;</pre>
34+
<p><span>To see if your server is running type the root URL of your WebDAV site in a browser and you will see the list of folders. Now&nbsp;</span><a href="https://www.webdavsystem.com/server/access/">connect to the server with any WebDAV client</a><span>.</span></p>
35+
<p>If you experience any problems examine the log created by tomcat:&nbsp;<code class="code">&lt;Your Tomcat location&gt;\Tomcat x.x\logs\localhost.xxxx-xx-xx.log</code>.</p>
36+
</li>
37+
<li><strong>In the case of Glassfish:</strong><ol type="a">
38+
<li>Deploy the collectionsync application.
39+
<p>From the main tree (<em>Common Tasks</em>)&nbsp;goto&nbsp;<em>Applications</em>.</p>
40+
<p>Press&nbsp;<em>Deploy</em>&nbsp;and specify following properties:</p>
41+
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Local Packaged File or Directory That Is Accessible from the Enterprise Server = &lt;path to collectionsync directory&gt;</p>
42+
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Type = Web Application</p>
43+
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Context Root = /</p>
44+
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Note:&nbsp;sample can be deployed to a non-root context, but some clients work only with servers deployed to root the context.</p>
45+
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Application Name =&nbsp;collectionsync</p>
46+
</li>
47+
<li>Launch the sample.
48+
<p>From the main tree (<em>Common Tasks</em>)&nbsp;go to&nbsp;<em>Applications</em>.</p>
49+
<p>Press&nbsp;<em>Launch</em>&nbsp;on collectionsync&nbsp;application.</p>
50+
<p>If everything was set up properly you should see a sample page with a list of sample files and folders. Now&nbsp;<a href="https://www.webdavsystem.com/server/access/">connect to the server with any WebDAV client</a>.</p>
51+
<p>If anything goes wrong please consult log usually located at&nbsp;<em>&lt;GLASSFISH_INSTANCE_ROOT&gt;/logs/server.log.</em></p>
52+
</li>
53+
</ol></li>
54+
<li><strong>In the case of JBoss WildFly:</strong><ol type="a">
55+
<li>By default WildFly restricts access to certain packages from Java SDK. So you need to allow&nbsp;<strong>com.sun.nio.file</strong>&nbsp;package in the&nbsp;<strong>sun/jdk&nbsp;</strong>module by adding the following line in the&nbsp;module.xml&nbsp;file:
56+
<pre class="brush:xml;auto-links:false;toolbar:false">&lt;path name="com/sun/nio/file"/&gt;</pre>
57+
<p>Restart WildFly.</p>
58+
</li>
59+
<li>Deploy the collectionsync application.
60+
<p>Create folder collectionsync<em>.war </em>under&nbsp;<em><em>&lt;WILDFLY_ROOT&gt;/deployments.</em></em></p>
61+
<p>Copy content of <em>samples/collectionsync&nbsp;</em>to&nbsp;<em><em><em>&lt;<em><em>WILDFLY_ROOT</em></em>&gt;/deployments/collectionsync<em>.war.</em></em></em></em></p>
62+
<p>Create file&nbsp;collectionsync<em>.war.dodeploy in&nbsp;<em><em>&lt;<em><em>WILDFLY_ROOT</em></em>&gt;/deployments/collectionsync<em>.war.</em></em></em></em></p>
63+
<p><span>If everything was set up properly you should see a sample page on the WildFly root context with a list of sample files and folders. Now&nbsp;</span><a href="https://www.webdavsystem.com/server/access/">connect to the server with any WebDAV client</a><span>.</span></p>
64+
<p>If anything goes wrong please consult log usually located at&nbsp;<em>&lt;<em><em>WILDFLY_ROOT</em></em>&gt;/log/server.log.</em></p>
65+
</li>
66+
</ol></li>
67+
</ul>
68+
</li>
69+
</ol>
70+
<h2>The Project&nbsp;Classes</h2>
71+
<p>On the diagram below you can see the classes in the WebDAV Collectionsyncproject:</p>
72+
<p><img id="__mcenew" alt="" src="https://www.webdavsystem.com/media/2195/syncdiagram.png" rel="124998"></p>
73+
<p>To adapt the sample to your needs, you will modify these classes to read and write data from and into your storage. You can find more about this in&nbsp;<a title="Creating WebDAV Server" href="https://www.webdavsystem.com/javaserver/doc/">Creating a Class 1 WebDAV Server</a>&nbsp;and&nbsp;<a title="Class 2 / 3 Server" href="https://www.webdavsystem.com/javaserver/doc/create_class_2_webdav_server/">Creating Class 2 WebDAV Server</a>&nbsp;article as well as in the&nbsp;<a href="http://java.webdavsystem.com/">class reference documentation</a>.</p>
74+
<p>&nbsp;</p>
75+
<h3>See Also:</h3>
76+
<ul>
77+
<li><a title="Running" href="https://www.webdavsystem.com/javaserver/server_examples/running_webdav_samples/">Running the WebDAV Samples</a></li>
78+
<li><a title="Troubleshooting" href="https://www.webdavsystem.com/javaserver/server_examples/troubleshooting/">WebDAV Server Samples Problems and Troubleshooting</a></li>
79+
<li><a title="Creating WebDAV Server" href="https://www.webdavsystem.com/javaserver/doc/">Creating a Class 1 WebDAV Server</a>&nbsp;</li>
80+
<li><a title="Class 2 / 3 Server" href="https://www.webdavsystem.com/javaserver/doc/create_class_2_webdav_server/">Creating a Class 2 WebDAV Server</a></li>
81+
</ul>
82+
<p>&nbsp;</p>
83+
<p class="p1" style='color: rgba(0, 0, 0, 0.85); line-height: normal; font-family: ".SF NS"; font-size: 26px; margin-bottom: 0px; margin-left: 0px; font-stretch: normal; font-feature-settings: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-variation-settings: normal;'>collectionsync</p>
84+
<h3 class="para d-inline next-article-heading">Next Article:</h3>
85+
<a title="Java WebDAV Server for Android" href="https://www.webdavsystem.com/javaserver/server_examples/android/">Java WebDAV Server Example for Android</a>
86+

Java/collectionsync/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.ithit.webdav.samples</groupId>
88
<artifactId>collectionsync</artifactId>
9-
<version>6.1.7907-Beta</version>
9+
<version>6.2.9080-Beta</version>
1010
<packaging>war</packaging>
1111

1212
<properties>
@@ -34,7 +34,7 @@
3434
<dependency>
3535
<groupId>com.ithit.webdav.integration</groupId>
3636
<artifactId>servlet-integration</artifactId>
37-
<version>6.1.7907-Beta</version>
37+
<version>6.2.9080-Beta</version>
3838
</dependency>
3939
<dependency>
4040
<groupId>commons-io</groupId>
@@ -55,9 +55,9 @@
5555
<scope>provided</scope>
5656
</dependency>
5757
<dependency>
58-
<groupId>com.oracle</groupId>
59-
<artifactId>ojdbc7</artifactId>
60-
<version>12.1.0.2</version>
58+
<groupId>com.oracle.database.jdbc</groupId>
59+
<artifactId>ojdbc8</artifactId>
60+
<version>23.2.0.0</version>
6161
<scope>provided</scope>
6262
</dependency>
6363
<dependency>
@@ -142,7 +142,7 @@
142142
<dependency>
143143
<groupId>com.ithit.webdav</groupId>
144144
<artifactId>webdav-server</artifactId>
145-
<version>6.1.7907-Beta</version>
145+
<version>6.2.9080-Beta</version>
146146
</dependency>
147147
<dependency>
148148
<groupId>net.java.dev.jna</groupId>
@@ -228,7 +228,7 @@
228228
<server>filesystem</server>
229229
<port>11021</port>
230230
<path>/</path>
231-
<warSourceDirectory>target/collectionsync-6.1.7907-Beta</warSourceDirectory>
231+
<warSourceDirectory>target/collectionsync-6.2.9080-Beta</warSourceDirectory>
232232
</configuration>
233233
</plugin>
234234
<plugin>

Java/collectionsync/src/main/java/com/ithit/webdav/samples/collectionsync/FileImpl.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
import com.ithit.webdav.samples.collectionsync.extendedattributes.ExtendedAttributesExtension;
44
import com.ithit.webdav.server.*;
5+
import com.ithit.webdav.server.File;
56
import com.ithit.webdav.server.exceptions.ConflictException;
67
import com.ithit.webdav.server.exceptions.LockedException;
78
import com.ithit.webdav.server.exceptions.MultistatusException;
89
import com.ithit.webdav.server.exceptions.ServerException;
910
import com.ithit.webdav.server.resumableupload.ResumableUpload;
1011
import com.ithit.webdav.server.resumableupload.UploadProgress;
1112

12-
import java.io.IOException;
13-
import java.io.InputStream;
14-
import java.io.OutputStream;
13+
import java.io.*;
1514
import java.nio.ByteBuffer;
1615
import java.nio.channels.SeekableByteChannel;
1716
import java.nio.file.*;
@@ -30,7 +29,7 @@ final class FileImpl extends HierarchyItemImpl implements File, Lock,
3029
private static final int BUFFER_SIZE = 1048576; // 1 Mb
3130

3231
private String snippet;
33-
32+
3433
private final OpenOption[] allowedOpenFileOptions;
3534

3635
/**
@@ -44,7 +43,7 @@ final class FileImpl extends HierarchyItemImpl implements File, Lock,
4443
*/
4544
private FileImpl(String name, String path, long created, long modified, WebDavEngine engine) {
4645
super(name, path, created, modified, engine);
47-
46+
4847
/* Mac OS X and Ubuntu doesn't work with ExtendedOpenOption.NOSHARE_DELETE */
4948
String systemName = System.getProperty("os.name").toLowerCase();
5049
this.allowedOpenFileOptions = (systemName.contains("mac") || systemName.contains("linux")) ?
@@ -76,15 +75,13 @@ private OpenOption noShareDeleteOption() {
7675
*/
7776
static FileImpl getFile(String path, WebDavEngine engine) throws ServerException {
7877
BasicFileAttributes view = null;
79-
Path fullPath;
8078
String name = null;
79+
ItemMapping itemMapping;
8180
try {
82-
String pathFragment = decodeAndConvertToPath(path);
83-
String rootFolder = getRootFolder();
84-
fullPath = Paths.get(rootFolder, pathFragment);
85-
if (Files.exists(fullPath)) {
86-
name = Paths.get(pathFragment).getFileName().toString();
87-
view = Files.getFileAttributeView(fullPath, BasicFileAttributeView.class).readAttributes();
81+
itemMapping = mapPath(path, false);
82+
if (Files.exists(itemMapping.fullPath)) {
83+
name = Paths.get(itemMapping.relativePath).getFileName().toString();
84+
view = Files.getFileAttributeView(itemMapping.fullPath, BasicFileAttributeView.class).readAttributes();
8885
}
8986
if (view == null) {
9087
return null;
@@ -94,7 +91,7 @@ static FileImpl getFile(String path, WebDavEngine engine) throws ServerException
9491
}
9592
long created = view.creationTime().toMillis();
9693
long modified = view.lastModifiedTime().toMillis();
97-
return new FileImpl(name, path, created, modified, engine);
94+
return new FileImpl(name, itemMapping.davPath, created, modified, engine);
9895
}
9996

10097
/**
@@ -330,7 +327,10 @@ private String getSerialNumber() throws ServerException {
330327
public void delete() throws LockedException, MultistatusException, ServerException {
331328
ensureHasToken();
332329
try {
333-
Files.delete(getFullPath());
330+
try (RandomAccessFile raf = new RandomAccessFile(getFullPath().toFile(), "rw")) {
331+
raf.setLength(0);
332+
}
333+
Files.setAttribute(getFullPath(), "dos:hidden", true, LinkOption.NOFOLLOW_LINKS);
334334
} catch (IOException e) {
335335
getEngine().getLogger().logError("Tried to delete file in use.", e);
336336
throw new ServerException(e);

Java/collectionsync/src/main/java/com/ithit/webdav/samples/collectionsync/FolderImpl.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,14 @@ private FolderImpl(String name, String path, long created, long modified,
6161
*/
6262
static FolderImpl getFolder(String path, WebDavEngine engine) throws ServerException {
6363
BasicFileAttributes view = null;
64-
Path fullPath;
6564
String name = null;
65+
ItemMapping itemMapping;
6666
try {
6767
boolean root = path.equals("/");
68-
String pathFragment = decodeAndConvertToPath(path);
69-
String rootFolder = getRootFolder();
70-
fullPath = root ? Paths.get(rootFolder) : Paths.get(rootFolder, pathFragment);
71-
if (Files.exists(fullPath)) {
72-
name = root ? "ROOT" : Paths.get(pathFragment).getFileName().toString();
73-
view = Files.getFileAttributeView(fullPath, BasicFileAttributeView.class).readAttributes();
68+
itemMapping = mapPath(path, root);
69+
if (Files.exists(itemMapping.fullPath)) {
70+
name = root ? "ROOT" : Paths.get(itemMapping.relativePath).getFileName().toString();
71+
view = Files.getFileAttributeView(itemMapping.fullPath, BasicFileAttributeView.class).readAttributes();
7472
}
7573
if (view == null || !view.isDirectory()) {
7674
return null;
@@ -81,7 +79,7 @@ static FolderImpl getFolder(String path, WebDavEngine engine) throws ServerExcep
8179

8280
long created = view.creationTime().toMillis();
8381
long modified = view.lastModifiedTime().toMillis();
84-
return new FolderImpl(name, fixPath(path), created, modified, engine);
82+
return new FolderImpl(name, fixPath(itemMapping.davPath), created, modified, engine);
8583
}
8684

8785
private static String fixPath(String path) {
@@ -123,16 +121,17 @@ public FileImpl createFile(String name) throws LockedException, ServerException
123121
* Creates new {@link FolderImpl} folder with the specified name in this folder.
124122
*
125123
* @param name Name of the folder to create.
124+
* @return Instance of newly created Folder.
126125
* @throws LockedException This folder was locked. Client did not provide the lock token.
127126
* @throws ServerException In case of an error.
128127
*/
129128
// <<<< createFolderImpl
130129
@Override
131-
public void createFolder(String name) throws LockedException,
130+
public Folder createFolder(String name) throws LockedException,
132131
ServerException {
133132
createFolderInternal(name);
134-
135133
getEngine().getWebSocketServer().notifyCreated(getPath() + encode(name), getWebSocketID());
134+
return FolderImpl.getFolder(getPath() + encode(name), getEngine());
136135
}
137136

138137
private void createFolderInternal(String name) throws LockedException,

0 commit comments

Comments
 (0)