|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--uk.org.ogsadai.dataresource.conx.ConnectionManager
|
+--uk.org.ogsadai.dataresource.conx.FileSystemConnectionManager
| Field Summary |
| Fields inherited from class uk.org.ogsadai.dataresource.conx.ConnectionManager |
mDriverClass, mLog, mRoleMapClass, mRoleMapper, mURI |
| Constructor Summary | |
FileSystemConnectionManager(ConnectionConfig config)
Configure this connection manager by initialising its top-level directory and confirming that it exists. |
|
| Method Summary | |
static void |
assertDirectoryExists(java.io.File dir)
A utility method to test whether a given File object,
representing a directory, exists. |
static void |
assertDirectoryReadable(java.io.File dir)
A utility method to test whether a directory is readable. |
static void |
assertFileDoesntExist(java.io.File file)
A utility method to test whether a file does not exist. |
static void |
assertFileExists(java.io.File file)
A utility method to test whether a file exists. |
static void |
assertFileIsDirectory(java.io.File file)
A utility method to test whether a given File object
represents a directory. |
static void |
assertFileReadable(java.io.File file)
A utility method to test whether a file is readable. |
static void |
assertFileWriteable(java.io.File file)
A utility method to test whether a file is writeable. |
static java.io.File |
getCanonicalFile(java.io.File file)
A utility method to obtain a canonical File object
for a given file. |
java.io.File |
getDirectory()
Return a File object representing the top-level directory. |
java.io.File |
getFile(java.lang.String filename)
A utility method to obtain a canonical File object
for a file specified as a path relative to the top-level directory. |
java.lang.String |
getPath()
Return the filename of the top-level directory. |
void |
validateFile(java.lang.String filename)
A utility method which checks whether a given pathname specified relative to the top-level directory is contained below that directory in the file system directory hierarchy. |
boolean |
verifyFileIsInsideDirectory(java.lang.String filename,
java.io.File directory)
A utility method which checks whether a given pathname specified relative to a given directory is contained below that directory in the file system directory hierarchy. |
| Methods inherited from class uk.org.ogsadai.dataresource.conx.ConnectionManager |
mapCertificate, setRoleMapsFile, setupRoleMapping, updateRoleMaps |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public FileSystemConnectionManager(ConnectionConfig config)
throws CoreSystemException,
CoreUserException
config - the configuration
CoreSystemException - if there is a problem reading from the directory
CoreUserException - if the directory doesn't exist| Method Detail |
public java.lang.String getPath()
public java.io.File getDirectory()
File object representing the top-level directory.
public void validateFile(java.lang.String filename)
throws CoreUserException,
CoreSystemException
CoreUserException is thrown.
For example,
validateFile("src/java/.classpath")
will return normally, even if the .classpath file
does not actually exist.
But
validateFile("src/../../private/config.xml", new File("c:/project"))
will throw an exception, since the
c:/project/src/../../private/config.xml resolves to
c:/private/config.xml, which is not below
c:/project in the directory hierarchy.
filename - the relative pathname to test
CoreUserException - if the filename is outside the directory, or another user-related problem occurs
CoreSystemException - if a system-related problem occurs
public java.io.File getFile(java.lang.String filename)
throws CoreUserException,
CoreSystemException
File object
for a file specified as a path relative to the top-level directory.
If the file is outside of the top-level directory's directory
hierarchy, a CoreUserException is thrown.
Note that the path need not specify an existing file.
filename - the path, relative to the top-level directory, to return the canonical form of
File object
CoreSystemException - if an I/O error occurs whilst obtaining the canonical pathname.
CoreUserException - if the filename is outside the top-level directory
public static java.io.File getCanonicalFile(java.io.File file)
throws CoreSystemException
File object
for a given file.
Note that the path need not specify an existing file.
file - the path to return the canonical form of
File object
CoreSystemException - if an I/O error occurs whilst obtaining the canonical pathname.
public static void assertFileExists(java.io.File file)
throws CoreUserException
CoreUserException is thrown.
file - the file to test for existence
CoreUserException - if the file does not exist
public static void assertFileDoesntExist(java.io.File file)
throws CoreUserException
CoreUserException is thrown.
file - the file to test for non-existence
CoreUserException - if the file does exist
public static void assertFileReadable(java.io.File file)
throws CoreUserException
CoreUserException is thrown.
file - the file to test for readability
CoreUserException - if the file is not readable
public static void assertFileWriteable(java.io.File file)
throws CoreUserException
CoreUserException is thrown.
file - the file to test for writeability
CoreUserException - if the file is not writeable
public static void assertFileIsDirectory(java.io.File file)
throws CoreUserException
File object
represents a directory. If it is not, then an
CoreUserException is thrown.
file - the file to test for directoryness
CoreUserException - if the File object is not a directory
public static void assertDirectoryExists(java.io.File dir)
throws CoreUserException
File object,
representing a directory, exists. If it does not, then an
CoreUserException is thrown.
dir - the directory to test
CoreUserException - if the directory does not exist
public static void assertDirectoryReadable(java.io.File dir)
throws CoreUserException
CoreUserException is thrown.
dir - the directory to test for readability
CoreUserException - if the file is not readable
public boolean verifyFileIsInsideDirectory(java.lang.String filename,
java.io.File directory)
throws CoreUserException,
CoreSystemException
filename - the relative pathname to testdirectory - the directory we are testing within
true iff the file exists below the directory
CoreUserException - if a user-related problem occurs
CoreSystemException - if a system-related problem occurs
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||