/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2011-2016 ForgeRock AS.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
*/
/**
* Implement this class to manually upgrade schema attributes.
*/
/**
* Update the optional value of an attribute schema
* @param attribute the attribute schema
* @param isOptional true if this attribute is optional
* @return the attribute schema modified
* @throws UpgradeException If there was an error while performing the attribute upgrade.
*/
throws UpgradeException {
if (isOptional) {
}
Node attributeNode = updateNode(doc, SMSUtils.ATTRIBUTE_OPTIONAL, attribute.getAttributeSchemaNode());
return attribute;
}
/**
* Update the choice values of an attribute schema
* @param attribute the attribute schema
* @param choiceValues the new choice values
* @return the attribute schema modified
* @throws UpgradeException If there was an error while performing the attribute upgrade.
*/
protected AttributeSchemaImpl updateChoiceValues(AttributeSchemaImpl attribute, Collection<String> choiceValues)
throws UpgradeException {
try {
final Element choiceValuesElement = choiceValuesDoc.createElement(SMSUtils.ATTRIBUTE_CHOICE_VALUES_ELEMENT);
}
} catch (ParserConfigurationException e) {
throw new UpgradeException(e);
}
return attribute;
}
/**
* Update the default values of an attribute schema
* @param attribute the attribute schema
* @param defaultValues the new default values
* @return the attribute schema modified
* @throws UpgradeException If there was an error while performing the attribute upgrade.
*/
protected AttributeSchemaImpl updateDefaultValues(AttributeSchemaImpl attribute, Set<String> defaultValues)
throws UpgradeException {
}
/**
* Update the example values of an attribute schema
* @param attribute the attribute schema
* @param exampleValues the new examples values
* @return the attribute schema modified
* @throws UpgradeException If there was an error while performing the attribute upgrade.
*/
protected AttributeSchemaImpl updateExampleValues(AttributeSchemaImpl attribute, Set<String> exampleValues)
throws UpgradeException {
}
private AttributeSchemaImpl updateListValues(AttributeSchemaImpl attribute, Set<String> values, String tabBegin,
}
}
return attribute;
}
/**
* Encrypts all values in the provided set.
*
* <p>To be used when copying default values which need to be stored encrypted.</p>
*
* @param values The values to encrypt.
* @return A Set containing the encrypted values.
*/
return values;
}
}
return encryptedValues;
}
}
}
if (newValueNode != null) {
Node newNode = attributeSchemaNode.getOwnerDocument().importNode(newValueNode.getFirstChild(), true);
SMSUtils.ATTRIBUTE_SCHEMA_CHILD newSchemaName = SMSUtils.ATTRIBUTE_SCHEMA_CHILD.valueOfName(element);
boolean isNewNodeInserted = false;
// Insert the new node in the right position: we are looking for the first element that has a higher
// ordinal than our's, and then we insert the node just in front of that.
isNewNodeInserted = true;
break;
}
}
}
if (!isNewNodeInserted) {
//By default, we insert the node at the end of the list. Happens when there are no other children
}
}
return attributeSchemaNode;
}
public AttributeSchemaImpl addNewAttribute(Set<AttributeSchemaImpl> existingAttrs, AttributeSchemaImpl newAttr)
throws UpgradeException {
return newAttr;
}
/**
* 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 {@link AbstractUpgradeHelper#attributes}.
*
* @param oldAttr The attribute schema definition currently specified.
* @param newAttr The attribute schema definition we are planning to upgrade to.
* @return If there is nothing to upgrade (i.e. there is no real difference between old and new attribute),
* implementations MUST return <code>null</code>, otherwise either the amended attribute or the newAttr can be
* returned directly.
* @throws UpgradeException If there was an error while performing the attribute upgrade.
*/
public abstract AttributeSchemaImpl upgradeAttribute(AttributeSchemaImpl oldAttr, 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
* {@link AbstractUpgradeHelper#attributes}.
*
* @param newAttr The attribute schema definition we are planning to upgrade to.
* @return If there is nothing to upgrade, implementations MUST return <code>null</code>,
* otherwise the amended attribute can be returned directly.
* @throws UpgradeException If there was an error while performing the attribute upgrade.
*/
return null;
}
return attributes;
}
}