com.xml_project.morganaxproc.filesystem
Class DefaultFilesystem

java.lang.Object
  extended by com.xml_project.morganaxproc.filesystem.XProcFilesystem
      extended by com.xml_project.morganaxproc.filesystem.AlternateFilesystem
          extended by com.xml_project.morganaxproc.filesystem.DefaultFilesystem
All Implemented Interfaces:
CollectionURIResolver, ModuleURIResolver, org.xml.sax.EntityResolver

public class DefaultFilesystem
extends AlternateFilesystem

This class provides an implementation for XProcFilesystem that support all required methods for 'file:', 'http:' and 'https:' and supports also sending http requests by using p:http-request. The basis functionally is provided by extending AlternateFileSystem while support for p:http-request is provided in this class.

Since this class heavily depends on Apache's Commons HttpClient(TM), you have to have the related jar-files on your class path. If you do not need support for p:http-request and/or do not want to have the Apache-classes on the class path, just switch to AlternateFilesystem as default in your configuration of MorganaXProc. The Apache jar files needed are:

Availabe at: http://hc.apache.org/httpcomponents-client-4.4.x/index.html

Used licence: Apache License, Version 2.0


Nested Class Summary
static class DefaultFilesystem.REDIRECTION_STRATEGY
          An enumeration of the possible redirection strategies.
 
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
static java.lang.String ContentTypeHeader
           
 
Fields inherited from class com.xml_project.morganaxproc.filesystem.XProcFilesystem
DIRECTORY_MARKER, theConfig
 
Constructor Summary
DefaultFilesystem(XProcConfiguration config)
          Create a new DefaultFilesystem with redirection strategy 'default'.
DefaultFilesystem(XProcConfiguration config, org.apache.http.impl.client.CloseableHttpClient httpClient, DefaultFilesystem.REDIRECTION_STRATEGY strategy)
          Creates a new DefaultFilesystem with the given XProcConfiguration.
DefaultFilesystem(XProcConfiguration config, DefaultFilesystem.REDIRECTION_STRATEGY strategy)
          Creates a new DefaultFilesystem with the given redirection strategy.
 
Method Summary
protected  void clearCookieStore()
          Clears the cookie storage associated with the instance of this class
protected  XProcHttpResponse httpRequest(XProcHttpRequest request)
          Performs a http request for uri schemes 'http:' and 'https'.
 
Methods inherited from class com.xml_project.morganaxproc.filesystem.AlternateFilesystem
copyResource, createDirectory, createTemp, deleteResource, getContentType, getDirectoryList, getEncoding, getInputStream, getOutputStream, getResourceInfo, moveResource, touchResource
 
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
 

Field Detail

ContentTypeHeader

public static final java.lang.String ContentTypeHeader
See Also:
Constant Field Values
Constructor Detail

DefaultFilesystem

public DefaultFilesystem(XProcConfiguration config)
                  throws java.lang.ClassNotFoundException
Create a new DefaultFilesystem with redirection strategy 'default'. See explanation for DefaultFileSystem(XProcConfiguration, CloseableHttpClient REDIRECTION_STRATEGY)

Parameters:
config - the configuration
Throws:
java.lang.ClassNotFoundException - if any of classes necessary not found, especially if one of the classes of Apache package is not available on the class path.

DefaultFilesystem

public DefaultFilesystem(XProcConfiguration config,
                         DefaultFilesystem.REDIRECTION_STRATEGY strategy)
                  throws java.lang.ClassNotFoundException
Creates a new DefaultFilesystem with the given redirection strategy. See explanation for DefaultFileSystem(XProcConfiguration, CloseableHttpClient REDIRECTION_STRATEGY)

Parameters:
config - the configuration
strategy - the redirection strategy to use.
Throws:
java.lang.ClassNotFoundException - if any of classes necessary not found, especially if one of the classes of Apache package is not available on the class path.

DefaultFilesystem

public DefaultFilesystem(XProcConfiguration config,
                         org.apache.http.impl.client.CloseableHttpClient httpClient,
                         DefaultFilesystem.REDIRECTION_STRATEGY strategy)
                  throws java.lang.ClassNotFoundException
Creates a new DefaultFilesystem with the given XProcConfiguration. If httpClient is null, a new one is created, otherwise the provided client is used. If creation fails, a ClassNotFoundException is thrown. This will cause MorganaXProc to switch back to an alternative file system, which usally is AlternateFilesystem.

Parameters:
config - the XProcConfiguration to use.
httpClient - a CloseableHttpClient or null to create a new one.
strategy - the redirection strategy to use.
Throws:
java.lang.ClassNotFoundException - if any of classes necessary not found, especially if one of the classes of Apache package is not available on the class path.
Method Detail

clearCookieStore

protected void clearCookieStore()
Clears the cookie storage associated with the instance of this class

Overrides:
clearCookieStore in class AlternateFilesystem

httpRequest

protected XProcHttpResponse httpRequest(XProcHttpRequest request)
                                 throws java.io.IOException,
                                        XProcFilesystem.UnknownSchemeException
Performs a http request for uri schemes 'http:' and 'https'.

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