355e5661379644c081271b23fa8b966a098a42d2Jon Branch/*
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
355e5661379644c081271b23fa8b966a098a42d2Jon Branch *
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * Copyright (c) 2015 ForgeRock AS. All Rights Reserved
355e5661379644c081271b23fa8b966a098a42d2Jon Branch *
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * The contents of this file are subject to the terms
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * of the Common Development and Distribution License
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * (the License). You may not use this file except in
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * compliance with the License.
355e5661379644c081271b23fa8b966a098a42d2Jon Branch *
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * You can obtain a copy of the License at
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * http://forgerock.org/license/CDDLv1.0.html
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * See the License for the specific language governing
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * permission and limitations under the License.
355e5661379644c081271b23fa8b966a098a42d2Jon Branch *
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * When distributing Covered Code, include this CDDL
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * Header Notice in each file and include the License file
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * at http://forgerock.org/license/CDDLv1.0.html
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * If applicable, add the following below the CDDL Header,
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * with the fields enclosed by brackets [] replaced by
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * your own identifying information:
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * "Portions Copyrighted [year] [name of copyright owner]"
355e5661379644c081271b23fa8b966a098a42d2Jon Branch *
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * Version {{version}}
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * Author {{author}}
355e5661379644c081271b23fa8b966a098a42d2Jon Branch */
355e5661379644c081271b23fa8b966a098a42d2Jon Branchpackage org.forgerock.openicf.connectors.{{lower packageName}}
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branchimport org.forgerock.openicf.connectors.{{lower packageName}}.{{packageName}}Configuration
355e5661379644c081271b23fa8b966a098a42d2Jon Branchimport org.forgerock.openicf.misc.scriptedcommon.OperationType
355e5661379644c081271b23fa8b966a098a42d2Jon Branchimport org.identityconnectors.common.logging.Log
355e5661379644c081271b23fa8b966a098a42d2Jon Branchimport org.identityconnectors.framework.common.objects.Attribute
355e5661379644c081271b23fa8b966a098a42d2Jon Branchimport org.identityconnectors.framework.common.objects.AttributesAccessor
355e5661379644c081271b23fa8b966a098a42d2Jon Branchimport org.identityconnectors.framework.common.objects.ObjectClass
355e5661379644c081271b23fa8b966a098a42d2Jon Branchimport org.identityconnectors.framework.common.objects.OperationOptions
355e5661379644c081271b23fa8b966a098a42d2Jon Branchimport org.identityconnectors.framework.common.objects.Uid
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branch/**
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * Built-in accessible objects
355e5661379644c081271b23fa8b966a098a42d2Jon Branch **/
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branch// OperationType is CREATE for this script
355e5661379644c081271b23fa8b966a098a42d2Jon Branchdef operation = operation as OperationType
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branch// The configuration class created specifically for this connector
355e5661379644c081271b23fa8b966a098a42d2Jon Branchdef configuration = configuration as {{packageName}}Configuration
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branch// Default logging facility
355e5661379644c081271b23fa8b966a098a42d2Jon Branchdef log = log as Log
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branch// Set of attributes describing the object to be created
355e5661379644c081271b23fa8b966a098a42d2Jon Branchdef createAttributes = new AttributesAccessor(attributes as Set<Attribute>)
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branch// The Uid of the object to be created, usually null indicating the Uid should be generated
a5c4e019584526e990bdb898f84300d790ebc708Jon Branchdef uid = id as Uid
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branch// The objectClass of the object to be created, e.g. ACCOUNT or GROUP
355e5661379644c081271b23fa8b966a098a42d2Jon Branchdef objectClass = objectClass as ObjectClass
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branch/**
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * Script action - Customizable
355e5661379644c081271b23fa8b966a098a42d2Jon Branch *
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * Create a new object in the external source. Connectors that do not support this should
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * throw an UnsupportedOperationException.
355e5661379644c081271b23fa8b966a098a42d2Jon Branch *
355e5661379644c081271b23fa8b966a098a42d2Jon Branch * This script should return a Uid object that represents the ID of the newly created object
355e5661379644c081271b23fa8b966a098a42d2Jon Branch **/
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branch/* Log something to demonstrate this script executed */
355e5661379644c081271b23fa8b966a098a42d2Jon Branchlog.info("Create script, operation = " + operation.toString());
355e5661379644c081271b23fa8b966a098a42d2Jon Branch
355e5661379644c081271b23fa8b966a098a42d2Jon Branchswitch (objectClass) {
355e5661379644c081271b23fa8b966a098a42d2Jon Branch {{#objectTypes}}case {{objectClass}}:
355e5661379644c081271b23fa8b966a098a42d2Jon Branch {{#hasProperties}}/* Known properties in the local representation:
355e5661379644c081271b23fa8b966a098a42d2Jon Branch {{#properties}} * {{name}}
355e5661379644c081271b23fa8b966a098a42d2Jon Branch {{/properties}} */{{/hasProperties}}
355e5661379644c081271b23fa8b966a098a42d2Jon Branch return new Uid("1");
355e5661379644c081271b23fa8b966a098a42d2Jon Branch {{/objectTypes}}
355e5661379644c081271b23fa8b966a098a42d2Jon Branch default:
355e5661379644c081271b23fa8b966a098a42d2Jon Branch throw new UnsupportedOperationException(operation.name() + " operation of type:" +
355e5661379644c081271b23fa8b966a098a42d2Jon Branch objectClass.objectClassValue + " is not supported.")
355e5661379644c081271b23fa8b966a098a42d2Jon Branch}