onRecon.groovy revision 894623f06f0b765163c8593164cf1cdd2f725819
1008N/A/**
1008N/A * The contents of this file are subject to the terms of the Common Development and
1008N/A * Distribution License (the License). You may not use this file except in compliance with the
1008N/A * License.
1008N/A *
1008N/A * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
1008N/A * specific language governing permission and limitations under the License.
1008N/A *
1008N/A * When distributing Covered Software, include this CDDL Header Notice in each file and include
1008N/A * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
1008N/A * Header, with the fields enclosed by brackets [] replaced by your own identifying
1008N/A * information: "Portions copyright [year] [name of copyright owner]".
1008N/A *
1008N/A * Copyright 2015 ForgeRock AS.
1008N/A */
1008N/A
1008N/A/**
1008N/A * Performs necessary setup on a reconciliation event.
1008N/A *
1008N/A * Pre-loads all roles.
1008N/A * Pre-loads all assignments associated with the current mapping.
1008N/A *
1008N/A * The following variables are supplied:
1008N/A * context: the current request context
1008N/A * mappingConfig: the mapping configuration
1008N/A */
1008N/A
1008N/Aimport org.forgerock.openidm.sync.ReconContext;
1008N/Aimport org.forgerock.services.context.Context;
1008N/A
1008N/Adef reconContext = context.asContext(ReconContext.class)
1008N/Adef source = mappingConfig.source.getObject() as String
1008N/A
1008N/Aif (source.equals("managed/user") && reconContext != null) {
1008N/A def assignments = openidm.query("managed/assignment", [ "_queryFilter" : '/mapping eq ' + mappingConfig.name ]).result
1008N/A def roles = openidm.query("managed/role", [ "_queryFilter" : 'true' ], [ "*", "assignments" ]).result
1008N/A
1008N/A reconContext.put("assignments", assignments)
1008N/A reconContext.put("roles", roles)
1008N/A}