Class BaseCliCommand

    • Field Detail

      • DT_PROJECT_STARTUP_DURATION

        protected static final Duration DT_PROJECT_STARTUP_DURATION
    • Constructor Detail

      • BaseCliCommand

        public BaseCliCommand()
    • Method Detail

      • getProjectsRecursively

        public Collection<File> getProjectsRecursively​(Path path)
        Gets all Eclipse .project files from a provided folder, with recursive search
        Parameters:
        path - The path to a folder which may contain projects. Cannot be null
        Returns:
        A collection of found projects. Never null but may be empty
      • accept

        public void accept​(org.apache.felix.service.command.CommandSession commandSession)
        Specified by:
        accept in interface Consumer<org.apache.felix.service.command.CommandSession>
      • backgroundOperation

        protected <R> R backgroundOperation​(String operationName,
                                            IDtProject dtProject,
                                            ProjectPipelineJob targetStage,
                                            Callable<R> callable)
        Executes logic within background-priority orchestrated operation (see IWorkspaceOrchestrator
        Type Parameters:
        R - Type of return value
        Parameters:
        operationName - The name of an operation to be executed. Cannot be null
        dtProject - Target project to execute the operation on. Cannot be null
        targetStage - Target stage of the project's pipeline. Cannot be null
        callable - Callable to execute. Cannot be null
        Returns:
        Result of the operation execution. Depends on the provided Callable. May be null
      • exclusiveOperation

        protected <V> V exclusiveOperation​(String operationName,
                                           IDtProject dtProject,
                                           ProjectPipelineJob targetJob,
                                           Callable<V> callable)
        Executes logic within exclusive-priority orchestrated operation (see IWorkspaceOrchestrator
        Type Parameters:
        R - Type of return value
        Parameters:
        operationName - The name of an operation to be executed. Cannot be null
        dtProject - Target project to execute the operation on. Cannot be null
        targetStage - Target stage of the project's pipeline. Cannot be null
        callable - Callable to execute. Cannot be null
        Returns:
        Result of the operation execution. Depends on the provided Callable. May be null
      • findProjectsRecursively

        protected Collection<File> findProjectsRecursively​(Path[] projectDirs)
        Finds project files recursively by given collection of directories
        Parameters:
        projectDirs - the project directories
        Returns:
        the collection of .../ProjectName/.project files, cannot return null.
      • getContext

        protected CliCommandContext getContext()
        Gets standard service context of a command
        Returns:
        A command context. May not be null in case of proper command initialization
      • startDtProject

        protected IDtProject startDtProject​(Path projectDir)
        Starts DT project that is pointed by a specified path. Do nothing if the project is already started to allow easy chaining of commands This method waits when DT project has started but it doesn't wait build completion Use workspace orchestration operation to do the job on correct lifecycle stage
        Parameters:
        projectDir - the project directory, cannot be null.
        Returns:
        the started DT project, cannot return null. May throw exception in case of errors during the project start
      • waitUntilStarted

        protected boolean waitUntilStarted​(IDtProject project,
                                           Duration waitDuration)
        Waits until a specified IDtProject is started (all service contexts are up and running)
        Parameters:
        project - The project to wait start for. Cannot be null
        waitDuration - Wait duration time. Cannot be null
        Returns:
        True if the project is started before the timeout
      • waitUntilStarted

        protected boolean waitUntilStarted​(org.eclipse.core.resources.IProject project,
                                           Duration waitDuration)
        Waits until a specified IProject is started (all service contexts are up and running)
        Parameters:
        project - The project to wait start for. Cannot be null
        waitDuration - Wait duration time. Cannot be null
        Returns:
        True if the project is started before the timeout
      • logError

        protected void logError​(String message)
        Logs an error with a specified message
        Parameters:
        message - Message to log as en error. Cannot be null
      • logError

        protected void logError​(String message,
                                Throwable cause)
        Logs an error with a specified message
        Parameters:
        message - Message to log as en error. Cannot be null
        cause - Throwable that caused/indicates error. Cannot be null