Spring Boot WebDAV Server Example with Oracle Back-end, Java

This sample provides a WebDAV server running on the Spring Boot framework. All data including file content, document structure, and custom attributes are stored in the Oracle database. The IT Hit WebDAV Ajax Library 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 them back directly to the server.

This sample can be downloaded in the product download area as well as it is published on GitHub.

Requirements

  • Java 1.8.
  • Oracle Database 10g or later version. Express, Standard, or Enterprise Edition.
  • Lombok plug-in should be installed in your favorite IDE otherwise syntax error will be displayed

Running the sample

  1. Set the license. Download your license file here. To set the license, edit the webdav.license section in \springboot\src\main\resources\application.properties and specify the path to the license.lic file. 
    webdav.license=C:\License.lic
    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.
  2. Configure the application server. Here we will configure the WebDAV server to run on the website non-root context (https://server/DAV/). This setting is located in the webdav.rootContext section in the \springboot\src\main\resources\application.properties.
    webdav.rootContext=/
    Note: 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 a 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. For this reason, this sample processes OPTIONS and PROPFIND requests on all folders, including on the site root (https://server/). See also Making Microsoft Office to Work with WebDAV Server and Opening Microsoft Office Documents and Other Types of Files for Editing From a Web Page.
    This Spring Boot sample supports those configuration requests and works properly on a non-root context.
  3. Set Oracle BD connection string. Provide you connection string and credentials in the \springboot\src\main\resources\application.properties.
    spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe
    spring.datasource.username=system
    spring.datasource.password=pwd
    Database structure for your WebDAV server will be created during application startup from the file springboot\src\main\resources\db\OracleStorage.sql
  4. Running the springboot sample. To start the sample, change the directory to springboot and execute the following command:
    mvnw spring-boot:run

    If everything was set up properly you should see a sample web page on  https://server/DAV/ URL. Now you can upload documents, open documents for editing, manage documents, as well as connect to the server with any WebDAV client.

    If anything goes wrong examine the log file. For Spring Boot, the log file is usually located at springboot/log/engine.log. You may also need to capture and examine the HTTP requests. See this article for more details. 

The Project Classes

On the diagram below you can see the classes in the WebDAV SpringBoot SQL sample:

Class diagram of the sample Java WebDAV Server running on Spring Boot for Oracle

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 Creating a Class 1 WebDAV Server and Creating Class 2 WebDAV Server article as well as in the class reference documentation.

 

See Also:

 

Next Article:

Spring Boot WebDAV Server Example with Amazon S3 Back-end, Java