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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddModuleToExport(String moduleName) Adds a module to the modules that should be exported.intcheckIn()Start export and check in of the selected modules.voidClears the selected modules.booleanGets 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.booleanReturns true if at least one valid configuration is present.booleanReturns true if the 'fetch and reset' flag is set.booleanisModuleInstalled(String moduleName) Tests if a module is installed.voidsetCheckout(boolean checkout) Sets the checkout flag.voidsetCommit(boolean autoCommit) Setter for the commit mode.voidsetCommitMessage(String message) Setter for the commit message.voidsetCopyAndUnzip(boolean copyAndUnzip) Setter for the copy and unzip mode.booleansetCurrentConfiguration(CmsGitConfiguration configuration) Sets the current configuration if it is a valid configuration.voidsetExcludeLibs(boolean excludeLibs) Setter for the exclude libs flag.voidsetFetchAndResetBeforeImport(boolean fetchAndReset) Sets the 'fetch and reset' flag.voidsetGitUserEmail(String useremail) Setter for the git user email.voidsetGitUserName(String username) Setter for the git user name.voidsetIgnoreUnclean(boolean ignore) Setter for the ignore-unclean flag.voidsetPullAfter(boolean autoPull) Setter for the pull-after flag.voidsetPullBefore(boolean autoPull) Setter for the pull-before flag.voidsetPush(boolean autoPush) Setter for the auto-push flag.voidsetResetHead(boolean reset) Setter for the reset-head flag.voidsetResetRemoteHead(boolean reset) Setter for the reset-remote-head flag.static voidzipRfsFolder(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.
-