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/
    • Constructor Detail

      • CmsGitCheckin

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

      • zipRfsFolder

        public static void zipRfsFolder​( root,
                                 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.

        root - the folder to zip
        zipOutput - the output stream which the zip file data should be written to
        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.
        moduleName - the name of the module to export.
      • checkIn

        public int checkIn()
        Start export and check in of the selected modules.
        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.

        the checkout flag
      • getCommitMessage

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

        the commitMessage
      • getGitUserEmail

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

        the gitUserEmail
      • getGitUserName

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

        the gitUserName
      • getInstalledModules

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

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

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

        the log text
      • hasValidConfiguration

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

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

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

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

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

        checkout - the checkout flag
      • setCommit

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

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

        public void setCopyAndUnzip​(boolean copyAndUnzip)
        Setter for the copy and unzip mode.
        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.
        configuration - the configuration to set.
        flag, indicating if the configuration is set.
      • setExcludeLibs

        public void setExcludeLibs​(boolean excludeLibs)
        Setter for the exclude libs flag.
        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.

        fetchAndReset - the 'fetch and reset' flag
      • setGitUserEmail

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

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

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

        public void setPullAfter​(boolean autoPull)
        Setter for the pull-after flag.
        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.
        autoPull - flag, indicating if a pull should be performed first.
      • setPush

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

        public void setResetHead​(boolean reset)
        Setter for the reset-head flag.
        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.
        reset - flag, indicating if a reset to the ${origin}/${branch} should be performed or not.