com.xml_project.morganaxproc.filesystem
Class XProcFilesystem

java.lang.Object
  extended by com.xml_project.morganaxproc.filesystem.XProcFilesystem
All Implemented Interfaces:
CollectionURIResolver, ModuleURIResolver, EntityResolver
Direct Known Subclasses:
AlternateFilesystem

public abstract class XProcFilesystem
extends Object
implements CollectionURIResolver, ModuleURIResolver, EntityResolver

This class is the core of file-/stream access in MorganaXProc although it does not provide any file-/stream access itself. This task is left to extending classes.

The basic methods for access files and streams via uri are implemented. The core implementation is left over to classes extending XProcFilesystem.

Practically you will probably never extend XProcFilesystem but extend one of the classes already implementing the abstract methods in XProcFilesystem. Typically you will extends DefaultFilesystem or AlternativeFilesystem to add support for additional uri schemes or enhance the implemented methods for http-request.


Nested Class Summary
static class XProcFilesystem.LoadResult
          A class wrapping the results from loading a resource from an uri.
static class XProcFilesystem.ParseMode
          The parsing modes used when building XOM documents.
static class XProcFilesystem.ProtectedResourceException
          An Exception thrown if the request resource needs authentication.
 class XProcFilesystem.StreamResult
          A class wrapping an InputStream and the uri from which the input stream was obtained.
static class XProcFilesystem.UnknownSchemeException
          An Exception thrown if the scheme in an uri is not known or not supported.
 class XProcFilesystem.UnsupportedMethodException
          An Exception thrown if a XProcHttpRequest which an unsupported method is found.
static class XProcFilesystem.UnsupportedXMLVersionException
           
 
Field Summary
static String DIRECTORY_MARKER
          A prefix to mark directory entries in the result of getDirectoryList.
 
Constructor Summary
protected XProcFilesystem(XProcConfiguration config)
           
 
Method Summary
 nu.xom.Document build(String textDoc, String uri, XProcFilesystem.ParseMode parseMode)
          Builds a XOM document from the given String using the given parseMode and with uri as base uri for the document.
protected abstract  void clearCookieStore()
          Makes sure the cookie store used for httpRequest is empty.
 XProcFilesystem copy(XProcConfiguration newConfig)
           Creates a new instance of the XProcFilesystem.
protected abstract  URI copyResource(URI source, URI target)
          Copies resource source to target.
 URI copyResourceChecked(URI source, URI target)
          Implementation for pxf:copy
protected abstract  URI createDirectory(URI uri)
          Create the directory names by the uri.
 URI createDirectoryChecked(URI uri)
          Implementation for pxf:mkdir
protected abstract  URI createTemp(URI uri, boolean createFolder, String prefix, String suffix, boolean deleteOnExit)
          Create Create a temp file in the directory named by uri.
 URI createTempChecked(URI folderURI, boolean createFolder, String prefix, String suffix, boolean deleteOnExit)
           
protected abstract  void deleteResource(URI uri, boolean recursive)
          Delete the resource designated by uri.
 void deleteResourceChecked(URI uri, boolean recursive)
          Implementation for pxf:delete
 XProcHttpResponse doHttpRequest(XProcHttpRequest request, com.xml_project.morganaxproc.morganapkg.MorganaPKG.UriSpaces space)
          This method performs a http request by calling abstract method httpRequest(XProcHttpRequest) or (if this fails) by getting the uri via getInputStream for method 'get'.
 StreamSource getAsStreamSource(URI uri)
           
protected abstract  String getContentType(URI uri)
          Return the content type of the resource designated by uri.
protected abstract  String[] getDirectoryList(URI uri)
          Returns a list of the resource names found in the directory found on the given uri.
 String[] getDirectoryList(XProcSecurityManager.Operations operation, URI uri)
          Gets a list of resource names in the directory named by the uri after a security check for the given operation is performed.
protected  nu.xom.Document getDocument(URI uri, XProcFilesystem.ParseMode parseMode)
           Creates a new XOM document by getting an InputStream via getInputStream for the given uri and then building it, using the given parseMode.
protected abstract  String getEncoding(URI uri)
          Return the encoding of the resource designated by uri.
