Class ManifoldCF

    • Constructor Summary

      Constructors 
      Constructor Description
      ManifoldCF()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void addFile​(java.io.File f)
      Add a file to the tracking system.
      static void addPollingHook​(IPollingHook hook)
      Add a polling hook to the list.
      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.
      static void cleanUpEnvironment()
      Deprecated.
      static void cleanUpEnvironment​(IThreadContext threadContext)
      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 java.io.File createTempDir​(java.lang.String prefix, java.lang.String suffix)
      Create temporary directory.
      static java.lang.String decrypt​(java.lang.String saltValue, java.lang.String passCode, java.lang.String input)
      Decrypt a string.
      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 saltValue, java.lang.String passCode, java.lang.String input)
      Encrypt a string in a reversible encryption.
      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 boolean getBooleanProperty​(java.lang.String s, boolean defaultValue)
      Read a boolean property
      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.
      protected static javax.crypto.Cipher getCipher​(java.lang.String saltValue, int mode, java.lang.String passCode, byte[] iv)  
      protected static javax.crypto.Cipher getCipher​(IThreadContext threadContext, int mode, java.lang.String passCode, byte[] iv)  
      static ManifoldCFConfiguration getConfiguration()
      Get current properties.
      static double getDoubleProperty​(java.lang.String s, double defaultValue)
      Read a float property, either from the system properties, or from the local configuration file.
      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 property, either from the system properties, or from the local configuration file.
      static long getLongProperty​(java.lang.String s, long defaultValue)
      Read a long property, 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 getMcfVersion()
      Get the mcf version.
      static java.lang.String getProcessID()
      Get process ID
      static java.lang.String getProperty​(java.lang.String s)
      Read a (string) property, either from the system properties, or from the local configuration file.
      protected static java.lang.String getSaltValue​(IThreadContext threadContext)  
      protected static byte[] getSecureRandom()  
      static java.lang.String getStringProperty​(java.lang.String s, java.lang.String defaultValue)
      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()
      Deprecated.
      static void initializeEnvironment​(IThreadContext threadContext)
      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 void pollAll​(IThreadContext threadContext)
      Poll all the registered polling services.
      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
      static void recursiveDelete​(java.io.File directoryPath)
      Recursive delete: for cleaning up company folder.
      protected static void registerConnectorServices()
      Register connector services provided in connectors and connector-commons
      static void resetEnvironment()
      Deprecated.
      static void resetEnvironment​(IThreadContext threadContext)
      Reset environment.
      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 systemExit​(int rval)
      Shutdown the system using a background thread.
      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

      • processID

        protected static java.lang.String processID
        Process ID (no more than 16 characters)
      • 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.
      • cleanupHooks

        protected static final java.util.List<IShutdownHook> cleanupHooks
        Array of cleanup hooks (for managing shutdown)
      • pollingHooks

        protected static final java.util.List<IPollingHook> pollingHooks
        Array of polling hooks (for managing polling)
      • shutdownThread

        protected static java.lang.Thread shutdownThread
        Shutdown thread
      • initializeLevel

        protected static int initializeLevel
      • alreadyClosed

        protected static boolean alreadyClosed
      • alreadyShutdown

        protected static boolean alreadyShutdown
      • initializeFlagLock

        protected static java.lang.Integer initializeFlagLock
      • mcfVersion

        protected static java.lang.String mcfVersion
      • masterDatabaseName

        protected static java.lang.String masterDatabaseName
      • masterDatabaseUsername

        protected static java.lang.String masterDatabaseUsername
      • masterDatabasePassword

        protected static java.lang.String masterDatabasePassword
      • 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
      • versionProperty

        public static final java.lang.String versionProperty
        The current ManifoldCF version string
        See Also:
        Constant Field Values
      • processIDProperty

        public static final java.lang.String processIDProperty
        Process ID - cannot exceed 16 characters
        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
      • databaseConnectionTrackingProperty

        public static final java.lang.String databaseConnectionTrackingProperty
        Connection tracking debug property
        See Also:
        Constant Field Values
      • databaseQueryMaxTimeProperty

        public static final java.lang.String databaseQueryMaxTimeProperty
        Elapsed time a query can take before a warning is output to the log, in seconds
        See Also:
        Constant Field Values
      • logConfigFileProperty

        public static final java.lang.String logConfigFileProperty
        Location of log configuration file
        See Also:
        Constant Field Values
      • fileResourcesProperty

        public static final java.lang.String fileResourcesProperty
        Location of file resources
        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
      • authImplementation

        public static final java.lang.String authImplementation
        Auth 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
      • saltProperty

        public static final java.lang.String saltProperty
        Encryption salt property
        See Also:
        Constant Field Values
    • Constructor Detail

      • ManifoldCF

        public ManifoldCF()
    • Method Detail

      • resetEnvironment

        @Deprecated
        public static void resetEnvironment()
        Deprecated.
        Reset environment, minting a thread context for convenience and backwards compatibility.
      • resetEnvironment

        public static void resetEnvironment​(IThreadContext threadContext)
        Reset environment.
      • initializeEnvironment

        @Deprecated
        public static void initializeEnvironment()
                                          throws ManifoldCFException
        Deprecated.
        Initialize environment, minting a thread context for backwards compatibility.
        Throws:
        ManifoldCFException
      • registerConnectorServices

        protected static void registerConnectorServices()
                                                 throws ManifoldCFException
        Register connector services provided in connectors and connector-commons
        Throws:
        ManifoldCFException
      • getProcessID

        public static final java.lang.String getProcessID()
        Get process ID
      • getConfiguration

        public static final ManifoldCFConfiguration getConfiguration()
        Get current properties. Makes no attempt to reread or interpret them.
      • 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.
      • getStringProperty

        public static java.lang.String getStringProperty​(java.lang.String s,
                                                         java.lang.String defaultValue)
        Read a (string) property, either from the system properties, or from the local configuration file.
        Parameters:
        s - is the property name.
        defaultValue - is the default value for the property.
        Returns:
        the property value, as a string.
      • getIntProperty

        public static int getIntProperty​(java.lang.String s,
                                         int defaultValue)
                                  throws ManifoldCFException
        Read an integer property, either from the system properties, or from the local configuration file.
        Throws:
        ManifoldCFException
      • getLongProperty

        public static long getLongProperty​(java.lang.String s,
                                           long defaultValue)
                                    throws ManifoldCFException
        Read a long property, either from the system properties, or from the local configuration file.
        Throws:
        ManifoldCFException
      • getDoubleProperty

        public static double getDoubleProperty​(java.lang.String s,
                                               double defaultValue)
                                        throws ManifoldCFException
        Read a float property, either from the system properties, or from the local configuration file.
        Throws:
        ManifoldCFException
      • deleteFolder

        public static void deleteFolder​(java.lang.String path)
        Delete a folder path.
        Parameters:
        path - is the folder path.
      • recursiveDelete

        public static void recursiveDelete​(java.io.File directoryPath)
        Recursive delete: for cleaning up company folder.
        Parameters:
        directoryPath - is the File describing the directory or file 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.
      • systemExit

        public static void systemExit​(int rval)
        Shutdown the system using a background thread.
      • getMcfVersion

        public static java.lang.String getMcfVersion()
        Get the mcf version.
        Returns:
        the version string
      • 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
      • getCipher

        protected static javax.crypto.Cipher getCipher​(java.lang.String saltValue,
                                                       int mode,
                                                       java.lang.String passCode,
                                                       byte[] iv)
                                                throws ManifoldCFException
        Throws:
        ManifoldCFException
      • getSecureRandom

        protected static byte[] getSecureRandom()
      • 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
      • 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
      • encrypt

        public static java.lang.String encrypt​(java.lang.String saltValue,
                                               java.lang.String passCode,
                                               java.lang.String input)
                                        throws ManifoldCFException
        Encrypt a string in a reversible encryption.
        Parameters:
        saltValue - is the salt value.
        passCode - is the pass code.
        input - is the input string.
        Returns:
        the output string.
        Throws:
        ManifoldCFException
      • decrypt

        public static java.lang.String decrypt​(java.lang.String saltValue,
                                               java.lang.String passCode,
                                               java.lang.String input)
                                        throws ManifoldCFException
        Decrypt a string.
        Parameters:
        saltValue - is the salt value.
        passCode - is the pass code.
        input - is the input string.
        Returns:
        the decoded string.
        Throws:
        ManifoldCFException
      • writeNibble

        protected static char writeNibble​(int value)
        Write a hex nibble.
        Parameters:
        value - is the value to write.
        Returns:
        the character.
      • 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
      • createTempDir

        public static java.io.File createTempDir​(java.lang.String prefix,
                                                 java.lang.String suffix)
                                          throws ManifoldCFException
        Create temporary directory.
        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.
      • 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.
      • addPollingHook

        public static void addPollingHook​(IPollingHook hook)
        Add a polling hook to the list. These hooks will be evaluated in the order they were added.
        Parameters:
        hook - is the polling hook that needs to be added to the sequence.
      • 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
      • cleanUpEnvironment

        @Deprecated
        public static void cleanUpEnvironment()
        Deprecated.
        Perform system shutdown, minting thread context for backwards compatibility
      • cleanUpEnvironment

        public static void cleanUpEnvironment​(IThreadContext threadContext)
        Perform system shutdown, using the registered shutdown hooks.