@@ -0,0 +1,3271 @@
+package com.hpe.application.automation.tools.common;%0A%0A%0Aimport hudson.model.Items;%0Aimport hudson.model.Run;%0A%0Aimport javax.annotation.Nonnull;%0Aimport java.util.logging.Logger;%0A%0A/**%0A * CompatibilityRebrander is an interface for all related to the company rebranding phase.%0A * %3Cp%3E%0A * This process is required because our serialized data includes the old package class name.%0A * A measure must be taken in order to maintain backward compatibility.%0A * %3Cp%3E%0A * Important note to mention is this class will only work after:%0A * %3Cul%3E%0A * %3Cli%3E Package path is renamed from the old brand to the new one%0A * %3Cli%3E Only the various Descriptors (e.g. BuildStepDescriptor) use this function%0A * %3C/ul%3E%0A */%0Apublic class CompatibilityRebrander %7B%0A    private final static String COM_HPE = %22com.hpe%22;%0A    private final static String COM_HP = %22com.hp%22;%0A    private final static String COM_MICROFOCUS = %22com.microfocus%22;%0A    private final static Logger LOG = Logger.getLogger(CompatibilityRebrander.class.getName());%0A%0A    /**%0A     * addAliases is the actual function who does the rebranding part for all the old package names%0A     * %3Cp%3E%0A     * Items.XSTREAM2.addCompatibilityAlias is for serializing project configurations.%0A     * Run.XSTREAM2.addCompatibilityAlias is for serializing builds and its associated Actions.%0A     *%0A     * @param newClass the Descriptor class we want to add alias for%0A     * @see hudson.model.Items#XSTREAM2%0A     * @see hudson.model.Run#XSTREAM2%0A     * @since 5.5%0A     */%0A    public static void addAliases(@Nonnull Class newClass) %7B%0A        String newClassName = newClass.toString().replaceFirst(%22class %22, %22%22);%0A        String oldHpeClassName = newClassName.replaceFirst(COM_MICROFOCUS, COM_HPE);%0A        String oldHpClassName = newClassName.replaceFirst(COM_MICROFOCUS, COM_HP);%0A%0A        LOG.info(%22Starting the rebranding aliasing%22);%0A        addAliasesForSingleClass(newClass, oldHpClassName, COM_HP);%0A        addAliasesForSingleClass(newClass, oldHpeClassName, COM_HPE);%0A    %7D%0A%0A    /**%0A     * addAliasesForSingleClass responsible for handling the rebranding for a single class%0A     */%0A    private static void addAliasesForSingleClass(@Nonnull Class newClass, String oldClassName, String beforeBrand) %7B%0A        handleReceivedWrongParameters(newClass, oldClassName, beforeBrand);%0A        invokeXstreamCompatibilityAlias(newClass, oldClassName);%0A    %7D%0A%0A    /**%0A     * invokeXstreamCompatibilityAlias invokes the XSTREAM2 functions required for the rebranding%0A     */%0A    private static void invokeXstreamCompatibilityAlias(@Nonnull Class newClass, String oldClassName) %7B%0A        LOG.info(String.format(%22Adding alias from %25s to %25s%22, oldClassName, newClass));%0A        Items.XSTREAM2.addCompatibilityAlias(oldClassName, newClass);%0A        Run.XSTREAM2.addCompatibilityAlias(oldClassName, newClass);%0A    %7D%0A%0A    /**%0A     * handleReceivedWrongParameters logs a warning when the passed newClass doesn't contain any of the package names%0A     * we trying to add alias to%0A     */%0A    private static void handleReceivedWrongParameters(@Nonnull Class newClass, String oldClassName, String beforeBrand) %7B%0A        if (!oldClassName.contains(beforeBrand))%0A            LOG.warning(String.format(%22The %25s class name doesn't contain: %25s class name%22, newClass.toString(), beforeBrand));%0A    %7D%0A%7D

Add rebranding function