Class AbstractUpgradeHelper

    • Field Detail

      • attributes

        protected final Set<String> attributes
    • Constructor Detail

      • AbstractUpgradeHelper

        public AbstractUpgradeHelper()
    • Method Detail

      • updateOptional

        protected AttributeSchemaImpl updateOptional​(AttributeSchemaImpl attribute,
                                                     boolean isOptional)
                                              throws UpgradeException
        Update the optional value of an attribute schema
        Parameters:
        attribute - the attribute schema
        isOptional - true if this attribute is optional
        Returns:
        the attribute schema modified
        Throws:
        UpgradeException - If there was an error while performing the attribute upgrade.
      • updateDefaultValues

        protected AttributeSchemaImpl updateDefaultValues​(AttributeSchemaImpl attribute,
                                                          Set<String> defaultValues)
                                                   throws UpgradeException
        Update the default values of an attribute schema
        Parameters:
        attribute - the attribute schema
        defaultValues - the new default values
        Returns:
        the attribute schema modified
        Throws:
        UpgradeException - If there was an error while performing the attribute upgrade.
      • updateExampleValues

        protected AttributeSchemaImpl updateExampleValues​(AttributeSchemaImpl attribute,
                                                          Set<String> exampleValues)
                                                   throws UpgradeException
        Update the example values of an attribute schema
        Parameters:
        attribute - the attribute schema
        exampleValues - the new examples values
        Returns:
        the attribute schema modified
        Throws:
        UpgradeException - If there was an error while performing the attribute upgrade.
      • encryptValues

        protected Set<String> encryptValues​(Set<String> values)
        Encrypts all values in the provided set.

        To be used when copying default values which need to be stored encrypted.

        Parameters:
        values - The values to encrypt.
        Returns:
        A Set containing the encrypted values.
      • updateNode

        protected static Node updateNode​(Document newValueNode,
                                         String element,
                                         Node attributeSchemaNode)
      • addNewAttribute

        public AttributeSchemaImpl addNewAttribute​(Set<AttributeSchemaImpl> existingAttrs,
                                                   AttributeSchemaImpl newAttr)
                                            throws UpgradeException
        Description copied from interface: UpgradeHelper
        Given the existing attributes in the schema and the new attribute the upgrade helper can decide how to change the new attr based on the state of the existing attributes. For example this could be useful, when you add a new attribute, and it's default value depends on other existing attribute.
        Specified by:
        addNewAttribute in interface UpgradeHelper
        Parameters:
        existingAttrs - The old attributes
        newAttr - The new attribute schema
        Returns:
        The possibly updated attribute schema, this will be used in the upgrade
        Throws:
        UpgradeException - If something bad happens, this will be used to log not stop the upgrade
      • upgradeAttribute

        public abstract AttributeSchemaImpl upgradeAttribute​(AttributeSchemaImpl oldAttr,
                                                             AttributeSchemaImpl newAttr)
                                                      throws UpgradeException
        Implement this method to perform modifications to an existing attribute based on custom logic. In order to create a hook for a certain attribute, during upgradehelper initialization the attribute name should be captured in attributes.
        Specified by:
        upgradeAttribute in interface UpgradeHelper
        Parameters:
        oldAttr - The attribute schema definition currently specified.
        newAttr - The attribute schema definition we are planning to upgrade to.
        Returns:
        If there is nothing to upgrade (i.e. there is no real difference between old and new attribute), implementations MUST return null, otherwise either the amended attribute or the newAttr can be returned directly.
        Throws:
        UpgradeException - If there was an error while performing the attribute upgrade.
      • upgradeAttribute

        public AttributeSchemaImpl upgradeAttribute​(AttributeSchemaImpl newAttr)
                                             throws UpgradeException
        Implement this method to perform modifications to a newly added attribute. In order to create a hook for a certain attribute, during upgradehelper initialization the attribute name should be captured in attributes.
        Specified by:
        upgradeAttribute in interface UpgradeHelper
        Parameters:
        newAttr - The attribute schema definition we are planning to upgrade to.
        Returns:
        If there is nothing to upgrade, implementations MUST return null, otherwise the amended attribute can be returned directly.
        Throws:
        UpgradeException - If there was an error while performing the attribute upgrade.
      • getAttributes

        public final Set<String> getAttributes()
        Description copied from interface: UpgradeHelper
        Return the Set of attributes that are to be upgrade by this service helper
        Specified by:
        getAttributes in interface UpgradeHelper
        Returns:
        The set of upgraded attributes names