|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object smbdav.AbstractHandler
An abstract implementation of the MethodHandler
interface.
This class serves as a convenient basis for building method handlers.
In addition to providing basic init
and destroy
methods, several useful utility methods are supplied.
Field Summary |
Fields inherited from interface smbdav.MethodHandler |
SC_FAILED_DEPENDENCY, SC_INSUFFICIENT_STORAGE, SC_LOCKED, SC_MULTISTATUS, SC_PROCESSING, SC_UNPROCESSABLE_ENTITY |
Constructor Summary | |
AbstractHandler()
|
Method Summary | |
protected int |
checkConditionalRequest(javax.servlet.http.HttpServletRequest request,
jcifs.smb.SmbFile file)
Checks if a conditional request should apply. |
protected int |
checkLockOwnership(javax.servlet.http.HttpServletRequest request,
jcifs.smb.SmbFile file)
Checks lock ownership. |
protected jcifs.smb.SmbFile |
createSmbFile(java.lang.String smbUrl,
jcifs.smb.NtlmPasswordAuthentication authentication)
Convenience method to create an SmbFile object
from a specified SMB URL and authentication information. |
void |
destroy()
Called by the Davenport servlet to indicate that the handler is being taken out of service. |
protected jcifs.smb.SmbFileFilter |
getFilter()
Returns the SmbFileFilter used to filter resource
requests. |
protected LockManager |
getLockManager()
Returns the LockManager used to maintain WebDAV locks. |
protected java.security.Principal |
getPrincipal(javax.servlet.http.HttpServletRequest request)
Obtains the requesting principal. |
protected java.lang.String |
getRequestURICharset()
Returns the charset used to interpret request URIs. |
protected java.lang.String |
getRequestURL(javax.servlet.http.HttpServletRequest request)
Convenience method to return the HTTP URL from the request, rewritten against the active context base as necessary. |
protected javax.servlet.ServletConfig |
getServletConfig()
Returns the ServletConfig object that was provided to the
init method. |
protected jcifs.smb.SmbFile |
getSmbFile(javax.servlet.http.HttpServletRequest request,
jcifs.smb.NtlmPasswordAuthentication auth)
Convenience method to retrieve the SmbFile that
is the target of the given request. |
protected java.lang.String |
getSmbURL(javax.servlet.http.HttpServletRequest request,
java.lang.String httpUrl)
Convenience method to convert a given HTTP URL to the corresponding SMB URL. |
protected java.lang.String |
getSmbURL(javax.servlet.http.HttpServletRequest request,
java.lang.String httpUrl,
java.lang.String charset)
Convenience method to convert a given HTTP URL to the corresponding SMB URL. |
void |
init(javax.servlet.ServletConfig config)
Initializes the method handler. |
protected java.lang.String |
rewriteURL(javax.servlet.http.HttpServletRequest request,
java.lang.String url)
Rewrites the supplied HTTP URL against the active context base if necessary. |
abstract void |
service(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
jcifs.smb.NtlmPasswordAuthentication auth)
Called by the Davenport servlet to allow the handler to service a request. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AbstractHandler()
Method Detail |
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
ServletConfig
object and makes it available
via the getServletConfig
method. Subclasses overriding
this method should start by invoking
super.init(config);
init
in interface MethodHandler
config
- a ServletConfig
object containing
the servlet's configuration and initialization parameters.
javax.servlet.ServletException
- If an error occurs during initialization.public void destroy()
MethodHandler
Servlet
destroy
method. This method
gives the handler an opportunity to clean up any resources that
are being held. After this method has been called, the
service
method will not be invoked again.
destroy
in interface MethodHandler
protected javax.servlet.ServletConfig getServletConfig()
ServletConfig
object that was provided to the
init
method.
ServletConfig
object containing the servlet's
configuration and initialization parameters.protected java.lang.String getRequestURICharset()
String
containing the charset name.protected java.lang.String rewriteURL(javax.servlet.http.HttpServletRequest request, java.lang.String url)
request
- The request being serviced.url
- The HTTP URL to process for rewriting.
String
containing the rewritten URL. If
no rewriting is required, the provided URL will be returned.protected java.lang.String getRequestURL(javax.servlet.http.HttpServletRequest request)
request
- The request being serviced.
String
containing the rewritten request URL.protected java.lang.String getSmbURL(javax.servlet.http.HttpServletRequest request, java.lang.String httpUrl) throws java.io.IOException
getRequestURICharset()
.
Note: Currently, the jCIFS library does not handle escaped
characters in SMB URLs (i.e.,
"smb://server/share/my%20file.txt
". The SMB URLs
returned by this method are unescaped for compatibility with jCIFS
(i.e., "smb://server/share/my file.txt
". This may result
in URLs which do not conform with RFC 2396. Such URLs may not be
accepted by systems expecting compliant URLs (such as Java 1.4's
java.net.URI
class).
request
- The servlet request upon which the HTTP URL is based.httpUrl
- An HTTP URL from which the SMB URL is derived.
java.io.IOException
- If an SMB URL cannot be constructed from the
given request and HTTP URL.protected java.lang.String getSmbURL(javax.servlet.http.HttpServletRequest request, java.lang.String httpUrl, java.lang.String charset) throws java.io.IOException
smb://server/share/my%20file.txt
". The SMB URLs
returned by this method are unescaped for compatibility with jCIFS
(i.e., "smb://server/share/my file.txt
". This may result
in URLs which do not conform with RFC 2396. Such URLs may not be
accepted by systems expecting compliant URLs (such as Java 1.4's
java.net.URI
class).
request
- The servlet request upon which the HTTP URL is based.httpUrl
- An HTTP URL from which the SMB URL is derived.charset
- The character set that should be used to interpret the
HTTP URL.
java.io.IOException
- If an SMB URL cannot be constructed from the
given request and HTTP URL.protected LockManager getLockManager()
LockManager
used to maintain WebDAV locks.
null
if no lock manager is present.protected jcifs.smb.SmbFileFilter getFilter()
SmbFileFilter
used to filter resource
requests. The default implementation uses the global filter
installed by the Davenport servlet (if applicable).
null
if no filter is to be applied.protected jcifs.smb.SmbFile getSmbFile(javax.servlet.http.HttpServletRequest request, jcifs.smb.NtlmPasswordAuthentication auth) throws java.io.IOException
SmbFile
that
is the target of the given request. This will attempt to obtain
the file by interpreting the URL with the character set given by
getRequestURICharset()
; if this file does not exist, a
second attempt will be made using the UTF-8 charset. If neither file
exists, the result of the first attempt will be returned.
request
- The request that is being serviced.auth
- The user's authentication information.
java.io.IOException
- If the SmbFile
targeted by
the specified request could not be created.protected jcifs.smb.SmbFile createSmbFile(java.lang.String smbUrl, jcifs.smb.NtlmPasswordAuthentication authentication) throws java.io.IOException
SmbFile
object
from a specified SMB URL and authentication information.
The SmbFile
returned will automatically be adjusted
to include a trailing slash ("/") in the event that it refers to a
directory, share, server, or workgroup.
smbUrl
- The SMB URL from which the SmbFile
object
will be created.authentication
- The authentication information to apply to the
SmbFile
object.
java.io.IOException
- If an SmbFile
object could not be
created from the provided information.protected int checkConditionalRequest(javax.servlet.http.HttpServletRequest request, jcifs.smb.SmbFile file) throws java.io.IOException
If-Match
",
"If-None-Match
", "If-Modified-Since
", or
"If-Unmodified-Since" -- "If-Range
" is not
currently supported), this method will indicate whether the
request should be processed. If locking is supported, this
method will additionally check the "If
" header to
determine whether the request should apply based on the status
of the relevant locks.
- Parameters:
request
- The servlet request whose conditional cache headers
will be examined.file
- The resource that is being examined.
- Returns:
- An HTTP status code indicating the result. This will be one of:
200
(HttpServletResponse.SC_OK
) --
if the request should be serviced normally
304
(HttpServletResponse.SC_NOT_MODIFIED
)
-- if the resource has not been modified
400
(HttpServletResponse.SC_BAD_REQUEST
) --
if the client has submitted a malformed conditional header
412
(HttpServletResponse.SC_PRECONDITION_FAILED
) --
if no matching entity was found, or the request should not proceed
based on the current lock status
- Throws:
jcifs.smb.SmbException
- If an error occurs while examining the resource.
java.io.IOException
protected java.security.Principal getPrincipal(javax.servlet.http.HttpServletRequest request) throws java.io.IOException
request
- The request being serviced.
Principal
object containing the authenticated
requesting principal.
java.io.IOException
protected int checkLockOwnership(javax.servlet.http.HttpServletRequest request, jcifs.smb.SmbFile file) throws java.io.IOException
request
- The request being serviced.file
- The requested resource.
int
containing the return HTTP status code.
java.io.IOException
- If an IO error occurs.public abstract void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, jcifs.smb.NtlmPasswordAuthentication auth) throws java.io.IOException, javax.servlet.ServletException
MethodHandler
service
in interface MethodHandler
request
- The request that is being serviced.response
- The servlet response object.auth
- The authentication information provided by the user.
javax.servlet.ServletException
- If an exception occurs that interferes with
normal operation.
java.io.IOException
- If an input or output exception occurs.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |