Class BackgroundProcessManager

    • Field Detail

      • PROCESS_REQ_ATTR

        public static final java.lang.String PROCESS_REQ_ATTR
    • Method Detail

      • init

        public void init()
      • propertiesChange

        public void propertiesChange​(JProperties properties)
        Handle properties change.
        Specified by:
        propertiesChange in interface JPropertiesListener
        Parameters:
        properties - the properties which have been submitted to change
      • getCurrentBackgroundProcess

        public BackgroundProcess getCurrentBackgroundProcess()
        Return the BackgroundProcess of the current thread if any.
        Returns:
        a BackgroundProcess instance, or null if none
        Since:
        jcms-10.0.8
      • start

        protected java.util.concurrent.CompletableFuture<java.lang.Void> start​(Member author,
                                                                               BackgroundProcess process)
        Parameters:
        process - the process to be started
        author - the member performing the operation
        Returns:
        a future result
        Since:
        jcms-10.0.8
      • saveNotifyPreference

        public void saveNotifyPreference​(BackgroundProcessInfo info,
                                         boolean isNotify)
        Parameters:
        info - process info
        isNotify - weither process author must be notified on process completed
        Since:
        jcms-10.0.8
      • getNotifyPreference

        public boolean getNotifyPreference​(BackgroundProcessInfo info)
        Parameters:
        info - process info
        Returns:
        weither process author must be notified on process completed
        Since:
        jcms-10.0.8
      • canBeNotified

        public boolean canBeNotified​(Member loggedMember,
                                     Member processAuthor)
        Only for author for now (see BackgroundProcessInfo.notify monovaluated boolean)
        Parameters:
        loggedMember - the member
        processAuthor - process author
        Returns:
        true if member is info author
        Since:
        jcms-10.0.8
      • hasBackgroundProcess

        public boolean hasBackgroundProcess​(Member member)
        Check if there is any BackgroundProcess started by specified member
        Parameters:
        member - a member (return false if null)
        Returns:
        true if there is at least one background process, false otherwise
        Since:
        jcms-10.0.8
      • getProcessList

        @Deprecated
        public java.util.List<BackgroundProcessInfo> getProcessList​(BackgroundProcess.Scope scope,
                                                                    java.lang.String domain,
                                                                    Member author)
        Deprecated.
        Lists all process (pending and completed) matching.
        Parameters:
        scope - the scope filter
        domain - the domain filter
        author - the author filter
        Returns:
        list of matching process
        Since:
        jcms-10.0.8
      • getPendingProcessList

        public java.util.List<BackgroundProcessInfo> getPendingProcessList​(Member loggedMember,
                                                                           BackgroundProcess.Scope scope,
                                                                           java.lang.String domain,
                                                                           Member author)
        Lists pending process matching.
        Parameters:
        loggedMember - member to use for read rights
        scope - the scope filter
        domain - the domain filter
        author - the author filter
        Returns:
        list of matching process
        Since:
        jcms-10.0.8
      • getPendingProcessList

        public java.util.List<BackgroundProcessInfo> getPendingProcessList​(Member loggedMember,
                                                                           BackgroundProcess.Scope scope,
                                                                           java.lang.String domain,
                                                                           Member author,
                                                                           java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
        Lists pending process matching.
        Parameters:
        loggedMember - member to use for read rights
        scope - the scope filter
        domain - the domain filter
        author - the author filter
        queryBuildHook - a hook to customize the queryBuilder
        Returns:
        list of matching process
        Since:
        jcms-10.0.8
      • getPendingProcessCount

        public long getPendingProcessCount​(BackgroundProcess.Scope scope,
                                           java.lang.String domain,
                                           Member author)
        Return count of process that are not completed.
        Parameters:
        scope - the scope filter
        domain - the domain filter
        author - the author filter
        Returns:
        count of matching process
        Since:
        jcms-10.0.8
      • getPendingProcessCount

        public long getPendingProcessCount​(BackgroundProcess.Scope scope,
                                           java.lang.String domain,
                                           Member author,
                                           java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
        Return count of process matching that are not completed.
        Parameters:
        scope - the scope filter
        domain - the domain filter
        author - the author filter
        queryBuildHook - a hook to customize the queryBuilder
        Returns:
        count of matching process
        Since:
        jcms-10.0.8
      • getProcessCount

        public long getProcessCount​(Member loggedMember,
                                    BackgroundProcess.Scope scope,
                                    java.lang.String domain,
                                    Member author)
        Return count of all process matching.
        Parameters:
        loggedMember - member to use for read rights
        scope - the scope filter
        domain - the domain filter
        author - the author filter
        Returns:
        count of matching process
        Since:
        jcms-10.0.8
      • getProcessCount

        public long getProcessCount​(Member loggedMember,
                                    BackgroundProcess.Scope scope,
                                    java.lang.String domain,
                                    Member author,
                                    java.util.function.Consumer<BackgroundProcessQueryBuilder> queryBuildHook)
        Return count of all process matching.
        Parameters:
        loggedMember - member to use for read rights
        scope - the scope filter
        domain - the domain filter
        author - the author filter
        queryBuildHook - a hook to customize the queryBuilder
        Returns:
        count of matching process
        Since:
        jcms-10.0.8
      • canStart

        protected ControllerStatus canStart​(Member author,
                                            BackgroundProcess process,
                                            BackgroundProcess.Scope scope,
                                            boolean unique)
        Returns weither process can be run or not as a controller status.
        Prevents unique process to be run simultaneously, depending on author, domain and scope.
        Prevents null-author process to be run, unless it is explicitely allowed using BackgroundProcess.allowNulLAuthor();
        Parameters:
        process - the process to check if it can be run
        scope - scope of the process to run, BackgroundProcess.Scope.WEBAPP used by default
        unique - true if no new same process can be run if another one is already running
        author - author of process to run
        Returns:
        a ControllerStatus
        Since:
        jcms-10.0.8
      • createInfo

        protected void createInfo​(BackgroundProcess process)
        Create a new BackgroundProcessInfo for the specified BackgroundProcess, and update BackgroundProcess to reference it.

        The BackgroundProcessInfo create is performed in another hibernate session/transcation leaving your current transaction untouched.

        Parameters:
        process - the BackgroundProcess for which info must be created
        Since:
        jcms-10.0.8
      • deleteInfo

        public void deleteInfo​(java.lang.String infoId)
        Delete the BackgroundProcessInfo specified by its id.

        The BackgroundProcessInfo is deleted in a dedicated thread, in another hibernate session/transaction leaving your current transaction untouched.

        Parameters:
        infoId - the id of BackgroundProcessInfo
        Since:
        jcms-10.0.8