protected abstract  XProcFilesystem.StreamResult getInputStream(URI uri)
          Returns a StreamResult from the given uri.
 XProcFilesystem.LoadResult getLoadResult(XProcSecurityManager.Operations operation, String href, URI primaryBase, String secondaryBase, String contentType, String dataWrapper)
          Returns a LoadResult obtained from href made absolute by using primaryBase or (if this fails) by secondaryBase after performing a security check for the given operation.
protected abstract  OutputStream getOutputStream(URI uri)
          Returns an OutputStream associated with the given uri.
protected abstract  nu.xom.Document getResourceInfo(URI uri, boolean writeAllowed)
          Returns a document as specified for pxf:info or null, if the resource does not exist.
 nu.xom.Document getResourceInfoChecked(URI uri)
          Implementation for pxf:info
protected abstract  XProcHttpResponse httpRequest(XProcHttpRequest request)
          Returns a XProcHttpResponse answering the given XProcHttpRequest.
 nu.xom.Document loadDocument(XProcSecurityManager.Operations operation, String href, URI primaryBase, String secondaryBase, XProcFilesystem.ParseMode parseMode)
          Returns a XOM document from the URI given by href either made absolute by using primaryBase or, if this fails, by using secondaryBase.
 nu.xom.Document loadDocument(XProcSecurityManager.Operations operation, URI uri, XProcFilesystem.ParseMode parseMode)
          Returns a XOM document from the given uri build with the given parseMode after a security check is performed for the given operation.
 nu.xom.Document loadDocumentFromPackage(XProcSecurityManager.Operations op, String href, com.xml_project.morganaxproc.morganapkg.MorganaPKG.UriSpaces space, XProcFilesystem.ParseMode mode)
          Tries to load a component as document from an EXPath packaging system, if one is installed.
protected abstract  URI moveResource(URI source, URI target)
          Moves file source to target.
 URI moveResourceChecked(URI source, URI target)
          Implementation for pxf:move
 StreamSource resolveAsStreamSource(String href, String base, com.xml_project.morganaxproc.morganapkg.MorganaPKG.UriSpaces spaces)
           
 List<URI> resolveCollection(URI theURI)
          Represents the default implementation for fn:collection used in XPath, p:xquery and p:xslt.
 InputSource resolveEntity(String publicId, String systemId)
           
 List<StreamSource> resolveModule(String targetNamespace, List<String> locationHints, String baseURI)
          Called to resolve module import in XQuery and p:xquery
 String resolveText(URI absoluteURI, String encoding)
           
 URI resolveURI(String href, URI baseURI)
          Generates an absolute URI from href and baseURI.
protected abstract  URI touchResource(URI uri, long timeStamp)
           
 URI touchResourceChecked(URI uri, long timestamp)
          Implementation for pxf:touch
protected  void writeData(byte[] data, URI uri)
          Writes data to the uri.
 String writeData(XProcSecurityManager.Operations operation, byte[] data, URI uri)
          Writes data to the uri after a security check for the given operation is performed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTORY_MARKER

public static final String DIRECTORY_MARKER
A prefix to mark directory entries in the result of getDirectoryList.

See Also:
Constant Field Values
Constructor Detail

XProcFilesystem

protected XProcFilesystem(XProcConfiguration config)
Method Detail

copy

public XProcFilesystem copy(XProcConfiguration newConfig)
                     throws Exception

Creates a new instance of the XProcFilesystem. This method is used in XProcConfiguration to create a new instance while creating a copy of an XProcConfiguration.
Implementers should overwrite this method, if the implementation does not support constructor with (XProcConfiguration config).

Parameters:
newConfig - the newConfiguration for the XProcFilesystem.
Returns:
a new instance of the filesystem.
Throws:
Exception - thrown, when unable to create a new instance.

getInputStream

protected abstract XProcFilesystem.StreamResult getInputStream(URI uri)
                                                        throws IOException,
                                                               XProcFilesystem.UnknownSchemeException,
                                                               XProcFilesystem.ProtectedResourceException
Returns a StreamResult from the given uri.

Parameters:
uri - the uri from which the StreamResult should be taken.
Returns:
the StreamResult an the given uri.
Throws:
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).

getOutputStream

protected abstract OutputStream getOutputStream(URI uri)
                                         throws IOException,
                                                XProcFilesystem.UnknownSchemeException,
                                                XProcFilesystem.ProtectedResourceException
Returns an OutputStream associated with the given uri.

