Adding G Suite Documents Editing to Your IT Hit WebDAV Server
In many cases, you may already have an up and running WebDAV server. In this case, adding G Suite editing becomes a simple task. The G Suite editing functionality is provided as part of IT Hit Server as a separate Engine - IT Hit Server Engine for G Suite. IT Hit Server Engine for G Suite will utilize your existing WebDAV server interfaces implementation to read and write documents data.
If your WebDAV server supports Class 2 locking, it can also lock a document with a shared lock when a new user joins editing. It will also automatically unlock the document and delete it from Google Drive when all users finish editing.
Adding G Suite Support to Your Server
Follow the steps below to add G Suite editing to your WebDAV server:
1. Upgrade your server code to IT Hit Server Engine for .NET v9 Beta. The v9 provides refactored interfaces that allow sharing Context between WebDAV Engine and G Suite Engine. See guides in Upgrading WebDAV Server Engine for .NET section.
2. Upgrade your WebDAV Ajax Library to v5.10. If you are using v5.x, typically you just need to replace the ITHitWebDAVClient.js file, otherwise, refer to the Upgrading WebDAV Ajax Library guides. You can get the latest build from NPM or download in the product download area.
3. Create a Google Drive account. At later steps, you will use your Google email and Google private key to configure IT Hit Server Engine for G Suite instance.
Note that while you can use any Google account, to implement SSO (to use accounts from your existing DMS/CRM/ERP, acting as an identity provider) you will need a G Suite Enterprise, Business, Basic, Education, or Drive Enterprise edition account.
4. Create an instance of IT Hit Server Engine for G Suite using GSuiteEngineAsync class. Pass your Google email and a private key to the constructor.
You may create G Suite Engine instance either before or after WebDAV Engine. In case or .NET Core, they may reside in a single middleware or in separate middlewares.
Important! In the case of ASP.NET HttpHandler, the WebDAV and G Suite Engines MUST reside in the same HttpHandler, do NOT create a separate handler for G Suite Engine, as WebDAV and G Suite Engines must both process OPTIONS request.
5. Pass your existing WebDAV context to GSuiteEngineAsync.RunAsync() method. The RunAsync() method accepts contexts based on ContextAsync<IHierarchyItemBaseAsync> class that all WebDAV contexts are derived from starting from v9, allowing sharing context between WebDAV and G Suite Engines.
// Your existing WebDAV Context as well as all interfaces // can be used for both WebDAV and G Suite Engines. MyWebDAVContext context = new MyWebDAVContext(...); // Create and run WebDAV Engine. DavEngineAsync davEngine = new DavEngineAsync(); davEngine.License = "..."; davEngine.RunAsync(context); // This will process WebDAV editing, locking and file management requests. // Create and run G Suite Engine. // Your e-mail, private key or any data is never shared with IT Hit or any third-party. GSuiteEngineAsync gsuiteEngine = new GSuiteEngineAsync('<email@example.com>', '<private key>'); gsuiteEngine.License = "..."; gsuiteEngine.RunAsync(context); // This will process G Suite editing requests and optional locking requests.
The G Suite Engine will call ContextAsync<THierarchyItemAsync>.GetHierarchyItemAsync() method and request an IContentAsync interface on the returned item to read and write file content. If locking is requested from the client app (see below) the G Suite Engine will also use ILockAsync interface to lock and unlock documents with shared locks.
Initiating Editing from Your Web Page
Omitting a second parameter will create a new web browser window.
Detecting G Suite Editing Support
Configuring Google Drive Notifications
When a document is updated by the users Google Drive will notify the G Suite Engine about file change. Your server must allow POST requests, that will be routed and processed by to G Suite Engine.
G Suite module will automatically lock the document before opening if locking is supported by your server implementation. To support locks your server must implement ILockAsync interface and your IT Hit G Suite module license must have a Class2 listed in the modules section. If your server does not support locking, the G Suite Online editing and collaboration are still supported, however, your document is not protected from modifications.
Unlike most WebDAV clients, that lock the document with an exclusive lock, the G Suite module will lock the document with a shared lock. A shared lock allows several users to lock the document simultaneously, providing collaboration capability. A shared lock is automatically removed when a user leaves G Suite Online editing. If your server does not support locking, the G Suite Online editing and collaboration are still supported, however, your document is not protected from modifications.
Important! Make sure your server supports shared locks, as shared lock requests may be new to your server implementation. WebDAV Ajax integration tests can help you detect many server issues, including shared locks support.
Microsoft Office desktop requires an exclusive lock and will notify the user that the document is locked if the document is locked with a shared lock. So the document can NOT be edited in MS Office desktop apps and in G Suite Online at the same time. The MS Office user still can edit a local copy in MS Office desktop and merge changes when all shared locks are released.
If the document is locked with an exclusive lock, it can NOT be opened in G Suite Online editor.