.NET Server

Creating DeltaV WebDAV Server

In this article

Creating DeltaV WebDAV Server

DeltaV Classes and Interfaces

DeltaV server provides the ability to check-out / check-in resources and keep versions track. To add versioning features, you must implement 3 additional interfaces: IVersionableItem, IVersion and IHistory. The class diagram below shows DeltaV interfaces that you will usually use to build DeltaV server. Interfaces specific to various server features are marked as Class 1, Class 2 and DeltaV:

The class diagram for DeltaV Server

Class 2 interfaces are optional for DeltaV server, if you do not need to support Class 2 clients (such as Web Folders on Windows 7, Windows Vista, Mac OS X, Microsoft Office, etc) you do not have to implement them. Class 2 interfaces will be also necessary if you would like to implement auto-versioning modes for versioning-unaware WebDAV clients.

Usually, you will implement IVersionableItem on your resource items in addition to IResource and ILock interfaces. You will also provide 2 new item types – version and history items. Your version items will implement IVersion and IResource interface representing a single resource version. History item will contain all versions of an item. The class diagram below shows classes in your application supporting both Class 2 and DeltaV:

The class diagram for Class 2 and DeltaV

As with Class 1 and Class 2 servers, each item in your repository must have its own unique URL including versions and history items. Now your Engine.GetHierarchyItem must return 5 types of items: resources, folders, lock-nulls, versions and history item.

Starting Versioning

Usually by default all items in the repository are not under version control. The item actually behaves like a Class 2 item. To start creating versions, DeltaV client application must first issue version-control command for an item. The engine will call IVersionableItem.PutUnderVersionControl method passing true as a parameter. If you want versioning to start automatically without an explicit request from the client you can set Engine.AutoPutUnderVersionControl to true. In this case IVersionableItem.PutUnderVersionControl will be called for non-version controlled items before the first item update.

In your IVersionableItem.PutUnderVersionControl implementation you must create a new version. You will copy content and properties from the item to newly created version and save the new version in your repository. After the call to PutUnderVersionControl the item must have 1 version in its versions list and IVersionableItem.VersionHistory must return object implementing IHistory interface that contains a single version. IHistory.CurrentVersion must point to the new version.

Updating Item Content and Properties

To start updating item, the client application must check-out the item. In your IVersionableItem.CheckOut implementation you will mark the item as checked-out and allow item modifications. When an item is in check-out state WebDAV client can issue commands updating item contents and properties. During the updates, the engine will call IResource.SaveFromStream and IHierarchyItem.UpdateProperties.

You should not create any new versions during IVersionableItem.CheckOut call or during the updates. Instead, you will create a new version during IVersionableItem.CheckIn call.

When a client finishes item updates it will the check-in item or rollback modifications issuing the uncheck-out command. During the IVersionableItem.CheckIn call, you must create a new version copying content and properties from modified item to a new version.

If the client issues the uncheck-out command you must restore the pre-check-out stare of the item. In this case during IVersionableItem.UncheckOut call you will copy content and properties from the latest version to the item. During the IVersionableItem.UncheckOut call item must be marked as checked-in.

Here is the typical versioning workflow:

  1. Engine calls PutUnderVersionControl. You must create a new version, copy content and properties from this item to a new version.
  2. Engine calls CheckOut. You mark the item as checked-out.
  3. Engine calls SaveFromStream or UpdateProperties. You modify item content and properties.
  4. Engine calls CheckIn or UnCheckOut. For CheckIn - create a new version, copy content and properties from this item to a new version. For UnCheckOut - copy content and properties from the current version to this item. Mark item as checked-in.

Stopping Versioning

Each object that implements IHistory interface must have its own unique URL returned by Path property. If the DeltaV client application decides to turn-off versioning it will submit delete request to this URL. Engine will call IVersionableItem.PutUnderVersionControl method passing false as a parameter. In your implementation, you will delete all versions. IVersionableItem.VersionHistory property must return null after this call.

Auto-versioning Modes

Auto-versioning provides backward compatibility with WebDAV clients that does not support DeltaV features (versioning-unaware WebDAV clients). If your item is being version-controlled and WebDAV client is trying to modify a checked-in item auto-versioning may automatically check-out the item and then check-in creating a new item version. To reduce number of versions created by versioning-unaware clients DeltaV standard and IT Hit WebDAV Server Engine provides several auto-versioning modes. The engine reads the mode from IVersionableItem.AutoVersion property before the update. You can find a description of each mode here. Note that all auto-versioning logics apply only to checked-in items. If you item is in checked-out state and your server permissions allow the user to modify the item the client application will be able to update items content and properties.

We will describe CheckOutUnlockedCheckIn mode that provides a balance between number of versions created and support for versioning-unaware clients. In this mode lock and unlock commands function as check-in/check-out. On the other hand Class 1 client applications without lock support can still update items and create versions.

When the update request issued, the item is being automatically checked-out by the engine. First the engine sets IVersionableItem.AutoCheckIn property to true and calls IVersionableItem.CheckOut. Then engine calls item update methods IResource.SaveFromStream or IHierarchyItem.UpdateProperties. After the update, engine checks-in the item if it was not locked.

If the item was locked, during the unlock request engine first reads AutoCheckIn property and calls IVersionableItem.CheckIn if it is true. Finally engine calls ILock.Unlock.

CheckOutUnlockedCheckIn mode workflow:

  1. Modification request:
  2. Unlock request:

Below you can see the how other 3 auto-versioning modes comparing to CheckOutUnlockedCheckIn mode:

DeltaV auto-versioning modes

Next Article:

Creating WebDAV HttpHandler