Class SystemTool


  • public class SystemTool
    extends java.lang.Object
    System toolbox
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static SystemTool INSTANCE
      Singleton
      static long KB
      Kilobytes
      static long MB
      Megabytes
      static java.lang.String PARAM_LOG_MEMORY
      Memory logging parameter name
      static java.lang.String PARAM_LOG_UI
      UI logging parameter name
    • Constructor Summary

      Constructors 
      Constructor Description
      SystemTool()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addTimestampColumns​(Grant g, java.lang.String datasource, java.lang.String table)
      Add timestamp columns if not exist
      static java.lang.String applyPatch​(java.lang.String url, java.lang.String login, java.lang.String pwd, java.lang.String patch, boolean log)
      Apply a path thru IO service
      static void buildMavenRepository​(java.lang.String mavenDir, java.lang.String classesDir, java.lang.String javadocDir, java.lang.String sourcesDir)
      Build Maven repository
      static SystemTool.SystemInfo cacheInfo()
      Cache memory info
      static SystemTool.SystemInfo cacheInfo​(SystemTool.SystemInfo info)
      Cache memory info
      static void cleanDeadSessions()
      Close dead sessions in m_session (i.e.
      static java.lang.String cleanSrcAndBinDirs()
      Purge sources and binaries directories
      static void clearCacheToURL​(java.lang.String url, java.lang.String user, boolean invalidate, boolean notify, java.lang.String login, java.lang.String pwd)
      Clear cache thru IO service
      static void clearCacheToURL​(java.lang.String url, java.lang.String login, java.lang.String pwd)
      Clear cache and invalidate sessions thru IO service
      static java.lang.String clearExportDir()
      Purge export directory
      static java.lang.String clearImportDir()
      Purge import directory
      static java.lang.String clearRecycleBin()
      Purge all deleted files in DBDoc
      static java.lang.String clearTempDir()
      Purge temporary directory
      static void compileResources()
      Rebuild JS+CSS resources (less and minification)
      static void compileThemes()
      Rebuild themes with less sources
      static int countSessionsToURL​(java.lang.String url, java.lang.String user, boolean unique, java.lang.String login, java.lang.String pwd)
      Count authenticated users thru IO service
      static java.lang.String createTable​(ObjectDB obj, boolean full)
      Table creation
      static java.lang.String createTable​(java.lang.String datasource, java.lang.String table, boolean timestamp, ObjectField rowIdField, ObjectDB obj)
      Table creation
      static void cronMonitoring​(java.lang.String column, java.lang.String value)
      Change cron of monitoring
      static java.lang.String deleteModuleToURL​(java.lang.String url, java.lang.String login, java.lang.String pwd, java.lang.String module)
      Delete a module definition thru IO service
      static SystemTool.SystemInfo diskInfo()
      Disk usage memory info
      static SystemTool.SystemInfo diskInfo​(SystemTool.SystemInfo info)
      Disk usage memory info
      static SystemTool.SystemInfo docInfo()
      Documents memory info
      static SystemTool.SystemInfo docInfo​(SystemTool.SystemInfo info)
      Documents memory info
      static java.lang.String dumpHeap()
      Dump the Java heap
      static SystemTool.ExecResult exec​(java.lang.String cmd, java.util.List<java.lang.String> args, java.lang.String dir)
      Exec a system command
      static SystemTool.ExecResult exec​(java.lang.String cmd, java.util.List<java.lang.String> args, java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.String dir)
      Exec a system command
      static SystemTool.ExecResult execScript​(byte[] script, java.lang.String interpreter, java.util.List<java.lang.String> args, boolean keepDir)
      Exec a system script using specified script interpreter (e.g.
      static SystemTool.ExecResult execScript​(java.lang.String script, java.lang.String interpreter, java.util.List<java.lang.String> args, boolean keepDir)
      Exec a system script using specified script interpreter (e.g.
      static void forceGC()
      Full Garbage collection of unused JVM objects
      static java.lang.String generateIndexes​(java.lang.String object, boolean apply)
      Generate business object DB indexes + full-text indexes (asynchronous)
      static java.lang.String generateIndexes​(java.lang.String object, boolean rebuildDBIndexes, boolean rebuildDataIndexes, boolean async)
      Generate business object DB indexes + full-text indexes (asynchronous or not)
      static java.lang.Thread[] getAllThreads()
      Get all JVM threads
      static SystemTool.ClassCount getClassCount()
      Get classes count
      static java.lang.String getCronExpr​(int sec)
      Get cron expression with a simple interval (seconds, minutes or hours)
      static int getCronInterval​(java.lang.String name, int def)
      Get a cron simple interval: detects seconds, minutes or hours frequency in the Cron expression
      static org.json.JSONObject getDevInfo​(java.lang.String module)
      Get development information for external development environment
      static java.lang.String getDockerOSName()
      Get Docker OS name if applicable.
      static SystemTool.SystemInfo getInfo()
      Get system information (JVM, cache, documents, disk usage)
      static SystemTool.SystemInfo getInfo​(boolean jvm, boolean cache, boolean doc, boolean disk)
      Get system information (JVM, cache, documents, disk usage)
      static java.io.InputStream getModuleFromURL​(java.lang.String url, java.lang.String login, java.lang.String pwd, java.lang.String module)
      Get a module definition thru IO service or simple HTTP call
      static org.json.JSONObject getModuleTreeFromURL​(java.lang.String url, java.lang.String login, java.lang.String pwd, java.lang.String module)
      Get a module definition tree thru IO service or simple HTTP call
      static java.lang.String getPID()
      Get the JVM process id
      static double getSystemLoadAverage()
      CPU usage
      static java.lang.Thread getThread​(long id, java.lang.String name)
      Look for a thread
      static SystemTool.ThreadTimes getThreadTimes()
      Get threads CPU times
      static void initMavenRepository()
      Initialize Maven repository
      static java.lang.String installModuleToURL​(java.lang.String url, java.lang.String login, java.lang.String pwd, java.lang.String module, java.lang.String xml, boolean log)
      Set a module definition thru IO service
      static boolean isCronStarted()
      Check cron status using admin rights
      static boolean isDocker()
      Is running inside a Docker image?
      static boolean isLinux()
      Is the OS Linux?
      static boolean isMac()
      Is the OS MacOS?
      static boolean isUnix()
      Is the OS UNIX?
      static boolean isWindows()
      Is the OS Windows?
      static SystemTool.SystemInfo jvmMemory()
      JVM memory info
      static SystemTool.SystemInfo jvmMemory​(SystemTool.SystemInfo info)
      JVM memory info
      static java.util.Map<java.lang.String,​java.lang.management.MemoryUsage> memoryUsage​(boolean peak)
      Get all memories metrics using MemoryPoolMXBean
      static java.lang.management.MemoryUsage memoryUsage​(java.lang.String name, boolean peak)
      Get memory metrics using MemoryPoolMXBean
      static java.lang.String monitoring​(boolean start)
      Stop/Start monitoring
      static int objectGC​(boolean full)
      Internal garbage collection of unused Simplicite objects (Object, Grant and Processes)
      static boolean ping​(java.lang.String url, boolean intern, int timeout)
      Ping an URL
      static void pingNodes()
      Check if nodes are responding thru /ping.
      static java.lang.String rebuildIndex()
      Rebuild document indexes
      static java.lang.String rebuildObjectIndex()
      Rebuild object indexes
      static boolean resetCache​(Grant g, boolean memory, boolean core, boolean invalidateSessions, boolean notify, int preCompile)
      Clears the system cache and update the LAST_CLEAR_CACHE to notify other servers.
      static boolean resetCache​(java.lang.String login, boolean invalidateSessions, boolean notify)
      Clears the cache for one user and update the usr_logout to notify other servers
      static void resetCacheAction​(Grant g, java.lang.String action)
      Clears specified action cache
      static void resetCacheConstraints​(java.lang.String obj, Grant g)
      Clears specified constraints cache
      static boolean resetCacheDisp​(Grant g, java.lang.String disp)
      Clears specified disposition cache
      static void resetCacheDomain​(Grant g, java.lang.String domain)
      Clears specified domain cache
      static void resetCacheField​(java.lang.String field)
      Clears specified field cache
      static void resetCacheField​(java.lang.String field, Grant g)
      Clears specified field cache
      static void resetCacheFieldArea​(java.lang.String area)
      Clears specified field area cache
      static void resetCacheFieldType​(java.lang.String type, Grant g)
      Clears specified field type cache
      static void resetCacheFunction​(java.lang.String obj, java.lang.String action, java.lang.String view, Grant g)  
      static void resetCacheGroup​(Grant g, java.lang.String group)  
      static void resetCacheGroups​(Grant g)  
      static boolean resetCacheList​(java.lang.String lovName)
      Clears specified List of values and all related objects
      static boolean resetCacheList​(java.lang.String lovName, Grant g)
      Clears specified List of values and all related objects
      static void resetCacheNotification​(Grant g, java.lang.String notification)
      Clears specified notification
      static boolean resetCacheObject​(java.lang.String object, java.lang.String instance)
      Clears specified business object from all user's cache
      static boolean resetCacheObject​(java.lang.String object, java.lang.String instance, Grant g)
      Clears specified business object from all user's cache
      static void resetCacheProcess​(Grant g, java.lang.String pcs)
      Clears specified process cache
      static void resetCacheResource​(Grant g, java.lang.String object, java.lang.String rowId)
      Clears specified resource cache
      static void resetCacheSysParam​(java.lang.String code, java.lang.String value, Grant g)
      Clears system parameter cache
      static void resetCacheTemplate​(Grant g, java.lang.String name)  
      static void resetCacheText()
      Clears TEXT List of values
      static void resetCacheTheme​(Grant g, java.lang.String theme)
      Clears specified theme
      static void resetCacheTimesheet​(Grant g, java.lang.String ts)
      Clears specified timesheet cache
      static void resetCacheView​(Grant g, java.lang.String view)
      Clears specified view cache
      static boolean restartCron​(boolean lock, boolean notify)
      Stop and restart the cron manager using admin rights (notify other servers)
      static void restartCronToURL​(java.lang.String url, boolean notify, java.lang.String login, java.lang.String pwd)
      Restart cron thru IO service
      static boolean startCron​(boolean lock)
      Start the cron table using admin rights
      static boolean stopCron​(boolean unlock)
      Stop the cron manager using admin rights
      static java.lang.String synchronizeDocs()
      Purge all unsynchronized DBDoc
      static SystemTool.ThreadInfos threadDump​(long id, int maxDepth)
      Get thread dump
      static java.util.List<SystemTool.ThreadInfos> threadInfos​(int maxDepth, boolean sort, boolean filter)
      Get threads info
      static boolean useClientMonitoring​(Grant g)
      Use client monitoring ?
      static boolean useServerMonitoring()
      Use server monitoring?
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SystemTool

        public SystemTool()
    • Method Detail

      • forceGC

        public static void forceGC()
        Full Garbage collection of unused JVM objects
      • objectGC

        public static int objectGC​(boolean full)
        Internal garbage collection of unused Simplicite objects (Object, Grant and Processes)
        Parameters:
        full - true to remove object from cache, false to remove only the dynamic data (keep objects definitions)
        Returns:
        Number of cleared objects
      • clearRecycleBin

        public static java.lang.String clearRecycleBin()
        Purge all deleted files in DBDoc
        Returns:
        Purge result message
      • clearImportDir

        public static java.lang.String clearImportDir()
        Purge import directory
        Returns:
        Purge result message
      • clearExportDir

        public static java.lang.String clearExportDir()
        Purge export directory
        Returns:
        Purge result message
      • clearTempDir

        public static java.lang.String clearTempDir()
        Purge temporary directory
        Returns:
        Purge result message
      • cleanSrcAndBinDirs

        public static java.lang.String cleanSrcAndBinDirs()
        Purge sources and binaries directories
        Returns:
        Purge result message
      • synchronizeDocs

        public static java.lang.String synchronizeDocs()
        Purge all unsynchronized DBDoc
        Returns:
        Purge result message
      • rebuildIndex

        public static java.lang.String rebuildIndex()
        Rebuild document indexes
        Returns:
        Rebuild document index result message
      • rebuildObjectIndex

        public static java.lang.String rebuildObjectIndex()
        Rebuild object indexes
        Returns:
        Rebuild object index result message
      • resetCache

        public static boolean resetCache​(Grant g,
                                         boolean memory,
                                         boolean core,
                                         boolean invalidateSessions,
                                         boolean notify,
                                         int preCompile)
        Clears the system cache and update the LAST_CLEAR_CACHE to notify other servers. No UI access is permitted during this operation.
        Parameters:
        g - User rights
        memory - true to clear the cache memory
        core - true clear the core definitions
        invalidateSessions - true to disconnect everybody
        notify - notify other servers ?
        preCompile - pre-compile objects and processes ? (0=no, 1=sync, 2=async)
      • resetCache

        public static boolean resetCache​(java.lang.String login,
                                         boolean invalidateSessions,
                                         boolean notify)
        Clears the cache for one user and update the usr_logout to notify other servers
        Parameters:
        login - user login
        invalidateSessions - true to disconnect user sessions
        notify - notify other servers ?
      • resetCacheObject

        public static boolean resetCacheObject​(java.lang.String object,
                                               java.lang.String instance)
        Clears specified business object from all user's cache
        Parameters:
        object - Object name
        instance - Object instance (null means all instances of the object)
      • resetCacheObject

        public static boolean resetCacheObject​(java.lang.String object,
                                               java.lang.String instance,
                                               Grant g)
        Clears specified business object from all user's cache
        Parameters:
        object - Object name
        instance - Object instance (null means all instances of the object)
        g - Optional user to notify thru websocket
      • resetCacheSysParam

        public static void resetCacheSysParam​(java.lang.String code,
                                              java.lang.String value,
                                              Grant g)
        Clears system parameter cache
        Parameters:
        code - Parameter name
        value - Parameter value
        g - Optional user rights to reload
      • resetCacheList

        public static boolean resetCacheList​(java.lang.String lovName)
        Clears specified List of values and all related objects
        Parameters:
        lovName - List name
      • resetCacheList

        public static boolean resetCacheList​(java.lang.String lovName,
                                             Grant g)
        Clears specified List of values and all related objects
        Parameters:
        lovName - List name
        g - Optional user to notify
      • resetCacheText

        public static void resetCacheText()
        Clears TEXT List of values
      • resetCacheDisp

        public static boolean resetCacheDisp​(Grant g,
                                             java.lang.String disp)
        Clears specified disposition cache
        Parameters:
        g - User rights
        disp - Disposition name
      • resetCacheResource

        public static void resetCacheResource​(Grant g,
                                              java.lang.String object,
                                              java.lang.String rowId)
        Clears specified resource cache
        Parameters:
        g - User rights
        object - Object name or Disposition
        rowId - Object row ID
      • resetCacheProcess

        public static void resetCacheProcess​(Grant g,
                                             java.lang.String pcs)
        Clears specified process cache
        Parameters:
        g - User rights
        pcs - Process/Workflow name
      • resetCacheTimesheet

        public static void resetCacheTimesheet​(Grant g,
                                               java.lang.String ts)
        Clears specified timesheet cache
        Parameters:
        g - User rights
        ts - Timesheet name
      • resetCacheView

        public static void resetCacheView​(Grant g,
                                          java.lang.String view)
        Clears specified view cache
        Parameters:
        g - User rights
        view - View name
      • resetCacheTheme

        public static void resetCacheTheme​(Grant g,
                                           java.lang.String theme)
        Clears specified theme
        Parameters:
        g - User rights
        theme - Theme name
      • resetCacheNotification

        public static void resetCacheNotification​(Grant g,
                                                  java.lang.String notification)
        Clears specified notification
        Parameters:
        g -
        notification -
      • compileThemes

        public static void compileThemes()
        Rebuild themes with less sources
      • compileResources

        public static void compileResources()
        Rebuild JS+CSS resources (less and minification)
      • initMavenRepository

        public static void initMavenRepository()
        Initialize Maven repository
      • buildMavenRepository

        public static void buildMavenRepository​(java.lang.String mavenDir,
                                                java.lang.String classesDir,
                                                java.lang.String javadocDir,
                                                java.lang.String sourcesDir)
        Build Maven repository
        Parameters:
        mavenDir - Maven repository directory
        classesDir - Compiled classes dir
        javadocDir - Optional Javadoc dir
        sourcesDir - Optional sources dir
      • resetCacheAction

        public static void resetCacheAction​(Grant g,
                                            java.lang.String action)
        Clears specified action cache
        Parameters:
        g - User rights
        action - Action name
      • resetCacheDomain

        public static void resetCacheDomain​(Grant g,
                                            java.lang.String domain)
        Clears specified domain cache
        Parameters:
        g - User rights
        domain - Domain name
      • resetCacheConstraints

        public static void resetCacheConstraints​(java.lang.String obj,
                                                 Grant g)
        Clears specified constraints cache
        Parameters:
        obj - Object name
      • resetCacheField

        public static void resetCacheField​(java.lang.String field)
        Clears specified field cache
        Parameters:
        field - Field name
      • resetCacheField

        public static void resetCacheField​(java.lang.String field,
                                           Grant g)
        Clears specified field cache
        Parameters:
        field - Field name
      • resetCacheFieldType

        public static void resetCacheFieldType​(java.lang.String type,
                                               Grant g)
        Clears specified field type cache
        Parameters:
        type - Field type
      • resetCacheFieldArea

        public static void resetCacheFieldArea​(java.lang.String area)
        Clears specified field area cache
        Parameters:
        area - Area name
      • resetCacheFunction

        public static void resetCacheFunction​(java.lang.String obj,
                                              java.lang.String action,
                                              java.lang.String view,
                                              Grant g)
      • resetCacheGroups

        public static void resetCacheGroups​(Grant g)
      • resetCacheGroup

        public static void resetCacheGroup​(Grant g,
                                           java.lang.String group)
      • resetCacheTemplate

        public static void resetCacheTemplate​(Grant g,
                                              java.lang.String name)
      • isCronStarted

        public static boolean isCronStarted()
        Check cron status using admin rights
        Returns:
        true if cron is started with scheduled jobs
      • startCron

        public static boolean startCron​(boolean lock)
        Start the cron table using admin rights
        Parameters:
        lock - true to unlock anyway and to lock with this platform
        Returns:
        true if cron has been restarted
      • stopCron

        public static boolean stopCron​(boolean unlock)
        Stop the cron manager using admin rights
        Parameters:
        unlock - true to unlock if the cron has been launched by this platform
        Returns:
        true if cron is stopped
      • restartCron

        public static boolean restartCron​(boolean lock,
                                          boolean notify)
        Stop and restart the cron manager using admin rights (notify other servers)
        Parameters:
        lock - true to unlock anyway and to lock with this platform
        notify - notify other servers ?
        Returns:
        true if cron has been restarted
      • getInfo

        public static SystemTool.SystemInfo getInfo​(boolean jvm,
                                                    boolean cache,
                                                    boolean doc,
                                                    boolean disk)
        Get system information (JVM, cache, documents, disk usage)
        Parameters:
        jvm - Process JVM info ?
        cache - Process cache info ?
        doc - Process documents info ?
        disk - Process disk info ?
        Returns:
        System information
      • getInfo

        public static SystemTool.SystemInfo getInfo()
        Get system information (JVM, cache, documents, disk usage)
        Returns:
        System information
      • getDevInfo

        public static org.json.JSONObject getDevInfo​(java.lang.String module)
        Get development information for external development environment
        Parameters:
        module - Optional module name
        Returns:
        Development information
      • useServerMonitoring

        public static boolean useServerMonitoring()
        Use server monitoring?
        Returns:
        True if using server monitoring
      • monitoring

        public static java.lang.String monitoring​(boolean start)
        Stop/Start monitoring
        Parameters:
        start - True = start, False = stop
        Returns:
        Start/stop confirmation message
      • useClientMonitoring

        public static boolean useClientMonitoring​(Grant g)
        Use client monitoring ?
        Returns:
        true when LOG_UI=yes and responsibility ADMIN or OPERATOR
      • cronMonitoring

        public static void cronMonitoring​(java.lang.String column,
                                          java.lang.String value)
        Change cron of monitoring
        Parameters:
        column - Column
        value - Value
      • memoryUsage

        public static java.lang.management.MemoryUsage memoryUsage​(java.lang.String name,
                                                                   boolean peak)
        Get memory metrics using MemoryPoolMXBean
        Parameters:
        name - Perm gen, Code Cache, Eden Space, Survivor Space, Old Gen
        peak - True to get peak or current usage
        Returns:
        Memory metrics
      • memoryUsage

        public static java.util.Map<java.lang.String,​java.lang.management.MemoryUsage> memoryUsage​(boolean peak)
        Get all memories metrics using MemoryPoolMXBean
        Parameters:
        peak - True to get peak or current usage
        Returns:
        Map of memory metrics
      • threadInfos

        public static java.util.List<SystemTool.ThreadInfos> threadInfos​(int maxDepth,
                                                                         boolean sort,
                                                                         boolean filter)
        Get threads info
        Parameters:
        maxDepth - Stack trace size (0=no stack)
        sort - To sort result by times (desc)
        filter - Only return thread executing Simplicite
        Returns:
        Array if JMX is supported
      • getAllThreads

        public static java.lang.Thread[] getAllThreads()
        Get all JVM threads
      • getThread

        public static java.lang.Thread getThread​(long id,
                                                 java.lang.String name)
        Look for a thread
        Parameters:
        id - id in name is unknown
        name - name if id is unknown
        Returns:
        null if not found
      • threadDump

        public static SystemTool.ThreadInfos threadDump​(long id,
                                                        int maxDepth)
        Get thread dump
        Parameters:
        id - Thread id
        maxDepth - Stack trace size
        Returns:
        Thread info with Stack
      • dumpHeap

        public static java.lang.String dumpHeap()
        Dump the Java heap
        Returns:
        path to the bin file
      • getPID

        public static java.lang.String getPID()
        Get the JVM process id
        Returns:
        PID or null
      • getSystemLoadAverage

        public static double getSystemLoadAverage()
        CPU usage
        Returns:
        System load average
      • getClassCount

        public static SystemTool.ClassCount getClassCount()
        Get classes count
        Returns:
        Number of classes
      • getCronInterval

        public static int getCronInterval​(java.lang.String name,
                                          int def)

        Get a cron simple interval: detects seconds, minutes or hours frequency in the Cron expression

        Example: '0/30 * * * * ?' = 30 seconds
        Example: '0 3/20 * * * ?' = 20*60 = 1200 seconds
        Example: '0 15 1/2 * * ?' = 2*60*60 = 7200 seconds

        Parameters:
        name - crontab name
        def - default interval
        Returns:
        Interval in seconds
      • getCronExpr

        public static java.lang.String getCronExpr​(int sec)
        Get cron expression with a simple interval (seconds, minutes or hours)
        Parameters:
        sec - polling interval in seconds
      • getModuleFromURL

        public static java.io.InputStream getModuleFromURL​(java.lang.String url,
                                                           java.lang.String login,
                                                           java.lang.String pwd,
                                                           java.lang.String module)
                                                    throws PlatformException
        Get a module definition thru IO service or simple HTTP call
        Parameters:
        url - Platform URL
        login - Login
        pwd - Password
        module - Module name
        Returns:
        input stream
        Throws:
        PlatformException
      • getModuleTreeFromURL

        public static org.json.JSONObject getModuleTreeFromURL​(java.lang.String url,
                                                               java.lang.String login,
                                                               java.lang.String pwd,
                                                               java.lang.String module)
                                                        throws PlatformException
        Get a module definition tree thru IO service or simple HTTP call
        Parameters:
        url - Platform URL
        login - Login
        pwd - Password
        module - Module name
        Returns:
        JSON tree
        Throws:
        PlatformException
      • installModuleToURL

        public static java.lang.String installModuleToURL​(java.lang.String url,
                                                          java.lang.String login,
                                                          java.lang.String pwd,
                                                          java.lang.String module,
                                                          java.lang.String xml,
                                                          boolean log)
                                                   throws java.lang.Exception
        Set a module definition thru IO service
        Parameters:
        url - Platform URL
        login - Login
        pwd - Password
        module - Module name
        xml - Module XML
        log - Full import log
        Returns:
        result
        Throws:
        java.lang.Exception
      • deleteModuleToURL

        public static java.lang.String deleteModuleToURL​(java.lang.String url,
                                                         java.lang.String login,
                                                         java.lang.String pwd,
                                                         java.lang.String module)
                                                  throws java.lang.Exception
        Delete a module definition thru IO service
        Parameters:
        url - Platform URL
        login - Login
        pwd - Password
        module - Module name
        Returns:
        result
        Throws:
        java.lang.Exception
      • applyPatch

        public static java.lang.String applyPatch​(java.lang.String url,
                                                  java.lang.String login,
                                                  java.lang.String pwd,
                                                  java.lang.String patch,
                                                  boolean log)
                                           throws java.lang.Exception
        Apply a path thru IO service
        Parameters:
        url - Platform URL
        login - Login
        pwd - Password
        patch - Patch XML
        log - Full import log
        Returns:
        Import result
        Throws:
        java.lang.Exception
      • clearCacheToURL

        public static void clearCacheToURL​(java.lang.String url,
                                           java.lang.String login,
                                           java.lang.String pwd)
                                    throws java.lang.Exception
        Clear cache and invalidate sessions thru IO service
        Parameters:
        url - Platform URL
        login - Login
        pwd - Password
        Throws:
        java.lang.Exception
      • clearCacheToURL

        public static void clearCacheToURL​(java.lang.String url,
                                           java.lang.String user,
                                           boolean invalidate,
                                           boolean notify,
                                           java.lang.String login,
                                           java.lang.String pwd)
                                    throws HTTPException
        Clear cache thru IO service
        Parameters:
        url - Platform URL
        user - Optional user to clear
        invalidate - Invalidate sessions ?
        notify - notify other servers ?
        login - Login
        pwd - Password
        Throws:
        HTTPException
      • restartCronToURL

        public static void restartCronToURL​(java.lang.String url,
                                            boolean notify,
                                            java.lang.String login,
                                            java.lang.String pwd)
                                     throws HTTPException
        Restart cron thru IO service
        Parameters:
        url - Platform URL
        login - Login
        pwd - Password
        Throws:
        HTTPException
      • countSessionsToURL

        public static int countSessionsToURL​(java.lang.String url,
                                             java.lang.String user,
                                             boolean unique,
                                             java.lang.String login,
                                             java.lang.String pwd)
                                      throws HTTPException
        Count authenticated users thru IO service
        Parameters:
        url - Platform URL
        user - specific login or all if null
        unique - distinct users or all authenticated sessions
        login - Login
        pwd - Password
        Returns:
        sessions count
        Throws:
        HTTPException
      • isWindows

        public static boolean isWindows()
        Is the OS Windows?
        Returns:
        True if OS is Windows
      • isLinux

        public static boolean isLinux()
        Is the OS Linux?
        Returns:
        True if OS is Linux
      • isUnix

        public static boolean isUnix()
        Is the OS UNIX?
        Returns:
        True if OS is UNIX
      • isMac

        public static boolean isMac()
        Is the OS MacOS?
        Returns:
        True if OS is MacOS
      • isDocker

        public static boolean isDocker()
        Is running inside a Docker image?
        Returns:
        True if running inside a Docker image (checked using the DOCKER environment variable)
      • getDockerOSName

        public static java.lang.String getDockerOSName()
        Get Docker OS name if applicable.
        Returns:
        The value of the DOCKER environment variable if present
      • exec

        public static SystemTool.ExecResult exec​(java.lang.String cmd,
                                                 java.util.List<java.lang.String> args,
                                                 java.lang.String dir)
                                          throws java.lang.InterruptedException
        Exec a system command
        Parameters:
        cmd - Command
        args - Arguments list
        dir - Execution directory
        Returns:
        System command output and error
        Throws:
        java.lang.InterruptedException
      • exec

        public static SystemTool.ExecResult exec​(java.lang.String cmd,
                                                 java.util.List<java.lang.String> args,
                                                 java.util.Map<java.lang.String,​java.lang.String> envs,
                                                 java.lang.String dir)
                                          throws java.lang.InterruptedException
        Exec a system command
        Parameters:
        cmd - Command
        args - Arguments list or null
        envs - Environment variables list or null
        dir - Execution directory
        Returns:
        System command output and error
        Throws:
        java.lang.InterruptedException
      • execScript

        public static SystemTool.ExecResult execScript​(byte[] script,
                                                       java.lang.String interpreter,
                                                       java.util.List<java.lang.String> args,
                                                       boolean keepDir)
                                                throws java.lang.InterruptedException
        Exec a system script using specified script interpreter (e.g. bash, node, python, ...)
        Parameters:
        script - Script as byte array (string e.g. read from a resource document, ...)
        interpreter - Intepreter path (e.g. /bin/bash or /usr/local/bin/node, /usr/bin/python, ...), can be left empty for directly executable scripts
        args - Arguments list
        keepDir - Keep execution dir after execution?
        Returns:
        System script execution output and error
        Throws:
        java.lang.InterruptedException
      • execScript

        public static SystemTool.ExecResult execScript​(java.lang.String script,
                                                       java.lang.String interpreter,
                                                       java.util.List<java.lang.String> args,
                                                       boolean keepDir)
                                                throws java.lang.InterruptedException
        Exec a system script using specified script interpreter (e.g. bash, node, python, ...)
        Parameters:
        script - Script as string (string e.g. read from a field value ...)
        interpreter - Intepreter path (e.g. /bin/bash or /usr/local/bin/node, /usr/bin/python, ...), can be left empty for directly executable scripts
        args - Arguments list
        keepDir - Keep execution dir after execution?
        Returns:
        System script execution output and error
        Throws:
        java.lang.InterruptedException
      • cleanDeadSessions

        public static void cleanDeadSessions()
        Close dead sessions in m_session (i.e. after a server crash)
      • ping

        public static boolean ping​(java.lang.String url,
                                   boolean intern,
                                   int timeout)
        Ping an URL
        Parameters:
        url - URL
        intern - call the internal /ping service
        timeout - in seconds
        Returns:
        true if URL is alive (HTTP 200)
      • pingNodes

        public static void pingNodes()
        Check if nodes are responding thru /ping. Remove dead instances from m_pf_node.
      • createTable

        public static java.lang.String createTable​(ObjectDB obj,
                                                   boolean full)
        Table creation
        Parameters:
        full - true to generate all fields' columns, false to generate only row_id and timestamps fields
        Returns:
        create DDL syntax
      • createTable

        public static java.lang.String createTable​(java.lang.String datasource,
                                                   java.lang.String table,
                                                   boolean timestamp,
                                                   ObjectField rowIdField,
                                                   ObjectDB obj)
        Table creation
        Parameters:
        datasource - Data source name
        table - Table name
        timestamp - Add the timestamp columns?
        rowIdField - Specific primary key
        obj - Optional definition to create columns
        Returns:
        create DDL syntax
      • addTimestampColumns

        public static void addTimestampColumns​(Grant g,
                                               java.lang.String datasource,
                                               java.lang.String table)
        Add timestamp columns if not exist
      • generateIndexes

        public static java.lang.String generateIndexes​(java.lang.String object,
                                                       boolean apply)
        Generate business object DB indexes + full-text indexes (asynchronous)
        Parameters:
        object - Object name
        apply - true to rebuild DB INDEX, false to only generate the SQL script
        Returns:
        SQL statements
      • generateIndexes

        public static java.lang.String generateIndexes​(java.lang.String object,
                                                       boolean rebuildDBIndexes,
                                                       boolean rebuildDataIndexes,
                                                       boolean async)
        Generate business object DB indexes + full-text indexes (asynchronous or not)
        Parameters:
        object - Object name
        rebuildDBIndexes - true to rebuild DB INDEX, false to only generate the SQL script
        rebuildDataIndexes - true to rebuild full-text indexes
        async - Asynchronously?
        Returns:
        SQL statements