org.apache.manifoldcf.core.system
Class ManifoldCF

java.lang.Object
  extended by org.apache.manifoldcf.core.system.ManifoldCF
Direct Known Subclasses:
ManifoldCF, ManifoldCF

public class ManifoldCF
extends java.lang.Object


Nested Class Summary
protected static class ManifoldCF.DatabaseConnectionReleaseThread
          The thread that actually releases database connections
protected static class ManifoldCF.DatabaseShutdown
          Class that cleans up database handles on exit
protected static class ManifoldCF.FileTrack
          Class that tracks files that need to be cleaned up on exit
protected static class ManifoldCF.ShutdownThread
          Finisher thread, to be registered with the runtime
 
Field Summary
static java.lang.String _rcsid
           
protected static boolean alreadyClosed
           
protected static java.lang.String applicationName
           
static java.lang.String ATTRIBUTE_NAME
           
static java.lang.String ATTRIBUTE_PATH
           
static java.lang.String ATTRIBUTE_VALUE
           
protected static java.util.ArrayList cleanupHooks
          Array of cleanup hooks (for managing shutdown)
static java.lang.String configSignalCommandProperty
          Script to invoke when configuration changes, if any
static java.lang.String databaseHandleMaxcountProperty
          Maximum open database handles property
static java.lang.String databaseHandleTimeoutProperty
          Database handle timeout property
static java.lang.String databaseImplementation
          Database implementation class
protected static ManifoldCF.DatabaseShutdown dbShutdown
          Database handle cleanup
protected static java.lang.Integer initializeFlagLock
           
protected static boolean isInitialized
           
static java.lang.String lcfConfigFileProperty
           
protected static ManifoldCFConfiguration localConfiguration
           
protected static java.util.Map localProperties
           
static java.lang.String lockManagerImplementation
          Lock manager implementation class
static java.lang.String logConfigFileProperty
          Location of log configuration file
static java.lang.String maintenanceFileSignalProperty
          File to look for to block access to UI during database maintenance
protected static java.lang.String masterDatabaseName
           
static java.lang.String masterDatabaseNameProperty
          Database name property
protected static java.lang.String masterDatabasePassword
           
static java.lang.String masterDatabasePasswordProperty
          Database password property
protected static java.lang.String masterDatabaseUsername
           
static java.lang.String masterDatabaseUsernameProperty
          Database user name property
static java.lang.String NODE_LIBDIR
           
static java.lang.String NODE_PROPERTY
           
protected static long propertyFilelastMod
           
protected static java.lang.String propertyFilePath
           
protected static ManifoldCFResourceLoader resourceLoader
          The object that manages ManifoldCF plugin class loading.
protected static java.lang.Thread shutdownThread
          Shutdown thread
protected static ManifoldCF.FileTrack tracker
          Temporary file collector
protected static java.io.File workingDirectory
          This is the working directory file object.
 
Constructor Summary
ManifoldCF()
           
 
Method Summary
static void addFile(java.io.File f)
          Add a file to the tracking system.
static void addShutdownHook(IShutdownHook hook)
          Add a cleanup hook to the list.
static void addToHash(java.security.MessageDigest digest, java.lang.String input)
          Add to hash
static boolean checkMaintenanceUnderway()
          Check if maintenance is underway.
static void checkProperties()
          Reloads properties as needed.
protected static void cleanUpSystem()
          Perform system shutdown, using the registered shutdown hooks.
static ManifoldCFResourceLoader createResourceLoader()
          Create a new resource loader based on the default one.
static void createSystemDatabase(IThreadContext threadcontext, java.lang.String masterUsername, java.lang.String masterPassword)
          Install system database.
static void deleteFile(java.io.File f)
          Use the tracking system to delete a file.
static void deleteFolder(java.lang.String path)
          Delete a folder path.
static java.lang.String deobfuscate(java.lang.String input)
          Decode a string encoded using the obfuscation technique.
static void dropSystemDatabase(IThreadContext threadcontext, java.lang.String masterUsername, java.lang.String masterPassword)
          Drop system database.
static java.lang.String encrypt(java.lang.String input)
          Perform standard one-way encryption of a string.
static void ensureFolder(java.lang.String path)
          Attempt to make sure a path is a folder
static java.lang.Class findClass(java.lang.String cname)
          Locate a class in the configuration-determined class path.