Parameters:
uri - the uri for which the OutputStream is requested.
Returns:
the requested output stream.
Throws:
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).

getContentType

protected abstract String getContentType(URI uri)
                                  throws IOException,
                                         XProcFilesystem.UnknownSchemeException,
                                         XProcFilesystem.ProtectedResourceException
Return the content type of the resource designated by uri.

Parameters:
uri - the uri for which the content type is requested.
Returns:
the requested content type.
Throws:
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).

getEncoding

protected abstract String getEncoding(URI uri)
                               throws IOException,
                                      XProcFilesystem.UnknownSchemeException,
                                      XProcFilesystem.ProtectedResourceException
Return the encoding of the resource designated by uri.

Parameters:
uri - the uri for which the encoding is requested.
Returns:
the requested encoding.
Throws:
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).

httpRequest

protected abstract XProcHttpResponse httpRequest(XProcHttpRequest request)
                                          throws IOException,
                                                 XProcFilesystem.UnknownSchemeException
Returns a XProcHttpResponse answering the given XProcHttpRequest.

Parameters:
request - the request to answer.
Returns:
the XProcHttpResponse for this request.
Throws:
IOException - if an IOException occurred.
XProcFilesystem.UnknownSchemeException - if the uri's scheme is unknown or not supported.

clearCookieStore

protected abstract void clearCookieStore()
Makes sure the cookie store used for httpRequest is empty.


getDirectoryList

protected abstract String[] getDirectoryList(URI uri)
                                      throws IOException,
                                             XProcFilesystem.ProtectedResourceException,
                                             XProcFilesystem.UnknownSchemeException
Returns a list of the resource names found in the directory found on the given uri. 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.

Parameters:
uri - the uri for which the directory listing is requested.
Returns:
a string array which the content of the requested directory.
Throws:
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.

getResourceInfo

protected abstract nu.xom.Document getResourceInfo(URI uri,
                                                   boolean writeAllowed)
                                            throws XProcFilesystem.UnknownSchemeException,
                                                   IOException,
                                                   FileNotFoundException
Returns a document as specified for pxf:info or null, if the resource does not exist.

Parameters:
uri - the uri to get the information for.
Returns:
the document or null.
Throws:
XProcFilesystem.UnknownSchemeException
IOException
FileNotFoundException

copyResource

protected abstract URI copyResource(URI source,
                                    URI target)
                             throws XProcFilesystem.UnknownSchemeException,
                                    FileNotFoundException,
                                    IOException
Copies resource 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.

Parameters:
source - a uri designating a file
target - a uri designating a file or a folder
Returns:
the target uri where source was copied to.
Throws:
XProcFilesystem.UnknownSchemeException
FileNotFoundException
IOException

moveResource

protected abstract URI moveResource(URI source,
                                    URI target)
                             throws XProcFilesystem.UnknownSchemeException,
                                    FileNotFoundException,
                                    IOException
Moves file 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.

Parameters:
source -
target -
Returns:
the absolute uri of the target.
Throws:
XProcFilesystem.UnknownSchemeException
FileNotFoundException
IOException

deleteResource

protected abstract void deleteResource(URI uri,
                                       boolean recursive)
                                throws XProcFilesystem.UnknownSchemeException,
                                       FileNotFoundException,
                                       IOException
Delete the resource designated by uri. If uri designated an non empty folder, recursive must be true, otherwise an IOException is thrown.

Parameters:
uri -
recursive -
Throws:
XProcFilesystem.UnknownSchemeException
FileNotFoundException
IOException

touchResource

protected abstract URI touchResource(URI uri,
                                     long timeStamp)
                              throws XProcFilesystem.UnknownSchemeException,
                                     FileNotFoundException,
                                     IOException
Parameters:
uri -
timeStamp - value.
Returns:
the absolute uri of the touched resource.
Throws:
XProcFilesystem.UnknownSchemeException
FileNotFoundException
IOException

createDirectory

protected abstract URI createDirectory(URI uri)
                                throws XProcFilesystem.UnknownSchemeException,
                                       IOException
Create the directory names by the uri.

Parameters:
uri -
Returns:
the absolute uri of the created directory.
Throws:
XProcFilesystem.UnknownSchemeException
IOException

createTemp

protected abstract URI createTemp(URI uri,
                                  boolean createFolder,
                                  String prefix,
                                  String suffix,
                                  boolean deleteOnExit)
                           throws XProcFilesystem.UnknownSchemeException,
                                  FileNotFoundException,
                                  IOException
