Package org.opencms.ui.apps.git
Class CmsGitCheckin
java.lang.Object
org.opencms.ui.apps.git.CmsGitCheckin
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addModuleToExport
(String moduleName) Adds a module to the modules that should be exported.int
checkIn()
Start export and check in of the selected modules.void
Clears the selected modules.boolean
Gets the checkout flag.Gets the CMS context.Returns the commitMessage.Returns the available configurations.Returns the currently used configuration.Returns the gitUserEmail.Returns the gitUserName.Returns the collection of all installed modules.Returns the path to the log file.Gets the log text.boolean
Returns true if at least one valid configuration is present.boolean
Returns true if the 'fetch and reset' flag is set.boolean
isModuleInstalled
(String moduleName) Tests if a module is installed.void
setCheckout
(boolean checkout) Sets the checkout flag.void
setCommit
(boolean autoCommit) Setter for the commit mode.void
setCommitMessage
(String message) Setter for the commit message.void
setCopyAndUnzip
(boolean copyAndUnzip) Setter for the copy and unzip mode.boolean
setCurrentConfiguration
(CmsGitConfiguration configuration) Sets the current configuration if it is a valid configuration.void
setExcludeLibs
(boolean excludeLibs) Setter for the exclude libs flag.void
setFetchAndResetBeforeImport
(boolean fetchAndReset) Sets the 'fetch and reset' flag.void
setGitUserEmail
(String useremail) Setter for the git user email.void
setGitUserName
(String username) Setter for the git user name.void
setIgnoreUnclean
(boolean ignore) Setter for the ignore-unclean flag.void
setPullAfter
(boolean autoPull) Setter for the pull-after flag.void
setPullBefore
(boolean autoPull) Setter for the pull-before flag.void
setPush
(boolean autoPush) Setter for the auto-push flag.void
setResetHead
(boolean reset) Setter for the reset-head flag.void
setResetRemoteHead
(boolean reset) Setter for the reset-remote-head flag.static void
zipRfsFolder
(File root, OutputStream zipOutput) Creates ZIP file data from the files / subfolders of the given root folder, and sends it to the given stream.
-
Constructor Details
-
CmsGitCheckin
Default constructor. Initializing member variables with default values.- Parameters:
cms
- the CMS context to use
-
-
Method Details
-
zipRfsFolder
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 zipzipOutput
- the output stream which the zip file data should be written to- Throws:
Exception
- if something goes wrong
-
addModuleToExport
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
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
Clears the selected modules. -
getCheckout
Gets the checkout flag.- Returns:
- the checkout flag
-
getCmsObject
Gets the CMS context.- Returns:
- the CMS context
-
getCommitMessage
Returns the commitMessage.- Returns:
- the commitMessage
-
getConfigurations
Returns the available configurations.- Returns:
- the available configurations.
-
getCurrentConfiguration
Returns the currently used configuration.- Returns:
- the currently used configuration.
-
getGitUserEmail
Returns the gitUserEmail.- Returns:
- the gitUserEmail
-
getGitUserName
Returns the gitUserName.- Returns:
- the gitUserName
-
getInstalledModules
Returns the collection of all installed modules.- Returns:
- the collection of all installed modules.
-
getLogFilePath
Returns the path to the log file.- Returns:
- the path to the log file.
-
getLogText
Gets the log text.- Returns:
- the log text
-
hasValidConfiguration
Returns true if at least one valid configuration is present.- Returns:
- true if at least one valid configuration is present.
-
isFetchAndResetBeforeImport
Returns true if the 'fetch and reset' flag is set.- Returns:
- true if 'fetch and reset' flag is set
-
isModuleInstalled
Tests if a module is installed.- Parameters:
moduleName
- name of the module to check.- Returns:
- Flag, indicating if the module is installed.
-
setCheckout
Sets the checkout flag.- Parameters:
checkout
- the checkout flag
-
setCommit
Setter for the commit mode.- Parameters:
autoCommit
- the commit mode to set.
-
setCommitMessage
Setter for the commit message.- Parameters:
message
- the commit message to set.
-
setCopyAndUnzip
Setter for the copy and unzip mode.- Parameters:
copyAndUnzip
- the copy and unzip mode to set.
-
setCurrentConfiguration
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
Setter for the exclude libs flag.- Parameters:
excludeLibs
- flag, indicating if the lib/ folder of the modules should be deleted before the commit.
-
setFetchAndResetBeforeImport
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
Setter for the git user email.- Parameters:
useremail
- the git user email to set.
-
setGitUserName
Setter for the git user name.- Parameters:
username
- the git user name to set.
-
setIgnoreUnclean
Setter for the ignore-unclean flag.- Parameters:
ignore
- flag, indicating if an unclean repository should be ignored.
-
setPullAfter
Setter for the pull-after flag.- Parameters:
autoPull
- flag, indicating if a pull should be performed directly after the commit.
-
setPullBefore
Setter for the pull-before flag.- Parameters:
autoPull
- flag, indicating if a pull should be performed first.
-
setPush
Setter for the auto-push flag.- Parameters:
autoPush
- flag, indicating if a push should be performed in the end.
-
setResetHead
Setter for the reset-head flag.- Parameters:
reset
- flag, indicating if a reset to the HEAD should be performed or not.
-
setResetRemoteHead
Setter for the reset-remote-head flag.- Parameters:
reset
- flag, indicating if a reset to the ${origin}/${branch} should be performed or not.
-