static java.lang.String getChildDatabaseName(IDBInterface companyDatabase, java.lang.String childDBIdentifier)
          Find a child database name given a company database instance and the child database identifier.
static java.io.File getFileProperty(java.lang.String s)
          Read a File property, either from the system properties, or from the local configuration file.
static java.lang.String getHashValue(java.security.MessageDigest digest)
          Calculate final hash value
static int getIntProperty(java.lang.String s, int defaultValue)
          Read an integer propert, either from the system properties, or from the local configuration file.
static java.lang.String getMasterDatabaseName()
          Get the master database name.
static java.lang.String getMasterDatabasePassword()
          Get the master database password.
static java.lang.String getMasterDatabaseUsername()
          Get the master database username.
static java.lang.String getProperty(java.lang.String s)
          Read a (string) property, either from the system properties, or from the local configuration file.
static java.lang.String hash(java.lang.String input)
          Perform standard hashing of a string
static void initializeEnvironment()
          Initialize environment.
static boolean isFolder(java.lang.String path)
          Discover if a path is a folder
static void noteConfigurationChange()
          Note configuration change.
static java.lang.String obfuscate(java.lang.String input)
          Encode a string in a reversible obfuscation.
static int readByte(java.io.InputStream is)
          Read a byte from an input stream
static byte[] readByteArray(java.io.InputStream is)
          Read a byte array from an input stream
static void readBytes(java.io.InputStream is, byte[] byteArray)
          Read bytes from the input stream into specified array.
static int readDword(java.io.InputStream is)
          Read a dword from an input stream
static float readfloat(java.io.InputStream os)
          Read a float value from an input stream
static java.lang.Long readLong(java.io.InputStream is)
          Read a Long from an input stream
protected static int readNibble(char value)
          Read a hex nibble.
static int readSdword(java.io.InputStream is)
          Read a signed dword from an input stream
static java.lang.String readString(java.io.InputStream is)
          Read a String from an input stream
static int readWord(java.io.InputStream is)
          Read a word from an input stream
protected static void recursiveDelete(java.io.File directoryPath)
          Recursive delete: for cleaning up company folder.
static java.io.File resolvePath(java.lang.String path)
          Resolve a file path, possibly relative to ManifoldCF's concept of its "working directory".
static java.lang.String safeFileName(java.lang.String value)
          Convert a string into a safe, unique filename.
static void sleep(long milliseconds)
          Use this method to sleep instead of Thread.sleep().
static java.security.MessageDigest startHash()
          Start creating a hash
static void writeByte(java.io.OutputStream os, int byteValue)
          Write a byte to an output stream
static void writeByteArray(java.io.OutputStream os, byte[] byteArray)
          Write a byte array to an output stream
static void writeBytes(java.io.OutputStream os, byte[] byteArray)
          Write a bunch of bytes to the output stream
static void writeDword(java.io.OutputStream os, int dwordValue)
          Write a dword to an output stream
static void writefloat(java.io.OutputStream os, float floatValue)
          Write a float value to an output stream
static void writeLong(java.io.OutputStream os, java.lang.Long longValue)
          Write a Long to an output stream
protected static char writeNibble(int value)
          Write a hex nibble.
static void writeSdword(java.io.OutputStream os, int dwordValue)
          Write a signed dword to an output stream
static void writeString(java.io.OutputStream os, java.lang.String stringValue)
          Write a String to an output stream
static void writeWord(java.io.OutputStream os, int wordValue)
          Write a word to an output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rcsid

public static final java.lang.String _rcsid
See Also:
Constant Field Values

NODE_PROPERTY

public static final java.lang.String NODE_PROPERTY
See Also:
Constant Field Values

ATTRIBUTE_NAME

public static final java.lang.String ATTRIBUTE_NAME
See Also:
Constant Field Values

ATTRIBUTE_VALUE

public static final java.lang.String ATTRIBUTE_VALUE
See Also:
Constant Field Values

NODE_LIBDIR

public static final java.lang.String NODE_LIBDIR
See Also:
Constant Field Values

ATTRIBUTE_PATH

public static final java.lang.String ATTRIBUTE_PATH
See Also:
Constant Field Values

workingDirectory

protected static java.io.File workingDirectory
This is the working directory file object.


resourceLoader