Create Create a temp file in the directory named by uri.

Parameters:
uri - 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.
Returns:
the absolute uri of the created temp file
Throws:
XProcFilesystem.UnknownSchemeException
FileNotFoundException
IOException

createDirectoryChecked

public final URI createDirectoryChecked(URI uri)
                                 throws XProcFilesystem.UnknownSchemeException,
                                        IOException,
                                        XProcSecurityException
Implementation for pxf:mkdir

Parameters:
uri -
Returns:
the absolute uri of the created resource.
Throws:
XProcFilesystem.UnknownSchemeException
IOException
XProcSecurityException

createTempChecked

public final URI createTempChecked(URI folderURI,
                                   boolean createFolder,
                                   String prefix,
                                   String suffix,
                                   boolean deleteOnExit)
                            throws XProcSecurityException,
                                   XProcFilesystem.UnknownSchemeException,
                                   FileNotFoundException,
                                   IOException
Parameters:
folderURI -
createFolder -
prefix -
suffix -
deleteOnExit -
Returns:
the absolute uri of the created resource.
Throws:
XProcSecurityException
XProcFilesystem.UnknownSchemeException
FileNotFoundException
IOException

touchResourceChecked

public final URI touchResourceChecked(URI uri,
                                      long timestamp)
                               throws XProcFilesystem.UnknownSchemeException,
                                      FileNotFoundException,
                                      XProcSecurityException,
                                      IOException
Implementation for pxf:touch

Parameters:
uri -
timestamp -
Returns:
the absolute uri of the touched resource.
Throws:
XProcFilesystem.UnknownSchemeException
FileNotFoundException
XProcSecurityException
IOException

moveResourceChecked

public final URI moveResourceChecked(URI source,
                                     URI target)
                              throws XProcFilesystem.UnknownSchemeException,
                                     FileNotFoundException,
                                     XProcSecurityException,
                                     IOException
Implementation for pxf:move

Parameters:
source -
target -
Returns:
the absolute uri of the target.
Throws:
XProcFilesystem.UnknownSchemeException
FileNotFoundException
XProcSecurityException
IOException

copyResourceChecked

public final URI copyResourceChecked(URI source,
                                     URI target)
                              throws XProcFilesystem.UnknownSchemeException,
                                     FileNotFoundException,
                                     XProcSecurityException,
                                     IOException
Implementation for pxf:copy

Parameters:
source -
target -
Returns:
the absolute uri of the target.
Throws:
XProcFilesystem.UnknownSchemeException
FileNotFoundException
XProcSecurityException
IOException

deleteResourceChecked

public final void deleteResourceChecked(URI uri,
                                        boolean recursive)
                                 throws XProcSecurityException,
                                        FileNotFoundException,
                                        XProcFilesystem.UnknownSchemeException,
                                        IOException
Implementation for pxf:delete

Parameters:
uri -
recursive -
Throws:
XProcSecurityException
FileNotFoundException
XProcFilesystem.UnknownSchemeException
IOException

getResourceInfoChecked

public final nu.xom.Document getResourceInfoChecked(URI uri)
                                             throws XProcSecurityException,
                                                    IOException,
                                                    FileNotFoundException,
                                                    XProcFilesystem.UnknownSchemeException
Implementation for pxf:info

Parameters:
uri -
Returns:
a document representing the read infos.
Throws:
XProcSecurityException
IOException
FileNotFoundException
XProcFilesystem.UnknownSchemeException

resolveCollection

public List<URI> resolveCollection(URI theURI)
                            throws XPathException
Represents the default implementation for fn:collection used in XPath, p:xquery and p:xslt.

The default behavior is this:

Specified by:
resolveCollection in interface CollectionURIResolver
Parameters:
theURI - which designates the collection
Returns:
a list of uris associated with the given uri.
Throws:
XPathException - raised, if any Exception occured.

getAsStreamSource

public final StreamSource getAsStreamSource(URI uri)
                                     throws TransformerException
Throws:
TransformerException

resolveURI

public final URI resolveURI(String href,
                            URI baseURI)
                     throws IOException
Generates an absolute URI from href and baseURI. If href is relative, baseURI is used to make it absolute.

