public abstract class Engine extends Object
Constructor and Description |
---|
Engine() |
Modifier and Type | Method and Description |
---|---|
boolean |
getAutoPutUnderVersionControl()
Determines if placing file under version control is automatic.
|
boolean |
getCalculateContentLength()
Indicates if response content length calculation will occur.
|
static List<String> |
getClientLockTokens(DavRequest request)
Deprecated.
As of Engine version > 3.0.2114. Moved to
DavRequest.getClientLockTokens() |
abstract HierarchyItem |
getHierarchyItem(String pathAndQuery)
Implementation of this abstract method is used by WebDAV engine to find hierarchy item objects by path.
|
abstract String |
getLicense()
Returns license string.
|
abstract Logger |
getLogger()
Returns logger that will be used by engine.
|
Set<String> |
getMaskRequestHeaders()
Gets the set of the request headers to be masked for the logging output.
|
Set<String> |
getMaskResponseHeaders()
Gets the set of the response headers to be masked for the logging output.
|
String |
getResponseCharacterEncoding()
Returns charset in which response shall be generated.
|
static String |
getVersion()
Returns version of engine at runtime.
|
MethodHandler |
registerMethodHandler(String method,
MethodHandler handler)
Registers custom method handler.
|
void |
service(DavRequest davRequest,
DavResponse davResponse)
Handles request.
|
public abstract HierarchyItem getHierarchyItem(String pathAndQuery) throws ServerException
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.null
if hierarchy item not found.ServerException
- Something unexpected occurred.
@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) { return item; } item = FileImpl.getFile(contextPath, this); if (item != null) { 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 }
public abstract Logger getLogger()
Logger
.public abstract String getLicense()
public String getResponseCharacterEncoding()
public MethodHandler registerMethodHandler(String method, MethodHandler 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.@Override protected void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { WebDavEngine engine = new WebDavEngine(logger, license, localMaskRequestHeaders); HttpServletDavRequest davRequest = new HttpServletDavRequest(httpServletRequest); HttpServletDavResponse davResponse = new HttpServletDavResponse(httpServletResponse); 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(davRequest, davResponse); } catch (DavException e) { if (e.getStatus() == WebDavStatus.INTERNAL_ERROR) { logger.logError("Exception during request processing", e); if (showExceptions) e.printStackTrace(new PrintStream(davResponse.getOutputStream())); } } }
@Deprecated public static List<String> getClientLockTokens(DavRequest request)
DavRequest.getClientLockTokens()
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
.public boolean getAutoPutUnderVersionControl()
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.
public boolean getCalculateContentLength()
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.
service(com.ithit.webdav.server.DavRequest, com.ithit.webdav.server.DavResponse)
method.
Default is true.public Set<String> getMaskRequestHeaders()
public Set<String> getMaskResponseHeaders()
public void service(DavRequest davRequest, DavResponse davResponse) throws DavException, IOException
davRequest
- Request.davResponse
- Response.DavException
- If an error occurrs in user or engine implementation.IOException
- If i/o exception occurs.public static String getVersion()
Copyright © ITHit. All Rights Reserved.