protected static ManifoldCFResourceLoader resourceLoader
The object that manages ManifoldCF plugin class loading. This is initialized when the initialize method is called.


tracker

protected static ManifoldCF.FileTrack tracker
Temporary file collector


dbShutdown

protected static ManifoldCF.DatabaseShutdown dbShutdown
Database handle cleanup


cleanupHooks

protected static java.util.ArrayList cleanupHooks
Array of cleanup hooks (for managing shutdown)


shutdownThread

protected static java.lang.Thread shutdownThread
Shutdown thread


isInitialized

protected static boolean isInitialized

alreadyClosed

protected static boolean alreadyClosed

initializeFlagLock

protected static java.lang.Integer initializeFlagLock

masterDatabaseName

protected static java.lang.String masterDatabaseName

masterDatabaseUsername

protected static java.lang.String masterDatabaseUsername

masterDatabasePassword

protected static java.lang.String masterDatabasePassword

localConfiguration

protected static ManifoldCFConfiguration localConfiguration

localProperties

protected static java.util.Map localProperties

propertyFilelastMod

protected static long propertyFilelastMod

propertyFilePath

protected static java.lang.String propertyFilePath

applicationName

protected static final java.lang.String applicationName
See Also:
Constant Field Values

lcfConfigFileProperty

public static final java.lang.String lcfConfigFileProperty
See Also:
Constant Field Values

masterDatabaseNameProperty

public static final java.lang.String masterDatabaseNameProperty
Database name property

See Also:
Constant Field Values

masterDatabaseUsernameProperty

public static final java.lang.String masterDatabaseUsernameProperty
Database user name property

See Also:
Constant Field Values

masterDatabasePasswordProperty

public static final java.lang.String masterDatabasePasswordProperty
Database password property

See Also:
Constant Field Values

databaseHandleMaxcountProperty

public static final java.lang.String databaseHandleMaxcountProperty
Maximum open database handles property

See Also:
Constant Field Values

databaseHandleTimeoutProperty

public static final java.lang.String databaseHandleTimeoutProperty
Database handle timeout property

See Also:
Constant Field Values

logConfigFileProperty

public static final java.lang.String logConfigFileProperty
Location of log configuration file

See Also:
Constant Field Values

lockManagerImplementation

public static final java.lang.String lockManagerImplementation
Lock manager implementation class

See Also:
Constant Field Values

databaseImplementation

public static final java.lang.String databaseImplementation
Database implementation class

See Also:
Constant Field Values

configSignalCommandProperty

public static final java.lang.String configSignalCommandProperty
Script to invoke when configuration changes, if any

See Also:
Constant Field Values

maintenanceFileSignalProperty

public static final java.lang.String maintenanceFileSignalProperty
File to look for to block access to UI during database maintenance

See Also:
Constant Field Values
Constructor Detail

ManifoldCF

public ManifoldCF()
Method Detail

initializeEnvironment

public static void initializeEnvironment()
                                  throws ManifoldCFException
Initialize environment.

Throws:
ManifoldCFException

checkProperties

public static final void checkProperties()
                                  throws ManifoldCFException
Reloads properties as needed.

Throws:
ManifoldCFException

resolvePath

public static java.io.File resolvePath(java.lang.String path)
Resolve a file path, possibly relative to ManifoldCF's concept of its "working directory".

Parameters:
path - is the path, to be calculated relative to the ManifoldCF "working directory".
Returns:
the resolved file.

getProperty

public static java.lang.String getProperty(java.lang.String s)
Read a (string) property, either from the system properties, or from the local configuration file.

Parameters:
s - is the property name.
Returns:
the property value, as a string.

getFileProperty

public static java.io.File getFileProperty(java.lang.String s)
Read a File property, either from the system properties, or from the local configuration file. Relative file references are resolved according to the "working directory" for ManifoldCF.


getIntProperty

public static int getIntProperty(java.lang.String s,
                                 int defaultValue)
                          throws ManifoldCFException
Read an integer propert, either from the system properties, or from the local configuration file.

Throws:
ManifoldCFException

ensureFolder

public static void ensureFolder(java.lang.String path)
                         throws ManifoldCFException
Attempt to make sure a path is a folder

Parameters:
path -
Throws:
ManifoldCFException

deleteFolder

public static void deleteFolder(java.lang.String path)
Delete a folder path.

