WebDAV Server Example with Versioning, Java
The sample provides DeltaV WebDAV server implementation that can be hosted in Apache Tomcat, GlassFish, JBoss, WebLogic or WebSphere. The data is stored in 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 back directly to server.
- Oracle Database 10g or later version. Express, Standard or Enterprise Edition.
- Apache Tomcat 7.0+ or GlassFish v4.1.1+ or WebLogic 12c+ or JBoss Wildfly 9+ or WebSphere 18.104.22.168+.
- Java 1.8.
Running the sample
- Create the database. The Oracle database script is located in \samples\deltav\db\deltav.sql file. This script creates tables and populates them with data so your WebDAV server initially has several folders and files. To run the script login to Oracle administration web interface, go to SQL->SQL Scripts->Create, then paste content of deltav.sql to script field, specify a script name and click Run.
It is also recommended to increase the datafile. After creating the database run the following command:
alter database datafile ' C:\oraclexe\oradata\XE\SYSTEM.DBF' resize 4g;
This is especially required if you would like to test WebDAV server running Oracle XE with IT Hit AJAX File Browser.
- Set license. Download your license file here. To set the license edit license section in \deltav\WEB-INF\web.xml and specify the path to the license.lic file.
<init-param> <param-name>license</param-name> <param-value>C:\License.lic</param-value> </init-param>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.
- Download the IT Hit WebDAV Ajax Library. You can do this with NPM command line tool, which is included with Node.js. Install the Node.js and navigate to \deltav\WEB-INF\wwwroot\js\ folder. Run:
- Configure the application server. Here we will configure WebDAV server to run on the website root (http://server.com/).While you can configure WebDAV server to run on site non-root (for instance on http://server.com/webdavroot/) 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 does not get the response they will not be able to connect. 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.
- In the case of Tomcat:
Copy \deltav folder to <Your Tomcat location>\Tomcat x.x\webapps folder. Add the following lines under the <Host> tag in <Your Tomcat location>\Tomcat x.x\conf\server.xml:
<Context path="" debug="0" docBase="deltav"> <Resource name="jdbc/Oracle" auth="Container" type="javax.sql.DataSource" username="system" password="pwd" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@localhost:1521:XE" maxActive="8" maxIdle="4" factory="org.apache.commons.dbcp.BasicDataSourceFactory"/> </Context>
Specify Oracle database login credentials in Context tag. Check you service instance Id in server url.
Finally, restart the Tomcat for configuration changes to take effect.
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 connect to the server with any WebDAV client.
If you experience any problems examine the log created by tomcat: <Your Tomcat location>\Tomcat x.x\logs\localhost.xxxx-xx-xx.log.
- In the case of Glassfish:
- Create oracle connection pool.
Copy \deltav\WEB-INF\lib\ojdbc6.jar to <GLASSFISH_HOME>/domains/domain1/lib/ext folder. Note that "domain1" is a default Glassfish domain. The domain may be different for specific deployments.
Open administrative console of the Glassfish server.
From the main tree (Common Tasks) expand Resources and go to JDBC > Connection Pools. Create a Connection pool:
- JNDI name = Oracle
- resource_type = javax.sql.ConnectionPoolDataSource
- Database Vendor = Oracle
Specify following additional properties (replace following values with your specific):
- url = jdbc:oracle:thin:@localhost:1521:XE
- user = system
- password = password
- xa-driver-does-not-support-non-tx-operations = true
Test connection with Ping button.
- Create DataSource.
From the main tree (Common Tasks) expand Resources and go to JDBC > JDBC Resources.
Press New and provide the following information:
- JNDI Name: JDBC/Oracle (must be called exactly like this).
- Pool Name: The pool name created in the previous section.
Press OK, JDBC-resource will be created.
- Deploy deltav storage application.
From the main tree (Common Tasks) goto Applications.
Press Deploy and specify following properties:
- Local Packaged File or Directory That Is Accessible from the Enterprise Server = <path to deltav storage directory>
- Type = Web Application
- Context Root = /
Note: sample can be deployed to a non-root context, but some clients work only with servers deployed to root the context.
- Application Name = deltav
- Launch sample.
From the main tree (Common Tasks) go to Applications.
Press Launch on oracle storage application.
If everything was set up properly you should see a sample page with a list of sample files and folders. Now connect to the server with any WebDAV client.
If anything goes wrong please consult log usually located at <GLASSFISH_INSTANCE_ROOT>/logs/server.log.
- Create oracle connection pool.
- In the case of Tomcat:
Using with Microsoft Office and other Applications.
By default, the WebDAV Versioning Example is using CheckOutUnlockedCheckIn auto versioning mode. You can see how this mode works on the diagram in the Creating DeltaV WebDAV Server article. The idea of this mode is to minimize an amount of versions automatically created when the file is being saved. This works especially well with applications that lock WebDAV files such as Microsoft Office.
In this mode, the new version is created when the file is being unlocked by Microsoft Office, usually when the user closes the document. Between Lock and Unlock no new versions are created, Lock/Unlock acts as a Check-out/Check-in operations. For applications that do not lock files, the new version is created each time the file is being saved.
The Example Project Classes
On the diagram below you can see the classes in WebDAV DeltaV project.
You can find more about building a server with versioning in Creating WebDAV Server with Versioning Support article. You may also want to read Creating a Class 1 WebDAV Server and Creating Class 2 WebDAV Server articles.
How Things Get Stored – Overview of the Oracle Back-end
The database consists of 5 entities as depicted in the figure below. 2 of them, Property and Lock, are identical to the tables found in SqlStorage example - Properties and Lock. The Repository table contains additional fields: CREATORDISPLAYNAME, CHANGENOTES, CHECKEDOUT, AUTOVERSION, VERSIONCONTROLLED, CHECKEDINDURINGUNLCOKand CHECKEDINONFILECOMPLETE.
The Version table contains file versions. If versioning is enabled each file contains at least one version in this table.
The VersionProperty table contains a snapshot of the properties that was attached to the item when this version was created.