Parameters:
href - an uri (fragment).
baseURI - an absolute uri.
Returns:
the absolute uri resulting from href and baseURI.
Throws:
IOException - if href is null or href is relative and baseURI is null or there is a syntax error in href.

loadDocument

public final nu.xom.Document loadDocument(XProcSecurityManager.Operations operation,
                                          String href,
                                          URI primaryBase,
                                          String secondaryBase,
                                          XProcFilesystem.ParseMode parseMode)
                                   throws IOException,
                                          nu.xom.ValidityException,
                                          nu.xom.ParsingException,
                                          XProcFilesystem.UnknownSchemeException,
                                          XProcSecurityException,
                                          XProcFilesystem.ProtectedResourceException,
                                          XProcFilesystem.UnsupportedXMLVersionException

Returns a XOM document from the URI given by href either made absolute by using primaryBase or, if this fails, by using secondaryBase. The document is build with the given parseMode after a security check is performed for the given operation. After making href absolute in the specified way, loadDocument(Operations,URI,ParseMode) is called.

Parameters:
operation - the Operation for which the docuement should be loaded.
href - the uri (fragment) form which the document should be loaded.
primaryBase - the first uri to use to make hrefabsolute.
secondaryBase - the second uri to use to make hrefabsolute.
Returns:
the document on the uri given by href and either primaryBase or secondary base.
Throws:
IOException - if an IOException occurred obtaining the input stream.
nu.xom.ParsingException - if the input stream is not a valid document.
nu.xom.ValidityException - if the input stream is not a valid document.
XProcFilesystem.UnknownSchemeException - if the scheme in uri is unknown or not supported.
XProcSecurityException - if accessing this resource for this operation is forbidden by the current setting of XProcSecurityManager.
XProcFilesystem.ProtectedResourceException - if the resource with the given uri cannot be obtained without authentication (HTPP status code 401).
XProcFilesystem.UnsupportedXMLVersionException - if the document is in an xml version not supported.

loadDocument

public final nu.xom.Document loadDocument(XProcSecurityManager.Operations operation,
                                          URI uri,
                                          XProcFilesystem.ParseMode parseMode)
                                   throws IOException,
                                          nu.xom.ParsingException,
                                          nu.xom.ValidityException,
                                          XProcFilesystem.UnknownSchemeException,
                                          XProcSecurityException,
                                          XProcFilesystem.ProtectedResourceException,
                                          XProcFilesystem.UnsupportedXMLVersionException

Returns a XOM document from the given uri build with the given parseMode after a security check is performed for the given operation. To build the document from the uri getDocument is called.

Parameters:
operation - the Operations for which the document should be loaded.
uri - the uri from which the document should be loaded.
parseMode - the ParseMode to use for building the document.
Returns:
the document on the given uri.
Throws:
IOException - if an IOException occurred obtaining the input stream.
nu.xom.ParsingException - if the input stream is not a valid document.
nu.xom.ValidityException - if the input stream is not a valid document.
XProcFilesystem.UnknownSchemeException - if the scheme in uri is unknown or not supported.
XProcSecurityException - if accessing this resource for this operation is forbidden by the current setting of XProcSecurityManager.
XProcFilesystem.ProtectedResourceException - if the resource with the given uri cannot be obtained without authentication (HTPP status code 401).
XProcFilesystem.UnsupportedXMLVersionException - if the document is in an xml version not supported.

build

public nu.xom.Document build(String textDoc,
                             String uri,
                             XProcFilesystem.ParseMode parseMode)
                      throws IOException,
                             nu.xom.ParsingException,
                             nu.xom.ValidityException

Builds a XOM document from the given String using the given parseMode and with uri as base uri for the document.

This method should only be used with sources already checked by XProcSecuritySystem because no security checking is performed here.

Parameters:
textDoc - the String with the serialized document.
uri - the base uri for the newly build document.
parseMode - the ParseMode to use while building the document.
Returns:
the newly build document
Throws:
IOException - if an error occurred reading the reader or if no builder for the parseMode was found.
nu.xom.ParsingException - if the reader does not contain a valid document.
nu.xom.ValidityException - if the reader does not contain a valid document.

getLoadResult

public final XProcFilesystem.LoadResult getLoadResult(XProcSecurityManager.Operations operation,
                                                      String href,
                                                      URI primaryBase,
                                                      String secondaryBase,
                                                      String contentType,
                                                      String dataWrapper)
                                               throws IOException,
                                                      XProcFilesystem.UnknownSchemeException,
                                                      XProcSecurityException,
                                                      XProcFilesystem.ProtectedResourceException

