Update script
An update script updates an object in the external resource. Connectors that do not support update operations should throw an UnsupportedOperationException.
A sample update script for an SQL database is provided in openidm/samples/scripted-sql-with-mysql/tools/UpdateScript.groovy.
- Input variables
-
The following variables are available to an update script:
- configuration
-
A handler to the connector’s configuration object.
- options
-
A handler to the Operation Options.
- operation
-
An OperationType that corresponds to the action (
UPDATE). - objectClass
-
The object class that is updated, such as
__ACCOUNT__or__GROUP__. - attributes
-
A collection of
ConnectorAttributesthat represent the entry attributes to update. - uid
-
The UID of the object to be updated. The UID corresponds to the OpenICF
UIDattribute. - id
-
The name of the object to be updated (optional). The id corresponds to the ICF
__NAME__attribute. It will not be injected and set unless the update is a rename. - log
-
A logger instance for the connector.
- Returns
-
The user unique ID (ICF
__UID__) of the updated object. Thetypeof the returned UID must be astringor aUid. If the UID is not modified by the update operation, return the value of the uid injected into the script.
def operation = operation as OperationType
def updateAttributes = attributes as Set<Attribute>
def configuration = configuration as ScriptedConfiguration
def id = id as String
def log = log as Log
def objectClass = objectClass as ObjectClass
def options = options as OperationOptions
def uid = uid as Uid
log.ok("Update...")
switch (operation) {
case OperationType.UPDATE:
switch (objectClass) {
case ObjectClass.ACCOUNT:
// ...
for (Attribute a : updateAttributes) {
if (a.is(Name.NAME)) {
// ...
return uid