Class AbstractPatchesSystemSetup

java.lang.Object
de.hybris.platform.patches.AbstractPatchesSystemSetup
Direct Known Subclasses:
PatchesDemoSystemSetup

public abstract class AbstractPatchesSystemSetup extends Object
Abstract system setup class that offers methods for creating system setup parameters and checking configuration.
  • Field Details

  • Constructor Details

    • AbstractPatchesSystemSetup

      public AbstractPatchesSystemSetup()
  • Method Details

    • getInitializationOptions

      public 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(String key, String label)
      Helper method for creating a system setup parameter with false boolean value.
      Parameters:
      key - key for system setup parameter
      label - 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 on
       patches.<patchId>.notSelected
       

      property. If this property is set to true - parameter has default value false with possibility to change it to true, if property is not specified or has false value assigned - parameter has default value true with possibility to change it to false.

      Parameters:
      patch - Patch
      Returns:
      SystemSetupParameter
    • createBooleanSystemSetupParameter

      protected SystemSetupParameter createBooleanSystemSetupParameter(String key, String label, boolean defaultValue)
      Helper method for creating a Boolean setup parameter.
      Parameters:
      key - key for system setup parameter
      label - label for system setup parameter
      defaultValue - 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 on
       patches.<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 Boolean getSystemSetupParameter(SystemSetupContext context, String key)
      Checks setting of a Boolean setup parameter taken from context. If there is no information about Patch in context method returns null.
      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 created
      rerunableEnabled - if rerunable functionality is enabled
      Returns:
      SystemSetupParameter with proper value
    • isPatchHidden

      protected boolean isPatchHidden(String patchId)
      Checks configuration for hidden Patch. If
       patches.<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(String patchId)
      Checks configuration for not selected Patch. If
       patches.<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(String patchId)
      Checks configuration for not selected Patch. If
       patches.<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. If
       patches.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 is
       patches.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 Boolean getBooleanValueForGivenKey(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 equals true, false if value is false, otherwise null
    • 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 in SystemSetupContext. 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(List<Patch> patches)
    • setPatchExecutionService

      public void setPatchExecutionService(PatchExecutionService patchExecutionService)