Parameters:
path - is the folder path.

recursiveDelete

protected static void recursiveDelete(java.io.File directoryPath)
Recursive delete: for cleaning up company folder.

Parameters:
directoryPath - is the File describing the directory to be removed.

isFolder

public static boolean isFolder(java.lang.String path)
Discover if a path is a folder

Parameters:
path - spec, 'unix' form mostly

safeFileName

public static java.lang.String safeFileName(java.lang.String value)
Convert a string into a safe, unique filename.

Parameters:
value - is the string.
Returns:
the file name.

getMasterDatabaseName

public static java.lang.String getMasterDatabaseName()
Get the master database name.

Returns:
the master database name

getMasterDatabaseUsername

public static java.lang.String getMasterDatabaseUsername()
Get the master database username.

Returns:
the master database username.

getMasterDatabasePassword

public static java.lang.String getMasterDatabasePassword()
Get the master database password.

Returns:
the master database password.

getChildDatabaseName

public static java.lang.String getChildDatabaseName(IDBInterface companyDatabase,
                                                    java.lang.String childDBIdentifier)
Find a child database name given a company database instance and the child database identifier.

Parameters:
companyDatabase - is the company database.
childDBIdentifier - is the identifier.
Returns:
the child database name.

hash

public static java.lang.String hash(java.lang.String input)
                             throws ManifoldCFException
Perform standard hashing of a string

Parameters:
input - is the string to hash.
Returns:
the encrypted string.
Throws:
ManifoldCFException

startHash

public static java.security.MessageDigest startHash()
                                             throws ManifoldCFException
Start creating a hash

Throws:
ManifoldCFException

addToHash

public static void addToHash(java.security.MessageDigest digest,
                             java.lang.String input)
                      throws ManifoldCFException
Add to hash

Throws:
ManifoldCFException

getHashValue

public static java.lang.String getHashValue(java.security.MessageDigest digest)
                                     throws ManifoldCFException
Calculate final hash value

Throws:
ManifoldCFException

encrypt

public static java.lang.String encrypt(java.lang.String input)
                                throws ManifoldCFException
Perform standard one-way encryption of a string.

Parameters:
input - is the string to encrypt.
Returns:
the encrypted string.
Throws:
ManifoldCFException

obfuscate

public static java.lang.String obfuscate(java.lang.String input)
                                  throws ManifoldCFException
Encode a string in a reversible obfuscation.

Parameters:
input - is the input string.
Returns:
the output string.
Throws:
ManifoldCFException

writeNibble

protected static char writeNibble(int value)
Write a hex nibble.

Parameters:
value - is the value to write.
Returns:
the character.

deobfuscate

public static java.lang.String deobfuscate(java.lang.String input)
                                    throws ManifoldCFException
Decode a string encoded using the obfuscation technique.

Parameters:
input - is the input string.
Returns:
the decoded string.
Throws:
ManifoldCFException

readNibble

protected static int readNibble(char value)
                         throws ManifoldCFException
Read a hex nibble.

Parameters:
value - is the character.
Returns:
the value.
Throws:
ManifoldCFException

createSystemDatabase

public static void createSystemDatabase(IThreadContext threadcontext,
                                        java.lang.String masterUsername,
                                        java.lang.String masterPassword)
                                 throws ManifoldCFException
Install system database.

Parameters:
threadcontext - is the thread context.
masterUsername - is the master database user name.
masterPassword - is the master database password.
Throws:
ManifoldCFException

dropSystemDatabase

public static void dropSystemDatabase(IThreadContext threadcontext,
                                      java.lang.String masterUsername,
                                      java.lang.String masterPassword)
                               throws ManifoldCFException
Drop system database.

Parameters:
threadcontext - is the thread context.
masterUsername - is the master database user name.
masterPassword - is the master database password.
Throws:
ManifoldCFException

addFile

public static void addFile(java.io.File f)
Add a file to the tracking system.


deleteFile

public static void deleteFile(java.io.File f)
Use the tracking system to delete a file. You MUST use this to delete any file that was added to the tracking system with addFile().


checkMaintenanceUnderway

public static boolean checkMaintenanceUnderway()
Check if maintenance is underway.


noteConfigurationChange

public static void noteConfigurationChange()
                                    throws ManifoldCFException
Note configuration change.

