Class Engine


public abstract class Engine extends Object
Serves as the abstract base class for WebDAV engine.
  • Constructor Details

    • Engine

      public Engine()
  • Method Details

    • getHierarchyItem

      public abstract HierarchyItem getHierarchyItem(String pathAndQuery) throws ServerException
      Implementation of this abstract method is used by WebDAV engine to find hierarchy item objects by path.

      When you inherit from the Engine class, you must override this abstract method. For WebDAV Class 1 or Class 2 server in this method implementation you will search for file or folder in your storage by path provided and return it to WebDAV engine. For DeltaV server in addition to folder and file you will return version and history items.

      pathAndQuery - Path of the hierarchy item object. It is always the full path from the root of the WebDAV repository.
      Hierarchy item object referenced by the specified path or null if hierarchy item not found.
      ServerException - Something unexpected occurred.

      The code below is part of Collection Synchronization sample provided with the SDK.
          public HierarchyItem getHierarchyItem(String contextPath) throws ServerException {
              int i = contextPath.indexOf('?');
              if (i >= 0) {
                  contextPath = contextPath.substring(0, i);
              HierarchyItemImpl item;
              item = FolderImpl.getFolder(contextPath, this);
              if (item != null && item.getChangeType() != Change.DELETED) {
                  return item;
              item = FileImpl.getFile(contextPath, this);
              if (item != null && item.getChangeType() != Change.DELETED) {
                  return item;
              getLogger().logDebug("Could not find item that corresponds to path: " + contextPath);
              return null; // no hierarchy item corresponds to path parameter was found in the repository
    • getLogger

      public abstract Logger getLogger()
      Returns logger that will be used by engine.
      Instance of Logger.
    • getLicense

      public abstract String getLicense()
      Returns license string.
      License string.
    • getResponseCharacterEncoding

      public String getResponseCharacterEncoding()
      Returns charset in which response shall be generated.
    • registerMethodHandler

      public MethodHandler registerMethodHandler(String method, MethodHandler handler)
      Registers custom method handler.

      Using this method you can register custom method handler to be caller by the engine. If the handler for the specified method was already defined it is returned from this method. The original handler can be saved and called later from your custom handler.

      The code below is part of File System Storage sample provided with the SDK.

      method - HTTP verb.
      handler - Custom handled implementing MethodHandler interface.
      Original handler if any.

      The code below is part of Collection Synchronization sample provided with the SDK.
          protected void serviceDav(HttpServletDavRequest httpServletRequest, HttpServletDavResponse httpServletResponse)
                  throws HttpServletDavException, IOException {
              WebDavEngine engine = new WebDavEngine(logger, license, localMaskRequestHeaders);
              CustomFolderGetHandler handler = new CustomFolderGetHandler(engine.getResponseCharacterEncoding(), Engine.getVersion());
              CustomFolderGetHandler handlerHead = new CustomFolderGetHandler(engine.getResponseCharacterEncoding(), Engine.getVersion());
              handler.setPreviousHandler(engine.registerMethodHandler("GET", handler));
              handlerHead.setPreviousHandler(engine.registerMethodHandler("HEAD", handlerHead));
              try {
                  engine.service(httpServletRequest, httpServletResponse);
              } catch (DavException e) {
                  if (e.getStatus() == WebDavStatus.INTERNAL_ERROR) {
                      logger.logError("Exception during request processing", e);
                      if (showExceptions)
                          e.printStackTrace(new PrintStream(httpServletResponse.getOutputStream()));
    • getClientLockTokens

      @Deprecated public static List<String> getClientLockTokens(DavRequest request)
      As of Engine version > 3.0.2114. Moved to DavRequest.getClientLockTokens()
      Gets the array of lock tokens submitted by client.

      Gets array of lock tokens submitted by client. You must generate the lock tokens during the call to your Lock.lock(boolean, boolean, long, java.lang.String) method implementation. During this call you associate generated token with an item in the repository and return it to the Engine. Engine than sends the new token to the WebDAV client. When WebDAV client is modifying any server item it sends back to server the list of lock tokens. In your WebDAV server Class 2 implementation before modifying any locked items you must check if WebDAV client provided necessary lock token.

      request - Instance of DavRequest.
      List of lock tokens submitted by client.
    • getAutoPutUnderVersionControl

      public boolean getAutoPutUnderVersionControl()
      Determines if placing file under version control is automatic.

      Determines whether files will be placed under version control automatically or explicit request from client shall be made to put a file under version control.

      If this property is true prior any item content or properties update VersionableItem.putUnderVersionControl(boolean) will be called.

      Boolean value indicating if items must be put under version control before content or properties update. Default is true.
    • getCalculateContentLength

      public boolean getCalculateContentLength()
      Indicates if response content length calculation will occur.

      If this method returns true engine will calculate output content length and set DavResponse.setContentLength(long) property before returning from service(com.ithit.webdav.server.DavRequest, com.ithit.webdav.server.DavResponse) method. If you would like to send chunked responses you must set this property to false.

      Boolean value indicating if content length will be calculated in service(com.ithit.webdav.server.DavRequest, com.ithit.webdav.server.DavResponse) method. Default is true.
    • getMaskRequestHeaders

      public Set<String> getMaskRequestHeaders()
      Gets the set of the request headers to be masked for the logging output.
      Set of the request header to be masked for the logging output.
    • getMaskResponseHeaders

      public Set<String> getMaskResponseHeaders()
      Gets the set of the response headers to be masked for the logging output.
      Set of the response header to be masked for the logging output.
    • service

      public void service(DavRequest davRequest, DavResponse davResponse) throws DavException, IOException
      Handles request.
      davRequest - Request.
      davResponse - Response.
      DavException - If an error occurrs in user or engine implementation.
      IOException - If i/o exception occurs.
    • getVersion

      public static String getVersion()
      Returns version of engine at runtime. Engine version is the same as jar version.
      Version of the engine.