Returns a LoadResult obtained from href made absolute by using primaryBase or (if this fails) by secondaryBase after performing a security check for the given operation.

Parameters:
operation - the Operations for which the LoadResult is requested.
href - a uri (fragment) to the resource.
primaryBase - the base uri used to make href absolute.
secondaryBase - the base uri used to make href absolute if loading of (href/baseURI) fails.
contentType - may be used to overwrite the content type of the obtained resource if it is empty, "application/octet-stream" or "content/unknown". If contentType is null, the original content type of the resource is used.
dataWrapper - the java class name of the DataWrapper to use or null. If dataWrapper is null, a possible wrapper for the data is determined using either the extension of the uri or the content type found and the settings in XProcConfiguration.
Returns:
the LoadResult found.
Throws:
IOException - if there is a problem with reading the data on the uri.
XProcFilesystem.UnknownSchemeException - if the uri's scheme is unknown or not supported.
XProcSecurityException - if accessing this resource for this operation is forbidden by the current setting of XProcSecurityManager.
XProcFilesystem.ProtectedResourceException - if the resource with the given uri cannot be obtained without authentication (HTPP status code 401).

writeData

public final String writeData(XProcSecurityManager.Operations operation,
                              byte[] data,
                              URI uri)
                       throws IOException,
                              XProcFilesystem.UnknownSchemeException,
                              XProcSecurityException,
                              XProcFilesystem.ProtectedResourceException

Writes data to the uri after a security check for the given operation is performed.

Parameters:
operation - the Operations for which the data should be written.
data - the data to be written.
uri - the uri to which the data should be written.
Returns:
the uri to which the data was actually written.
Throws:
IOException - if any problem occurs writing the data.
XProcFilesystem.UnknownSchemeException - if the uri's scheme is unknown or not supported.
XProcSecurityException - if accessing this resource for this operation is forbidden by the current setting of XProcSecurityManager.
XProcFilesystem.ProtectedResourceException - if the resource with the made uri cannot be accessed without authentication (HTPP status code 401).

writeData

protected void writeData(byte[] data,
                         URI uri)
                  throws XProcFilesystem.UnknownSchemeException,
                         XProcFilesystem.ProtectedResourceException,
                         IOException

Writes data to the uri.

This is a low level method called by writeData(Operations, byte[], URI)

.

You should never call it directly, because there is no security checking in this method. The method is declared protected so you can overwrite it in extending classes to store data to uris where no output stream is available or which need special treatment.

Parameters:
data - data the data to be written.
uri - the uri to which the data should be written.
Throws:
XProcFilesystem.UnknownSchemeException - if the uri's scheme is unknown or not supported.
XProcFilesystem.ProtectedResourceException - if the resource with the made uri cannot be accessed without authentication (HTPP status code 401).
IOException - if any problem occurs writing the data.

getDirectoryList

public final String[] getDirectoryList(XProcSecurityManager.Operations operation,
                                       URI uri)
                                throws XProcSecurityException,
                                       XProcFilesystem.ProtectedResourceException,
                                       XProcFilesystem.UnknownSchemeException,
                                       IOException

Gets a list of resource names in the directory named by the uri after a security check for the given operation is performed.

Parameters:
operation - the Operations for which the data should be written.
uri - the uri to which the data should be written.
Returns:
a list with the ressource names found on the given uri.
Throws:
XProcSecurityException - if accessing this resource for this operation is forbidden by the current setting of XProcSecurityManager.
XProcFilesystem.ProtectedResourceException - if the resource with the made uri cannot be accessed without authentication (HTPP status code 401).
XProcFilesystem.UnknownSchemeException - if the uri's scheme is unknown or not supported.
IOException - if any problem occurs reading the directory.

doHttpRequest

public final XProcHttpResponse doHttpRequest(XProcHttpRequest request,
                                             com.xml_project.morganaxproc.morganapkg.MorganaPKG.UriSpaces space)
                                      throws IOException,
                                             XProcFilesystem.UnknownSchemeException,
                                             XProcFilesystem.ProtectedResourceException,
                                             com.xml_project.morganaxproc.core.XProcRuntimeException,
                                             XProcFilesystem.UnsupportedMethodException,
                                             XProcSecurityException

