Class AbstractPatchesSystemSetup
- java.lang.Object
-
- de.hybris.platform.patches.AbstractPatchesSystemSetup
-
- Direct Known Subclasses:
PatchesDemoSystemSetup
public abstract class AbstractPatchesSystemSetup extends java.lang.Object
Abstract system setup class that offers methods for creating system setup parameters and checking configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
BOOLEAN_FALSE
protected static java.lang.String
BOOLEAN_TRUE
-
Constructor Summary
Constructors Constructor Description AbstractPatchesSystemSetup()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SystemSetupParameter
createBooleanSystemSetupParameter(java.lang.String key, java.lang.String label, boolean defaultValue)
Helper method for creating a Boolean setup parameter.protected void
createEssentialData(SystemSetupContext setupContext)
Method to create initial objects which will be called by system creator during initialization and system update.protected SystemSetupParameter
createFalseBooleanValueSystemSetupParameter(java.lang.String key, java.lang.String label)
Helper method for creating a system setup parameter withfalse
boolean value.protected void
createProjectData(SystemSetupContext setupContext)
Method to create data that is used in your project.protected SystemSetupParameter
createSystemSetupParameterBasedOnExecutionInfo(Patch patch, boolean rerunableEnabled)
Helper method for creating a system setup parameter for Update process type based on rerunable functionality.protected SystemSetupParameter
createSystemSetupParameterBasedOnNotSelectedProperty(Patch patch)
Helper method for creating a Boolean system setup parameter based onprotected void
executePatchBasedOnConfiguration(SystemSetup.Type type, Patch patch, boolean isInit)
Method executes Patches based on configuration from Properties.protected void
executePatchBasedOnDataType(SystemSetup.Type type, Patch patch)
Method executes Patches based on data type (ESSENTIAL/PROJECT).protected void
executePatchBasedOnNotSelectedProperty(SystemSetup.Type type, Patch patch)
Helper method for executing Patch based onprotected void
executePatches(SystemSetupContext setupContext, SystemSetup.Type type)
Based on executionType kept in JaloSession different execution Patch method is called.protected void
executePatchesBasedOnConfiguration(SystemSetup.Type type, boolean isInit)
Method iterates through list of Patches and for each executes checking Patch configuration based on properties.protected void
executePatchesBasedOnSetupContext(SystemSetupContext setupContext, SystemSetup.Type type)
Method iterates through list of Patches and executes these which were setup inSystemSetupContext
.protected void
executeVersionOnPatch(Patch patch)
This method executes given Patch with given version.protected java.lang.Boolean
getBooleanValueForGivenKey(java.lang.String propertyKey)
Checks configuration specified in properties file for given propertyKey.java.util.List<SystemSetupParameter>
getInitializationOptions()
Iterates through list of patches which is configured in spring.protected java.lang.Boolean
getSystemSetupParameter(SystemSetupContext context, java.lang.String key)
Checks setting of a Boolean setup parameter taken from context.protected boolean
isPatchHidden(java.lang.String patchId)
Checks configuration for hidden Patch.protected boolean
isPatchNotSelected(java.lang.String patchId)
Checks configuration for not selected Patch.protected boolean
isPatchRerunable(Patch patch)
Checks if specified patch is re runnable.protected boolean
isPatchRerunableFunctionalityEnabled()
Checks configuration for rerunable Patches.protected boolean
isPatchSelected(java.lang.String patchId)
Checks configuration for not selected Patch.void
setPatches(java.util.List<Patch> patches)
void
setPatchExecutionService(PatchExecutionService patchExecutionService)
-
-
-
Field Detail
-
BOOLEAN_TRUE
protected static final java.lang.String BOOLEAN_TRUE
- See Also:
- Constant Field Values
-
BOOLEAN_FALSE
protected static final java.lang.String BOOLEAN_FALSE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInitializationOptions
public java.util.List<SystemSetupParameter> getInitializationOptions()
Iterates through list of patches which is configured in spring. Checks configuration for each Patch and based on it creates system setup parameter with default value.- Returns:
List<SystemSetupParameter>
which should be visible in hac console
-
createEssentialData
protected void createEssentialData(SystemSetupContext setupContext)
Method to create initial objects which will be called by system creator during initialization and system update. It sets jsp context as a ThreadLocal variable (it is needed for logging data in hac console) and removes after all Patches are executed.- Parameters:
setupContext
- the context provides the selected parameters and values
-
createProjectData
protected void createProjectData(SystemSetupContext setupContext)
Method to create data that is used in your project. This method will be called during the system initialization and system update. It sets jsp context as a ThreadLocal variable (it is needed for logging data in hac console) and removes after all Patches are executed.- Parameters:
setupContext
- the context provides the selected parameters and values
-
createFalseBooleanValueSystemSetupParameter
protected SystemSetupParameter createFalseBooleanValueSystemSetupParameter(java.lang.String key, java.lang.String label)
Helper method for creating a system setup parameter withfalse
boolean value.- Parameters:
key
- key for system setup parameterlabel
- label for system setup parameter- Returns:
SystemSetupParameter
with one value
-
createSystemSetupParameterBasedOnNotSelectedProperty
protected SystemSetupParameter createSystemSetupParameterBasedOnNotSelectedProperty(Patch patch)
Helper method for creating a Boolean system setup parameter based onpatches.<patchId>.notSelected
property. If this property is set to true - parameter has default value
false
with possibility to change it totrue
, if property is not specified or hasfalse
value assigned - parameter has default valuetrue
with possibility to change it tofalse
.- Parameters:
patch
-Patch
- Returns:
SystemSetupParameter
-
createBooleanSystemSetupParameter
protected SystemSetupParameter createBooleanSystemSetupParameter(java.lang.String key, java.lang.String label, boolean defaultValue)
Helper method for creating a Boolean setup parameter.- Parameters:
key
- key for system setup parameterlabel
- label for system setup parameterdefaultValue
- default true/false value for system setup parameter- Returns:
SystemSetupParameter
with one value
-
executePatchBasedOnNotSelectedProperty
protected void executePatchBasedOnNotSelectedProperty(SystemSetup.Type type, Patch patch)
Helper method for executing Patch based onpatches.<patchId>.notSelected
property. If this property is set to true - patch won't be executed, if property is not specified or has
false
value assigned - patch will be executed.- Parameters:
type
-SystemSetup.Type
patch
-Patch
-
getSystemSetupParameter
protected java.lang.Boolean getSystemSetupParameter(SystemSetupContext context, java.lang.String key)
Checks setting of a Boolean setup parameter taken from context. If there is no information about Patch in context method returnsnull
.- Parameters:
context
-SystemSetupContext
key
- key used as a parameter suffix- Returns:
true
if parameter is set to Yes,false
if parameter is set to No,null
if there is no information about Patch
-
createSystemSetupParameterBasedOnExecutionInfo
protected SystemSetupParameter createSystemSetupParameterBasedOnExecutionInfo(Patch patch, boolean rerunableEnabled)
Helper method for creating a system setup parameter for Update process type based on rerunable functionality.- Parameters:
patch
- for which setup should be createdrerunableEnabled
- if rerunable functionality is enabled- Returns:
SystemSetupParameter
with proper value
-
isPatchHidden
protected boolean isPatchHidden(java.lang.String patchId)
Checks configuration for hidden Patch. Ifpatches.<patchId>.hide
property is not specified, value of property
patches.hideAll
is checked. If it's also not specified, default value is returned:
false
.- Parameters:
patchId
- id of the patch- Returns:
true
if patch should be hidden,false
otherwise
-
isPatchNotSelected
protected boolean isPatchNotSelected(java.lang.String patchId)
Checks configuration for not selected Patch. Ifpatches.<patchId>.notSelected
property is set to true returned is
true
. If it's not specified, default value is taken:false
.- Parameters:
patchId
- id of the patch- Returns:
true
if patch should not be selected,false
otherwise
-
isPatchSelected
protected boolean isPatchSelected(java.lang.String patchId)
Checks configuration for not selected Patch. Ifpatches.<patchId>.notSelected
property is set to false returned is
true
. If it's not specified, default value is taken:false
.- Parameters:
patchId
- id of the patch- Returns:
true
if patch should not be selected,false
otherwise
-
isPatchRerunableFunctionalityEnabled
protected boolean isPatchRerunableFunctionalityEnabled()
Checks configuration for rerunable Patches. Ifpatches.allow.rerun.patches
property is set to true returned is
true
. If it's not specified, default value is taken:false
.- Returns:
true
if patches can be executed again,false
otherwise
-
isPatchRerunable
protected boolean isPatchRerunable(Patch patch)
Checks if specified patch is re runnable. Checked ispatches.allow.rerun.patches
property or if Patch implements
Rerunnable
interface .- Parameters:
patch
-Patch
- Returns:
true
if patch can be executed again,false
otherwise
-
getBooleanValueForGivenKey
protected java.lang.Boolean getBooleanValueForGivenKey(java.lang.String propertyKey)
Checks configuration specified in properties file for given propertyKey.- Parameters:
propertyKey
- property key used in configuration file- Returns:
true
if value for given propertyKey equalstrue
,false
if value isfalse
, otherwisenull
-
executePatches
protected void executePatches(SystemSetupContext setupContext, SystemSetup.Type type)
Based on executionType kept in JaloSession different execution Patch method is called. For HAC execution depends on SystemSetupContext, for ANT: on Configuration from Properties. Handles major exceptions and logs them in patch execution and console. Handled exception is thrown further to stop init/update process. Stack trace is logged by platform mechanism.- Parameters:
setupContext
-SystemSetupContext
type
-SystemSetup.Type
-
executePatchesBasedOnSetupContext
protected void executePatchesBasedOnSetupContext(SystemSetupContext setupContext, SystemSetup.Type type)
Method iterates through list of Patches and executes these which were setup inSystemSetupContext
. If no information about Patch is in context and Patch is hidden checked is configuration based on properties.- Parameters:
setupContext
-SystemSetupContext
type
-SystemSetup.Type
-
executePatchesBasedOnConfiguration
protected void executePatchesBasedOnConfiguration(SystemSetup.Type type, boolean isInit)
Method iterates through list of Patches and for each executes checking Patch configuration based on properties.- Parameters:
type
-SystemSetup.Type
isInit
-true
if current processType is Init, otherwise (update)false
-
executePatchBasedOnConfiguration
protected void executePatchBasedOnConfiguration(SystemSetup.Type type, Patch patch, boolean isInit)
Method executes Patches based on configuration from Properties.- Parameters:
type
-SystemSetup.Type
patch
-Patch
isInit
-true
if current processType is Init, otherwise (update)false
-
executePatchBasedOnDataType
protected void executePatchBasedOnDataType(SystemSetup.Type type, Patch patch)
Method executes Patches based on data type (ESSENTIAL/PROJECT).- Parameters:
type
-SystemSetup.Type
patch
-Patch
-
executeVersionOnPatch
protected void executeVersionOnPatch(Patch patch)
This method executes given Patch with given version. It also means that if given Patch introduced new version comparing to previous one, all previous patches will be executed with this new version (or versions).- Parameters:
patch
-Patch
-
setPatches
public void setPatches(java.util.List<Patch> patches)
-
setPatchExecutionService
public void setPatchExecutionService(PatchExecutionService patchExecutionService)
-
-