Throws:
ManifoldCFException

sleep

public static void sleep(long milliseconds)
                  throws java.lang.InterruptedException
Use this method to sleep instead of Thread.sleep(). Thread.sleep() doesn't seem to work well when the system time is reset.

Throws:
java.lang.InterruptedException

writeBytes

public static void writeBytes(java.io.OutputStream os,
                              byte[] byteArray)
                       throws java.io.IOException
Write a bunch of bytes to the output stream

Throws:
java.io.IOException

writeByte

public static void writeByte(java.io.OutputStream os,
                             int byteValue)
                      throws java.io.IOException
Write a byte to an output stream

Throws:
java.io.IOException

writeWord

public static void writeWord(java.io.OutputStream os,
                             int wordValue)
                      throws java.io.IOException
Write a word to an output stream

Throws:
java.io.IOException

writeDword

public static void writeDword(java.io.OutputStream os,
                              int dwordValue)
                       throws java.io.IOException
Write a dword to an output stream

Throws:
java.io.IOException

writeSdword

public static void writeSdword(java.io.OutputStream os,
                               int dwordValue)
                        throws java.io.IOException
Write a signed dword to an output stream

Throws:
java.io.IOException

writeLong

public static void writeLong(java.io.OutputStream os,
                             java.lang.Long longValue)
                      throws java.io.IOException
Write a Long to an output stream

Throws:
java.io.IOException

writeString

public static void writeString(java.io.OutputStream os,
                               java.lang.String stringValue)
                        throws java.io.IOException
Write a String to an output stream

Throws:
java.io.IOException

writeByteArray

public static void writeByteArray(java.io.OutputStream os,
                                  byte[] byteArray)
                           throws java.io.IOException
Write a byte array to an output stream

Throws:
java.io.IOException

writefloat

public static void writefloat(java.io.OutputStream os,
                              float floatValue)
                       throws java.io.IOException
Write a float value to an output stream

Throws:
java.io.IOException

readBytes

public static void readBytes(java.io.InputStream is,
                             byte[] byteArray)
                      throws java.io.IOException
Read bytes from the input stream into specified array.

Throws:
java.io.IOException

readByte

public static int readByte(java.io.InputStream is)
                    throws java.io.IOException
Read a byte from an input stream

Throws:
java.io.IOException

readWord

public static int readWord(java.io.InputStream is)
                    throws java.io.IOException
Read a word from an input stream

Throws:
java.io.IOException

readDword

public static int readDword(java.io.InputStream is)
                     throws java.io.IOException
Read a dword from an input stream

Throws:
java.io.IOException

readSdword

public static int readSdword(java.io.InputStream is)
                      throws java.io.IOException
Read a signed dword from an input stream

Throws:
java.io.IOException

readLong

public static java.lang.Long readLong(java.io.InputStream is)
                               throws java.io.IOException
Read a Long from an input stream

Throws:
java.io.IOException

readString

public static java.lang.String readString(java.io.InputStream is)
                                   throws java.io.IOException
Read a String from an input stream

Throws:
java.io.IOException

readByteArray

public static byte[] readByteArray(java.io.InputStream is)
                            throws java.io.IOException
Read a byte array from an input stream

Throws:
java.io.IOException

readfloat

public static float readfloat(java.io.InputStream os)
                       throws java.io.IOException
Read a float value from an input stream

Throws:
java.io.IOException

addShutdownHook

public static void addShutdownHook(IShutdownHook hook)
Add a cleanup hook to the list. These hooks will be evaluated in the reverse order than the order in which they were added.

Parameters:
hook - is the shutdown hook that needs to be added to the sequence.

createResourceLoader

public static ManifoldCFResourceLoader createResourceLoader()
                                                     throws ManifoldCFException
Create a new resource loader based on the default one. This is used by connectors wishing to make their own resource loaders for isolation purposes.

Throws:
ManifoldCFException

findClass

public static java.lang.Class findClass(java.lang.String cname)
                                 throws java.lang.ClassNotFoundException,
                                        ManifoldCFException
Locate a class in the configuration-determined class path. This method is designed for loading plugin classes, and their downstream dependents.

Throws:
java.lang.ClassNotFoundException
ManifoldCFException

cleanUpSystem

protected static void cleanUpSystem()
Perform system shutdown, using the registered shutdown hooks.