Class Engine
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines if placing file under version control is automatic.boolean
Indicates if response content length calculation will occur.getClientLockTokens
(DavRequest request) Deprecated.As of Engine version > 3.0.2114.abstract HierarchyItem
getHierarchyItem
(String pathAndQuery) Implementation of this abstract method is used by WebDAV engine to find hierarchy item objects by path.abstract String
Returns license string.abstract Logger
Returns logger that will be used by engine.Gets the set of the request headers to be masked for the logging output.Gets the set of the response headers to be masked for the logging output.Returns charset in which response shall be generated.static String
Returns version of engine at runtime.registerMethodHandler
(String method, MethodHandler handler) Registers custom method handler.void
service
(DavRequest davRequest, DavResponse davResponse) Handles request.
-
Constructor Details
-
Engine
public Engine()
-
-
Method Details
-
getHierarchyItem
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.- Parameters:
pathAndQuery
- Path of the hierarchy item object. It is always the full path from the root of the WebDAV repository.- Returns:
- Hierarchy item object referenced by the specified path or
null
if hierarchy item not found. - Throws:
ServerException
- Something unexpected occurred.
The code below is part of Collection Synchronization sample provided with the SDK.@Override 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
Returns logger that will be used by engine.- Returns:
- Instance of
Logger
.
-
getLicense
Returns license string.- Returns:
- License string.
-
getResponseCharacterEncoding
Returns charset in which response shall be generated.- Returns:
- Charset.
-
registerMethodHandler
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.
- Parameters:
method
- HTTP verb.handler
- Custom handled implementingMethodHandler
interface.- Returns:
- Original handler if any.
The code below is part of Collection Synchronization sample provided with the SDK.@Override 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)); engine.setSearchFacade(searchFacade); 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.As of Engine version > 3.0.2114. Moved toDavRequest.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.- Parameters:
request
- Instance ofDavRequest
.- Returns:
- 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.- Returns:
- 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 fromservice(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.- Returns:
- 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
Gets the set of the request headers to be masked for the logging output.- Returns:
- Set of the request header to be masked for the logging output.
-
getMaskResponseHeaders
Gets the set of the response headers to be masked for the logging output.- Returns:
- 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.- Parameters:
davRequest
- Request.davResponse
- Response.- Throws:
DavException
- If an error occurrs in user or engine implementation.IOException
- If i/o exception occurs.
-
getVersion
Returns version of engine at runtime. Engine version is the same as jar version.- Returns:
- Version of the engine.
-