|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.xml_project.morganaxproc.filesystem.XProcFilesystem com.xml_project.morganaxproc.filesystem.AlternateFilesystem
public class AlternateFilesystem
This class provides the basic stream-/file access functionality needed in MorganaXProc
by implementing the abstract classes of XProcFilesystem
with the notable exception of
httpRequest
which is just implemented by throwing an UnknownSchemeException
.
This leads to an activation of the "switch back"-feature of doHttpRequest(XProcHttpRequest)
in XProcFilesystem
(see there).
AlternateFilesystem
gets it's name from the standard mechanism for choosing an
implementation for XProcFilesystem
used by MorganaXProc
. It first tries
first to access DefaultFilesystem
(which provides also a working implementation for
p:http-request). If this fails due to missing external java libs, MorganaXProc
switches
back to AlternateFilesystem
. So while this class in the first in order of
extending/implementing XProcFilesystem
it is only the second best choice when
running MorganaXProc
.
This class supports stream access for the following schemes: 'file:', 'http:' and 'https:' realized
via URLConnection
or the standard java.io-package (for 'file:'). Credentials must be
set by using java.net.Authenticator.setDefault. getDirectoryList(URI)
is only implemented
for "file:"-scheme.
To add support for additional uri schemes just extend this class, test whether the uri has one
of the schemes your implementation supports or fall back to this implementation for the standard
schemes. Of course you can also implement your own extension of XProcFilesystem
without
any reference to this class or just use the implementation in StandardFilesystem
as your
base.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.xml_project.morganaxproc.filesystem.XProcFilesystem |
---|
XProcFilesystem.DefectiveURIException, XProcFilesystem.LoadResult, XProcFilesystem.ParseMode, XProcFilesystem.ProtectedResourceException, XProcFilesystem.StreamResult, XProcFilesystem.UnknownSchemeException, XProcFilesystem.UnsupportedMethodException, XProcFilesystem.UnsupportedXMLVersionException |
Field Summary |
---|
Fields inherited from class com.xml_project.morganaxproc.filesystem.XProcFilesystem |
---|
DIRECTORY_MARKER, theConfig |
Constructor Summary | |
---|---|
AlternateFilesystem(XProcConfiguration config)
Creates a new instance of AlternateFilesystem . |
Method Summary | |
---|---|
protected void |
clearCookieStore()
Just an empty method, for there is no support for p:http-request in this class. |
protected java.net.URI |
copyResource(java.net.URI source,
java.net.URI target)
Copies resource source to target . |
protected java.net.URI |
createDirectory(java.net.URI uri)
Create the directory names by the uri. |
protected java.net.URI |
createTemp(java.net.URI folderURI,
boolean createFolder,
java.lang.String prefix,
java.lang.String suffix,
boolean deleteOnExit)
Create Create a temp file in the directory named by uri . |
protected void |
deleteResource(java.net.URI uri,
boolean recursive)
Implementation for file: |
protected java.lang.String |
getContentType(java.net.URI uri)
Returns the content type for the resource with the given uri. |
protected java.lang.String[] |
getDirectoryList(java.net.URI uri)
Returns a list of the resource names found in the directory found on the given uri only
if it has a 'file:' scheme. |
protected java.lang.String |
getEncoding(java.net.URI uri)
Returns the encoding for uri schemes 'file:/', 'http:' and 'https:' throws UnknownSchemeException
for other schemes. |
protected XProcFilesystem.StreamResult |
getInputStream(java.net.URI uri)
Return a StreamResult for the given uri if it has one of supported schemes 'file:', 'http:'
or 'https:'. |
protected java.io.OutputStream |
getOutputStream(java.net.URI uri)
Return an OutputStream for the given uri, but with different behavior according to
the scheme: For 'file:' a regular FileOutputStream is provided, that can be used for
writing data to a medium. |
protected nu.xom.Document |
getResourceInfo(java.net.URI uri,
boolean writeAllowed)
Implementation for file and http(s): Supported standard attributes for "file" are Readable, Writable, Hidden, LastModified and Size. |
protected XProcHttpResponse |
httpRequest(XProcHttpRequest request)
Always throws an UnknownSchemeException since no support for p:http-request is
provided by this class. |
protected java.net.URI |
moveResource(java.net.URI source,
java.net.URI target)
Moves file source to target . |
protected java.net.URI |
touchResource(java.net.URI uri,
long timeStamp)
|
Methods inherited from class com.xml_project.morganaxproc.filesystem.XProcFilesystem |
---|
build, copy, copyResourceChecked, createDirectoryChecked, createTempChecked, deleteResourceChecked, doHttpRequest, getAsStreamSource, getDirectoryList, getDocument, getLoadResult, getResourceInfoChecked, loadDocument, loadDocument, loadDocumentFromPackage, moveResourceChecked, resolveAsStreamSource, resolveCollection, resolveEntity, resolveModule, resolveText, resolveURI, touchResourceChecked, writeData, writeData |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AlternateFilesystem(XProcConfiguration config)
AlternateFilesystem
.
config
- Method Detail |
---|
protected XProcFilesystem.StreamResult getInputStream(java.net.URI uri) throws java.io.IOException, XProcFilesystem.UnknownSchemeException, XProcFilesystem.ProtectedResourceException
StreamResult
for the given uri if it has one of supported schemes 'file:', 'http:'
or 'https:'. For any other scheme, an UnknownSchemeException
is thrown. For 'http:' and
'https:' a ProtectedResourceException
is thrown if the resource can only be accessed by
providing credentials (HTTP response code 401).
getInputStream
in class XProcFilesystem
uri
- the uri from which the StreamResult
should be taken.
StreamResult
an the given uri.
java.io.IOException
- if an error occurred reading the uri.
XProcFilesystem.UnknownSchemeException
- if the uri's scheme is unknown or not supported.
XProcFilesystem.ProtectedResourceException
- if the resource with the given uri
cannot be obtained
without authentication (HTPP status code 401).protected java.io.OutputStream getOutputStream(java.net.URI uri) throws java.io.IOException, XProcFilesystem.UnknownSchemeException, XProcFilesystem.ProtectedResourceException
OutputStream
for the given uri, but with different behavior according to
the scheme: For 'file:' a regular FileOutputStream
is provided, that can be used for
writing data to a medium. If the scheme is 'http:' or 'https:' a request with http method 'post'
is issued. Again: a ProtectedResourceException
is thrown if the resource can only be accessed by
providing credentials (HTTP response code 401).
getOutputStream
in class XProcFilesystem
uri
- the uri for which the OutputStream
is requested.
java.io.IOException
- if an error occurred making the OutputStream
for the uri.
XProcFilesystem.UnknownSchemeException
- if the uri's scheme is unknown or not supported.
XProcFilesystem.ProtectedResourceException
- if the resource with the given uri
cannot be obtained
without authentication (HTPP status code 401).protected java.lang.String getContentType(java.net.URI uri) throws java.io.IOException, XProcFilesystem.UnknownSchemeException, XProcFilesystem.ProtectedResourceException
UnknownSchemeException
is thrown. A ProtectedResourceException
is thrown if the resource can only be accessed by providing credentials (HTTP response code 401).
getContentType
in class XProcFilesystem
uri
- the uri for which the content type is requested.
java.io.IOException
- if any error occurred while requesting the content type.
XProcFilesystem.UnknownSchemeException
- if the uri's scheme is unknown or not supported.
XProcFilesystem.ProtectedResourceException
- if the resource with the given uri
cannot be obtained
without authentication (HTPP status code 401).protected java.lang.String getEncoding(java.net.URI uri) throws java.io.IOException, XProcFilesystem.UnknownSchemeException, XProcFilesystem.ProtectedResourceException
UnknownSchemeException
for other schemes. A ProtectedResourceException
is thrown if the resource can only be accessed by providing credentials (HTTP response code 401).
getEncoding
in class XProcFilesystem
uri
- the uri for which the encoding is requested.
java.io.IOException
- if any error occurred while requesting the encoding.
XProcFilesystem.UnknownSchemeException
- if the uri's scheme is unknown or not supported.
XProcFilesystem.ProtectedResourceException
- if the resource with the given uri
cannot be obtained
without authentication (HTPP status code 401).protected XProcHttpResponse httpRequest(XProcHttpRequest request) throws java.io.IOException, XProcFilesystem.UnknownSchemeException
UnknownSchemeException
since no support for p:http-request is
provided by this class.
httpRequest
in class XProcFilesystem
request
- the request to answer.
XProcHttpResponse
for this request.
java.io.IOException
- if an IOException occurred.
XProcFilesystem.UnknownSchemeException
- if the uri's scheme is unknown or not supported.protected void clearCookieStore()
clearCookieStore
in class XProcFilesystem
protected java.net.URI createTemp(java.net.URI folderURI, boolean createFolder, java.lang.String prefix, java.lang.String suffix, boolean deleteOnExit) throws XProcFilesystem.UnknownSchemeException, java.io.FileNotFoundException, java.io.IOException
XProcFilesystem
uri
.
createTemp
in class XProcFilesystem
folderURI
- the directory in which the temp file should be created.prefix
- the file names prefix or null.suffix
- the file names suffix or null.deleteOnExit
- true, if the created file should be deleted when the processor terminates.
XProcFilesystem.UnknownSchemeException
java.io.FileNotFoundException
java.io.IOException
protected java.net.URI createDirectory(java.net.URI uri) throws XProcFilesystem.UnknownSchemeException, java.io.IOException
XProcFilesystem
createDirectory
in class XProcFilesystem
XProcFilesystem.UnknownSchemeException
java.io.IOException
protected java.net.URI touchResource(java.net.URI uri, long timeStamp) throws XProcFilesystem.UnknownSchemeException, java.io.FileNotFoundException, java.io.IOException
touchResource
in class XProcFilesystem
timeStamp
- value.
XProcFilesystem.UnknownSchemeException
java.io.FileNotFoundException
java.io.IOException
protected java.net.URI moveResource(java.net.URI source, java.net.URI target) throws XProcFilesystem.UnknownSchemeException, java.io.FileNotFoundException, java.io.IOException
XProcFilesystem
source
to target
. If target
names
a folder, the copy is put into this folder. If a file with target
already exists,
it is overwritten.
moveResource
in class XProcFilesystem
XProcFilesystem.UnknownSchemeException
java.io.FileNotFoundException
java.io.IOException
protected java.net.URI copyResource(java.net.URI source, java.net.URI target) throws XProcFilesystem.UnknownSchemeException, java.io.FileNotFoundException, java.io.IOException
XProcFilesystem
source
to target
. If target
names
a folder, the copy is put into this folder. If a file with target
already exists,
it is overwritten.
copyResource
in class XProcFilesystem
source
- a uri designating a filetarget
- a uri designating a file or a folder
source
was copied to.
XProcFilesystem.UnknownSchemeException
java.io.FileNotFoundException
java.io.IOException
protected void deleteResource(java.net.URI uri, boolean recursive) throws XProcFilesystem.UnknownSchemeException, java.io.FileNotFoundException, java.io.IOException
deleteResource
in class XProcFilesystem
XProcFilesystem.UnknownSchemeException
java.io.FileNotFoundException
java.io.IOException
protected nu.xom.Document getResourceInfo(java.net.URI uri, boolean writeAllowed) throws XProcFilesystem.UnknownSchemeException, java.io.IOException, java.io.FileNotFoundException
getResourceInfo
in class XProcFilesystem
uri
- the uri to get the information for.
UnknownSchemeException
java.io.FileNotFoundException
XProcFilesystem.UnknownSchemeException
java.io.IOException
protected java.lang.String[] getDirectoryList(java.net.URI uri) throws java.io.IOException, XProcFilesystem.UnknownSchemeException, XProcFilesystem.ProtectedResourceException
uri
only
if it has a 'file:' scheme. If the
uri does not name a directory, an IOException
is thrown. The names appearing in the
result are just the file names, i.e. the last segment of the path. If the directory at uri
contains directories, the names of this directories must be returned
prefix with DIRECTORY_MARKER
. For any non 'file:' scheme, an UnknownSchemeException
is thrown.
getDirectoryList
in class XProcFilesystem
uri
- the uri for which the directory listing is requested.
java.io.IOException
- if an error occurred reading the resource at uri or if the resource is no directory.
XProcFilesystem.ProtectedResourceException
- if the resource with the given uri
cannot be obtained
without authentication (HTPP status code 401).
XProcFilesystem.UnknownSchemeException
- if the uri's scheme is unknown or not supported.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |