ScriptOnResourceScript.groovy revision 3b9de50fdf0980762d6930a49e1a0f20b61a6f6b
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * The contents of this file are subject to the terms
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * of the Common Development and Distribution License
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * (the License). You may not use this file except in
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * compliance with the License.
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * You can obtain a copy of the License at
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * See the License for the specific language governing
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * permission and limitations under the License.
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * When distributing Covered Code, include this CDDL
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * Header Notice in each file and include the License file
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * If applicable, add the following below the CDDL Header,
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * with the fields enclosed by brackets [] replaced by
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * your own identifying information:
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay * "Portions Copyrighted [year] [name of copyright owner]"
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemayimport org.forgerock.openicf.connectors.scriptedcrest.ScriptedCRESTConfiguration
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemayimport org.forgerock.openicf.misc.scriptedcommon.OperationType
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemayimport org.identityconnectors.framework.common.objects.OperationOptions
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemaydef configuration = configuration as ScriptedCRESTConfiguration
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay ActionRequest request = Requests.newActionRequest("users", scriptText)
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay request.setContent(new JsonValue(scriptArguments))
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay def response = connection.action(new RootContext(), request)
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay ActionRequest request = Requests.newActionRequest("system/ldap/account", "script")
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay if ("resource".equalsIgnoreCase(scriptLanguage)) {
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay request.setAdditionalParameter("_scriptExecuteMode", "resource")
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay request.setAdditionalParameter("_scriptVariablePrefix", options.options.variablePrefix)
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay scriptArguments.each { String key, Object value ->
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay request.setAdditionalParameter(key, value as String)
3b9de50fdf0980762d6930a49e1a0f20b61a6f6bJason Lemay log.warn("Argument parameter ${key} is ignored because its type ${value?.class} is not supported.")