Package com.sun.identity.sm
Class AbstractUpgradeHelper
- java.lang.Object
-
- com.sun.identity.sm.AbstractUpgradeHelper
-
- All Implemented Interfaces:
UpgradeHelper
- Direct Known Subclasses:
AgentServiceHelper,AuditUpgradeHelper,AuthAuthenticatorOathHelper,AuthServiceHelper,DashboardServiceHelper,IdRepoServiceHelper,LoggingUpgradeHelper,MailServiceUpgradeHelper,OAuth2AuthModuleUpgradeHelper,OAuth2ProviderUpgradeHelper,OpenIdConnectAuthModuleServiceHelper,PolicyConfigUpgradeHelper,RestApiUpgradeHelper,SAML2ConfigHelper,ScriptedAuthHelper,SessionServiceHelper,UmaProviderUpgradeHelper
public abstract class AbstractUpgradeHelper extends Object implements UpgradeHelper
Implement this class to manually upgrade schema attributes.
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<String>attributes
-
Constructor Summary
Constructors Constructor Description AbstractUpgradeHelper()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AttributeSchemaImpladdNewAttribute(Set<AttributeSchemaImpl> existingAttrs, AttributeSchemaImpl newAttr)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.protected Set<String>encryptValues(Set<String> values)Encrypts all values in the provided set.Set<String>getAttributes()Return the Set of attributes that are to be upgrade by this service helperprotected AttributeSchemaImplupdateChoiceValues(AttributeSchemaImpl attribute, Collection<String> choiceValues)Update the choice values of an attribute schemaprotected AttributeSchemaImplupdateDefaultValues(AttributeSchemaImpl attribute, Set<String> defaultValues)Update the default values of an attribute schemaprotected AttributeSchemaImplupdateExampleValues(AttributeSchemaImpl attribute, Set<String> exampleValues)Update the example values of an attribute schemaprotected static NodeupdateNode(Document newValueNode, String element, Node attributeSchemaNode)protected AttributeSchemaImplupdateOptional(AttributeSchemaImpl attribute, boolean isOptional)Update the optional value of an attribute schemaAttributeSchemaImplupgradeAttribute(AttributeSchemaImpl newAttr)Implement this method to perform modifications to a newly added attribute.abstract AttributeSchemaImplupgradeAttribute(AttributeSchemaImpl oldAttr, AttributeSchemaImpl newAttr)Implement this method to perform modifications to an existing attribute based on custom logic.
-
-
-
Method Detail
-
updateOptional
protected AttributeSchemaImpl updateOptional(AttributeSchemaImpl attribute, boolean isOptional) throws UpgradeException
Update the optional value of an attribute schema- Parameters:
attribute- the attribute schemaisOptional- true if this attribute is optional- Returns:
- the attribute schema modified
- Throws:
UpgradeException- If there was an error while performing the attribute upgrade.
-
updateChoiceValues
protected AttributeSchemaImpl updateChoiceValues(AttributeSchemaImpl attribute, Collection<String> choiceValues) throws UpgradeException
Update the choice values of an attribute schema- Parameters:
attribute- the attribute schemachoiceValues- the new choice values- 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 schemadefaultValues- 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 schemaexampleValues- 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:UpgradeHelperGiven 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:
addNewAttributein interfaceUpgradeHelper- Parameters:
existingAttrs- The old attributesnewAttr- 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 inattributes.- Specified by:
upgradeAttributein interfaceUpgradeHelper- 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 inattributes.- Specified by:
upgradeAttributein interfaceUpgradeHelper- 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:UpgradeHelperReturn the Set of attributes that are to be upgrade by this service helper- Specified by:
getAttributesin interfaceUpgradeHelper- Returns:
- The set of upgraded attributes names
-
-