Class CmsGitCheckin


  • public class CmsGitCheckin
    extends java.lang.Object
    The class provides methods to automatically export modules from OpenCms and check in the exported, unzipped modules into some git repository. The feature is only available under Linux at the moment. It uses a shell script. Which modules are exported to and checked in to which git repository is configured in the file /WEB-INF/git-scripts/module-checkin.sh.
    • Constructor Detail

      • CmsGitCheckin

        public CmsGitCheckin​(CmsObject cms)
        Default constructor. Initializing member variables with default values.
        Parameters:
        cms - the CMS context to use
    • Method Detail

      • zipRfsFolder

        public static void zipRfsFolder​(java.io.File root,
                                        java.io.OutputStream zipOutput)
                                 throws java.lang.Exception
        Creates ZIP file data from the files / subfolders of the given root folder, and sends it to the given stream.

        The stream passed as an argument is closed after the data is written.

        Parameters:
        root - the folder to zip
        zipOutput - the output stream which the zip file data should be written to
        Throws:
        java.lang.Exception - if something goes wrong
      • addModuleToExport

        public void addModuleToExport​(java.lang.String moduleName)
        Adds a module to the modules that should be exported. If called at least once, the explicitly added modules will be exported instead of the default modules.
        Parameters:
        moduleName - the name of the module to export.
      • checkIn

        public int checkIn()
        Start export and check in of the selected modules.
        Returns:
        The exit code of the check in procedure (like a script's exit code).
      • clearModules

        public void clearModules()
        Clears the selected modules.

      • getCheckout

        public boolean getCheckout()
        Gets the checkout flag.

        Returns:
        the checkout flag
      • getCommitMessage

        public java.lang.String getCommitMessage()
        Returns the commitMessage.

        Returns:
        the commitMessage
      • getGitUserEmail

        public java.lang.String getGitUserEmail()
        Returns the gitUserEmail.

        Returns:
        the gitUserEmail
      • getGitUserName

        public java.lang.String getGitUserName()
        Returns the gitUserName.

        Returns:
        the gitUserName
      • getInstalledModules

        public java.util.Collection<java.lang.String> getInstalledModules()
        Returns the collection of all installed modules.
        Returns:
        the collection of all installed modules.
      • getLogFilePath

        public java.lang.String getLogFilePath()
        Returns the path to the log file.
        Returns:
        the path to the log file.
      • getLogText

        public java.lang.String getLogText()
        Gets the log text.

        Returns:
        the log text
      • hasValidConfiguration

        public boolean hasValidConfiguration()
        Returns true if at least one valid configuration is present.
        Returns:
        true if at least one valid configuration is present.
      • isFetchAndResetBeforeImport

        public boolean isFetchAndResetBeforeImport()
        Returns true if the 'fetch and reset' flag is set.

        Returns:
        true if 'fetch and reset' flag is set
      • isModuleInstalled

        public boolean isModuleInstalled​(java.lang.String moduleName)
        Tests if a module is installed.
        Parameters:
        moduleName - name of the module to check.
        Returns:
        Flag, indicating if the module is installed.
      • setCheckout

        public void setCheckout​(boolean checkout)
        Sets the checkout flag.

        Parameters:
        checkout - the checkout flag
      • setCommit

        public void setCommit​(boolean autoCommit)
        Setter for the commit mode.
        Parameters:
        autoCommit - the commit mode to set.
      • setCommitMessage

        public void setCommitMessage​(java.lang.String message)
        Setter for the commit message.
        Parameters:
        message - the commit message to set.
      • setCopyAndUnzip

        public void setCopyAndUnzip​(boolean copyAndUnzip)
        Setter for the copy and unzip mode.
        Parameters:
        copyAndUnzip - the copy and unzip mode to set.
      • setCurrentConfiguration

        public boolean setCurrentConfiguration​(CmsGitConfiguration configuration)
        Sets the current configuration if it is a valid configuration. Otherwise the configuration is not set.
        Parameters:
        configuration - the configuration to set.
        Returns:
        flag, indicating if the configuration is set.
      • setExcludeLibs

        public void setExcludeLibs​(boolean excludeLibs)
        Setter for the exclude libs flag.
        Parameters:
        excludeLibs - flag, indicating if the lib/ folder of the modules should be deleted before the commit.
      • setFetchAndResetBeforeImport

        public void setFetchAndResetBeforeImport​(boolean fetchAndReset)
        Sets the 'fetch and reset' flag.

        If this flag is set, the script will be used to fetch the remote branch and reset the current branch to the remote state before trying to import the modules.

        Parameters:
        fetchAndReset - the 'fetch and reset' flag
      • setGitUserEmail

        public void setGitUserEmail​(java.lang.String useremail)
        Setter for the git user email.
        Parameters:
        useremail - the git user email to set.
      • setGitUserName

        public void setGitUserName​(java.lang.String username)
        Setter for the git user name.
        Parameters:
        username - the git user name to set.
      • setIgnoreUnclean

        public void setIgnoreUnclean​(boolean ignore)
        Setter for the ignore-unclean flag.
        Parameters:
        ignore - flag, indicating if an unclean repository should be ignored.
      • setPullAfter

        public void setPullAfter​(boolean autoPull)
        Setter for the pull-after flag.
        Parameters:
        autoPull - flag, indicating if a pull should be performed directly after the commit.
      • setPullBefore

        public void setPullBefore​(boolean autoPull)
        Setter for the pull-before flag.
        Parameters:
        autoPull - flag, indicating if a pull should be performed first.
      • setPush

        public void setPush​(boolean autoPush)
        Setter for the auto-push flag.
        Parameters:
        autoPush - flag, indicating if a push should be performed in the end.
      • setResetHead

        public void setResetHead​(boolean reset)
        Setter for the reset-head flag.
        Parameters:
        reset - flag, indicating if a reset to the HEAD should be performed or not.
      • setResetRemoteHead

        public void setResetRemoteHead​(boolean reset)
        Setter for the reset-remote-head flag.
        Parameters:
        reset - flag, indicating if a reset to the ${origin}/${branch} should be performed or not.