SyncScript.groovy revision 3d1633e2e59dde32f1ada8abb88b8867b0596b5b
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * The contents of this file are subject to the terms
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * of the Common Development and Distribution License
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * (the License). You may not use this file except in
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * compliance with the License.
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * You can obtain a copy of the License at
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * See the License for the specific language governing
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * permission and limitations under the License.
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * When distributing Covered Code, include this CDDL
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * Header Notice in each file and include the License file
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * If applicable, add the following below the CDDL Header,
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * with the fields enclosed by brackets [] replaced by
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * your own identifying information:
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * "Portions Copyrighted [year] [name of copyright owner]"
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.forgerock.openicf.connectors.scriptedrest.ScriptedRESTConfiguration
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.forgerock.openicf.misc.scriptedcommon.OperationType
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.identityconnectors.framework.common.objects.ObjectClass
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.identityconnectors.framework.common.objects.SyncToken
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef configuration = configuration as ScriptedRESTConfiguration
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef connection = customizedConnection as RESTClient
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayif (OperationType.GET_LATEST_SYNC_TOKEN.equals(operation)) {
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay} else if (OperationType.SYNC.equals(operation)) {
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay _queryFilter: "_id gt \"${token}\" and targetDN co \"ou=people,dc=example,dc=com\"",
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay resourceId = resourceId.substring(4, resourceId.indexOf(','))
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay } else if ("modify".equals(changeLogEntry.changeType)) {
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay } else if ("delete".equals(changeLogEntry.changeType)) {
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute 'telephoneNumber', value?.contactInformation?.telephoneNumber
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute 'emailAddress', value?.contactInformation?.emailAddress
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute 'lastModified', value?.meta?.lastModified
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay _queryFilter: "_id gt \"${token}\" and targetDN co \"ou=groups,dc=example,dc=com\"",
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay resourceId = resourceId.substring(3, resourceId.indexOf(','))
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay } else if ("modify".equals(changeLogEntry.changeType)) {
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay } else if ("delete".equals(changeLogEntry.changeType)) {
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute 'lastModified', value?.meta?.lastModified
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay} else { // action not implemented
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay log.error("Sync script: action '" + operation + "' is not implemented in this script");