This method performs a http request by calling abstract method httpRequest(XProcHttpRequest) or (if this fails) by getting the uri via getInputStream for method 'get'.

This method work as a bridge between implementations of XProcFilesystem supporting httpRequest and those not supporting it. A not supporting implementation is required to throw an UnknownSchemaException. If this occurs and the method in request is get, doHttpRequest will try to make a XProcHttpResponse with a response body obtained by calling abstract method getInputStream with the uri from request.

Parameters:
request - the XProcHttpRequest to perform.
Returns:
an XProcHttpResponse to the request.
Throws:
IOException - if an IOException occurred.
XProcFilesystem.UnknownSchemeException - if the scheme in the uri is not known or not supported.
XProcFilesystem.ProtectedResourceException - if the resource with the given uri cannot be obtained without authentication (HTPP status code 401).
com.xml_project.morganaxproc.core.XProcRuntimeException - if an XProcRuntimeException occured while calling httpRequest.
XProcFilesystem.UnsupportedMethodException - if the xml version is not supported.
XProcSecurityException

getDocument

protected nu.xom.Document getDocument(URI uri,
                                      XProcFilesystem.ParseMode parseMode)
                               throws IOException,
                                      nu.xom.ParsingException,
                                      nu.xom.ValidityException,
                                      XProcFilesystem.UnknownSchemeException,
                                      XProcFilesystem.ProtectedResourceException

Creates a new XOM document by getting an InputStream via getInputStream for the given uri and then building it, using the given parseMode.

This is a low level method called by loadDocument. You should never call it directly, because there is no security checking in this method. (This is done by loadDocument). The method is declared protected so you can overwrite it in extending classes to return XOM documents which are not available via getInputStream or come from a special source (like a document buffer for instance).

Parameters:
uri - the uri for the document to create.
parseMode - the ParseMode that must be used to create the document.
Returns:
the newly created document
Throws:
IOException - if an IOException occurred obtaining the input stream.
nu.xom.ParsingException - if the input stream is not a valid document.
nu.xom.ValidityException - if the input stream is not a valid document.
XProcFilesystem.UnknownSchemeException - if the scheme in uri is unknown or not supported.
XProcFilesystem.ProtectedResourceException - if the resource with the given uri cannot be obtained without authentication (HTPP status code 401).

resolveText

public String resolveText(URI absoluteURI,
                          String encoding)
                   throws XPathException
Parameters:
absoluteURI -
encoding - may be null
Returns:
a string
Throws:
XPathException
XPathException

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException,
                                 IOException
Specified by:
resolveEntity in interface EntityResolver
Throws:
SAXException
IOException

resolveAsStreamSource

public final StreamSource resolveAsStreamSource(String href,
                                                String base,
                                                com.xml_project.morganaxproc.morganapkg.MorganaPKG.UriSpaces spaces)
                                         throws TransformerException
Parameters:
href -
base -
Returns:
the resolved resource
Throws:
TransformerException

resolveModule

public final List<StreamSource> resolveModule(String targetNamespace,
                                              List<String> locationHints,
                                              String baseURI)
Description copied from interface: ModuleURIResolver
Called to resolve module import in XQuery and p:xquery

Specified by:
resolveModule in interface ModuleURIResolver
Parameters:
targetNamespace - the target namespace of the module
locationHints - the location hints (if any)
baseURI - the base uri of the importing module
Returns:
a list of StreamSource's. May be null, if no modules are found.

loadDocumentFromPackage

public final nu.xom.Document loadDocumentFromPackage(XProcSecurityManager.Operations op,
                                                     String href,
                                                     com.xml_project.morganaxproc.morganapkg.MorganaPKG.UriSpaces space,
                                                     XProcFilesystem.ParseMode mode)
                                              throws nu.xom.ParsingException
Tries to load a component as document from an EXPath packaging system, if one is installed. In case of an ParsingException for spaces UriSpaces.XQuery or RelaxNG a document with the root element or is created and the resource found at href is inserted as text child to this root.

Parameters:
op - - the operation for security check
href - - the uri of the component
space - - the uri space to look for
mode - - the parseMode
Returns:
the document or null, if an error occurred, no packaging system is found or no component with this uri is found.
Throws:
nu.xom.ParsingException