Package org.opencms.ui.apps.git
Class CmsGitCheckin
- java.lang.Object
-
- org.opencms.ui.apps.git.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 Summary
Constructors Constructor Description CmsGitCheckin(CmsObject cms)
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addModuleToExport(java.lang.String moduleName)
Adds a module to the modules that should be exported.int
checkIn()
Start export and check in of the selected modules.void
clearModules()
Clears the selected modules.boolean
getCheckout()
Gets the checkout flag.CmsObject
getCmsObject()
Gets the CMS context.java.lang.String
getCommitMessage()
Returns the commitMessage.java.util.Collection<CmsGitConfiguration>
getConfigurations()
Returns the available configurations.CmsGitConfiguration
getCurrentConfiguration()
Returns the currently used configuration.java.lang.String
getGitUserEmail()
Returns the gitUserEmail.java.lang.String
getGitUserName()
Returns the gitUserName.java.util.Collection<java.lang.String>
getInstalledModules()
Returns the collection of all installed modules.java.lang.String
getLogFilePath()
Returns the path to the log file.java.lang.String
getLogText()
Gets the log text.boolean
hasValidConfiguration()
Returns true if at least one valid configuration is present.boolean
isFetchAndResetBeforeImport()
Returns true if the 'fetch and reset' flag is set.boolean
isModuleInstalled(java.lang.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(java.lang.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(java.lang.String useremail)
Setter for the git user email.void
setGitUserName(java.lang.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(java.io.File root, java.io.OutputStream zipOutput)
Creates ZIP file data from the files / subfolders of the given root folder, and sends it to the given stream.
-
-
-
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 zipzipOutput
- 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
-
getCmsObject
public CmsObject getCmsObject()
Gets the CMS context.- Returns:
- the CMS context
-
getCommitMessage
public java.lang.String getCommitMessage()
Returns the commitMessage.- Returns:
- the commitMessage
-
getConfigurations
public java.util.Collection<CmsGitConfiguration> getConfigurations()
Returns the available configurations.- Returns:
- the available configurations.
-
getCurrentConfiguration
public CmsGitConfiguration getCurrentConfiguration()
Returns the currently used configuration.- Returns:
- the currently used configuration.
-
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.
-
-