[prev in list] [next in list] [prev in thread] [next in thread]
List: forgerock-openicf-commit
Subject: [Commitopenicf] [6509] trunk/connectors/java/scriptedcommon: CR-3333 / OPENICF-185 ?\226? \128?\147
From: anonymous () forgerock ! org
Date: 2014-04-15 9:47:57
Message-ID: 20140415094757.EF6D240994 () sources ! internal ! forgerock ! com
[Download RAW message or body]
[Attachment #2 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[6509] trunk/connectors/java/scriptedcommon: CR-3333 / OPENICF-185 \
?\226?\128?\147 ScriptedCommon upgrade to OpenICF 1.4</title> </head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: \
bold} #msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: \
6px; } #logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em \
0; } #logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg \
h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; } \
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; \
} #logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: \
-1.5em; padding-left: 1.5em; } #logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em \
1em 0 1em; background: white;} #logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid \
#fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { \
text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted \
#fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: \
0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid \
#fa0; } #logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a \
href="http://sources.forgerock.org/changelog/openicf/?cs=6509">6509</a></dd> \
<dt>Author</dt> <dd>Laszlo</dd> <dt>Date</dt> <dd>2014-04-15 10:47:57 +0100 (Tue, 15 \
Apr 2014)</dd> </dl>
<h3>Log Message</h3>
<pre>CR-3333 / OPENICF-185 ?\226?\128?\147 ScriptedCommon upgrade to OpenICF \
1.4</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkconnectorsjavascriptedcommonpomxml">trunk/connectors/java/scriptedcommon/pom.xml</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaindocbkxchapscriptedcommonxml">tr \
unk/connectors/java/scriptedcommon/src/main/docbkx/chap-scriptedcommon.xml</a></li> \
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaindocbkxindexxml">trunk/connectors/java/scriptedcommon/src/main/docbkx/index.xml</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaindocbkxlegalxml">trunk/connectors/java/scriptedcommon/src/main/docbkx/legal.xml</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfmiscsc \
riptedcommonICFObjectBuildergroovy">trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/scriptedcommon/ICFObjectBuilder.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfmiscsc \
riptedcommonScriptedConnectorBasegroovy">trunk/connectors/java/scriptedcommon/src/main \
/groovy/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnectorBase.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscri \
ptedcommonFilterVisitorjava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/FilterVisitor.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscri \
ptedcommonMapFilterVisitorjava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/MapFilterVisitor.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscri \
ptedcommonScriptedConfigurationjava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConfiguration.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscri \
ptedcommonScriptedConnectionjava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnection.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscri \
ptedcommonScriptedFilterTranslatorjava">trunk/connectors/java/scriptedcommon/src/main/ \
java/org/forgerock/openicf/misc/scriptedcommon/ScriptedFilterTranslator.java</a></li> \
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainresourcesorgforgerockopenicfconn \
ectorsgroovyMessagesproperties">trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/groovy/Messages.properties</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcsitesitexml">trunk/connectors/java/scriptedcommon/src/site/site.xml</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfmiscscri \
ptedcommonScriptedConnectorTestjava">trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnectorTest.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovyAuthenticateScri \
ptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/AuthenticateScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovyCreateScriptgroo \
vy">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/CreateScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovyDeleteScriptgroo \
vy">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/DeleteScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovyResolveUsernameS \
criptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/ResolveUsernameScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovySchemaScriptgroo \
vy">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/SchemaScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovyScriptOnResource \
Scriptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/ScriptOnResourceScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovySearchScriptgroo \
vy">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/SearchScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovySyncScriptgroovy \
">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/SyncScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovyTestScriptgroovy \
">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/TestScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovyUpdateScriptgroo \
vy">trunk/connectors/java/scriptedcommon/src/test/resources/groovy/UpdateScript.groovy</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/connectors/java/scriptedcommon/src/assemble/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcassemblesamplesxml">trunk/connectors/java/scriptedcommon/src/assemble/samples.xml</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedcrest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnec \
torsscriptedcrestRemoteConnectiongroovy">trunk/connectors/java/scriptedcommon/src/main \
/groovy/org/forgerock/openicf/connectors/scriptedcrest/RemoteConnection.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnec \
torsscriptedcrestScriptedCRESTConfigurationgroovy">trunk/connectors/java/scriptedcommo \
n/src/main/groovy/org/forgerock/openicf/connectors/scriptedcrest/ScriptedCRESTConfiguration.groovy</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedrest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnec \
torsscriptedrestScriptedRESTConfigurationgroovy">trunk/connectors/java/scriptedcommon/ \
src/main/groovy/org/forgerock/openicf/connectors/scriptedrest/ScriptedRESTConfiguration.groovy</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedsql/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnec \
torsscriptedsqlScriptedSQLConfigurationgroovy">trunk/connectors/java/scriptedcommon/sr \
c/main/groovy/org/forgerock/openicf/connectors/scriptedsql/ScriptedSQLConfiguration.groovy</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/soap/</li>
<li>trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/crest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfmisccr \
estCRESTFilterVisitorgroovy">trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/crest/CRESTFilterVisitor.groovy</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/</li>
<li>trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/groovy/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnecto \
rsgroovyScriptedConnectorjava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/groovy/ScriptedConnector.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnecto \
rsgroovyScriptedPoolableConnectorjava">trunk/connectors/java/scriptedcommon/src/main/j \
ava/org/forgerock/openicf/connectors/groovy/ScriptedPoolableConnector.java</a></li> \
<li>trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedcrest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnecto \
rsscriptedcrestScriptedCRESTConnectorjava">trunk/connectors/java/scriptedcommon/src/ma \
in/java/org/forgerock/openicf/connectors/scriptedcrest/ScriptedCRESTConnector.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnecto \
rsscriptedcrestStreamingJsonSlurperjava">trunk/connectors/java/scriptedcommon/src/main \
/java/org/forgerock/openicf/connectors/scriptedcrest/StreamingJsonSlurper.java</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedrest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnecto \
rsscriptedrestScriptedRESTConnectorjava">trunk/connectors/java/scriptedcommon/src/main \
/java/org/forgerock/openicf/connectors/scriptedrest/ScriptedRESTConnector.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnecto \
rsscriptedrestpackageinfojava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedrest/package-info.java</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedsql/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnecto \
rsscriptedsqlScriptedSQLConnectorjava">trunk/connectors/java/scriptedcommon/src/main/j \
ava/org/forgerock/openicf/connectors/scriptedsql/ScriptedSQLConnector.java</a></li> \
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnector \
sscriptedsqlpackageinfojava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedsql/package-info.java</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/crest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmisccres \
tAbstractRemoteConnectionjava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/crest/AbstractRemoteConnection.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmisccres \
tJsonEntityjava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/crest/JsonEntity.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscri \
ptedcommonOperationTypejava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/OperationType.java</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedcrest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainresourcesorgforgerockopenicfcon \
nectorsscriptedcrestMessagesproperties">trunk/connectors/java/scriptedcommon/src/main/ \
resources/org/forgerock/openicf/connectors/scriptedcrest/Messages.properties</a></li> \
<li>trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedrest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainresourcesorgforgerockopenicfcon \
nectorsscriptedrestMessagesproperties">trunk/connectors/java/scriptedcommon/src/main/r \
esources/org/forgerock/openicf/connectors/scriptedrest/Messages.properties</a></li> \
<li>trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedsql/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainresourcesorgforgerockopenicfcon \
nectorsscriptedsqlMessagesproperties">trunk/connectors/java/scriptedcommon/src/main/re \
sources/org/forgerock/openicf/connectors/scriptedsql/Messages.properties</a></li> \
<li>trunk/connectors/java/scriptedcommon/src/test/config/org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase/</li>
<li>trunk/connectors/java/scriptedcommon/src/test/config/org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase/config/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestconfigorgforgerockopenicfmiscsc \
riptedcommonScriptedConnectorBaseconfigconfiggroovy">trunk/connectors/java/scriptedcom \
mon/src/test/config/org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase/config/config.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfconnecto \
rsRESTTestBasejava">trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/RESTTestBase.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfconnecto \
rsScriptedCRESTConnectorTestjava">trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedCRESTConnectorTest.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfconnecto \
rsScriptedRESTConnectorTestjava">trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedRESTConnectorTest.java</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfconnecto \
rsScriptedSQLConnectorTestjava">trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedSQLConnectorTest.java</a></li>
<li>trunk/connectors/java/scriptedcommon/src/test/resources/crest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestAuthenticateScript \
groovy">trunk/connectors/java/scriptedcommon/src/test/resources/crest/AuthenticateScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestCreateScriptgroov \
y">trunk/connectors/java/scriptedcommon/src/test/resources/crest/CreateScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestDeleteScriptgroov \
y">trunk/connectors/java/scriptedcommon/src/test/resources/crest/DeleteScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestResolveUsernameSc \
riptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/crest/ResolveUsernameScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestSchemaScriptgroov \
y">trunk/connectors/java/scriptedcommon/src/test/resources/crest/SchemaScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestScriptOnConnector \
Scriptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/crest/ScriptOnConnectorScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestScriptOnResourceS \
criptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/crest/ScriptOnResourceScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestSearchScriptgroov \
y">trunk/connectors/java/scriptedcommon/src/test/resources/crest/SearchScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestSyncScriptgroovy" \
>trunk/connectors/java/scriptedcommon/src/test/resources/crest/SyncScript.groovy</a></li>
>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestTestScriptgroovy"> \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/TestScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestUpdateAttributeVa \
luesScriptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/crest/UpdateAttributeValuesScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcescrestUpdateScriptgroov \
y">trunk/connectors/java/scriptedcommon/src/test/resources/crest/UpdateScript.groovy</a></li>
<li>trunk/connectors/java/scriptedcommon/src/test/resources/groovy/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesgroovyTestHelpergroovy" \
>trunk/connectors/java/scriptedcommon/src/test/resources/groovy/TestHelper.groovy</a></li>
>
<li>trunk/connectors/java/scriptedcommon/src/test/resources/rest/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestAuthenticateScriptg \
roovy">trunk/connectors/java/scriptedcommon/src/test/resources/rest/AuthenticateScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestCreateScriptgroovy \
">trunk/connectors/java/scriptedcommon/src/test/resources/rest/CreateScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestDeleteScriptgroovy \
">trunk/connectors/java/scriptedcommon/src/test/resources/rest/DeleteScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestResolveUsernameScr \
iptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/rest/ResolveUsernameScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestSchemaScriptgroovy \
">trunk/connectors/java/scriptedcommon/src/test/resources/rest/SchemaScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestScriptOnConnectorS \
criptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/rest/ScriptOnConnectorScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestScriptOnResourceSc \
riptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/rest/ScriptOnResourceScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestSearchScriptgroovy \
">trunk/connectors/java/scriptedcommon/src/test/resources/rest/SearchScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestSyncScriptgroovy"> \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/SyncScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestTestScriptgroovy"> \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/TestScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestUpdateAttributeVal \
uesScriptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/rest/UpdateAttributeValuesScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcesrestUpdateScriptgroovy \
">trunk/connectors/java/scriptedcommon/src/test/resources/rest/UpdateScript.groovy</a></li>
<li>trunk/connectors/java/scriptedcommon/src/test/resources/sql/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlAuthenticateScriptgr \
oovy">trunk/connectors/java/scriptedcommon/src/test/resources/sql/AuthenticateScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlCreateScriptgroovy" \
>trunk/connectors/java/scriptedcommon/src/test/resources/sql/CreateScript.groovy</a></li>
>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlDeleteScriptgroovy"> \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/DeleteScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlResolveUsernameScri \
ptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/sql/ResolveUsernameScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlSchemaScriptgroovy" \
>trunk/connectors/java/scriptedcommon/src/test/resources/sql/SchemaScript.groovy</a></li>
>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlScriptOnResourceScri \
ptgroovy">trunk/connectors/java/scriptedcommon/src/test/resources/sql/ScriptOnResourceScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlSearchScriptgroovy" \
>trunk/connectors/java/scriptedcommon/src/test/resources/sql/SearchScript.groovy</a></li>
>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlSyncScriptgroovy">tr \
unk/connectors/java/scriptedcommon/src/test/resources/sql/SyncScript.groovy</a></li> \
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlTestScriptgroovy">tr \
unk/connectors/java/scriptedcommon/src/test/resources/sql/TestScript.groovy</a></li> \
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqlUpdateScriptgroovy"> \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/UpdateScript.groovy</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresourcessqltestDatabaseddl">tr \
unk/connectors/java/scriptedcommon/src/test/resources/sql/testDatabase.ddl</a></li> \
</ul>
<h3>Removed Paths</h3>
<ul>
<li>trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/groovy/</li>
<li><a href="#trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscri \
ptedcommonLoggerjava">trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/Logger.java</a></li>
<li>trunk/connectors/java/scriptedcommon/src/main/resources/samples/</li>
<li>trunk/connectors/java/scriptedcommon/src/test/config/org.forgerock.openicf.connectors.groovy.ScriptedConnector/</li>
<li>trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/groovy/</li>
<li>trunk/connectors/java/scriptedcommon/src/test/resources/case1/</li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#trunkconnectorsjavascriptedcommon">trunk/connectors/java/scriptedcommon/</a></li>
<li><a href="#trunkconnectorsjavascriptedcommonsrctestresources">trunk/connectors/java/scriptedcommon/src/test/resources/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkconnectorsjavascriptedcommon"></a>
<div class="propset"><h4>Property changes: trunk/connectors/java/scriptedcommon</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnignore"></a>
<div class="modfile"><h4>Modified: svn:ignore</h4></div>
<span class="cx">classes
</span><span class="cx">scriptedcommon.iml
</span><span class="cx">target
</span><span class="cx">.clover
</span><span class="cx"> + .idea
</span><span class="cx">classes
</span><span class="cx">scriptedcommon.iml
</span><span class="cx">target
</span><span class="cx">.clover
</span><span class="cx">groovy-connector.iml
</span><a id="trunkconnectorsjavascriptedcommonpomxml"></a>
<div class="modfile"><h4>Modified: trunk/connectors/java/scriptedcommon/pom.xml (6508 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- trunk/connectors/java/scriptedcommon/pom.xml 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/pom.xml 2014-04-15 09:47:57 UTC (rev 6509)
</span><span class="lines">@@ -34,13 +34,19 @@
</span><span class="cx"> <artifactId>groovy-connector</artifactId>
</span><span class="cx"> <version>1.4.0.0-SNAPSHOT</version>
</span><span class="cx"> <packaging>bundle</packaging>
</span><del>- <name>Scripted Common</name>
</del><ins>+ <name>Groovy Connector</name>
</ins><span class="cx"> <description>This is a generic bundle that contains \
base classes and interfaces needed to write a scripted </span><span class="cx"> \
connector, such as Scripted connector. </span><span class="cx"> \
</description> </span><span class="cx"> <properties>
</span><del>- \
<connectorPackage>org.forgerock.openicf.connectors.groovy</connectorPackage>
</del><ins>+ <!-- maven-compiler-plugin -->
+ <maven.compiler.target>1.7</maven.compiler.target>
+ <maven.compiler.source>1.7</maven.compiler.source>
+ <connectorPackage>org.forgerock.openicf.connectors</connectorPackage>
</ins><span class="cx"> \
<connectorClass>ScriptedConnector</connectorClass> </span><ins>+ \
<openicf.osgi.import.defaults> + \
org.codehaus.groovy*;version="[1.8,3)",groovy*;version="[1.8,3)" \
+ </openicf.osgi.import.defaults> </ins><span class="cx"> \
</properties> </span><span class="cx"> <repositories>
</span><span class="cx"> <repository>
</span><span class="lines">@@ -78,6 +84,45 @@
</span><span class="cx"> <scope>provided</scope>
</span><span class="cx"> </dependency>
</span><span class="cx">
</span><ins>+ <!-- Scripted SQL -->
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jdbc</artifactId>
+ <version>8.0.5</version>
+ <!--version>7.0.52</version-->
+ </dependency>
+
+ <!-- Scripted REST -->
+ <dependency>
+ <groupId>org.codehaus.groovy.modules.http-builder</groupId>
+ <artifactId>http-builder</artifactId>
+ <version>0.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.1</version>
+ </dependency>
+
+ <!-- Scripted SOAP -->
+
+ <!-- CREST -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpasyncclient</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.forgerock.commons</groupId>
+ <artifactId>json-resource</artifactId>
+ <version>2.2.4</version>
+ </dependency>
+
</ins><span class="cx"> <!-- Test Dependencies -->
</span><span class="cx"> <dependency>
</span><span class="cx"> <groupId>org.testng</groupId>
</span><span class="lines">@@ -94,6 +139,50 @@
</span><span class="cx"> \
<artifactId>connector-test-common</artifactId> </span><span class="cx"> \
<scope>test</scope> </span><span class="cx"> </dependency>
</span><ins>+ <!--dependency>
+ <groupId>org.forgerock.openicf.framework</groupId>
+ <artifactId>icfl-over-slf4j</artifactId>
+ <version>1.4.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.1.1</version>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.forgerock.commons</groupId>
+ <artifactId>json-resource-servlet</artifactId>
+ <version>2.2.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <version>8.1.14.v20131031</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>8.1.14.v20131031</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>2.3.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.3.175</version>
+ <scope>test</scope>
+ </dependency>
</ins><span class="cx"> </dependencies>
</span><span class="cx"> <build>
</span><span class="cx"> <pluginManagement>
</span><span class="lines">@@ -167,8 +256,82 @@
</span><span class="cx"> \
<artifactId>groovy-all</artifactId> </span><span class="cx"> \
<version>2.2.2</version> </span><span class="cx"> \
</dependency> </span><ins>+ <dependency>
+ <groupId>org.forgerock.commons</groupId>
+ <artifactId>json-resource</artifactId>
+ <version>2.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpasyncclient</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+ <dependency>
+ \
<groupId>org.codehaus.groovy.modules.http-builder</groupId> + \
<artifactId>http-builder</artifactId> + \
<version>0.7.1</version> + </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jdbc</artifactId>
+ <version>8.0.5</version>
+ <!--version>7.0.52</version-->
+ </dependency>
</ins><span class="cx"> </dependencies>
</span><span class="cx"> </plugin>
</span><ins>+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ \
<excludes>**/generated-sources/groovy-stubs/**/*</excludes> + \
</configuration> + </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <excludes>
+ <exclude>**/groovy-stubs/*.java</exclude>
+ </excludes>
+ <excludeRoots>
+ \
<excludeRoot>${project.build.directory}/generated-sources/groovy-stubs</excludeRoot>
+ </excludeRoots>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <linkJavadoc>true</linkJavadoc>
+ <includes>
+ <include>**/*.java</include>
+ <include>**/*.groovy</include>
+ </includes>
+ <excludes>
+ <exclude>target/generated/groovy-stubs</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <descriptors>
+ \
<descriptor>src/assemble/samples.xml</descriptor> + \
</descriptors> + </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</ins><span class="cx"> </plugins>
</span><span class="cx"> </build>
</span><span class="cx"> </project>
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcassemblesamplesxml"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/assemble/samples.xml (0 => 6509)</h4> <pre \
class="diff"><span> <span class="info">--- \
trunk/connectors/java/scriptedcommon/src/assemble/samples.xml \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/assemble/samples.xml 2014-04-15 09:47:57 \
UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ ~
+ ~ Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ ~
+ ~ The contents of this file are subject to the terms
+ ~ of the Common Development and Distribution License
+ ~ (the License). You may not use this file except in
+ ~ compliance with the License.
+ ~
+ ~ You can obtain a copy of the License at
+ ~ http://forgerock.org/license/CDDLv1.0.html
+ ~ See the License for the specific language governing
+ ~ permission and limitations under the License.
+ ~
+ ~ When distributing Covered Code, include this CDDL
+ ~ Header Notice in each file and include the License file
+ ~ at http://forgerock.org/license/CDDLv1.0.html
+ ~ If applicable, add the following below the CDDL Header,
+ ~ with the fields enclosed by brackets [] replaced by
+ ~ your own identifying information:
+ ~ "Portions Copyrighted [year] [name of copyright owner]"
+ -->
+
+<!--
+ URL zipUrl = ??.class.getResource("/resources/groovy-connector-1.4.0.0-SNAPSHOT-samples.zip");
+ URL entryUrl = new URL("jar:" + zipUrl + "!/groovy/");
+-->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 \
http://maven.apache.org/xsd/assembly-1.1.2.xsd"> + \
<id>samples</id> + <formats>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>${basedir}/src/test/resources</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>**/*.*</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaindocbkxchapscriptedcommonxml"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/docbkx/chap-scriptedcommon.xml (6508 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/docbkx/chap-scriptedcommon.xml 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/docbkx/chap-scriptedcommon.xml 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -60,6 +60,9 @@
</span><span class="cx">
</span><span class="cx"> <xinclude:include \
href="sec-config-scriptedconnector.xml" /> </span><span class="cx"> \
<xinclude:include href="sec-config-scriptedpoolableconnector.xml" /> \
</span><ins>+ <xinclude:include \
href="sec-config-scriptedcrestconnector.xml" /> + <xinclude:include \
href="sec-config-scriptedrestconnector.xml" /> + <xinclude:include \
href="sec-config-scriptedsqlconnector.xml" /> </ins><span class="cx"> \
<!--xinclude:include href="sec-schema-scriptedcommon.xml" > \
</span><span class="cx"> <fallback> </span><span class="cx"> \
<para> </span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaindocbkxindexxml"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/docbkx/index.xml (6508 => 6509)</h4> \
<pre class="diff"><span> <span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/docbkx/index.xml 2014-04-14 21:18:24 \
UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/docbkx/index.xml 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> !
</span><span class="cx"> ! CCPL HEADER END
</span><span class="cx"> !
</span><del>- ! Copyright 2011-2013 ForgeRock AS
</del><ins>+ ! Copyright 2011-2014 ForgeRock AS
</ins><span class="cx"> !
</span><span class="cx"> -->
</span><span class="cx"> <book xml:id='integrators-guide'
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaindocbkxlegalxml"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/docbkx/legal.xml (6508 => 6509)</h4> \
<pre class="diff"><span> <span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/docbkx/legal.xml 2014-04-14 21:18:24 \
UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/docbkx/legal.xml 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> !
</span><span class="cx"> ! CCPL HEADER END
</span><span class="cx"> !
</span><del>- ! Copyright 2011-2013 ForgeRock AS
</del><ins>+ ! Copyright 2011-2014 ForgeRock AS
</ins><span class="cx"> !
</span><span class="cx"> -->
</span><span class="cx"> <legalnotice xml:id='legalnotice'
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnectorsscriptedcrestRemoteConnectiongroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedcrest/RemoteConnection.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedcrest/RemoteConnection.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedcrest/RemoteConnection.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,178 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors.scriptedcrest
+
+import groovy.json.JsonException
+import org.apache.http.HttpEntity
+import org.apache.http.HttpResponse
+import org.apache.http.StatusLine
+import org.apache.http.client.methods.HttpUriRequest
+import org.apache.http.concurrent.FutureCallback
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer
+import org.forgerock.json.fluent.JsonValue
+import org.forgerock.json.resource.BadRequestException
+import org.forgerock.json.resource.InternalServerErrorException
+import org.forgerock.json.resource.QueryResult
+import org.forgerock.json.resource.QueryResultHandler
+import org.forgerock.json.resource.ResourceException
+import org.forgerock.openicf.misc.crest.AbstractRemoteConnection
+import org.forgerock.openicf.misc.crest.AbstractRemoteConnection.HttpResponseResourceException
+//Add import org.forgerock.openicf.misc.crest.AbstractRemoteConnection.HttpResponseResourceException
+
+import java.util.concurrent.Future
+
+/**
+ *
+ *
+ * @author Laszlo Hordos
+ */
+class RemoteConnection extends AbstractRemoteConnection {
+
+ private final ScriptedCRESTConfiguration configuration;
+
+ RemoteConnection(final ScriptedCRESTConfiguration configuration) {
+ super(configuration.getResourceName(), configuration.getHttpHost())
+ this.configuration = configuration
+ }
+
+ @Override
+ public boolean isClosed() {
+ return configuration.isClosed();
+ }
+
+ def <T> Future<T> execute(HttpUriRequest request, \
HttpAsyncResponseConsumer<T> responseConsumer, FutureCallback<T> \
callback) { + return configuration.execute(request, responseConsumer, \
callback) + }
+
+
+ protected JsonValue parseJsonBody(final HttpEntity entity, final boolean \
allowEmpty) + throws ResourceException {
+ StreamingJsonSlurper parser = new StreamingJsonSlurper();
+ try {
+
+ // Ensure that there is no trailing data following the JSON
+ // resource.
+ boolean hasTrailingGarbage;
+ def content = parser.parse(entity, null, (Closure) { lexer, object ->
+ try {
+ hasTrailingGarbage = lexer.nextToken() != null;
+ } catch (JsonException e) {
+ hasTrailingGarbage = true;
+ }
+ })
+
+
+ if (hasTrailingGarbage) {
+ throw new BadRequestException(
+ "The request could not be processed because there is \
" + + "trailing data after the JSON \
content"); + }
+
+ return new JsonValue(content);
+ } catch (final JsonException e) {
+ throw new BadRequestException(
+ "The request could not be processed because the provided \
" + + "content is not valid JSON", \
e).setDetail(new JsonValue(e + .getMessage()));
+ } catch (final EOFException e) {
+ if (allowEmpty) {
+ return null;
+ } else {
+ throw new BadRequestException("The request could not be \
processed " + + "because it did not contain any JSON \
content", e); + }
+ } catch (final IOException e) {
+ throw adapt(e);
+ }
+ }
+
+ protected QueryResult parseQueryResponse(final HttpResponse response,
+ final QueryResultHandler handler) \
throws ResourceException { + final StatusLine statusLine = \
response.getStatusLine(); + final HttpEntity entity = response.getEntity();
+
+ ResourceException exception = isOK(statusLine, entity);
+
+ if (null != exception) {
+ throw exception;
+ }
+
+ StreamingJsonSlurper parser = new StreamingJsonSlurper();
+ try {
+
+ // Ensure that there is no trailing data following the
+ // JSON
+ // resource.
+ boolean hasTrailingGarbage;
+
+ def content = parser.parse(entity, {
+ handler.handleResource(getAsResource(it));
+ }, { lexer, object ->
+ try {
+ hasTrailingGarbage = lexer.nextToken() != null;
+ } catch (JsonException e) {
+ hasTrailingGarbage = true;
+ }
+ })
+
+ if (content."${QueryResult.FIELD_ERROR}" != null) {
+ exception =
+ getAsResourceException(new \
JsonValue(content."${QueryResult.FIELD_ERROR}")); + throw \
new HttpResponseResourceException(exception); + }
+
+ String pagedResultsCookie = \
content."${QueryResult.FIELD_PAGED_RESULTS_COOKIE}"; + int \
remainingPagedResults = \
content."${QueryResult.FIELD_REMAINING_PAGED_RESULTS}"; +
+
+ if (hasTrailingGarbage) {
+ // throw new BadRequestException(
+ // "The request could not be processed because there is "
+ // + "trailing data after the JSON content");
+ }
+ return new QueryResult(pagedResultsCookie, remainingPagedResults);
+
+ } catch (final JsonException e) {
+ // throw new BadRequestException(
+ // "The request could not be processed because the provided "
+ // + "content is not valid JSON", e).setDetail(new
+ // JsonValue(e
+ // .getMessage()));
+ throw new InternalServerErrorException(e);
+ } catch (final EOFException e) {
+ // if (allowEmpty) {
+ // return null;
+ // } else {
+ // throw new
+ // BadRequestException("The request could not be processed "
+ // + "because it did not contain any JSON content");
+ // }
+ throw new InternalServerErrorException(e);
+ } catch (final IOException e) {
+ // throw adapt(e);
+ throw new InternalServerErrorException(e);
+ }
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnectorsscriptedcrestScriptedCRESTConfigurationgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedcrest/ScriptedCRESTConfiguration.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedcrest/ScriptedCRESTConfiguration.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedcrest/ScriptedCRESTConfiguration.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,291 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors.scriptedcrest
+
+import org.apache.http.HttpHost
+import org.apache.http.auth.AuthScope
+import org.apache.http.auth.UsernamePasswordCredentials
+import org.apache.http.client.CredentialsProvider
+import org.apache.http.client.config.RequestConfig
+import org.apache.http.client.methods.HttpUriRequest
+import org.apache.http.client.protocol.HttpClientContext
+import org.apache.http.concurrent.FutureCallback
+import org.apache.http.conn.routing.HttpRoute
+import org.apache.http.conn.ssl.SSLContexts
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy
+import org.apache.http.impl.client.BasicCookieStore
+import org.apache.http.impl.client.BasicCredentialsProvider
+import org.apache.http.impl.nio.client.CloseableHttpAsyncClient
+import org.apache.http.impl.nio.client.HttpAsyncClients
+import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager
+import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor
+import org.apache.http.nio.client.HttpAsyncClient
+import org.apache.http.nio.client.methods.HttpAsyncMethods
+import org.apache.http.nio.conn.NHttpClientConnectionManager
+import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer
+import org.apache.http.nio.reactor.ConnectingIOReactor
+import org.forgerock.json.resource.ResourceName
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.common.Assertions
+import org.identityconnectors.framework.spi.ConfigurationProperty
+
+import javax.net.ssl.SSLContext
+import java.security.KeyStore
+import java.util.concurrent.Future
+import java.util.concurrent.TimeUnit
+
+/**
+ * A ScriptedCRESTConfiguration.
+ *
+ * @author Laszlo Hordos
+ */
+class ScriptedCRESTConfiguration extends ScriptedConfiguration {
+
+ URI serviceAddress = null;
+
+ URI proxyAddress = null;
+
+ @ConfigurationProperty(required = true)
+ URI getServiceAddress() {
+ return serviceAddress
+ }
+
+ void setServiceAddress(URI serviceAddress) {
+ this.serviceAddress = serviceAddress
+ host = null;
+ resourceName = null;
+ }
+
+ URI getProxyAddress() {
+ return proxyAddress
+ }
+
+ void setProxyAddress(URI proxyAddress) {
+ this.proxyAddress = proxyAddress
+ proxy = null;
+ }
+
+ @Override
+ void validate() {
+ Assertions.nullCheck(serviceAddress, "serviceAddress")
+ super.validate()
+ }
+
+ private HttpHost host = null;
+
+ private HttpHost proxy = null;
+
+ private ResourceName resourceName = null;
+
+
+ ResourceName getResourceName() {
+ resourceName = ResourceName.valueOf(serviceAddress?.path);
+ }
+
+ private HttpHost getHttpHost() {
+ host = new HttpHost(serviceAddress?.host, serviceAddress?.port, \
serviceAddress?.scheme); +
+ }
+
+ private HttpHost getProxyHost() {
+ if (null != proxyAddress) {
+ return new HttpHost(proxyAddress?.host, proxyAddress?.port, \
proxyAddress?.scheme); + }
+ return null;
+ }
+
+
+ private CloseableHttpAsyncClient httpClient = null;
+
+ private IdleConnectionEvictor connectionEvictor = null;
+
+ // Create a local instance of cookie store
+ private final BasicCookieStore cookieStore = new BasicCookieStore();
+
+
+ boolean isClosed() {
+ return null == httpClient || !httpClient.isRunning();
+ }
+
+ public <T> Future<T> execute(
+ final HttpUriRequest request,
+ final HttpAsyncResponseConsumer<T> responseConsumer, final \
FutureCallback<T> callback) { + HttpClientContext localContext = \
HttpClientContext.create(); + localContext.setCookieStore(cookieStore);
+
+ return getHttpAsyncClient().execute(
+ HttpAsyncMethods.create(getHttpHost(), request),
+ responseConsumer,
+ localContext, callback);
+ }
+
+ HttpAsyncClient getHttpAsyncClient() {
+ if (null == httpClient) {
+ synchronized (this) {
+ if (null == httpClient) {
+
+ //SEE: \
http://hc.apache.org/httpcomponents-asyncclient-4.0.x/httpasyncclient/examples/org/apache/http/examples/nio/client/AsyncClientConfiguration.java
+
+ if (false) {
+
+ KeyStore trustStore = \
KeyStore.getInstance(KeyStore.getDefaultType()); + \
FileInputStream instream = new FileInputStream(new File("my.keystore")); + \
try { + trustStore.load(instream, \
"nopassword".toCharArray()); + } finally {
+ instream.close();
+ }
+ // Trust own CA and all self-signed certs
+ SSLContext sslcontext = SSLContexts.custom()
+ .loadTrustMaterial(trustStore, new \
TrustSelfSignedStrategy()) + .build();
+ // Allow TLSv1 protocol only
+ SSLIOSessionStrategy sslSessionStrategy = new \
SSLIOSessionStrategy( + sslcontext,
+ ["TLSv1"] as String[],
+ null,
+ \
SSLIOSessionStrategy.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); + }
+
+ // Authentication
+
+ // It's part of the http client spec to request the resource \
anonymously + // first and respond to the 401 with the \
Authorization header. + CredentialsProvider credsProvider = new \
BasicCredentialsProvider(); + credsProvider.setCredentials(
+ new AuthScope(getHttpHost().getHostName(), \
getHttpHost().getPort()), + new \
UsernamePasswordCredentials("admin", "Passw0rd")); +
+ //PROXY
+ if (false) {
+ HttpHost proxy = new HttpHost("someproxy", 8080);
+ RequestConfig config = RequestConfig.custom()
+ .setProxy(proxy)
+
+ // configure timeout on the entire client
+ /*
+ * .
+ * \
setConnectionRequestTimeout + \
* ( 50). + * \
setConnectTimeout + * \
(50) + * \
.setSocketTimeout + * \
(50) +
+ */
+ .build();
+
+ credsProvider.setCredentials(
+ new AuthScope(proxy.getHostName(), proxy.getPort()),
+ new \
UsernamePasswordCredentials("username", "password")); + \
} +
+
+
+ ConnectingIOReactor ioReactor = new \
DefaultConnectingIOReactor(); + \
PoolingNHttpClientConnectionManager cm = new \
PoolingNHttpClientConnectionManager(ioReactor); + // Increase max \
total connection to 200 + cm.setMaxTotal(200);
+ // Increase default max connection per route to 20
+ cm.setDefaultMaxPerRoute(20);
+ // Increase max connections for target host to 50
+ cm.setMaxPerRoute(new HttpRoute(getHttpHost()), 50);
+
+
+ httpClient = HttpAsyncClients.custom()
+ .setConnectionManager(cm)
+ //.setSSLStrategy(sslSessionStrategy)
+ .setDefaultCredentialsProvider(credsProvider)
+ //.setDefaultRequestConfig(config)
+ .build();
+
+
+ httpClient.start();
+
+ connectionEvictor = new IdleConnectionEvictor(cm);
+ connectionEvictor.start();
+
+ }
+ }
+ }
+ return httpClient;
+ }
+
+ @Override
+ void release() {
+ synchronized (this) {
+ super.release()
+ if (null != httpClient) {
+ httpClient.close();
+ httpClient = null;
+ }
+ if (null != connectionEvictor) {
+ // Shut down the evictor thread
+ connectionEvictor.shutdown();
+ connectionEvictor.join();
+ connectionEvictor = null;
+ }
+ }
+ }
+
+
+ public static class IdleConnectionEvictor extends Thread {
+
+ private final NHttpClientConnectionManager connMgr;
+
+ private volatile boolean shutdown;
+
+ public IdleConnectionEvictor(NHttpClientConnectionManager connMgr) {
+ super();
+ this.connMgr = connMgr;
+ }
+
+ @Override
+ public void run() {
+ try {
+ while (!shutdown) {
+ synchronized (this) {
+ wait(5000);
+ // Close expired connections
+ connMgr.closeExpiredConnections();
+ // Optionally, close connections
+ // that have been idle longer than 5 sec
+ connMgr.closeIdleConnections(5, TimeUnit.SECONDS);
+ }
+ }
+ } catch (InterruptedException ex) {
+ // terminate
+ }
+ }
+
+ public void shutdown() {
+ shutdown = true;
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnectorsscriptedrestScriptedRESTConfigurationgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedrest/ScriptedRESTConfiguration.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedrest/ScriptedRESTConfiguration.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedrest/ScriptedRESTConfiguration.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,314 @@
</span><ins>+/*
+ * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013-2014 ForgeRock AS All rights reserved.
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors.scriptedrest
+
+import groovyx.net.http.ContentType
+import groovyx.net.http.RESTClient
+import groovyx.net.http.StringHashMap
+import org.apache.http.HttpHost
+import org.apache.http.auth.AuthScope
+import org.apache.http.auth.UsernamePasswordCredentials
+import org.apache.http.client.AuthCache
+import org.apache.http.client.ClientProtocolException
+import org.apache.http.client.CredentialsProvider
+import org.apache.http.client.config.RequestConfig
+import org.apache.http.client.protocol.HttpClientContext
+import org.apache.http.conn.routing.HttpRoute
+import org.apache.http.impl.auth.BasicScheme
+import org.apache.http.impl.client.BasicAuthCache
+import org.apache.http.impl.client.BasicCredentialsProvider
+import org.apache.http.impl.client.CloseableHttpClient
+import org.apache.http.impl.client.HttpClientBuilder
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.common.Assertions
+import org.identityconnectors.common.security.GuardedString
+import org.identityconnectors.framework.spi.AbstractConfiguration
+import org.identityconnectors.framework.spi.ConfigurationProperty
+import org.identityconnectors.framework.spi.StatefulConfiguration
+
+/**
+ * Extends the {@link AbstractConfiguration} class to provide all the necessary
+ * parameters to initialize the ScriptedREST Connector.
+ *
+ * @author Gael Allioux <gael.allioux@gmail.com>
+ * @version 1.1.0.0
+ */
+public class ScriptedRESTConfiguration extends ScriptedConfiguration {
+
+ // Exposed configuration properties.
+
+ // ===============================================
+ // HTTP authentication
+ // ===============================================
+
+ public enum AuthMethod {
+ NONE, BASIC, BASIC_PREEMPTIVE, DIGEST, NTLM, SPNEGO, CERT, OAUTH
+ }
+
+ /*
+ * authMethod
+ * Can be:
+ * BASIC
+ * BASIC_PREEMPTIVE
+ * CERT
+ * OAUTH
+ */
+ String defaultAuthMethod = AuthMethod.BASIC.name();
+
+ /**
+ * The Remote user to authenticate with.
+ */
+ private String username = null;
+
+ /**
+ * The Password to authenticate with.
+ */
+ private GuardedString password = null;
+
+ @ConfigurationProperty(order = 1, displayMessageKey = \
"username.display", + groupMessageKey = "basic.group", \
helpMessageKey = "username.help", + required = true)
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ @ConfigurationProperty(order = 2, displayMessageKey = \
"password.display", + groupMessageKey = "basic.group", \
helpMessageKey = "password.help", + confidential = true)
+ public GuardedString getPassword() {
+ return password;
+ }
+
+ public void setPassword(GuardedString password) {
+ this.password = password;
+ }
+
+ // ===============================================
+ // HTTP connection
+ // ===============================================
+
+ URI serviceAddress = null;
+
+ @ConfigurationProperty(required = true)
+ URI getServiceAddress() {
+ return serviceAddress
+ }
+
+ void setServiceAddress(URI serviceAddress) {
+ this.serviceAddress = serviceAddress
+ host = null;
+ }
+
+ // ===============================================
+ // HTTP Proxy
+ // ===============================================
+
+ URI proxyAddress = null;
+
+ URI getProxyAddress() {
+ return proxyAddress
+ }
+
+ void setProxyAddress(URI proxyAddress) {
+ this.proxyAddress = proxyAddress
+ proxy = null;
+ }
+
+ // ===============================================
+ // HTTP content
+ // ===============================================
+
+ /*
+ * default content type
+ * Can be:
+ * ANY
+ * TEXT("text/plain")
+ * JSON("application/json","application/javascript","text/javascript")
+ * XML("application/xml","text/xml","application/xhtml+xml","application/atom+xml")
+ * HTML("text/html")
+ * URLENC("application/x-www-form-urlencoded")
+ * BINARY("application/octet-stream")
+ */
+ String defaultContentType = ContentType.JSON.name();
+
+ protected final Map<Object, Object> defaultRequestHeaders = new \
StringHashMap<Object>(); +
+ String[] getDefaultRequestHeaders() {
+ def headers = []
+ return defaultRequestHeaders.each { key, value ->
+ headers.add("${key}=${value}")
+ }
+ return headers as String[]
+ }
+
+ void setDefaultRequestHeaders(String[] headers) {
+ defaultRequestHeaders.clear()
+ if (null != headers) {
+ headers.each {
+ def kv = it.split('=')
+ assert kv.size() == 2
+ defaultRequestHeaders.put(kv[0], kv[1])
+ }
+ }
+ }
+
+ private HttpHost host = null;
+
+ private HttpHost proxy = null;
+
+ private HttpHost getHttpHost() {
+ return new HttpHost(serviceAddress?.host, serviceAddress?.port, \
serviceAddress?.scheme); + }
+
+ private HttpHost getProxyHost() {
+ if (proxyAddress != null) {
+ return new HttpHost(proxyAddress?.host, proxyAddress?.port, \
proxyAddress?.scheme); + }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void validate() {
+ Assertions.nullCheck(getServiceAddress(), "serviceAddress")
+ super.validate()
+ }
+
+ private CloseableHttpClient httpClient = null;
+ //Need for Preemptive Auth
+ private AuthCache authCache = null;
+
+ @SuppressWarnings("fallthrough")
+ RESTClient getRESTClient() {
+ if (null == httpClient) {
+ synchronized (this) {
+ if (null == httpClient) {
+
+ //SETUP: org.apache.http
+
+ PoolingHttpClientConnectionManager cm = new \
PoolingHttpClientConnectionManager(); + // Increase max total \
connection to 200 + cm.setMaxTotal(200);
+ // Increase default max connection per route to 20
+ cm.setDefaultMaxPerRoute(20);
+ // Increase max connections for localhost:8080 to 50
+
+ cm.setMaxPerRoute(new HttpRoute(getHttpHost()), 50);
+
+ // configure timeout on the entire client
+ RequestConfig requestConfig = RequestConfig.custom()/*
+ * .
+ * \
setConnectionRequestTimeout + \
* ( 50). + * \
setConnectTimeout + * \
(50) + * \
.setSocketTimeout + * \
(50) + */.build();
+
+ HttpClientBuilder builder =
+ HttpClientBuilder.create().
+ setConnectionManager(cm).
+ setDefaultRequestConfig(requestConfig).
+ setProxy(getProxyHost());
+
+
+ switch (AuthMethod.valueOf(getDefaultAuthMethod())) {
+ case AuthMethod.BASIC_PREEMPTIVE:
+
+ // Create AuthCache instance
+ authCache = new BasicAuthCache();
+ // Generate BASIC scheme object and add it to the local \
auth cache + authCache.put(getHttpHost(), new \
BasicScheme()); +
+ case AuthMethod.BASIC:
+ // It's part of the http client spec to request the \
resource anonymously + // first and respond to the 401 \
with the Authorization header. + final CredentialsProvider \
credentialsProvider = new BasicCredentialsProvider(); +
+ getPassword().access(new GuardedString.Accessor() {
+ @Override
+ public void access(char[] clearChars) {
+ credentialsProvider.setCredentials(new \
AuthScope(getHttpHost().getHostName(), getHttpHost().getPort()), + \
new UsernamePasswordCredentials(getUsername(), new String(clearChars))); + \
} + });
+
+ \
builder.setDefaultCredentialsProvider(credentialsProvider); + \
break; + case AuthMethod.NONE:
+ break;
+ default:
+ throw new IllegalArgumentException();
+ }
+
+ httpClient = builder.build();
+
+ }
+ }
+ }
+
+ //SETUP: groovyx.net.http
+
+ RESTClient restClient = new RESTClient() {
+ @Override
+ protected Object doRequest(
+ final groovyx.net.http.HTTPBuilder.RequestConfigDelegate \
delegate) throws ClientProtocolException, IOException { + // Add \
AuthCache to the execution context + if (null != authCache) {
+ //do Preemptive Auth
+ delegate.getContext().setAttribute(HttpClientContext.AUTH_CACHE, \
authCache); + }
+ return super.doRequest(delegate)
+ }
+
+ @Override
+ void shutdown() {
+ //Do not allow to shutdown the HttpClient
+ }
+ };
+ restClient.setClient(httpClient);
+ restClient.setUri(getHttpHost().toURI());
+ restClient.setContentType(defaultContentType);
+ restClient.setHeaders(defaultRequestHeaders)
+ return restClient;
+ }
+
+ @Override
+ void release() {
+ super.release()
+ if (null != httpClient) {
+ httpClient.close();
+ httpClient = null;
+ }
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnectorsscriptedsqlScriptedSQLConfigurationgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedsql/ScriptedSQLConfiguration.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedsql/ScriptedSQLConfiguration.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/scriptedsql/ScriptedSQLConfiguration.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,174 @@
</span><ins>+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * " Portions Copyrighted [year] [name of copyright owner]"
+ *
+ */
+
+package org.forgerock.openicf.connectors.scriptedsql
+
+import org.apache.tomcat.jdbc.pool.DataSource
+import org.apache.tomcat.jdbc.pool.PoolProperties
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.common.StringUtil
+import org.identityconnectors.common.logging.Log
+import org.identityconnectors.framework.spi.ConfigurationClass
+
+/**
+ * Extends the {@link \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration} class to provide all \
the necessary + * parameters to initialize the ScriptedSQL Connector.
+ *
+ * The Driver class. The jdbcDriver is located by connector framework to
+ * connect to database. Required configuration property, and should be
+ * validated.
+ *
+ * <pre>
+ * <ul>
+ * <li>Oracle: oracle.jdbc.driver.OracleDriver</li>
+ * <li>MySQL: com.mysql.jdbc.Driver</li>
+ * <li>DB2: COM.ibm.db2.jdbc.net.DB2Driver</li>
+ * <li>MSSQL: com.microsoft.sqlserver.jdbc.SQLServerDriver</li>
+ * <li>Sybase: com.sybase.jdbc2.jdbc.SybDriver</li>
+ * <li>Derby: org.apache.derby.jdbc.ClientDriver</li>
+ * <li>Derby embedded: org.apache.derby.jdbc.EmbeddedDriver</li>
+ * <li></li>
+ * </ul>
+ * </pre>
+ * <p>
+ *
+ * The new connection validation query. The query can be empty. Then the
+ * auto commit true/false command is applied by default. This can be
+ * insufficient on some database drivers because of caching Then the
+ * validation query is required.
+ *
+ * Database validationQuery notes:
+ * </p>
+ *
+ * <pre>
+ * <ul>
+ * <li>hsqldb - select 1 from INFORMATION_SCHEMA.SYSTEM_USERS</li>
+ * <li>Oracle - select 1 from dual</li>
+ * <li>DB2 - select 1 from sysibm.sysdummy1</li>
+ * <li>mysql - select 1</li>
+ * <li>microsoft SQL Server - select 1 (tested on SQL-Server 9.0, 10.5 \
[2008])</li> + * <li>postgresql - select 1</li>
+ * <li>ingres - select 1</li>
+ * <li>derby - values 1</li>
+ * <li>H2 - select 1</li>
+ * <li>Firebird - select 1 from rdb$database</li>
+ * </ul>
+ * </pre>
+ *
+ * @author Gael Allioux <gael.allioux@forgerock.com>
+ *
+ */
+@ConfigurationClass(skipUnsupported = true)
+public class ScriptedSQLConfiguration extends ScriptedConfiguration {
+
+ /**
+ * Setup logging for the {@link ScriptedSQLConfiguration}.
+ */
+ static final Log log = Log.getLog(ScriptedSQLConfiguration.class);
+
+ @Delegate
+ private final PoolProperties poolProperties = new PoolProperties();
+
+ // =======================================================================
+ // Configuration Interface
+ // =======================================================================
+
+ /**
+ * Attempt to validate the arguments added to the Configuration.
+ */
+ @Override
+ public void validate() {
+ super.validate();
+ log.info("Validate ScriptedSQLConfiguration");
+ // check the url is configured
+ if (StringUtil.isNotBlank(getUrl())) {
+ log.info("Validate driver configuration.");
+
+ // determine if you can get a connection to the database..
+ if (getUsername() == null) {
+ throw new \
IllegalArgumentException(getMessage("MSG_USER_BLANK")); + }
+ // check that there is a pwd to query..
+ if (getPassword() == null) {
+ throw new \
IllegalArgumentException(getMessage("MSG_PASSWORD_BLANK")); + }
+
+ // make sure the jdbcDriver is in the class path..
+ if (StringUtil.isBlank(getDriverClassName())) {
+ throw new \
IllegalArgumentException(getMessage("MSG_JDBC_DRIVER_BLANK")); + \
} + try {
+ Class.forName(getDriverClassName());
+ } catch (ClassNotFoundException e) {
+ throw new \
IllegalArgumentException(getMessage("MSG_JDBC_DRIVER_NOT_FOUND")); + \
} + log.ok("driver configuration is ok");
+ } else {
+ throw new \
IllegalArgumentException(getMessage("MSG_JDBC_TEMPLATE_BLANK")); + }
+ log.ok("Configuration is valid");
+ }
+
+ //private ScriptedConnection<DataSource> scriptedConnection = null;
+ private DataSource dataSource = null;
+
+ DataSource getDataSource() {
+ if (null == dataSource) {
+ synchronized (this) {
+ if (null == dataSource) {
+
+ dataSource = new DataSource();
+ dataSource.setPoolProperties(poolProperties);
+
+ }
+ }
+ }
+ return dataSource;
+ }
+
+ @Override
+ public void release() {
+ synchronized (this) {
+ super.release();
+ if (null != dataSource) {
+ dataSource.close();
+ dataSource = null;
+ }
+ }
+ }
+
+ /**
+ * Format the connector message
+ *
+ * @param key
+ * key of the message
+ * @return return the formated message
+ */
+ public String getMessage(String key) {
+ final String fmt = getConnectorMessages().format(key, key);
+ log.ok("Get for a key {0} connector message {1}", key, fmt);
+ return fmt;
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfmisccrest"></a>
<div class="propset"><h4>Property changes: \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/crest</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnignore"></a>
<div class="addfile"><h4>Added: svn:ignore</h4></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfmisccrestCRESTFilterVisitorgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/crest/CRESTFilterVisitor.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/crest/CRESTFilterVisitor.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/crest/CRESTFilterVisitor.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,123 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.misc.crest
+
+import org.forgerock.json.resource.QueryFilter
+import org.forgerock.openicf.misc.scriptedcommon.AbstractFilterVisitor
+import org.identityconnectors.framework.common.objects.AttributeUtil
+import org.identityconnectors.framework.common.objects.filter.AndFilter
+import org.identityconnectors.framework.common.objects.filter.ContainsAllValuesFilter
+import org.identityconnectors.framework.common.objects.filter.ContainsFilter
+import org.identityconnectors.framework.common.objects.filter.EndsWithFilter
+import org.identityconnectors.framework.common.objects.filter.EqualsFilter
+import org.identityconnectors.framework.common.objects.filter.GreaterThanFilter
+import org.identityconnectors.framework.common.objects.filter.GreaterThanOrEqualFilter
+import org.identityconnectors.framework.common.objects.filter.LessThanFilter
+import org.identityconnectors.framework.common.objects.filter.LessThanOrEqualFilter
+import org.identityconnectors.framework.common.objects.filter.NotFilter
+import org.identityconnectors.framework.common.objects.filter.OrFilter
+import org.identityconnectors.framework.common.objects.filter.StartsWithFilter
+
+/**
+ * A CRESTFilterVisitor converts ICF {@link \
org.identityconnectors.framework.common.objects.filter.Filter} + * to CREST {@link \
QueryFilter}. + *
+ * @author Laszlo Hordos
+ */
+class CRESTFilterVisitor extends AbstractFilterVisitor<Void, QueryFilter> {
+
+ static final CRESTFilterVisitor VISITOR = new CRESTFilterVisitor()
+
+ QueryFilter visit(Void parameter, AndFilter subFilters) {
+ QueryFilter left = this.accept(parameter, subFilters.left)
+ QueryFilter right = this.accept(parameter, subFilters.right)
+ return QueryFilter.and(left, right)
+ }
+
+ QueryFilter visit(Void parameter, OrFilter subFilters) {
+ QueryFilter left = this.accept(parameter, subFilters.left)
+ QueryFilter right = this.accept(parameter, subFilters.right)
+ return QueryFilter.or(left, right)
+ }
+
+ QueryFilter visit(Void parameter, NotFilter subFilter) {
+ return QueryFilter.not(this.accept(parameter, subFilter.filter))
+ }
+
+ /**
+ * EndsWith filter
+ */
+ private static final String EW = "ew";
+
+ /**
+ * ContainsAll filter
+ */
+ private static final String CA = "ca";
+
+ // AttributeFilter
+
+ QueryFilter visit(Void parameter, EqualsFilter filter) {
+ //TODO: Support other then Single values
+ return QueryFilter.equalTo(filter.name, \
AttributeUtil.getSingleValue(filter.attribute)) + }
+
+ QueryFilter visit(Void parameter, ContainsAllValuesFilter filter) {
+ //TODO: Support other then Single values
+ return QueryFilter.comparisonFilter(filter.name, CA, \
AttributeUtil.getSingleValue(filter.attribute)) + }
+
+ // StringFilter
+
+ QueryFilter visit(Void parameter, ContainsFilter filter) {
+ return QueryFilter.contains(filter.name, \
AttributeUtil.getStringValue(filter.attribute)) + }
+
+ QueryFilter visit(Void parameter, StartsWithFilter filter) {
+ return QueryFilter.startsWith(filter.name, \
AttributeUtil.getSingleValue(filter.attribute)) + }
+
+ QueryFilter visit(Void parameter, EndsWithFilter filter) {
+ return QueryFilter.comparisonFilter(filter.name, EW, \
AttributeUtil.getStringValue(filter.attribute)) + }
+
+ // ComparableAttributeFilter
+
+ QueryFilter visit(Void parameter, GreaterThanFilter filter) {
+ return QueryFilter.greaterThan(filter.name, \
AttributeUtil.getSingleValue(filter.attribute)) + }
+
+ QueryFilter visit(Void parameter, GreaterThanOrEqualFilter filter) {
+ return QueryFilter.greaterThanOrEqualTo(filter.name, \
AttributeUtil.getSingleValue(filter.attribute)) + }
+
+ QueryFilter visit(Void parameter, LessThanFilter filter) {
+ return QueryFilter.lessThan(filter.name, \
AttributeUtil.getSingleValue(filter.attribute)) + }
+
+ QueryFilter visit(Void parameter, LessThanOrEqualFilter filter) {
+ return QueryFilter.lessThanOrEqualTo(filter.name, \
AttributeUtil.getSingleValue(filter.attribute)) + }
+
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfmiscscriptedcommonICFObjectBuildergroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/scriptedcommon/ICFObjectBuilder.groovy \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/scriptedcommon/ICFObjectBuilder.groovy 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/scriptedcommon/ICFObjectBuilder.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx"> static private <B> AbstractICFBuilder<B> \
delegateToTag(Class<? extends AbstractICFBuilder<B>> clazz, Closure body, \
B builder) { </span><span class="cx"> AbstractICFBuilder<B> tag = \
(AbstractICFBuilder<B>) clazz.newInstance(builder) </span><span class="cx"> \
def clone = body.rehydrate(tag, this, this) </span><ins>+ \
clone.resolveStrategy = Closure.DELEGATE_FIRST </ins><span class="cx"> \
clone() </span><span class="cx"> return tag
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfmiscscriptedcommonScriptedConnectorBasegroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnectorBase.groovy \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnectorBase.groovy 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnectorBase.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -27,9 +27,8 @@
</span><span class="cx"> import org.codehaus.groovy.runtime.InvokerHelper
</span><span class="cx"> import org.identityconnectors.common.CollectionUtil
</span><span class="cx"> import org.identityconnectors.common.StringUtil
</span><del>-import org.identityconnectors.common.security.GuardedByteArray
</del><ins>+import org.identityconnectors.common.logging.Log
</ins><span class="cx"> import org.identityconnectors.common.security.GuardedString
</span><del>-import org.identityconnectors.common.security.SecurityUtil
</del><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.ConnectorException </span><span \
class="cx"> import org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.Attribute </span><span \
class="lines">@@ -63,7 +62,7 @@ </span><span class="cx"> import \
org.identityconnectors.framework.spi.operations.SearchOp </span><span class="cx"> \
import org.identityconnectors.framework.spi.operations.SyncOp </span><span \
class="cx"> import org.identityconnectors.framework.spi.operations.TestOp \
</span><del>-import org.identityconnectors.framework.spi.operations.UpdateAttributeValuesOp
</del><ins>+import org.identityconnectors.framework.spi.operations.UpdateOp
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Main implementation of the Scripted Common code.
</span><span class="lines">@@ -73,7 +72,7 @@
</span><span class="cx"> */
</span><span class="cx"> public class ScriptedConnectorBase<C extends \
ScriptedConfiguration> implements AuthenticateOp, CreateOp, DeleteOp, \
ResolveUsernameOp, </span><span class="cx"> SchemaOp, ScriptOnConnectorOp, \
ScriptOnResourceOp, SearchOp<Filter>, SyncOp, TestOp, </span><del>- \
UpdateAttributeValuesOp { </del><ins>+ UpdateOp {
</ins><span class="cx">
</span><span class="cx"> protected static final String USERNAME = \
"username" </span><span class="cx"> protected static final String \
PASSWORD = "password" </span><span class="lines">@@ -98,24 +97,6 @@
</span><span class="cx"> protected static final String FILTER = \
"filter" </span><span class="cx"> protected static final String GROOVY \
= "GROOVY" </span><span class="cx">
</span><del>-
- public enum Action {
- AUTHENTICATE,
- CREATE,
- DELETE,
- GET_LATEST_SYNC_TOKEN,
- RESOLVE_USERNAME,
- SCHEMA,
- SEARCH,
- SYNC,
- TEST,
- RUNSCRIPTONCONNECTOR,
- RUNSCRIPTONRESOURCE,
- UPDATE,
- ADD_ATTRIBUTE_VALUES,
- REMOVE_ATTRIBUTE_VALUES;
- }
-
</del><span class="cx"> /**
</span><span class="cx"> * Place holder for the Connector schema created in the \
Schema() method. </span><span class="cx"> */
</span><span class="lines">@@ -131,7 +112,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Setup logging for the {@link ScriptedConnectorBase}.
</span><span class="cx"> */
</span><del>- Logger logger;
</del><ins>+ private static final Log logger = \
Log.getLog(ScriptedConnectorBase.class); </ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Gets the Configuration context for this connector.
</span><span class="lines">@@ -154,7 +135,6 @@
</span><span class="cx"> */
</span><span class="cx"> public void init(final Configuration config) {
</span><span class="cx"> this.configuration = (C) config;
</span><del>- logger = configuration.getLogger(getClass(), 12);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -176,29 +156,24 @@
</span><span class="cx"> /**
</span><span class="cx"> * {@inheritDoc}
</span><span class="cx"> */
</span><ins>+ @Override
</ins><span class="cx"> public Uid authenticate(ObjectClass objectClass, String \
username, GuardedString password, </span><span class="cx"> \
OperationOptions options) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getAuthenticateScriptFileName())) { \
</span><del>- logger.debugLocale("DEBUG_INVOKE_AUTHENTICATE", \
"Invoke Authenticate ObjectClass:{0}->{1}", </del><ins>+ \
logger.ok("Invoke Authenticate ObjectClass:{0}->{1}", </ins><span \
class="cx"> objectClass.getObjectClassValue(), username) \
</span><ins>+ + Object uidAfter = null;
</ins><span class="cx"> try {
</span><del>- Object uidAfter = \
executeAuthenticate(getScriptedConfiguration().getAuthenticateScriptFileName(), \
</del><ins>+ uidAfter = \
executeAuthenticate(getScriptedConfiguration().getAuthenticateScriptFileName(), \
</ins><span class="cx"> objectClass, username, password, \
options); </span><del>- if (uidAfter instanceof String) {
- logger.debug("{0}:{1} authenticated", \
objectClass.getObjectClassValue(), uidAfter);
- return new Uid((String) uidAfter);
- } else if (uidAfter instanceof Uid) {
- logger.debug("{0}:{1} authenticated", \
objectClass.getObjectClassValue(), uidAfter);
- return (Uid) uidAfter;
- } else {
- throw new ConnectorException(
- "Authenticate script didn't return with the \
uid(__UID__) value");
- }
</del><span class="cx"> } catch (final RuntimeException e) {
</span><span class="cx"> throw e;
</span><span class="cx"> } catch (final Exception e) {
</span><ins>+ //throw ConnectorException.wrap(e);
</ins><span class="cx"> throw new \
ConnectorException("Authenticate script error", e); </span><span \
class="cx"> } </span><ins>+ return \
returnUid(OperationType.AUTHENTICATE, objectClass, uidAfter); </ins><span class="cx"> \
} else { </span><span class="cx"> throw new \
UnsupportedOperationException(); </span><span class="cx"> }
</span><span class="lines">@@ -208,40 +183,36 @@
</span><span class="cx"> OperationOptions \
options) { </span><span class="cx"> final Binding arguments = new Binding();
</span><span class="cx"> arguments.setVariable(USERNAME, username);
</span><del>- arguments.setVariable(PASSWORD, \
getGuardedStringValue(password));
- return evaluateScript(scriptName, createBinding(arguments, \
Action.AUTHENTICATE, objectClass, null, null, options)); </del><ins>+ \
arguments.setVariable(PASSWORD, password); + return evaluateScript(scriptName, \
createBinding(arguments, OperationType.AUTHENTICATE, objectClass, null, null, \
options)); </ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * {@inheritDoc}
+ */
+ @Override
</ins><span class="cx"> public Uid create(final ObjectClass objectClass, final \
Set<Attribute> createAttributes, </span><span class="cx"> \
final OperationOptions options) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getCreateScriptFileName())) { \
</span><del>- logger.debugLocale("DEBUG_INVOKE_CREATE", \
"Invoke Create ObjectClass:{0}", </del><ins>+ \
logger.ok("Invoke Create ObjectClass:{0}", </ins><span class="cx"> \
objectClass.getObjectClassValue()); </span><ins>+ Object uidAfter = null;
</ins><span class="cx"> try {
</span><del>- Object uidAfter = \
executeCreate(getScriptedConfiguration().getCreateScriptFileName(), </del><ins>+ \
uidAfter = executeCreate(getScriptedConfiguration().getCreateScriptFileName(), \
</ins><span class="cx"> objectClass, createAttributes, \
options) </span><del>- if (uidAfter instanceof String) {
- logger.debug("{0}:{1} created", \
objectClass.getObjectClassValue(), uidAfter);
- return new Uid(uidAfter);
- } else if (uidAfter instanceof Uid) {
- logger.debug("{0}:{1} created", \
objectClass.getObjectClassValue(), uidAfter);
- return (Uid) uidAfter;
- } else {
- throw new ConnectorException(
- "Create script didn't return with the uid(__UID__) \
value");
- }
</del><span class="cx"> } catch (final RuntimeException e) {
</span><span class="cx"> throw e;
</span><span class="cx"> } catch (final Exception e) {
</span><span class="cx"> throw new ConnectorException("Create \
script error", e); </span><span class="cx"> }
</span><ins>+ return returnUid(OperationType.CREATE, objectClass, \
uidAfter); </ins><span class="cx"> } else {
</span><span class="cx"> throw new UnsupportedOperationException();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- protected Object executeCreate(String scriptName, final ObjectClass \
objectClass, final Set<Attribute> createAttributes,
- final OperationOptions options) {
</del><ins>+ protected Uid executeCreate(String scriptName, final ObjectClass \
objectClass, final Set<Attribute> createAttributes, + \
final OperationOptions options) { </ins><span class="cx"> final Binding \
arguments = new Binding(); </span><span class="cx"> final Map<String, \
Attribute> attributes = CollectionUtil.<Attribute> newCaseInsensitiveMap(); \
</span><span class="cx"> // We give the id (name) as an argument, more \
friendly than dealing </span><span class="lines">@@ -259,7 +230,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> arguments.setVariable(ATTRIBUTES, attributes);
</span><del>- return evaluateScript(scriptName, createBinding(arguments, \
Action.CREATE, objectClass, null, createAttributes, options)); </del><ins>+ \
return returnUid(OperationType.CREATE, objectClass, evaluateScript(scriptName, \
createBinding(arguments, OperationType.CREATE, objectClass, null, createAttributes, \
options))); </ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -268,12 +239,12 @@
</span><span class="cx"> @Override
</span><span class="cx"> public void delete(final ObjectClass objectClass, final \
Uid uid, final OperationOptions options) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getDeleteScriptFileName())) { \
</span><del>- logger.debugLocale("DEBUG_INVOKE_DELETE", \
"Invoke Delete ObjectClass:{0}->{1}",
- objectClass.getObjectClassValue(), uid);
</del><ins>+ logger.ok("Invoke Delete ObjectClass:{0}->{1}",
+ objectClass.getObjectClassValue(), uid.uidValue);
</ins><span class="cx"> try {
</span><span class="cx"> \
executeDelete(getScriptedConfiguration().getDeleteScriptFileName(), </span><span \
class="cx"> objectClass, uid, options); </span><del>- \
logger.debug("{0}:{1} deleted", objectClass.getObjectClassValue(), uid); \
</del><ins>+ logger.ok("{0}:{1} deleted", \
objectClass.getObjectClassValue(), uid); </ins><span class="cx"> } catch \
(final RuntimeException e) { </span><span class="cx"> throw e;
</span><span class="cx"> } catch (final Exception e) {
</span><span class="lines">@@ -284,36 +255,30 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- protected void executeDelete(String scriptName, ObjectClass \
objectClass, Uid uid, OperationOptions options) {
- evaluateScript(scriptName, createBinding(new Binding(), Action.DELETE, \
objectClass, uid, null, options)); </del><ins>+ protected void \
executeDelete(String scriptName, ObjectClass objectClass, Uid uid, OperationOptions \
options) throws Exception { + evaluateScript(scriptName, createBinding(new \
Binding(), OperationType.DELETE, objectClass, uid, null, options)); </ins><span \
class="cx"> } </span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * {@inheritDoc}
</span><span class="cx"> */
</span><ins>+ @Override
</ins><span class="cx"> public Uid resolveUsername(ObjectClass objectClass, \
String username, OperationOptions options) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getResolveUsernameScriptFileName())) \
{ </span><del>- \
logger.debugLocale("DEBUG_INVOKE_RESOLVE_USERNAME", "Invoke Resolve \
Username ObjectClass:{0}->{1}", </del><ins>+ \
logger.ok("Invoke Resolve Username ObjectClass:{0}->{1}", </ins><span \
class="cx"> objectClass.getObjectClassValue(), username); \
</span><ins>+ Object uidAfter = null; </ins><span class="cx"> \
try { </span><del>- Object uidAfter = \
executeResolveUsername(getScriptedConfiguration().getResolveUsernameScriptFileName(), \
</del><ins>+ uidAfter = \
executeResolveUsername(getScriptedConfiguration().getResolveUsernameScriptFileName(), \
</ins><span class="cx"> objectClass, username, options); \
</span><del>-
- if (uidAfter instanceof String) {
- logger.debug("Username:{0} resolved to:{1}", username, \
uidAfter);
- return new Uid(uidAfter);
- } else if (uidAfter instanceof Uid) {
- logger.debug("Username:{0} resolved to:{1}", username, \
uidAfter);
- return (Uid) uidAfter;
- } else {
- throw new ConnectorException(
- "ResolveUsernameScript didn't return with the \
uid(__UID__) value");
- }
</del><span class="cx"> } catch (final RuntimeException e) {
</span><span class="cx"> throw e;
</span><span class="cx"> } catch (final Exception e) {
</span><span class="cx"> throw new \
ConnectorException("ResolveUsernameScript error", e); </span><span \
class="cx"> } </span><ins>+
+ return returnUid(OperationType.RESOLVE_USERNAME, objectClass, uidAfter);
+
</ins><span class="cx"> } else {
</span><span class="cx"> throw new UnsupportedOperationException();
</span><span class="cx"> }
</span><span class="lines">@@ -323,17 +288,18 @@
</span><span class="cx"> final Binding arguments = new Binding();
</span><span class="cx"> arguments.setVariable(USERNAME, username);
</span><span class="cx"> return evaluateScript(scriptName,
</span><del>- createBinding(arguments, Action.RESOLVE_USERNAME, \
objectClass, null, null, options)); </del><ins>+ \
createBinding(arguments, OperationType.RESOLVE_USERNAME, objectClass, null, null, \
options)); </ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * {@inheritDoc}
</span><span class="cx"> */
</span><ins>+ @Override
</ins><span class="cx"> public Schema schema() {
</span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getSchemaScriptFileName())) { \
</span><span class="cx"> if (null == schema) { </span><span class="cx"> \
try { </span><del>- \
logger.debugLocale("DEBUG_INVOKE_SCHEMA", "Invoke Schema"); \
</del><ins>+ logger.ok("Invoke Schema"); </ins><span \
class="cx"> Object result = \
executeSchema(getScriptedConfiguration().getSchemaScriptFileName(), </span><span \
class="cx"> getClass() as Class<? extends \
Connector>); </span><span class="cx"> if (result instanceof \
Schema) { </span><span class="lines">@@ -357,7 +323,7 @@
</span><span class="cx"> protected Object executeSchema(String scriptName, \
Class<? extends Connector> connectorClass) { </span><span class="cx"> \
final Binding arguments = new Binding(); </span><span class="cx"> \
arguments.setVariable(BUILDER, new ICFObjectBuilder(connectorClass)); </span><del>- \
return evaluateScript(scriptName, createBinding(arguments, Action.SCHEMA, null, null, \
null, null)); </del><ins>+ return evaluateScript(scriptName, \
createBinding(arguments, OperationType.SCHEMA, null, null, null, null)); </ins><span \
class="cx"> } </span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -373,7 +339,7 @@
</span><span class="cx"> Object result = \
InvokerHelper.createScript(getScriptedConfiguration().getGroovyScriptEngine(). \
</span><span class="cx"> \
getGroovyClassLoader().parseClass(codeSource, false), </span><span class="cx"> \
new Binding(request.scriptArguments)).run(); </span><del>- \
logger.debug("runScriptOnConnector ok"); </del><ins>+ \
logger.ok("runScriptOnConnector ok"); </ins><span class="cx"> \
return result; </span><span class="cx"> } catch (final RuntimeException \
e) { </span><span class="cx"> throw e;
</span><span class="lines">@@ -391,7 +357,7 @@
</span><span class="cx"> @Override
</span><span class="cx"> public Object runScriptOnResource(ScriptContext request, \
OperationOptions options) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getScriptOnResourceScriptFileName())) \
{ </span><del>- \
logger.debugLocale("DEBUG_INVOKE_RUNSCRIPTONRESOURCE", "Invoke \
RunScriptOnResource") </del><ins>+ logger.ok("Invoke \
RunScriptOnResource") </ins><span class="cx"> try {
</span><span class="cx"> return \
executeRunScriptOnResource(getScriptedConfiguration().getScriptOnResourceScriptFileName(),
</span><span class="cx"> request, options);
</span><span class="lines">@@ -412,12 +378,13 @@
</span><span class="cx"> arguments.setVariable("scriptLanguage", \
request.scriptLanguage) </span><span class="cx">
</span><span class="cx"> return evaluateScript(scriptName,
</span><del>- createBinding(arguments, Action.RUNSCRIPTONRESOURCE, \
null, null, null, options)); </del><ins>+ createBinding(arguments, \
OperationType.RUNSCRIPTONRESOURCE, null, null, null, options)); </ins><span \
class="cx"> } </span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * {@inheritDoc}
</span><span class="cx"> */
</span><ins>+ @Override
</ins><span class="cx"> public FilterTranslator<Filter> \
createFilterTranslator(final ObjectClass objectClass, </span><span class="cx"> \
final OperationOptions options) { </span><span class="cx"> return \
ScriptedFilterTranslator.INSTANCE; </span><span class="lines">@@ -426,29 +393,30 @@
</span><span class="cx"> /**
</span><span class="cx"> * {@inheritDoc}
</span><span class="cx"> */
</span><ins>+ @Override
</ins><span class="cx"> public void executeQuery(final ObjectClass objectClass, \
final Filter query, final ResultsHandler handler, </span><span class="cx"> \
final OperationOptions options) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getSearchScriptFileName())) { \
</span><del>- logger.debugLocale("DEBUG_INVOKE_SEARCH", \
"Invoke Execute Query ObjectClass:{0}", </del><ins>+ \
logger.ok("Invoke Execute Query ObjectClass:{0}", </ins><span class="cx"> \
objectClass.objectClassValue) </span><span class="cx"> try {
</span><span class="cx"> Object searchResult = \
executeQuery(getScriptedConfiguration().getSearchScriptFileName(), </span><span \
class="cx"> objectClass, query, </span><span class="cx"> \
{ res -> </span><del>- boolean doContinue = false
</del><span class="cx"> if (res instanceof \
ConnectorObject) { </span><del>- doContinue = \
handler.handle(res) </del><ins>+ return \
handler.handle(res) </ins><span class="cx"> } else if \
(res instanceof Closure) { </span><del>- doContinue = \
handler.handle(ICFObjectBuilder.co(res)); </del><ins>+ \
return handler.handle(ICFObjectBuilder.co(res)); + } else \
{ + throw new ConnectorException("Can not handle \
type of " + null != res ? res.class.name : "null") </ins><span \
class="cx"> } </span><del>- \
doContinue </del><span class="cx"> }, options);
</span><span class="cx"> if (searchResult instanceof SearchResult) {
</span><span class="cx"> ((SearchResultsHandler) \
handler).handleResult((SearchResult) searchResult); </span><span class="cx"> \
} else if (searchResult instanceof String) { </span><span class="cx"> \
((SearchResultsHandler) handler).handleResult(new SearchResult((String) searchResult, \
-1)); </span><span class="cx"> }
</span><del>- logger.debug("Search ok");
</del><ins>+ logger.ok("Search ok");
</ins><span class="cx"> } catch (final RuntimeException e) {
</span><span class="cx"> throw e;
</span><span class="cx"> } catch (final Exception e) {
</span><span class="lines">@@ -472,27 +440,30 @@
</span><span class="cx"> arguments.setVariable(HANDLER, handler)
</span><span class="cx">
</span><span class="cx"> return evaluateScript(scriptName,
</span><del>- createBinding(arguments, Action.SEARCH, objectClass, \
null, null, options)); </del><ins>+ createBinding(arguments, \
OperationType.SEARCH, objectClass, null, null, options)); </ins><span class="cx"> \
} </span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * {@inheritDoc}
</span><span class="cx"> */
</span><ins>+ @Override
</ins><span class="cx"> public void sync(ObjectClass objectClass, SyncToken \
token, SyncResultsHandler handler, </span><span class="cx"> \
final OperationOptions options) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getSyncScriptFileName())) { \
</span><del>- logger.debugLocale("DEBUG_INVOKE_SYNC", \
"Invoke Sync ObjectClass:{0}->{1}", </del><ins>+ \
logger.ok("Invoke Sync ObjectClass:{0}->{1}", </ins><span class="cx"> \
objectClass.getObjectClassValue(), token); </span><span class="cx"> try {
</span><span class="cx"> Object newToken = \
executeSync(getScriptedConfiguration().getSyncScriptFileName(), </span><span \
class="cx"> objectClass, token, { delta -> </span><span \
class="cx"> if (delta instanceof SyncDelta) { </span><del>- \
handler.handle(((SyncDelta) delta)) </del><ins>+ return \
handler.handle(((SyncDelta) delta)) </ins><span class="cx"> } \
else if (delta instanceof Closure) { </span><del>- \
handler.handle(ICFObjectBuilder.delta(delta)); </del><ins>+ \
return handler.handle(ICFObjectBuilder.delta(delta)); + } else {
+ throw new ConnectorException("Can not handle type of \
" + null != delta ? delta.class.name : "null") </ins><span class="cx"> \
} </span><span class="cx"> }, options);
</span><del>- logger.debug("Sync ok");
</del><ins>+ logger.ok("Sync ok");
</ins><span class="cx"> if (newToken instanceof SyncToken) {
</span><span class="cx"> ((SyncTokenResultsHandler) \
handler).handleResult((SyncToken) newToken); </span><span class="cx"> \
} else if (null != newToken) { </span><span class="lines">@@ -512,7 +483,7 @@
</span><span class="cx"> final Binding arguments = new Binding();
</span><span class="cx"> arguments.setVariable(TOKEN, token != null ? \
token.getValue() : null); </span><span class="cx"> \
arguments.setVariable(HANDLER, handler) </span><del>- return \
evaluateScript(scriptName, createBinding(arguments, Action.SYNC, objectClass, null, \
null, options)); </del><ins>+ return evaluateScript(scriptName, \
createBinding(arguments, OperationType.SYNC, objectClass, null, null, options)); \
</ins><span class="cx"> } </span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -522,12 +493,12 @@
</span><span class="cx"> public SyncToken getLatestSyncToken(ObjectClass \
objectClass) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getSyncScriptFileName())) { \
</span><span class="cx"> SyncToken syncToken = null; </span><del>- \
debugLocale("DEBUG_INVOKE_GET_LATEST_SYNC_TOKEN", "Invoke \
GetLatestSyncToken ObjectClass:{0}", </del><ins>+ \
logger.ok("Invoke GetLatestSyncToken ObjectClass:{0}", </ins><span \
class="cx"> objectClass.getObjectClassValue()); </span><span \
class="cx"> try { </span><span class="cx"> Object result \
= executeGetLatestSyncToken(getScriptedConfiguration().getSyncScriptFileName(), \
</span><span class="cx"> objectClass); </span><del>- \
logger.debug("GetLatestSyncToken ok"); </del><ins>+ \
logger.ok("GetLatestSyncToken ok"); </ins><span class="cx"> \
if (result instanceof SyncToken) { </span><span class="cx"> \
syncToken = (SyncToken) result; </span><span class="cx"> } else if \
(null != result) { </span><span class="lines">@@ -546,7 +517,7 @@
</span><span class="cx">
</span><span class="cx"> protected Object executeGetLatestSyncToken(String \
scriptName, ObjectClass objectClass) { </span><span class="cx"> return \
evaluateScript(scriptName, </span><del>- createBinding(new Binding(), \
Action.GET_LATEST_SYNC_TOKEN, objectClass, null, null, null)); </del><ins>+ \
createBinding(new Binding(), OperationType.GET_LATEST_SYNC_TOKEN, objectClass, null, \
null, null)); </ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -556,10 +527,10 @@
</span><span class="cx"> public void test() {
</span><span class="cx"> getScriptedConfiguration().validate()
</span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getTestScriptFileName())) { \
</span><del>- logger.debugLocale("DEBUG_INVOKE_TEST", \
"Invoke Test") </del><ins>+ logger.ok("Invoke Test")
</ins><span class="cx"> try {
</span><span class="cx"> \
executeTest(getScriptedConfiguration().getTestScriptFileName()); </span><del>- \
logger.debug("Test ok"); </del><ins>+ logger.ok("Test \
ok"); </ins><span class="cx"> } catch (final RuntimeException e) {
</span><span class="cx"> throw e;
</span><span class="cx"> } catch (final Exception e) {
</span><span class="lines">@@ -570,7 +541,7 @@
</span><span class="cx">
</span><span class="cx"> protected void executeTest(String scriptName) {
</span><span class="cx"> evaluateScript(scriptName,
</span><del>- createBinding(new Binding(), Action.TEST, null, null, \
null, null)); </del><ins>+ createBinding(new Binding(), \
OperationType.TEST, null, null, null, null)); </ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -580,113 +551,83 @@
</span><span class="cx"> public Uid update(ObjectClass objectClass, Uid uid, \
Set<Attribute> replaceAttributes, </span><span class="cx"> \
OperationOptions options) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getUpdateScriptFileName())) { \
</span><del>- logger.debugLocale("DEBUG_INVOKE_UPDATE", \
"Invoke Update ObjectClass:{0}->{1}",
- objectClass.getObjectClassValue(), uid);
</del><ins>+ logger.ok("Invoke Update ObjectClass:{0}->{1}",
+ objectClass.getObjectClassValue(), uid.uidValue);
+ Object uidAfter = null;
</ins><span class="cx"> try {
</span><del>- Object uidAfter = \
executeUpdate(getScriptedConfiguration().getUpdateScriptFileName(), </del><ins>+ \
uidAfter = executeUpdate(getScriptedConfiguration().getUpdateScriptFileName(), \
</ins><span class="cx"> objectClass, uid, replaceAttributes, \
options) </span><del>- if (uidAfter instanceof String) {
- logger.debug("{0}:{1} updated", \
objectClass.getObjectClassValue(), uidAfter);
- return new Uid(uidAfter);
- } else if (uidAfter instanceof Uid) {
- logger.debug("{0}:{1} updated", \
objectClass.getObjectClassValue(), uidAfter);
- return (Uid) uidAfter;
- } else {
- throw new ConnectorException(
- "Update script didn't return with the uid(__UID__) \
value");
- }
</del><span class="cx"> } catch (final RuntimeException e) {
</span><span class="cx"> throw e;
</span><span class="cx"> } catch (final Exception e) {
</span><span class="cx"> throw new ConnectorException("Update \
(Update) script error", e); </span><span class="cx"> }
</span><ins>+ return returnUid(OperationType.UPDATE, objectClass, \
uidAfter); </ins><span class="cx"> } else {
</span><span class="cx"> throw new UnsupportedOperationException();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> protected Object executeUpdate(String scriptName, \
ObjectClass objectClass, Uid uid, Set<Attribute> replaceAttributes, \
OperationOptions options) { </span><del>- return genericUpdate(scriptName, \
Action.UPDATE, objectClass, uid, replaceAttributes, options); </del><ins>+ \
return genericUpdate(scriptName, OperationType.UPDATE, objectClass, uid, \
replaceAttributes, options); </ins><span class="cx"> }
</span><span class="cx">
</span><del>- /**
- * {@inheritDoc}
- */
- @Override
</del><span class="cx"> public Uid addAttributeValues(ObjectClass objectClass, \
Uid uid, Set<Attribute> valuesToAdd, </span><span class="cx"> \
OperationOptions options) { </span><span class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getUpdateScriptFileName())) { \
</span><del>- \
logger.debugLocale("DEBUG_INVOKE_ADD_ATTRIBUTE_VALUES", "Invoke \
AddAttributeValues ObjectClass:{0}->{1}", </del><ins>+ \
logger.ok("Invoke AddAttributeValues ObjectClass:{0}->{1}", </ins><span \
class="cx"> objectClass.getObjectClassValue(), uid); \
</span><ins>+ Object uidAfter = null; </ins><span class="cx"> \
try { </span><del>- Object uidAfter = \
executeAddAttributeValues(getScriptedConfiguration().getUpdateScriptFileName(), \
</del><ins>+ uidAfter = \
executeAddAttributeValues(getScriptedConfiguration().getUpdateScriptFileName(), \
</ins><span class="cx"> objectClass, uid, valuesToAdd, \
options) </span><del>- if (uidAfter instanceof String) {
- logger.debug("{0}:{1} updated", \
objectClass.getObjectClassValue(), uidAfter);
- return new Uid(uidAfter);
- } else if (uidAfter instanceof Uid) {
- logger.debug("{0}:{1} updated", \
objectClass.getObjectClassValue(), uidAfter);
- return (Uid) uidAfter;
- } else {
- throw new ConnectorException(
- "Update script didn't return with the uid(__UID__) \
value");
- }
</del><span class="cx"> } catch (final RuntimeException e) {
</span><span class="cx"> throw e;
</span><span class="cx"> } catch (final Exception e) {
</span><span class="cx"> throw new ConnectorException("Update \
(AddAttributeValues) script error", e); </span><span class="cx"> }
</span><ins>+ return returnUid(OperationType.ADD_ATTRIBUTE_VALUES, \
objectClass, uidAfter); </ins><span class="cx"> } else {
</span><span class="cx"> throw new UnsupportedOperationException();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> protected Object executeAddAttributeValues(String \
scriptName, ObjectClass objectClass, Uid uid, Set<Attribute> valuesToAdd, \
OperationOptions options) { </span><del>- return genericUpdate(scriptName, \
Action.ADD_ATTRIBUTE_VALUES, objectClass, uid, valuesToAdd, options); </del><ins>+ \
return genericUpdate(scriptName, OperationType.ADD_ATTRIBUTE_VALUES, objectClass, \
uid, valuesToAdd, options); </ins><span class="cx"> }
</span><span class="cx">
</span><del>- /**
- * {@inheritDoc}
- */
- @Override
</del><span class="cx"> public Uid removeAttributeValues(ObjectClass objectClass, \
Uid uid, </span><span class="cx"> \
Set<Attribute> valuesToRemove, OperationOptions options) { </span><span \
class="cx"> if \
(StringUtil.isNotBlank(getScriptedConfiguration().getUpdateScriptFileName())) { \
</span><del>- \
logger.debugLocale("DEBUG_INVOKE_REMOVE_ATTRIBUTE_VALUES", "Invoke \
RemoveAttributeValues ObjectClass:{0}->{1}", </del><ins>+ \
logger.ok("Invoke RemoveAttributeValues ObjectClass:{0}->{1}", \
</ins><span class="cx"> objectClass.getObjectClassValue(), uid); \
</span><ins>+ Object uidAfter = null; </ins><span class="cx"> \
try { </span><del>- Object uidAfter = \
executeRemoveAttributeValues(getScriptedConfiguration().getUpdateScriptFileName(), \
</del><ins>+ uidAfter = \
executeRemoveAttributeValues(getScriptedConfiguration().getUpdateScriptFileName(), \
</ins><span class="cx"> objectClass, uid, valuesToRemove, \
options) </span><del>- if (uidAfter instanceof String) {
- logger.debug("{0}:{1} updated", \
objectClass.getObjectClassValue(), uidAfter);
- return new Uid(uidAfter);
- } else if (uidAfter instanceof Uid) {
- logger.debug("{0}:{1} updated", \
objectClass.getObjectClassValue(), uidAfter);
- return (Uid) uidAfter;
- } else {
- throw new ConnectorException(
- "Update script didn't return with the uid(__UID__) \
value");
- }
</del><span class="cx"> } catch (final RuntimeException e) {
</span><span class="cx"> throw e;
</span><span class="cx"> } catch (final Exception e) {
</span><span class="cx"> throw new ConnectorException("Update \
(RemoveAttributeValues) script error", e); </span><span class="cx"> \
} </span><ins>+ return returnUid(OperationType.REMOVE_ATTRIBUTE_VALUES, \
objectClass, uidAfter); </ins><span class="cx"> } else {
</span><span class="cx"> throw new UnsupportedOperationException();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> protected Object executeRemoveAttributeValues(String \
scriptName, ObjectClass objectClass, Uid uid, Set<Attribute> valuesToRemove, \
OperationOptions options) { </span><del>- return genericUpdate(scriptName, \
Action.REMOVE_ATTRIBUTE_VALUES, objectClass, uid, valuesToRemove, options); \
</del><ins>+ return genericUpdate(scriptName, \
OperationType.REMOVE_ATTRIBUTE_VALUES, objectClass, uid, valuesToRemove, options); \
</ins><span class="cx"> } </span><span class="cx">
</span><del>- protected Object evaluateScript(String scriptName, Binding \
arguments) { </del><ins>+ protected Object evaluateScript(String scriptName, \
Binding arguments) throws Exception { </ins><span class="cx"> return \
getScriptedConfiguration().evaluate(scriptName, arguments, null) </span><span \
class="cx"> } </span><span class="cx">
</span><del>- protected Binding createBinding(final Binding arguments, Action \
action, final ObjectClass objectClass, final Uid uid, final Set<Attribute> \
attributes,
- final OperationOptions options) {
</del><ins>+ protected Binding createBinding(
+ final Binding arguments, OperationType action,
+ final ObjectClass objectClass, final Uid uid, final Set<Attribute> \
attributes, + final OperationOptions options) {
</ins><span class="cx"> arguments.setVariable(ACTION, action);
</span><span class="cx"> if (null != objectClass) {
</span><span class="cx"> arguments.setVariable(OBJECT_CLASS, \
objectClass); </span><span class="lines">@@ -694,12 +635,20 @@
</span><span class="cx"> if (null != uid) {
</span><span class="cx"> arguments.setVariable(UID, uid);
</span><span class="cx"> }
</span><del>-// if (null != attributes) {
-// AttributesAccessor accessor = new AttributesAccessor(attributes);
-// arguments.setVariable(ATTRIBUTES, accessor);
-// Name name = accessor.getName();
-// arguments.setVariable(ID, null != name ? name : null);
-// }
</del><ins>+ if (null != attributes) {
+ //Filter out the __NAME__ here. The __UID__ is filtered out by the \
Framework + Set<Attribute> attributeSet = new \
HashSet<Attribute>() + Attribute name = null;
+ for (Attribute a : attributes) {
+ if (a.is(Name.NAME)) {
+ name = a;
+ } else {
+ attributeSet.add(a)
+ }
+ }
+ arguments.setVariable(ATTRIBUTES, attributeSet);
+ arguments.setVariable(ID, null != name ? \
AttributeUtil.getStringValue(name) : null); + }
</ins><span class="cx"> if (null != options) {
</span><span class="cx"> arguments.setVariable(OPTIONS, options);
</span><span class="cx"> }
</span><span class="lines">@@ -709,59 +658,21 @@
</span><span class="cx"> return arguments;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- protected Object getGuardedStringValue(GuardedString password) {
- // Password - if allowed we provide it in clear
- if (getScriptedConfiguration().getClearTextPasswordToScript()) {
- if (password != null) {
- return SecurityUtil.decrypt(password);
- }
</del><ins>+ protected Uid returnUid(OperationType action, ObjectClass \
objectClass, Object uidAfter) { + if (uidAfter instanceof String) {
+ logger.ok(action.debugTrace(), objectClass.getObjectClassValue(), \
uidAfter); + return new Uid((String) uidAfter);
+ } else if (uidAfter instanceof Uid) {
+ logger.ok(action.debugTrace(), objectClass.getObjectClassValue(), \
uidAfter.uidValue); + return (Uid) uidAfter;
+ } else if (null != uidAfter) {
+ throw new ConnectorException(action.fail2(uidAfter.getClass()));
</ins><span class="cx"> } else {
</span><del>- return { clearString ->
- if (password != null) {
- password.access(new GuardedString.Accessor() {
- @Override
- public void access(char[] clearChars) {
- if (clearString instanceof Closure) {
- clearString(new String(clearChars));
- } else {
- clearString = new String(clearChars);
- }
- }
- });
- clearString
- }
- };
</del><ins>+ throw new ConnectorException(action.fail1());
</ins><span class="cx"> }
</span><del>- return null;
</del><span class="cx"> }
</span><span class="cx">
</span><del>- protected Object getGuardedByteArrayValue(GuardedByteArray password) \
{
- // Password - if allowed we provide it in clear
- if (getScriptedConfiguration().getClearTextPasswordToScript()) {
- if (password != null) {
- return SecurityUtil.decrypt(password);
- }
- } else {
- return { clearBytesOut ->
- if (password != null) {
- password.access(new GuardedByteArray.Accessor() {
- @Override
- void access(byte[] clearBytes) {
- if (clearBytesOut instanceof Closure) {
- clearBytesOut(clearBytes);
- } else {
- clearBytesOut = clearBytes;
- }
- }
- });
- clearBytesOut
- }
- };
- }
- return null;
- }
-
- protected Object genericUpdate(String scriptName, Action method, ObjectClass \
objectClass, Uid uid, Set<Attribute> attributes, </del><ins>+ protected \
Object genericUpdate(String scriptName, OperationType method, ObjectClass \
objectClass, Uid uid, Set<Attribute> attributes, </ins><span class="cx"> \
OperationOptions options) { </span><span class="cx"> final Binding arguments \
= new Binding(); </span><span class="cx"> final Map<String, Object> \
attributesMap = new HashMap<String, Object>() </span><span class="lines">@@ \
-772,10 +683,10 @@ </span><span class="cx"> if (attribute.is(Name.NAME)) \
{ </span><span class="cx"> arguments.setVariable(ID, \
AttributeUtil.getSingleValue(attribute)) </span><span class="cx"> } else \
if ((attribute.is(OperationalAttributes.PASSWORD_NAME) || </span><del>- \
attribute.is(OperationalAttributes.CURRENT_PASSWORD_NAME)) && \
method.equals(Action.UPDATE)) { </del><ins>+ \
attribute.is(OperationalAttributes.CURRENT_PASSWORD_NAME)) && \
method.equals(OperationType.UPDATE)) { </ins><span class="cx"> \
attributesMap.put(attribute.getName(), </span><span class="cx"> \
getGuardedStringValue(AttributeUtil.getGuardedStringValue(attribute))); </span><del>- \
} else if (OperationalAttributes.isOperationalAttribute(attribute) && \
method.equals(Action.UPDATE)) { </del><ins>+ } else if \
(OperationalAttributes.isOperationalAttribute(attribute) && \
method.equals(OperationType.UPDATE)) { </ins><span class="cx"> \
attributesMap.put(attribute.getName(), attribute.getValue()); </span><span \
class="cx"> } else { </span><span class="cx"> \
attributesMap.put(attribute.getName(), attribute.getValue()); \
</span></span></pre></div> <a \
id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnectorsgroovyScr \
iptedConnectorjavafromrev6504trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnectorsgroovyScriptedConnectorgroovy"></a>
<div class="copfile"><h4>Copied: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/groovy/ScriptedConnector.java \
(from rev 6504, trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/groovy/ScriptedConnector.groovy) \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/groovy/ScriptedConnector.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/groovy/ScriptedConnector.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors.groovy;
+
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration;
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase;
+import org.identityconnectors.framework.spi.Connector;
+import org.identityconnectors.framework.spi.ConnectorClass;
+
+/**
+ * A ScriptedConnector is a generic Groovy Connector.
+ *
+ * @author Laszlo Hordos
+ */
+@ConnectorClass(displayNameKey = "groovy.connector.display",
+ configurationClass = ScriptedConfiguration.class)
+public class ScriptedConnector extends \
ScriptedConnectorBase<ScriptedConfiguration> implements Connector { +}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnectorsgroovy \
ScriptedPoolableConnectorjavafromrev6504trunkconnectorsjavascriptedcommonsrcmaingroovyorgforgerockopenicfconnectorsgroovyScriptedPoolableConnectorgroovy"></a>
<div class="copfile"><h4>Copied: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/groovy/ScriptedPoolableConnector.java \
(from rev 6504, trunk/connectors/java/scriptedcommon/src/main/groovy/org/forgerock/openicf/connectors/groovy/ScriptedPoolableConnector.groovy) \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/groovy/ScriptedPoolableConnector.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/groovy/ScriptedPoolableConnector.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,67 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors.groovy;
+
+import java.util.Set;
+
+import org.forgerock.openicf.misc.scriptedcommon.OperationType;
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration;
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase;
+import org.identityconnectors.common.StringUtil;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptions;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.identityconnectors.framework.spi.ConnectorClass;
+import org.identityconnectors.framework.spi.PoolableConnector;
+
+import groovy.lang.Binding;
+
+/**
+ * A ScriptedPoolableConnector is a generic Groovy Poolable Connector.
+ *
+ * @author Laszlo Hordos
+ */
+@ConnectorClass(displayNameKey = "groovy.poolable.connector.display",
+ configurationClass = ScriptedConfiguration.class)
+public class ScriptedPoolableConnector extends \
ScriptedConnectorBase<ScriptedConfiguration> + implements \
PoolableConnector { +
+ @Override
+ public void checkAlive() {
+ }
+
+ @Override
+ protected Binding createBinding(Binding arguments, OperationType action, \
ObjectClass objectClass, Uid uid, + \
Set<Attribute> attributes, OperationOptions options) { + Binding binding \
= super.createBinding(arguments, action, objectClass, uid, attributes, options); + \
if (!OperationType.SCHEMA.equals(action) && StringUtil + \
.isNotBlank(getScriptedConfiguration().getSchemaScriptFileName())) { + \
arguments.setVariable(SCHEMA, schema()); + }
+ return binding;
+ }
+
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnectorsscriptedcrestScriptedCRESTConnectorjava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedcrest/ScriptedCRESTConnector.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedcrest/ScriptedCRESTConnector.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedcrest/ScriptedCRESTConnector.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,70 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors.scriptedcrest;
+
+import java.util.Set;
+
+import org.forgerock.openicf.misc.scriptedcommon.OperationType;
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase;
+import org.identityconnectors.common.StringUtil;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptions;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.identityconnectors.framework.spi.ConnectorClass;
+import org.identityconnectors.framework.spi.PoolableConnector;
+
+import groovy.lang.Binding;
+
+/**
+ * A NAME does ...
+ *
+ * @author Laszlo Hordos
+ */
+@ConnectorClass(displayNameKey = "groovy.crest.connector.display",
+ configurationClass = ScriptedCRESTConfiguration.class,
+ messageCatalogPaths = \
{"org/forgerock/openicf/connectors/groovy/Messages", + \
"org/forgerock/openicf/connectors/scriptedrest/Messages", + \
"org/forgerock/openicf/connectors/scriptedcrest/Messages"}) +public class \
ScriptedCRESTConnector extends \
ScriptedConnectorBase<ScriptedCRESTConfiguration> + implements \
PoolableConnector { +
+ @Override
+ public void checkAlive() {
+ }
+
+ @Override
+ protected Binding createBinding(Binding arguments, OperationType action, \
ObjectClass objectClass, + Uid uid, \
Set<Attribute> attributes, OperationOptions options) { + Binding b = \
super.createBinding(arguments, action, objectClass, uid, attributes, options); + \
b.setVariable(CONNECTION, new RemoteConnection( + \
(ScriptedCRESTConfiguration) getScriptedConfiguration())); + if \
(!OperationType.SCHEMA.equals(action) && StringUtil + \
.isNotBlank(getScriptedConfiguration().getSchemaScriptFileName())) { + \
arguments.setVariable(SCHEMA, schema()); + }
+ return b;
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnectorsscriptedcrestStreamingJsonSlurperjava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedcrest/StreamingJsonSlurper.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedcrest/StreamingJsonSlurper.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedcrest/StreamingJsonSlurper.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,269 @@
</span><ins>+/*
+ * Copyright 2003-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.forgerock.openicf.connectors.scriptedcrest;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.http.HttpEntity;
+import org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport;
+import org.codehaus.groovy.runtime.IOGroovyMethods;
+import org.forgerock.json.resource.QueryResult;
+
+import groovy.json.JsonException;
+import groovy.json.JsonLexer;
+import groovy.json.JsonToken;
+import groovy.lang.Closure;
+import static groovy.json.JsonTokenType.*;
+
+/**
+ * JSON slurper which parses text or reader content into a data structure of lists \
and maps. + * <p/>
+ * Example usage: <code><pre>
+ * def slurper = new JsonSlurper()
+ * def result = slurper.parseText('{"person":{"name":"Guilla \
ume","age":33,"pets":["dog","cat"]}}') + \
* <p/> + * assert result.person.name == "Guillaume"
+ * assert result.person.age == 33
+ * assert result.person.pets.size() == 2
+ * assert result.person.pets[0] == "dog"
+ * assert result.person.pets[1] == "cat"
+ * </pre></code>
+ *
+ * @author Guillaume Laforge
+ * @since 1.8.0
+ */
+public class StreamingJsonSlurper {
+
+ /**
+ * Parse a JSON data structure from content from a reader
+ *
+ * @param reader
+ * reader over a JSON content
+ * @return a data structure of lists and maps
+ */
+ public Object parse(Reader reader, Closure handler, Closure<Object> \
callback) { + Object content = null;
+
+ JsonLexer lexer = new JsonLexer(reader);
+
+ JsonToken token = lexer.nextToken();
+ if (token.getType() == OPEN_CURLY) {
+ content = parseObject(lexer, handler);
+ } else if (token.getType() == OPEN_BRACKET) {
+ parseArray(lexer, handler);
+ } else {
+ throw new JsonException("A JSON payload should start with " + \
OPEN_CURLY.getLabel() + + " or " + \
OPEN_BRACKET.getLabel() + ".\n" + "Instead, '" + token.getText() \
+ + "' was found " + "on line: " + \
token.getStartLine() + ", " + "column: " + + \
token.getStartColumn()); + }
+
+ if (null != callback) {
+ callback.call(lexer, content);
+ }
+ return content;
+ }
+
+ public Object parse(HttpEntity entity, Closure handler, Closure<Object> \
callback) { + Reader reader = null;
+ try {
+ return parse(IOGroovyMethods.newReader(entity.getContent()), handler, \
callback); + } catch (IOException ioe) {
+ throw new JsonException("Unable to process Entity Content", \
ioe); + } finally {
+ if (reader != null) {
+ DefaultGroovyMethodsSupport.closeWithWarning(reader);
+ }
+ }
+ }
+
+ /**
+ * Parse an array from the lexer
+ *
+ * @param lexer
+ * the lexer
+ * @return a list of JSON values
+ */
+ @SuppressWarnings("unchecked")
+ private List parseArray(JsonLexer lexer, Closure handler) {
+ List content = new ArrayList();
+
+ JsonToken currentToken;
+
+ for (; ; ) {
+ currentToken = lexer.nextToken();
+
+ if (currentToken == null) {
+ throw new JsonException("Expected a value on line: " + \
lexer.getReader().getLine() + + ", " + "column: \
" + lexer.getReader().getColumn() + ".\n" + + \
"But got an unterminated array."); + }
+
+ if (currentToken.getType() == OPEN_CURLY) {
+ if (null != handler) {
+ handler.call(parseObject(lexer, null));
+ } else {
+ content.add(parseObject(lexer, handler));
+ }
+ } else if (currentToken.getType() == OPEN_BRACKET) {
+ content.add(parseArray(lexer, handler));
+ } else if (currentToken.getType().ordinal() >= NULL.ordinal()) {
+ content.add(currentToken.getValue());
+ } else if (currentToken.getType() == CLOSE_BRACKET) {
+ return content;
+ } else {
+ throw new JsonException("Expected a value, an array, or an \
object " + "on line: " + + \
currentToken.getStartLine() + ", " + "column: " + \
+ currentToken.getStartColumn() + ".\n" + "But got '" + \
+ currentToken.getText() + "' instead."); + }
+
+ currentToken = lexer.nextToken();
+
+ if (currentToken == null) {
+ throw new JsonException("Expected " + \
CLOSE_BRACKET.getLabel() + " " + "or " + + \
COMMA.getLabel() + " " + "on line: " + \
lexer.getReader().getLine() + ", " + + "column: \
" + lexer.getReader().getColumn() + ".\n" + + \
"But got an unterminated array."); + }
+
+ // Expect a comma for an upcoming value
+ // or a closing bracket for the end of the array
+ if (currentToken.getType() == CLOSE_BRACKET) {
+ break;
+ } else if (currentToken.getType() != COMMA) {
+ throw new JsonException("Expected a value or " + \
CLOSE_BRACKET.getLabel() + " " + + "on line: \
" + currentToken.getStartLine() + " " + "column: " + \
+ currentToken.getStartColumn() + ".\n" + "But got '" + \
+ currentToken.getText() + "' instead."); + }
+ }
+
+ return content;
+ }
+
+ /**
+ * Parses an object from the lexer
+ *
+ * @param lexer
+ * the lexer
+ * @return a Map representing a JSON object
+ */
+ private Map parseObject(JsonLexer lexer, Closure handler) {
+ Map content = new HashMap();
+
+ JsonToken previousToken = null;
+ JsonToken currentToken = null;
+
+ for (; ; ) {
+ currentToken = lexer.nextToken();
+
+ if (currentToken == null) {
+ throw new JsonException("Expected a String key on line: "
+ + lexer.getReader().getLine() + ", " + \
"column: " + + lexer.getReader().getColumn() + \
".\n" + "But got an unterminated object."); + }
+
+ // expect a string key, or already a closing curly brace
+
+ if (currentToken.getType() == CLOSE_CURLY) {
+ return content;
+ } else if (currentToken.getType() != STRING) {
+ throw new JsonException("Expected " + STRING.getLabel() + \
" key " + "on line: " + + \
currentToken.getStartLine() + ", " + "column: " + \
+ currentToken.getStartColumn() + ".\n" + "But got '" + \
+ currentToken.getText() + "' instead."); + }
+
+ String mapKey = (String) currentToken.getValue();
+
+ currentToken = lexer.nextToken();
+
+ if (currentToken == null) {
+ throw new JsonException("Expected a " + COLON.getLabel() + \
" " + "on line: " + + \
lexer.getReader().getLine() + ", " + "column: " + \
+ lexer.getReader().getColumn() + ".\n" + "But got an unterminated \
object."); + }
+
+ // expect a colon between the key and value pair
+
+ if (currentToken.getType() != COLON) {
+ throw new JsonException("Expected " + COLON.getLabel() + \
" " + "on line: " + + \
currentToken.getStartLine() + ", " + "column: " + \
+ currentToken.getStartColumn() + ".\n" + "But got '" + \
+ currentToken.getText() + "' instead."); + }
+
+ currentToken = lexer.nextToken();
+
+ if (currentToken == null) {
+ throw new JsonException("Expected a value " + "on \
line: " + + lexer.getReader().getLine() + ", " \
+ "column: " + + lexer.getReader().getColumn() + \
".\n" + "But got an unterminated object."); + }
+
+ // value can be an object, an array, a number, string, boolean or
+ // null values
+
+ if (currentToken.getType() == OPEN_CURLY) {
+ content.put(mapKey, parseObject(lexer, null));
+ } else if (currentToken.getType() == OPEN_BRACKET) {
+ if (mapKey.equals(QueryResult.FIELD_RESULT)) {
+ content.put(mapKey, parseArray(lexer, handler));
+ } else {
+ content.put(mapKey, parseArray(lexer, null));
+ }
+ } else if (currentToken.getType().ordinal() >= NULL.ordinal()) {
+ content.put(mapKey, currentToken.getValue());
+ } else {
+ throw new JsonException("Expected a value, an array, or an \
object " + "on line: " + + \
currentToken.getStartLine() + ", " + "column: " + \
+ currentToken.getStartColumn() + ".\n" + "But got '" + \
+ currentToken.getText() + "' instead."); + }
+
+ previousToken = currentToken;
+ currentToken = lexer.nextToken();
+
+ // premature end of the object
+
+ if (currentToken == null) {
+ throw new JsonException("Expected " + \
CLOSE_CURLY.getLabel() + " or " + + COMMA.getLabel() \
+ " " + "on line: " + previousToken.getEndLine() + ", " \
+ + "column: " + previousToken.getEndColumn() + \
".\n" + + "But got an unterminated \
object."); + }
+
+ // Expect a comma for an upcoming key/value pair
+ // or a closing curly brace for the end of the object
+ if (currentToken.getType() == CLOSE_CURLY) {
+ break;
+ } else if (currentToken.getType() != COMMA) {
+ throw new JsonException("Expected a value or " + \
CLOSE_CURLY.getLabel() + " " + + "on line: \
" + currentToken.getStartLine() + ", " + "column: " + \
+ currentToken.getStartColumn() + ".\n" + "But got '" + \
+ currentToken.getText() + "' instead."); + }
+ }
+
+ return content;
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnectorsscriptedrestScriptedRESTConnectorjava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedrest/ScriptedRESTConnector.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedrest/ScriptedRESTConnector.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedrest/ScriptedRESTConnector.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013-2014 ForgeRock AS All rights reserved.
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+package org.forgerock.openicf.connectors.scriptedrest;
+
+import java.util.Set;
+
+import org.forgerock.openicf.misc.scriptedcommon.OperationType;
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptions;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.identityconnectors.framework.spi.Connector;
+import org.identityconnectors.framework.spi.ConnectorClass;
+
+import groovy.lang.Binding;
+
+/**
+ * Main implementation of the ScriptedREST Connector.
+ *
+ * @author Gael Allioux <gael.allioux@forgerock.com>
+ */
+@ConnectorClass(displayNameKey = "groovy.rest.connector.display",
+ configurationClass = ScriptedRESTConfiguration.class,
+ messageCatalogPaths = \
{"org/forgerock/openicf/connectors/groovy/Messages", + \
"org/forgerock/openicf/connectors/scriptedrest/Messages"}) +public class \
ScriptedRESTConnector extends ScriptedConnectorBase<ScriptedRESTConfiguration> \
+ implements Connector { +
+ protected Binding createBinding(Binding arguments, OperationType action, \
ObjectClass objectClass, + Uid uid, \
Set<Attribute> attributes, OperationOptions options) { + Binding b = \
super.createBinding(arguments, action, objectClass, uid, attributes, options); + \
b.setVariable(CONNECTION, ((ScriptedRESTConfiguration) getScriptedConfiguration()) + \
.getRESTClient()); + return b;
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnectorsscriptedrestpackageinfojava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedrest/package-info.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedrest/package-info.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedrest/package-info.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+/*
+ * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 ForgeRock Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+/**
+ * This is the core package for the connector.
+ *
+ */
+package org.forgerock.openicf.connectors.scriptedrest;
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnectorsscriptedsqlScriptedSQLConnectorjava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedsql/ScriptedSQLConnector.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedsql/ScriptedSQLConnector.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedsql/ScriptedSQLConnector.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * " Portions Copyrighted [year] [name of copyright owner]"
+ *
+ */
+package org.forgerock.openicf.connectors.scriptedsql;
+
+import java.sql.Connection;
+
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase;
+import org.identityconnectors.framework.spi.Connector;
+import org.identityconnectors.framework.spi.ConnectorClass;
+
+import groovy.lang.Binding;
+
+/**
+ * Main implementation of the ScriptedSQL Connector.
+ *
+ * @author Gael Allioux <gael.allioux@forgerock.com>
+ */
+@ConnectorClass(displayNameKey = "groovy.sql.connector.display",
+ configurationClass = ScriptedSQLConfiguration.class,
+ messageCatalogPaths = \
{"org/forgerock/openicf/connectors/groovy/Messages", + \
"org/forgerock/openicf/connectors/scriptedsql/Messages"}) +public class \
ScriptedSQLConnector extends ScriptedConnectorBase<ScriptedSQLConfiguration> \
implements + Connector {
+
+ protected Object evaluateScript(String scriptName, Binding arguments) throws \
Exception { + final Connection c =
+ ((ScriptedSQLConfiguration) \
getScriptedConfiguration()).getDataSource() + \
.getConnection(); + try {
+ arguments.setVariable(CONNECTION, c);
+ return super.evaluateScript(scriptName, arguments);
+ } finally {
+ // Put back the connection to pool
+ c.close();
+ }
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfconnectorsscriptedsqlpackageinfojava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedsql/package-info.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedsql/package-info.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/connectors/scriptedsql/package-info.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+/*
+ * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2012 ForgeRock Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+/**
+ * This is the core package for the connector.
+ *
+ */
+package org.forgerock.openicf.connectors.scriptedsql;
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmisccrestAbstractRemoteConnectionjava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/crest/AbstractRemoteConnection.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/crest/AbstractRemoteConnection.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/crest/AbstractRemoteConnection.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,908 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.misc.crest;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.regex.Pattern;
+
+import org.apache.http.ContentTooLongException;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.annotation.Immutable;
+import org.apache.http.client.HttpResponseException;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPatch;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.entity.ContentType;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.IOControl;
+import org.apache.http.nio.entity.ContentBufferEntity;
+import org.apache.http.nio.protocol.AbstractAsyncResponseConsumer;
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
+import org.apache.http.nio.util.HeapByteBufferAllocator;
+import org.apache.http.nio.util.SimpleInputBuffer;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Asserts;
+import org.apache.http.util.EntityUtils;
+import org.forgerock.json.fluent.JsonPointer;
+import org.forgerock.json.fluent.JsonValue;
+import org.forgerock.json.fluent.JsonValueException;
+import org.forgerock.json.resource.ActionRequest;
+import org.forgerock.json.resource.Connection;
+import org.forgerock.json.resource.Context;
+import org.forgerock.json.resource.CreateRequest;
+import org.forgerock.json.resource.DeleteRequest;
+import org.forgerock.json.resource.FutureResult;
+import org.forgerock.json.resource.InternalServerErrorException;
+import org.forgerock.json.resource.PatchOperation;
+import org.forgerock.json.resource.PatchRequest;
+import org.forgerock.json.resource.QueryRequest;
+import org.forgerock.json.resource.QueryResult;
+import org.forgerock.json.resource.QueryResultHandler;
+import org.forgerock.json.resource.ReadRequest;
+import org.forgerock.json.resource.Request;
+import org.forgerock.json.resource.Resource;
+import org.forgerock.json.resource.ResourceException;
+import org.forgerock.json.resource.ResourceName;
+import org.forgerock.json.resource.ResultHandler;
+import org.forgerock.json.resource.ServiceUnavailableException;
+import org.forgerock.json.resource.SortKey;
+import org.forgerock.json.resource.UpdateRequest;
+
+/**
+ * A NAME does ...
+ *
+ * @author Laszlo Hordos
+ */
+public abstract class AbstractRemoteConnection implements Connection {
+
+ static final String ETAG_ANY = "*";
+ static final String PARAM_ACTION = param(ActionRequest.FIELD_ACTION);
+ static final String PARAM_FIELDS = param(Request.FIELD_FIELDS);
+ static final String PARAM_PAGE_SIZE = param(QueryRequest.FIELD_PAGE_SIZE);
+ static final String PARAM_PAGED_RESULTS_COOKIE = \
param(QueryRequest.FIELD_PAGED_RESULTS_COOKIE); + static final String \
PARAM_PAGED_RESULTS_OFFSET = param(QueryRequest.FIELD_PAGED_RESULTS_OFFSET); + \
static final String PARAM_QUERY_EXPRESSION = \
param(QueryRequest.FIELD_QUERY_EXPRESSION); + static final String \
PARAM_QUERY_FILTER = param(QueryRequest.FIELD_QUERY_FILTER); + static final String \
PARAM_QUERY_ID = param(QueryRequest.FIELD_QUERY_ID); + static final String \
PARAM_SORT_KEYS = param(QueryRequest.FIELD_SORT_KEYS); +
+ static final Pattern CONTENT_TYPE_REGEX = Pattern.compile(
+ "^application/json([ ]*;[ ]*charset=utf-8)?$", \
Pattern.CASE_INSENSITIVE); +
+
+ private final ResourceName resourceName;
+
+ private final HttpHost httpHost;
+
+ protected AbstractRemoteConnection(ResourceName resourceName, HttpHost httpHost) \
{ + this.resourceName = resourceName;
+ this.httpHost = httpHost;
+ }
+
+ public abstract <T> Future<T> execute(final HttpUriRequest request,
+ final HttpAsyncResponseConsumer<T> \
responseConsumer, + final \
FutureCallback<T> callback); +
+
+ protected abstract JsonValue parseJsonBody(final HttpEntity entity, final \
boolean allowEmpty) + throws ResourceException;
+
+ protected abstract QueryResult parseQueryResponse(final HttpResponse response,
+ final QueryResultHandler \
handler) throws ResourceException; +
+
+ public ResourceName getResourceName() {
+ return resourceName;
+ }
+
+ public HttpHost getHttpHost() {
+ return httpHost;
+ }
+
+
+ @Override
+ public void close() {
+ //Do Nothing
+ }
+
+ @Override
+ public boolean isValid() {
+ return !isClosed();
+ }
+
+ private final HttpAsyncResponseConsumer<JsonValue> \
JSON_VALUE_RESPONSE_HANDLER = + new JsonValueResponseHandler();
+
+ private final HttpAsyncResponseConsumer<Resource> \
RESOURCE_RESPONSE_HANDLER = + new ResourceResponseHandler();
+
+ @Override
+ public JsonValue action(final Context context, final ActionRequest request)
+ throws ResourceException {
+ final FutureResult<JsonValue> future = actionAsync(context, request, \
null); + try {
+ return future.get();
+ } catch (final InterruptedException e) {
+ throw interrupted(e);
+ } finally {
+ // Cancel the request if it hasn't completed.
+ future.cancel(false);
+ }
+ }
+
+ @Override
+ public FutureResult<JsonValue> actionAsync(final Context context, final \
ActionRequest request, + final \
ResultHandler<? super JsonValue> handler) { + try {
+
+ final Future<JsonValue> result =
+ execute(convert(request),
+ JSON_VALUE_RESPONSE_HANDLER, new \
InternalFutureCallback<JsonValue>( + \
(ResultHandler<JsonValue>) handler) + );
+
+ return new InternalFutureResult<JsonValue>(result);
+ } catch (final Throwable t) {
+ final ResourceException exception = adapt(t);
+ if (null != handler) {
+ handler.handleError(exception);
+ }
+ return new FailedFutureResult<JsonValue>(exception);
+ }
+ }
+
+ @Override
+ public QueryResult query(final Context context, final QueryRequest request,
+ final QueryResultHandler handler) throws \
ResourceException { + final FutureResult<QueryResult> future = \
queryAsync(context, request, handler); + try {
+ return future.get();
+ } catch (final InterruptedException e) {
+ throw interrupted(e);
+ } finally {
+ // Cancel the request if it hasn't completed.
+ future.cancel(false);
+ }
+ }
+
+ @Override
+ public QueryResult query(final Context context, final QueryRequest request,
+ final Collection<? super Resource> results) \
throws ResourceException { + final QueryResultHandler handler = new \
QueryResultHandler() { +
+ @Override
+ public void handleError(final ResourceException error) {
+ // Ignore - handled by future.
+ }
+
+ @Override
+ public boolean handleResource(final Resource resource) {
+ results.add(resource);
+ return true;
+ }
+
+ @Override
+ public void handleResult(final QueryResult result) {
+ // Ignore - handled by future.
+ }
+ };
+ return query(context, request, handler);
+ }
+
+ @Override
+ public FutureResult<QueryResult> queryAsync(Context context, QueryRequest \
request, + final QueryResultHandler \
handler) { + try {
+
+ final Future<QueryResult> result =
+ execute(convert(request),
+ new QueryResultResponseHandler(handler),
+ new InternalFutureCallback<QueryResult>(handler));
+
+ return new InternalFutureResult<QueryResult>(result);
+ } catch (final Throwable t) {
+ final ResourceException exception = adapt(t);
+ if (null != handler) {
+ handler.handleError(exception);
+ }
+ return new FailedFutureResult<QueryResult>(exception);
+ }
+ }
+
+
+ @Override
+ public Resource create(final Context context, final CreateRequest request)
+ throws ResourceException {
+ final FutureResult<Resource> future = createAsync(context, request, \
null); + try {
+ return future.get();
+ } catch (final InterruptedException e) {
+ throw interrupted(e);
+ } finally {
+ // Cancel the request if it hasn't completed.
+ future.cancel(false);
+ }
+ }
+
+
+ @Override
+ public FutureResult<Resource> createAsync(Context context, CreateRequest \
request, + ResultHandler<? super \
Resource> handler) { + return handleRequestAsync(request, handler);
+ }
+
+ @Override
+ public Resource delete(final Context context, final DeleteRequest request)
+ throws ResourceException {
+ final FutureResult<Resource> future = deleteAsync(context, request, \
null); + try {
+ return future.get();
+ } catch (final InterruptedException e) {
+ throw interrupted(e);
+ } finally {
+ // Cancel the request if it hasn't completed.
+ future.cancel(false);
+ }
+ }
+
+ @Override
+ public FutureResult<Resource> deleteAsync(Context context, DeleteRequest \
request, + ResultHandler<? super \
Resource> handler) { + return handleRequestAsync(request, handler);
+ }
+
+ @Override
+ public Resource patch(final Context context, final PatchRequest request)
+ throws ResourceException {
+ final FutureResult<Resource> future = patchAsync(context, request, \
null); + try {
+ return future.get();
+ } catch (final InterruptedException e) {
+ throw interrupted(e);
+ } finally {
+ // Cancel the request if it hasn't completed.
+ future.cancel(false);
+ }
+ }
+
+ @Override
+ public FutureResult<Resource> patchAsync(Context context, PatchRequest \
request, + ResultHandler<? super \
Resource> handler) { + return handleRequestAsync(request, handler);
+ }
+
+ @Override
+ public Resource read(final Context context, final ReadRequest request) throws \
ResourceException { + final FutureResult<Resource> future = \
readAsync(context, request, null); + try {
+ return future.get();
+ } catch (final InterruptedException e) {
+ throw interrupted(e);
+ } finally {
+ // Cancel the request if it hasn't completed.
+ future.cancel(false);
+ }
+ }
+
+ @Override
+ public FutureResult<Resource> readAsync(Context context, ReadRequest \
request, + ResultHandler<? super \
Resource> handler) { + return handleRequestAsync(request, handler);
+ }
+
+ @Override
+ public Resource update(final Context context, final UpdateRequest request)
+ throws ResourceException {
+ final FutureResult<Resource> future = updateAsync(context, request, \
null); + try {
+ return future.get();
+ } catch (final InterruptedException e) {
+ throw interrupted(e);
+ } finally {
+ // Cancel the request if it hasn't completed.
+ future.cancel(false);
+ }
+ }
+
+ @Override
+ public FutureResult<Resource> updateAsync(Context context, UpdateRequest \
request, + ResultHandler<? super \
Resource> handler) { + return handleRequestAsync(request, handler);
+ }
+
+ private HttpUriRequest convert(Request request) throws ResourceException {
+ URIBuilder builder = getUriBuilder(request);
+ HttpUriRequest rq = null;
+ try {
+ switch (request.getRequestType()) {
+ case ACTION: {
+ ActionRequest actionRequest = (ActionRequest) request;
+
+ builder.setParameter(PARAM_ACTION, actionRequest.getAction());
+ for (Map.Entry<String, String> entry : actionRequest
+ .getAdditionalParameters().entrySet()) {
+ builder.setParameter(entry.getKey(), entry.getValue());
+ }
+
+ HttpPost httpRequest = new HttpPost(builder.build());
+ httpRequest.setEntity(new \
JsonEntity(actionRequest.getContent())); +
+ rq = httpRequest;
+ rq.addHeader(HttpHeaders.ACCEPT, \
ContentType.APPLICATION_JSON.toString()); + \
rq.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); + \
break; + }
+ case CREATE: {
+ CreateRequest createRequest = (CreateRequest) request;
+
+ if (null == createRequest.getNewResourceId()) {
+ builder.setParameter(PARAM_ACTION, \
ActionRequest.ACTION_ID_CREATE); + HttpPost httpRequest = new \
HttpPost(builder.build()); + httpRequest.setEntity(new \
JsonEntity(createRequest.getContent())); + rq = httpRequest;
+ } else {
+ HttpPut httpRequest = new HttpPut(builder.build());
+ httpRequest.setEntity(new \
JsonEntity(createRequest.getContent())); + \
httpRequest.setHeader(HttpHeaders.IF_NONE_MATCH, ETAG_ANY); + \
rq = httpRequest; + }
+ rq.addHeader(HttpHeaders.ACCEPT, \
ContentType.APPLICATION_JSON.toString()); + \
rq.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); + \
break; + }
+ case UPDATE: {
+ UpdateRequest updateRequest = (UpdateRequest) request;
+
+ HttpPut httpRequest = new HttpPut(builder.build());
+ httpRequest.setEntity(new \
JsonEntity(updateRequest.getNewContent())); +
+ if (null != updateRequest.getRevision()) {
+ httpRequest.setHeader(HttpHeaders.ETAG, \
updateRequest.getRevision()); + }
+
+ rq = httpRequest;
+ rq.addHeader(HttpHeaders.ACCEPT, \
ContentType.APPLICATION_JSON.toString()); + \
rq.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); + \
break; + }
+ case PATCH: {
+ PatchRequest patchRequest = (PatchRequest) request;
+
+ List<Map<String, Object>> patch =
+ new ArrayList<Map<String, \
Object>>(patchRequest.getPatchOperations().size()); + for \
(PatchOperation operation : patchRequest.getPatchOperations()) { + \
patch.add(operation.toJsonValue().asMap()); + }
+
+ HttpPatch httpRequest = new HttpPatch(builder.build());
+ httpRequest.setEntity(new JsonEntity(patch));
+
+ if (null != patchRequest.getRevision()) {
+ httpRequest.setHeader(HttpHeaders.ETAG, \
patchRequest.getRevision()); + }
+
+ rq = httpRequest;
+ rq.addHeader(HttpHeaders.ACCEPT, \
ContentType.APPLICATION_JSON.toString()); + \
rq.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); + \
break; + }
+ case DELETE: {
+ DeleteRequest deleteRequest = (DeleteRequest) request;
+
+ rq = new HttpDelete(builder.build());
+ if (null != deleteRequest.getRevision()) {
+ rq.setHeader(HttpHeaders.ETAG, deleteRequest.getRevision());
+ }
+ break;
+ }
+ case READ: {
+ rq = new HttpGet(builder.build());
+ break;
+ }
+ case QUERY: {
+ QueryRequest queryRequest = (QueryRequest) request;
+
+ for (Map.Entry<String, String> entry : \
queryRequest.getAdditionalQueryParameters() + .entrySet()) \
{ + builder.setParameter(entry.getKey(), entry.getValue());
+ }
+
+ if (null != queryRequest.getQueryId()) {
+ builder.setParameter(PARAM_QUERY_ID, \
queryRequest.getQueryId()); + } else if (null != \
queryRequest.getQueryFilter()) { + \
builder.setParameter(PARAM_QUERY_FILTER, queryRequest.getQueryFilter() + \
.toString()); + } else if (null != \
queryRequest.getQueryExpression()) { + \
builder.setParameter(PARAM_QUERY_EXPRESSION, queryRequest.getQueryExpression()); + \
} +
+ if (0 < queryRequest.getPageSize()) {
+ builder.setParameter(PARAM_PAGE_SIZE, \
Integer.toString(queryRequest + .getPageSize()));
+
+ if (null != queryRequest.getPagedResultsCookie()) {
+ builder.setParameter(PARAM_PAGED_RESULTS_COOKIE, \
queryRequest + .getPagedResultsCookie());
+ }
+ builder.setParameter(PARAM_PAGED_RESULTS_OFFSET, \
Integer.toString(queryRequest + \
.getPagedResultsOffset())); + }
+
+ for (SortKey key : queryRequest.getSortKeys()) {
+ builder.setParameter(PARAM_SORT_KEYS, key.toString());
+ }
+ rq = new HttpGet(builder.build());
+ break;
+ }
+ }
+ } catch (URISyntaxException e) {
+ throw new InternalServerErrorException(e);
+ }
+ return rq;
+ }
+
+ private URIBuilder getUriBuilder(Request request) {
+ ResourceName resourceName = \
getResourceName().concat(request.getResourceNameObject()); +
+ if (request instanceof CreateRequest
+ && null != ((CreateRequest) request).getNewResourceId()) {
+ resourceName = resourceName.concat(((CreateRequest) \
request).getNewResourceId()); + }
+
+ URIBuilder builder =
+ new \
URIBuilder().setScheme(getHttpHost().getSchemeName()).setHost(getHttpHost().getHostName())
+ .setPort(getHttpHost().getPort()).setPath("/" + \
resourceName.toString()); +
+ for (JsonPointer field : request.getFields()) {
+ builder.setParameter(PARAM_FIELDS, field.toString());
+ }
+ return builder;
+ }
+
+
+ private FutureResult<Resource> handleRequestAsync(Request request,
+ ResultHandler<? super \
Resource> handler) { + try {
+
+ final Future<Resource> result =
+ execute(convert(request),
+ RESOURCE_RESPONSE_HANDLER, new \
InternalFutureCallback<Resource>( + \
(ResultHandler<Resource>) handler) + );
+
+ return new InternalFutureResult<Resource>(result);
+ } catch (final Throwable t) {
+ final ResourceException exception = adapt(t);
+ if (null != handler) {
+ handler.handleError(exception);
+ }
+ return new FailedFutureResult<Resource>(exception);
+ }
+ }
+
+ // Handle thread interruption.
+ private ResourceException interrupted(final InterruptedException e) {
+ return new ServiceUnavailableException("Client thread \
interrupted", e); + }
+
+ // Internal Class definitions
+
+
+ @Immutable
+ static abstract public class AbstractJsonValueResponseHandler<T> extends \
AbstractAsyncResponseConsumer<T> { +
+ protected volatile HttpResponse response;
+ private volatile SimpleInputBuffer buf;
+
+ @Override
+ protected void onResponseReceived(final HttpResponse response) throws \
IOException { + this.response = response;
+ }
+
+ @Override
+ protected void onEntityEnclosed(
+ final HttpEntity entity, final ContentType contentType) throws \
IOException { + long len = entity.getContentLength();
+ if (len > Integer.MAX_VALUE) {
+ throw new ContentTooLongException("Entity content is too long: \
" + len); + }
+ if (len < 0) {
+ len = 4096;
+ }
+ this.buf = new SimpleInputBuffer((int) len, new \
HeapByteBufferAllocator()); + this.response.setEntity(new \
ContentBufferEntity(entity, this.buf)); + }
+
+ @Override
+ protected void onContentReceived(
+ final ContentDecoder decoder, final IOControl ioctrl) throws \
IOException { + Asserts.notNull(this.buf, "Content buffer");
+ this.buf.consumeContent(decoder);
+ }
+
+ @Override
+ protected void releaseResources() {
+ this.response = null;
+ this.buf = null;
+ }
+
+ }
+
+ /**
+ * A {@link org.apache.http.client.ResponseHandler} that returns the response \
body as a JsonValue for successful + * (2xx) responses. If the response code was \
>= 300, the response body is consumed and an {@link + * \
HttpResponseResourceException} is thrown. + * <p/>
+ * If this is used with {@link \
org.apache.http.client.HttpClient#execute(org.apache.http.client.methods.HttpUriRequest,
+ * org.apache.http.client.ResponseHandler)} , HttpClient may handle redirects \
(3xx responses) internally. + */
+ @Immutable
+ public class JsonValueResponseHandler extends \
AbstractJsonValueResponseHandler<JsonValue> { +
+ /**
+ * Returns the response body as a String if the response was successful (a \
2xx status code). If no response body + * exists, this returns null. If the \
response was unsuccessful (>= 300 status code), throws an {@link + * \
org.apache.http.client.HttpResponseException}. + */
+ @Override
+ protected JsonValue buildResult(HttpContext context) throws Exception {
+ return parseResponse(response);
+ }
+
+ }
+
+ /**
+ * A {@link org.apache.http.client.ResponseHandler} that returns the response \
body as a String for successful (2xx) + * responses. If the response code was \
>= 300, the response body is consumed and an {@link + * \
org.apache.http.client.HttpResponseException} is thrown. + * <p/>
+ * If this is used with {@link \
org.apache.http.client.HttpClient#execute(org.apache.http.client.methods.HttpUriRequest,
+ * org.apache.http.client.ResponseHandler)} , HttpClient may handle redirects \
(3xx responses) internally. + */
+ @Immutable
+ public class QueryResultResponseHandler extends \
AbstractJsonValueResponseHandler<QueryResult> { +
+ private final QueryResultHandler handler;
+
+ public QueryResultResponseHandler(final QueryResultHandler handler) {
+ this.handler = handler;
+ }
+
+ /**
+ * Returns the response body as a String if the response was successful (a \
2xx status code). If no response body + * exists, this returns null. If the \
response was unsuccessful (>= 300 status code), throws an {@link + * \
org.apache.http.client.HttpResponseException}. + */
+ public QueryResult buildResult(HttpContext context) throws Exception {
+
+ return parseQueryResponse(response, handler);
+
+ }
+
+ }
+
+ /**
+ * A {@link org.apache.http.client.ResponseHandler} that returns the response \
body as a Resource for successful + * (2xx) responses. If the response code was \
>= 300, the response body is consumed and an {@link + * \
HttpResponseResourceException} is thrown. + * <p/>
+ * If this is used with {@link \
org.apache.http.client.HttpClient#execute(org.apache.http.client.methods.HttpUriRequest,
+ * org.apache.http.client.ResponseHandler)} , HttpClient may handle redirects \
(3xx responses) internally. + */
+ @Immutable
+ public class ResourceResponseHandler extends \
AbstractJsonValueResponseHandler<Resource> { +
+ /**
+ * Returns the response body as a String if the response was successful (a \
2xx status code). If no response body + * exists, this returns null. If the \
response was unsuccessful (>= 300 status code), throws an {@link + * \
org.apache.http.client.HttpResponseException}. + */
+ public Resource buildResult(HttpContext context) throws Exception {
+
+ return getAsResource(parseResponse(response));
+
+ }
+
+
+ }
+
+ /**
+ * The HttpResponseResourceException wraps the {@link ResourceException} into \
{@link + * org.apache.http.client.HttpResponseException}.
+ * <p/>
+ * This exception is used inside {@link \
org.apache.http.client.ResponseHandler#handleResponse(org.apache.http.HttpResponse)}. \
+ */ + public static class HttpResponseResourceException extends \
HttpResponseException { +
+ private final ResourceException cause;
+
+ public HttpResponseResourceException(ResourceException wrapped) {
+ super(wrapped.getCode(), wrapped.getReason());
+ cause = wrapped;
+ }
+
+ @Override
+ public ResourceException getCause() {
+ return cause;
+ }
+ }
+
+ static private class InternalFutureCallback<R> implements \
FutureCallback<R> { +
+ private final ResultHandler<R> handler;
+
+ protected InternalFutureCallback(final ResultHandler<R> handler) {
+ this.handler = handler;
+ }
+
+ protected ResultHandler<R> getResultHandler() {
+ return handler;
+ }
+
+ protected R adapt(R source) throws ResourceException {
+ return source;
+ }
+
+ @Override
+ public void completed(final R s) {
+ final ResultHandler<R> handler = getResultHandler();
+ if (null != handler) {
+ try {
+ handler.handleResult(adapt(s));
+ } catch (final ResourceException e) {
+ handler.handleError(e);
+ }
+ }
+ }
+
+ @Override
+ public void failed(final Exception e) {
+ final ResultHandler<R> handler = getResultHandler();
+ if (null != handler) {
+ if (e instanceof HttpResponseResourceException) {
+ handler.handleError(((HttpResponseResourceException) \
e).getCause()); + } else {
+ handler.handleError(new InternalServerErrorException(e));
+ }
+ }
+ }
+
+ @Override
+ public void cancelled() {
+ final ResultHandler<R> handler = getResultHandler();
+ if (null != handler) {
+ handler.handleError(new ServiceUnavailableException("Client \
thread interrupted")); + }
+ }
+ }
+
+ /**
+ * @param <
+ * T >
+ */
+ private static class InternalFutureResult<T> implements \
FutureResult<T> { +
+ private final Future<T> futureTask;
+
+ protected InternalFutureResult(final Future<T> futureTask) {
+ this.futureTask = futureTask;
+ }
+
+ protected Future<T> getResult() {
+ return futureTask;
+ }
+
+ @Override
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ return getResult().cancel(mayInterruptIfRunning);
+ }
+
+ @Override
+ public T get() throws ResourceException, InterruptedException {
+ try {
+ return getResult().get();
+ } catch (ExecutionException e) {
+ final Throwable cause = e.getCause();
+ if (cause instanceof ResourceException) {
+ throw (ResourceException) cause;
+ }
+ throw new InternalServerErrorException(e);
+ }
+ }
+
+ @Override
+ public T get(long timeout, TimeUnit unit) throws ResourceException, \
TimeoutException, + InterruptedException {
+ try {
+ return getResult().get(timeout, unit);
+ } catch (ExecutionException e) {
+ final Throwable cause = e.getCause();
+ if (cause instanceof ResourceException) {
+ throw (ResourceException) cause;
+ }
+ throw new InternalServerErrorException(e);
+ }
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return getResult().isCancelled();
+ }
+
+ @Override
+ public boolean isDone() {
+ return getResult().isDone();
+ }
+ }
+
+ static class FailedFutureResult<V> implements FutureResult<V> {
+ private ResourceException exception;
+
+ FailedFutureResult(final ResourceException result) {
+ this.exception = result;
+ }
+
+ @Override
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ return false; // Cannot cancel.
+ }
+
+ @Override
+ public V get() throws ResourceException, InterruptedException {
+ throw exception;
+ }
+
+ @Override
+ public V get(long timeout, TimeUnit unit) throws ResourceException, \
TimeoutException, + InterruptedException {
+ throw exception;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return false;
+ }
+
+ @Override
+ public boolean isDone() {
+ return true;
+ }
+
+ }
+
+ //
+ // Protected static methods
+ //
+
+ protected static Resource getAsResource(final JsonValue value) throws \
ResourceException { + try {
+ return new \
Resource(value.get(Resource.FIELD_CONTENT_ID).required().asString(), value + \
.get(Resource.FIELD_CONTENT_REVISION).asString(), value); + } catch \
(JsonValueException e) { + // What shell we do if the response does not \
contains the _id + throw new InternalServerErrorException(e);
+ }
+ }
+
+ protected static ResourceException getAsResourceException(JsonValue \
resourceException) { + ResourceException exception = null;
+ if (resourceException.isMap()) {
+ JsonValue code = resourceException.get(ResourceException.FIELD_CODE);
+ if (code.isNumber()) {
+ String message = \
resourceException.get(ResourceException.FIELD_MESSAGE).asString(); +
+ exception = ResourceException.getException(code.asInteger(), \
message); +
+ String reason = \
resourceException.get(ResourceException.FIELD_REASON).asString(); + if \
(null != reason) { + exception.setReason(reason);
+ }
+
+ JsonValue detail = \
resourceException.get(ResourceException.FIELD_DETAIL); + if \
(!detail.isNull()) { + exception.setDetail(detail);
+ }
+ }
+ }
+ return exception;
+ }
+
+ protected ResourceException isOK(StatusLine statusLine, HttpEntity entity) {
+ ResourceException exception = null;
+ if (statusLine.getStatusCode() >= 300) {
+
+ String contentType = entity.getContentType().getValue();
+ if (contentType != null && \
CONTENT_TYPE_REGEX.matcher(contentType).matches()) { + try {
+ JsonValue resourceException = parseJsonBody(entity, true);
+
+ exception = getAsResourceException(resourceException);
+
+ } catch (ResourceException e) {
+ /* ignore */
+ }
+ } else {
+ try {
+ EntityUtils.consume(entity);
+ } catch (IOException e) {
+ /* ignore */
+ }
+ }
+ if (null == exception) {
+ exception =
+ ResourceException.getException(statusLine.getStatusCode(), \
statusLine + .getReasonPhrase());
+ }
+ }
+ return exception;
+ }
+
+ protected JsonValue parseResponse(final HttpResponse response) throws \
ResourceException { + final StatusLine statusLine = response.getStatusLine();
+ final HttpEntity entity = response.getEntity();
+ ResourceException exception = isOK(statusLine, entity);
+ if (null != exception) {
+ throw exception;
+ }
+ return parseJsonBody(entity, true);
+ }
+
+ protected static String param(final String field) {
+ return "_" + field;
+ }
+
+ /**
+ * Adapts an {@code Exception} to a {@code ResourceException}.
+ *
+ * @param t
+ * The exception which caused the request to fail.
+ * @return The equivalent resource exception.
+ */
+ protected static ResourceException adapt(final Throwable t) {
+ if (t instanceof ResourceException) {
+ return (ResourceException) t;
+ } else {
+ return new InternalServerErrorException(t);
+ }
+ }
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmisccrestJsonEntityjava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/crest/JsonEntity.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/crest/JsonEntity.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/crest/JsonEntity.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.misc.crest;
+
+import java.util.Map;
+
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.forgerock.json.fluent.JsonValue;
+
+import groovy.json.JsonOutput;
+
+/**
+ * A self contained, repeatable entity that obtains its content from a {@link \
String}. + *
+ * @author Laszlo Hordos
+ */
+@NotThreadSafe
+class JsonEntity extends StringEntity {
+
+ /**
+ * Creates a JsonEntity with the specified content.
+ *
+ * @param content
+ * content to be used. Not {@code null}.
+ * @throws IllegalArgumentException
+ * if the source parameter is null
+ */
+ public JsonEntity(final Object content) {
+ super(getJsonContent(content), ContentType.APPLICATION_JSON);
+ }
+
+ /**
+ * Creates a JsonEntity.
+ *
+ * @throws IllegalArgumentException
+ * if the string parameter is null
+ */
+ public JsonEntity(final String string) {
+ super(string, ContentType.APPLICATION_JSON);
+ }
+
+ private static String getJsonContent(Object source) {
+
+ Object value = null;
+ if (source instanceof JsonValue) {
+ value = ((JsonValue) source).getObject();
+ } else {
+ value = source;
+ }
+ if (value instanceof Map) {
+ return JsonOutput.toJson((Map) value);
+ } else if (value instanceof Number) {
+ return JsonOutput.toJson((Number) value);
+ } else if (value instanceof String) {
+ return JsonOutput.toJson((String) value);
+ } else if (value instanceof Boolean) {
+ return JsonOutput.toJson((Boolean) value);
+ }
+ return JsonOutput.toJson(value);
+
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscriptedcommonFilterVisitorjava"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/FilterVisitor.java \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/FilterVisitor.java 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/FilterVisitor.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -39,32 +39,29 @@
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * A visitor of {@code Filter}s, in the style of the visitor \
design pattern. </span><del>- * <p>
- * Classes implementing this interface can query filters in a type-safe manner.
- * When a visitor is passed to a filter's accept method, the corresponding visit
- * method most applicable to that filter is invoked.
</del><ins>+ * <p/>
+ * Classes implementing this interface can query filters in a type-safe manner. When \
a visitor is passed to a filter's + * accept method, the corresponding visit method \
most applicable to that filter is invoked. </ins><span class="cx"> *
</span><span class="cx"> * @param <R>
</span><del>- * The return type of this visitor's methods. Use
- * {@link java.lang.Void} for visitors that do not need to return
- * results.
</del><ins>+ * The return type of this visitor's methods. Use {@link \
java.lang.Void} for visitors that do not need to return + * results.
</ins><span class="cx"> * @param <P>
</span><del>- * The type of the additional parameter to this visitor's \
methods.
- * Use {@link java.lang.Void} for visitors that do not need an
- * additional parameter.
</del><ins>+ * The type of the additional parameter to this visitor's \
methods. Use {@link java.lang.Void} for visitors that + * do not need an \
additional parameter. </ins><span class="cx"> */
</span><span class="cx"> public interface FilterVisitor<P, R> {
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Visits an {@code and} filter.
</span><del>- * <p>
- * <b>Implementation note</b>: for the purposes of matching, an \
empty
- * sub-filter list should always evaluate to {@code true}.
</del><ins>+ * <p/>
+ * <b>Implementation note</b>: for the purposes of matching, an \
empty sub-filter list should always evaluate to + * {@code true}.
</ins><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param subFilters
</span><del>- * The unmodifiable list of sub-filters.
</del><ins>+ * The unmodifiable list of sub-filters.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, AndFilter subFilters);
</span><span class="lines">@@ -73,9 +70,9 @@
</span><span class="cx"> * Visits a {@code contains all} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param filter
</span><del>- * The value assertion.
</del><ins>+ * The value assertion.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, ContainsAllValuesFilter \
filter); </span><span class="lines">@@ -84,9 +81,9 @@
</span><span class="cx"> * Visits a {@code contains} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param filter
</span><del>- * The value assertion.
</del><ins>+ * The value assertion.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, ContainsFilter filter);
</span><span class="lines">@@ -95,9 +92,9 @@
</span><span class="cx"> * Visits a {@code ends with} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param filter
</span><del>- * The value assertion.
</del><ins>+ * The value assertion.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, EndsWithFilter filter);
</span><span class="lines">@@ -106,9 +103,9 @@
</span><span class="cx"> * Visits a {@code equality} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param filter
</span><del>- * The value assertion.
</del><ins>+ * The value assertion.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, EqualsFilter filter);
</span><span class="lines">@@ -117,9 +114,9 @@
</span><span class="cx"> * Visits a {@code greater than} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param filter
</span><del>- * The value assertion.
</del><ins>+ * The value assertion.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, GreaterThanFilter filter);
</span><span class="lines">@@ -128,9 +125,9 @@
</span><span class="cx"> * Visits a {@code greater than or equal to} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param filter
</span><del>- * The value assertion.
</del><ins>+ * The value assertion.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, GreaterThanOrEqualFilter \
filter); </span><span class="lines">@@ -139,9 +136,9 @@
</span><span class="cx"> * Visits a {@code less than} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param filter
</span><del>- * The value assertion.
</del><ins>+ * The value assertion.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, LessThanFilter filter);
</span><span class="lines">@@ -150,9 +147,9 @@
</span><span class="cx"> * Visits a {@code less than or equal to} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param filter
</span><del>- * The value assertion.
</del><ins>+ * The value assertion.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, LessThanOrEqualFilter \
filter); </span><span class="lines">@@ -161,23 +158,23 @@
</span><span class="cx"> * Visits a {@code not} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param subFilter
</span><del>- * The sub-filter.
</del><ins>+ * The sub-filter.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, NotFilter subFilter);
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Visits an {@code or} filter.
</span><del>- * <p>
- * <b>Implementation note</b>: for the purposes of matching, an \
empty
- * sub-filter list should always evaluate to {@code false}.
</del><ins>+ * <p/>
+ * <b>Implementation note</b>: for the purposes of matching, an \
empty sub-filter list should always evaluate to + * {@code false}.
</ins><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param subFilters
</span><del>- * The unmodifiable list of sub-filters.
</del><ins>+ * The unmodifiable list of sub-filters.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, OrFilter subFilters);
</span><span class="lines">@@ -186,9 +183,9 @@
</span><span class="cx"> * Visits a {@code starts with} filter.
</span><span class="cx"> *
</span><span class="cx"> * @param parameter
</span><del>- * A visitor specified parameter.
</del><ins>+ * A visitor specified parameter.
</ins><span class="cx"> * @param filter
</span><del>- * The value assertion.
</del><ins>+ * The value assertion.
</ins><span class="cx"> * @return Returns a visitor specified result.
</span><span class="cx"> */
</span><span class="cx"> public R visit(P parameter, StartsWithFilter filter);
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscriptedcommonLoggerjava"></a>
<div class="delfile"><h4>Deleted: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/Logger.java \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/Logger.java 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/Logger.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -1,89 +0,0 @@
</span><del>-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- */
-
-package org.forgerock.openicf.misc.scriptedcommon;
-
-/**
- * A Logger is another logging abstraction.
- *
- * @author Laszlo Hordos
- */
-public interface Logger {
-
- public boolean isDebug();
-
- public boolean isInfo();
-
- public boolean isWarning();
-
- public boolean isError();
-
- public void debug(Throwable ex, String format, Object... args);
-
- public void debugLocale(Throwable ex, String key, Object... args);
-
- public void debugLocale(Throwable ex, String key, String defaultMessage, \
Object... args);
-
- public void info(Throwable ex, String format, Object... args);
-
- public void infoLocale(Throwable ex, String key, Object... args);
-
- public void infoLocale(Throwable ex, String key, String defaultMessage, \
Object... args);
-
- public void warn(Throwable ex, String format, Object... args);
-
- public void warnLocale(Throwable ex, String key, Object... args);
-
- public void warnLocale(Throwable ex, String key, String defaultMessage, \
Object... args);
-
- public void error(Throwable ex, String format, Object... args);
-
- public void errorLocale(Throwable ex, String key, Object... args);
-
- public void errorLocale(Throwable ex, String key, String defaultMessage, \
Object... args);
-
- public void debug(String format, Object... args);
-
- public void debugLocale(String key, Object... args);
-
- public void debugLocale(String key, String defaultMessage, Object... args);
-
- public void info(String format, Object... args);
-
- public void infoLocale(String key, Object... args);
-
- public void infoLocale(String key, String defaultMessage, Object... args);
-
- public void warn(String format, Object... args);
-
- public void warnLocale(String key, Object... args);
-
- public void warnLocale(String key, String defaultMessage, Object... args);
-
- public void error(String format, Object... args);
-
- public void errorLocale(String key, Object... args);
-
- public void errorLocale(String key, String defaultMessage, Object... args);
-}
</del></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscriptedcommonMapFilterVisitorjava"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/MapFilterVisitor.java \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/MapFilterVisitor.java 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/MapFilterVisitor.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -44,9 +44,7 @@
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.filter.StartsWithFilter; </span><span \
class="cx"> </span><span class="cx"> /**
</span><del>- * A MapFilterVisitor converts a
- * {@link org.identityconnectors.framework.common.objects.filter.Filter} to
- * {@link Map}.
</del><ins>+ * A MapFilterVisitor converts a {@link \
org.identityconnectors.framework.common.objects.filter.Filter} to {@link Map}. \
</ins><span class="cx"> * </span><span class="cx"> * @author Gael Allioux \
<gael.allioux@forgerock.com> </span><span class="cx"> */
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscriptedcommonOperationTypejava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/OperationType.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/OperationType.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/OperationType.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.misc.scriptedcommon;
+
+/**
+ * A NAME does ...
+ *
+ * @author Laszlo Hordos
+ */
+public enum OperationType {
+ AUTHENTICATE,
+ CREATE,
+ DELETE,
+ GET_LATEST_SYNC_TOKEN,
+ RESOLVE_USERNAME,
+ SCHEMA,
+ SEARCH,
+ SYNC,
+ TEST,
+ RUNSCRIPTONCONNECTOR,
+ RUNSCRIPTONRESOURCE,
+ UPDATE,
+ ADD_ATTRIBUTE_VALUES,
+ REMOVE_ATTRIBUTE_VALUES;
+
+ public String debugTrace() {
+ return new StringBuilder("{0}:{1} \
").append(this.name()).toString(); + }
+
+ public String fail1() {
+ return new StringBuilder(this.name()).append(" script didn't return \
with the uid(__UID__) value").toString(); + }
+
+ public String fail2(Class<?> clazz) {
+ return new StringBuilder(this.name()).append(" script returned with an \
unsupported uid(__UID__) value type: ") + \
.append(clazz).toString(); + }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscriptedcommonScriptedConfigurationjava"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConfiguration.java \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConfiguration.java 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConfiguration.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -23,11 +23,8 @@
</span><span class="cx"> */
</span><span class="cx"> package org.forgerock.openicf.misc.scriptedcommon;
</span><span class="cx">
</span><del>-import static \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase.LOGGER;
-
</del><span class="cx"> import java.io.File;
</span><span class="cx"> import java.net.URL;
</span><del>-import java.text.MessageFormat;
</del><span class="cx"> import java.util.Arrays;
</span><span class="cx"> import java.util.HashSet;
</span><span class="cx"> import java.util.concurrent.ConcurrentHashMap;
</span><span class="lines">@@ -35,13 +32,12 @@
</span><span class="cx">
</span><span class="cx"> import org.codehaus.groovy.control.CompilerConfiguration;
</span><span class="cx"> import \
org.codehaus.groovy.control.customizers.ImportCustomizer; </span><del>-import \
org.identityconnectors.common.ReflectionUtil; </del><span class="cx"> import \
org.identityconnectors.common.StringUtil; </span><span class="cx"> import \
org.identityconnectors.common.logging.Log; </span><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.ConnectorException; \
</span><del>-import org.identityconnectors.framework.common.objects.ConnectorMessages;
</del><span class="cx"> import \
org.identityconnectors.framework.common.objects.ConnectorObject; </span><span \
class="cx"> import org.identityconnectors.framework.spi.AbstractConfiguration; \
</span><ins>+import org.identityconnectors.framework.spi.ConfigurationProperty; \
</ins><span class="cx"> import \
org.identityconnectors.framework.spi.StatefulConfiguration; </span><span class="cx">
</span><span class="cx"> import groovy.lang.Binding;
</span><span class="lines">@@ -51,13 +47,13 @@
</span><span class="cx"> import groovy.util.GroovyScriptEngine;
</span><span class="cx"> import groovy.util.ResourceException;
</span><span class="cx"> import groovy.util.ScriptException;
</span><ins>+import static \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase.LOGGER; </ins><span \
class="cx"> </span><span class="cx"> /**
</span><del>- * Extends the {@link AbstractConfiguration} class to provide all the \
necessary
- * parameters to initialize the Scripted Connector.
</del><ins>+ * Extends the {@link AbstractConfiguration} class to provide all the \
necessary parameters to initialize the Scripted + * Connector.
</ins><span class="cx"> *
</span><span class="cx"> * @author Gael Allioux <gael.allioux@forgerock.com>
</span><del>- *
</del><span class="cx"> */
</span><span class="cx"> public class ScriptedConfiguration extends \
AbstractConfiguration implements StatefulConfiguration { </span><span class="cx">
</span><span class="lines">@@ -68,39 +64,17 @@
</span><span class="cx"> private static final String DOT_STAR = ".*";
</span><span class="cx"> private static final String EMPTY_STRING = "";
</span><span class="cx"> private final CompilerConfiguration config;
</span><ins>+
</ins><span class="cx"> {
</span><span class="cx"> config = new \
CompilerConfiguration(CompilerConfiguration.DEFAULT); </span><span class="cx"> \
config.setSourceEncoding("UTF-8"); </span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // \
======================================================================= </span><del>- \
// Scripts </del><ins>+ // Operation Script Files
</ins><span class="cx"> // \
======================================================================= </span><span \
class="cx"> </span><span class="cx"> /**
</span><del>- * Should password be passed to scripts in clear text?
- */
- private boolean clearTextPasswordToScript = true;
-
- /**
- * Return the clearTextPasswordToScript boolean
- *
- * @return value
- */
- public boolean getClearTextPasswordToScript() {
- return clearTextPasswordToScript;
- }
-
- /**
- * Set the clearTextPasswordToScript value
- *
- * @param value
- */
- public void setClearTextPasswordToScript(boolean value) {
- this.clearTextPasswordToScript = value;
- }
-
- /**
</del><span class="cx"> * Authenticate script filename
</span><span class="cx"> */
</span><span class="cx"> private String authenticateScriptFileName = null;
</span><span class="lines">@@ -110,6 +84,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getAuthenticateScriptFileName() { </span><span class="cx"> return \
authenticateScriptFileName; </span><span class="cx"> }
</span><span class="lines">@@ -133,6 +108,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getCreateScriptFileName() { </span><span class="cx"> return \
createScriptFileName; </span><span class="cx"> }
</span><span class="lines">@@ -156,6 +132,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return updateScriptFileName value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getUpdateScriptFileName() { </span><span class="cx"> return \
updateScriptFileName; </span><span class="cx"> }
</span><span class="lines">@@ -179,6 +156,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return deleteScriptFileName value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getDeleteScriptFileName() { </span><span class="cx"> return \
deleteScriptFileName; </span><span class="cx"> }
</span><span class="lines">@@ -202,6 +180,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return resolveUsernameScriptFileName value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getResolveUsernameScriptFileName() { </span><span class="cx"> return \
resolveUsernameScriptFileName; </span><span class="cx"> }
</span><span class="lines">@@ -216,29 +195,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * ScriptOnConnector script FileName
- */
- private String scriptOnConnectorScriptFileName = null;
-
- /**
- * Return the ScriptOnConnector script FileName
- *
- * @return scriptOnConnectorScriptFileName value
- */
- public String getScriptOnConnectorScriptFileName() {
- return scriptOnConnectorScriptFileName;
- }
-
- /**
- * Set the ScriptOnConnector script FileName
- *
- * @param value
- */
- public void setScriptOnConnectorScriptFileName(String value) {
- this.scriptOnConnectorScriptFileName = value;
- }
-
- /**
</del><span class="cx"> * ScriptOnResource script FileName
</span><span class="cx"> */
</span><span class="cx"> private String scriptOnResourceScriptFileName = null;
</span><span class="lines">@@ -248,6 +204,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return scriptOnResourceScriptFileName value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getScriptOnResourceScriptFileName() { </span><span class="cx"> return \
scriptOnResourceScriptFileName; </span><span class="cx"> }
</span><span class="lines">@@ -271,6 +228,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return searchScriptFileName value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getSearchScriptFileName() { </span><span class="cx"> return \
searchScriptFileName; </span><span class="cx"> }
</span><span class="lines">@@ -294,6 +252,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return syncScriptFileName value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getSyncScriptFileName() { </span><span class="cx"> return syncScriptFileName;
</span><span class="cx"> }
</span><span class="lines">@@ -317,6 +276,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return schemaScriptFileName value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getSchemaScriptFileName() { </span><span class="cx"> return \
schemaScriptFileName; </span><span class="cx"> }
</span><span class="lines">@@ -340,6 +300,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return testScriptFileName value
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = \
"groovy.operation.scripts") </ins><span class="cx"> public String \
getTestScriptFileName() { </span><span class="cx"> return testScriptFileName;
</span><span class="cx"> }
</span><span class="lines">@@ -353,10 +314,31 @@
</span><span class="cx"> this.testScriptFileName = value;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+ // =======================================================================
+ // Groovy Engine configuration
+ // =======================================================================
+
+
</ins><span class="cx"> /**
</span><del>- * Gets the currently configured warning level. See WarningMessage \
for level
- * details.
</del><ins>+ * Gets extensions used to find a groovy files
+ *
+ * @return
</ins><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
+ public String[] getScriptExtensions() {
+ return config.getScriptExtensions().toArray(new \
String[config.getScriptExtensions().size()]); + }
+
+ public void setScriptExtensions(String[] scriptExtensions) {
+ config.setScriptExtensions(
+ null != scriptExtensions ? new \
HashSet<String>(Arrays.asList(scriptExtensions)) : null); + }
+
+ /**
+ * Gets the currently configured warning level. See WarningMessage for level \
details. + */
+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public int getWarningLevel() {
</span><span class="cx"> return config.getWarningLevel();
</span><span class="cx"> }
</span><span class="lines">@@ -371,6 +353,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Gets the currently configured source file encoding.
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public String getSourceEncoding() {
</span><span class="cx"> return config.getSourceEncoding();
</span><span class="cx"> }
</span><span class="lines">@@ -385,6 +368,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Gets the target directory for writing classes.
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public File getTargetDirectory() {
</span><span class="cx"> return config.getTargetDirectory();
</span><span class="cx"> }
</span><span class="lines">@@ -399,6 +383,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * @return the classpath
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public String[] getClasspath() {
</span><span class="cx"> if (null != config.getClasspath()) {
</span><span class="cx"> return config.getClasspath().toArray(new \
String[config.getClasspath().size()]); </span><span class="lines">@@ -416,6 +401,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Returns true if verbose operation has been requested.
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public boolean getVerbose() {
</span><span class="cx"> return config.getVerbose();
</span><span class="cx"> }
</span><span class="lines">@@ -430,6 +416,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Returns true if debugging operation has been \
requested. </span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public boolean getDebug() {
</span><span class="cx"> return config.getDebug();
</span><span class="cx"> }
</span><span class="lines">@@ -444,55 +431,58 @@
</span><span class="cx"> /**
</span><span class="cx"> * Returns the requested error tolerance.
</span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public int getTolerance() {
</span><span class="cx"> return config.getTolerance();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Sets the error tolerance, which is the number of non-fatal errors \
(per
- * unit) that should be tolerated before compilation is aborted.
</del><ins>+ * Sets the error tolerance, which is the number of non-fatal errors \
(per unit) that should be tolerated before + * compilation is aborted.
</ins><span class="cx"> */
</span><span class="cx"> public void setTolerance(int tolerance) {
</span><span class="cx"> config.setTolerance(tolerance);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Gets the name of the base class for scripts. It must be a \
subclass of
- * Script.
</del><ins>+ * Gets the name of the base class for scripts. It must be a subclass \
of Script. </ins><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public String getScriptBaseClass() {
</span><span class="cx"> return config.getScriptBaseClass();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Sets the name of the base class for scripts. It must be a \
subclass of
- * Script.
</del><ins>+ * Sets the name of the base class for scripts. It must be a subclass \
of Script. </ins><span class="cx"> */
</span><span class="cx"> public void setScriptBaseClass(String scriptBaseClass) {
</span><span class="cx"> config.setScriptBaseClass(scriptBaseClass);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- public void setRecompileGroovySource(boolean recompile) {
- config.setRecompileGroovySource(recompile);
- }
-
</del><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public boolean getRecompileGroovySource() {
</span><span class="cx"> return config.getRecompileGroovySource();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- public void setMinimumRecompilationInterval(int time) {
- config.setMinimumRecompilationInterval(time);
</del><ins>+ public void setRecompileGroovySource(boolean recompile) {
+ config.setRecompileGroovySource(recompile);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public int getMinimumRecompilationInterval() {
</span><span class="cx"> return config.getMinimumRecompilationInterval();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ public void setMinimumRecompilationInterval(int time) {
+ config.setMinimumRecompilationInterval(time);
+ }
+
</ins><span class="cx"> /**
</span><span class="cx"> * Returns the list of disabled global AST \
transformation class names. </span><span class="cx"> *
</span><span class="cx"> * @return a list of global AST transformation fully \
qualified class names </span><span class="cx"> */
</span><ins>+ @ConfigurationProperty(groupMessageKey = "groovy.engine")
</ins><span class="cx"> public String[] getDisabledGlobalASTTransformations() {
</span><span class="cx"> if (null != \
config.getDisabledGlobalASTTransformations()) { </span><span class="cx"> \
return config.getDisabledGlobalASTTransformations().toArray(new String[0]); \
</span><span class="lines">@@ -513,6 +503,10 @@ </span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ // =======================================================================
+ // Other Configuration Properties
+ // =======================================================================
+
</ins><span class="cx"> public void release() {
</span><span class="cx"> groovyScriptEngine = null;
</span><span class="cx"> loggerCache.clear();
</span><span class="lines">@@ -528,7 +522,6 @@
</span><span class="cx"> loadScript(getDeleteScriptFileName());
</span><span class="cx"> loadScript(getResolveUsernameScriptFileName());
</span><span class="cx"> loadScript(getSchemaScriptFileName());
</span><del>- loadScript(getScriptOnConnectorScriptFileName());
</del><span class="cx"> loadScript(getScriptOnResourceScriptFileName());
</span><span class="cx"> loadScript(getSearchScriptFileName());
</span><span class="cx"> loadScript(getSyncScriptFileName());
</span><span class="lines">@@ -537,13 +530,13 @@
</span><span class="cx"> logger.info("Scripts are loaded");
</span><span class="cx"> }
</span><span class="cx">
</span><del>- private static ConcurrentMap<String, Logger> loggerCache =
- new ConcurrentHashMap<String, Logger>(11);
</del><ins>+ private static ConcurrentMap<String, Log> loggerCache =
+ new ConcurrentHashMap<String, Log>(11);
</ins><span class="cx">
</span><del>- Object evaluate(String scriptName, Binding binding, Object delegate) \
{ </del><ins>+ Object evaluate(String scriptName, Binding binding, Object \
delegate) throws Exception { </ins><span class="cx"> try {
</span><span class="cx"> Script scr = \
getGroovyScriptEngine().createScript(scriptName, binding); </span><del>- \
binding.setVariable(LOGGER, getLogger(scr.getClass(), 12)); </del><ins>+ \
binding.setVariable(LOGGER, getLogger(scr.getClass())); </ins><span class="cx"> \
if (scr instanceof DelegatingScript && null != delegate) { </span><span \
class="cx"> ((DelegatingScript) scr).setDelegate(delegate); \
</span><span class="cx"> } </span><span class="lines">@@ -555,19 +548,6 \
@@ </span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- Logger getLogger(final Class<?> clazz, int depth) {
- final String key = clazz.getName();
- Logger logger = loggerCache.get(key);
- if (null == logger) {
- logger = new LoggerImpl(clazz, getConnectorMessages(), depth);
- Logger l = loggerCache.putIfAbsent(key, logger);
- if (l != null) {
- logger = l;
- }
- }
- return logger;
- }
-
</del><span class="cx"> Class loadScript(String scriptName) {
</span><span class="cx"> if (StringUtil.isNotBlank(scriptName)) {
</span><span class="cx"> try {
</span><span class="lines">@@ -581,6 +561,19 @@
</span><span class="cx"> return null;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ private Log getLogger(final Class<?> clazz) {
+ final String key = clazz.getName();
+ Log logger = loggerCache.get(key);
+ if (null == logger) {
+ logger = Log.getLog(clazz);
+ Log l = loggerCache.putIfAbsent(key, logger);
+ if (l != null) {
+ logger = l;
+ }
+ }
+ return logger;
+ }
+
</ins><span class="cx"> private GroovyScriptEngine groovyScriptEngine = null;
</span><span class="cx">
</span><span class="cx"> GroovyScriptEngine getGroovyScriptEngine() {
</span><span class="lines">@@ -625,182 +618,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> protected String[] getImports() {
</span><del>- return new String[] { \
ConnectorObject.class.getPackage().getName() + ".*" }; </del><ins>+ \
return new String[]{ConnectorObject.class.getPackage().getName() + ".*"}; \
</ins><span class="cx"> } </span><del>-
- protected static class LoggerImpl implements Logger {
-
- private static final String DFLT = "__IGNORE__";
- private final Class<?> clazz;
- private final ConnectorMessages connectorMessages;
- private final Log log;
- private final Integer methodDepth;
-
- protected LoggerImpl(final Class<?> clazz, final ConnectorMessages \
messages, int depth) {
- this.clazz = clazz;
- log = Log.getLog(this.clazz);
- connectorMessages = messages;
- methodDepth = depth;
- }
-
- protected Log getLog() {
- return log;
- }
-
- /**
- * Logs based on the parameters given. Uses the format parameter inside
- * {@link java.text.MessageFormat}.
- *
- * @param level
- * the logging level at which to write the message.
- * @param ex
- * [optional] exception stack trace to log.
- * @param format
- * [optional] create a message of a particular format.
- * @param args
- * [optional] parameters to the format string.
- */
- public void log(final Log.Level level, final Throwable ex, final String key,
- final String format, final Object... args) {
- if (getLog().isLoggable(level)) {
- String message = format;
- if (key != null) {
- String messageLocal = connectorMessages.format(key, DFLT, args);
- if (!DFLT.equals(messageLocal)) {
- // MessageKey was found
- message = messageLocal;
- } else {
- // MessageKey not was found
- if (format != null && args != null) {
- message = MessageFormat.format(format, args);
- } else if (format == null && ex != null) {
- message = ex.getLocalizedMessage();
- } else if (format == null) {
- message = key;
- }
- }
- } else {
- if (format != null && args != null) {
- message = MessageFormat.format(format, args);
- } else if (format == null && ex != null) {
- message = ex.getLocalizedMessage();
- }
- }
- final String methodName = ReflectionUtil.getMethodName(methodDepth);
- getLog().log(clazz, methodName, level, message, ex);
- }
- }
-
- public boolean isDebug() {
- return getLog().isOk();
- }
-
- public boolean isInfo() {
- return getLog().isInfo();
- }
-
- public boolean isWarning() {
- return getLog().isWarning();
- }
-
- public boolean isError() {
- return getLog().isError();
- }
-
- public void debug(Throwable ex, String format, Object... args) {
- log(Log.Level.OK, ex, null, format, args);
- }
-
- public void debugLocale(Throwable ex, String key, Object... args) {
- log(Log.Level.OK, ex, key, null, args);
- }
-
- public void debugLocale(Throwable ex, String key, String defaultMessage, \
Object... args) {
- log(Log.Level.OK, ex, key, defaultMessage, args);
- }
-
- public void info(Throwable ex, String format, Object... args) {
- log(Log.Level.INFO, ex, null, format, args);
- }
-
- public void infoLocale(Throwable ex, String key, Object... args) {
- log(Log.Level.INFO, ex, key, null, args);
- }
-
- public void infoLocale(Throwable ex, String key, String defaultMessage, \
Object... args) {
- log(Log.Level.INFO, ex, key, defaultMessage, args);
- }
-
- public void warn(Throwable ex, String format, Object... args) {
- log(Log.Level.WARN, ex, null, format, args);
- }
-
- public void warnLocale(Throwable ex, String key, Object... args) {
- log(Log.Level.WARN, ex, key, null, args);
- }
-
- public void warnLocale(Throwable ex, String key, String defaultMessage, \
Object... args) {
- log(Log.Level.WARN, ex, key, defaultMessage, args);
- }
-
- public void error(Throwable ex, String format, Object... args) {
- log(Log.Level.ERROR, ex, null, format, args);
- }
-
- public void errorLocale(Throwable ex, String key, Object... args) {
- log(Log.Level.ERROR, ex, key, null, args);
- }
-
- public void errorLocale(Throwable ex, String key, String defaultMessage, \
Object... args) {
- log(Log.Level.ERROR, ex, key, defaultMessage, args);
- }
-
- public void debug(String format, Object... args) {
- log(Log.Level.OK, null, null, format, args);
- }
-
- public void debugLocale(String key, Object... args) {
- log(Log.Level.OK, null, key, null, args);
- }
-
- public void debugLocale(String key, String defaultMessage, Object... args) {
- log(Log.Level.OK, null, key, defaultMessage, args);
- }
-
- public void info(String format, Object... args) {
- log(Log.Level.INFO, null, null, format, args);
- }
-
- public void infoLocale(String key, Object... args) {
- log(Log.Level.INFO, null, key, null, args);
- }
-
- public void infoLocale(String key, String defaultMessage, Object... args) {
- log(Log.Level.INFO, null, key, defaultMessage, args);
- }
-
- public void warn(String format, Object... args) {
- log(Log.Level.WARN, null, null, format, args);
- }
-
- public void warnLocale(String key, Object... args) {
- log(Log.Level.WARN, null, key, null, args);
- }
-
- public void warnLocale(String key, String defaultMessage, Object... args) {
- log(Log.Level.WARN, null, key, defaultMessage, args);
- }
-
- public void error(String format, Object... args) {
- log(Log.Level.ERROR, null, null, format, args);
- }
-
- public void errorLocale(String key, Object... args) {
- log(Log.Level.ERROR, null, key, null, args);
- }
-
- public void errorLocale(String key, String defaultMessage, Object... args) {
- log(Log.Level.ERROR, null, key, defaultMessage, args);
- }
- }
</del><span class="cx"> }
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscriptedcommonScriptedConnectionjava"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnection.java \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnection.java 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnection.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -21,13 +21,13 @@
</span><span class="cx"> * your own identifying information:
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><ins>+
</ins><span class="cx"> package org.forgerock.openicf.misc.scriptedcommon;
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- *
</del><span class="cx"> * @author Gael Allioux <gael.allioux@forgerock.com>
</span><span class="cx"> */
</span><del>-public interface ScriptedConnection {
</del><ins>+public interface ScriptedConnection<T> {
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Release internal resources.
</span><span class="lines">@@ -40,11 +40,11 @@
</span><span class="cx"> public void test();
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * The connection needs to provide a generic handler object
- * that will be used by every scripts to connect to the remote system
</del><ins>+ * The connection needs to provide a generic handler object that will \
be used by every scripts to connect to the + * remote system
</ins><span class="cx"> *
</span><span class="cx"> * @return the connection handler generic Object
</span><span class="cx"> */
</span><del>- public Object getConnectionHandler();
</del><ins>+ public T getConnectionHandler();
</ins><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainjavaorgforgerockopenicfmiscscriptedcommonScriptedFilterTranslatorjava"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedFilterTranslator.java \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedFilterTranslator.java 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedFilterTranslator.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -24,10 +24,6 @@
</span><span class="cx">
</span><span class="cx"> package org.forgerock.openicf.misc.scriptedcommon;
</span><span class="cx">
</span><del>-import static \
org.identityconnectors.framework.common.objects.filter.FilterBuilder.and;
-import static org.identityconnectors.framework.common.objects.filter.FilterBuilder.not;
-import static org.identityconnectors.framework.common.objects.filter.FilterBuilder.or;
-
</del><span class="cx"> import \
org.identityconnectors.framework.common.objects.filter.AbstractFilterTranslator; \
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.filter.ContainsAllValuesFilter; \
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.filter.ContainsFilter; </span><span \
class="lines">@@ -40,10 +36,10 @@ </span><span class="cx"> import \
org.identityconnectors.framework.common.objects.filter.LessThanOrEqualFilter; \
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.filter.StartsWithFilter; </span><span \
class="cx"> </span><ins>+import static \
org.identityconnectors.framework.common.objects.filter.FilterBuilder.*; +
</ins><span class="cx"> /**
</span><del>- *
</del><span class="cx"> * @author Gael Allioux <gael.allioux@forgerock.com>
</span><del>- *
</del><span class="cx"> */
</span><span class="cx"> public class ScriptedFilterTranslator extends \
AbstractFilterTranslator<Filter> { </span><span class="cx">
</span><span class="lines">@@ -62,7 +58,7 @@
</span><span class="cx"> */
</span><span class="cx"> @Override
</span><span class="cx"> protected Filter createContainsAllValuesExpression(final \
ContainsAllValuesFilter filter, </span><del>- boolean not) {
</del><ins>+ boolean not) {
</ins><span class="cx"> return not ? not(filter) : filter;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -79,7 +75,7 @@
</span><span class="cx"> */
</span><span class="cx"> @Override
</span><span class="cx"> protected Filter createEndsWithExpression(final \
EndsWithFilter filter, boolean not) { </span><del>- return \
super.createEndsWithExpression(filter, not); </del><ins>+ return not ? \
not(filter) : filter; </ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -103,7 +99,7 @@
</span><span class="cx"> */
</span><span class="cx"> @Override
</span><span class="cx"> protected Filter \
createGreaterThanOrEqualExpression(final GreaterThanOrEqualFilter filter, \
</span><del>- boolean not) { </del><ins>+ \
boolean not) { </ins><span class="cx"> return not ? not(filter) : filter;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainresourcesorgforgerockopenicfconnectorsgroovyMessagesproperties"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/groovy/Messages.properties \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/groovy/Messages.properties 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/groovy/Messages.properties 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -1,7 +1,8 @@
</span><del>-# DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
</del><span class="cx"> #
</span><del>-# Copyright (c) 2013-2014 ForgeRock AS. All rights reserved.
</del><ins>+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
</ins><span class="cx"> #
</span><ins>+# Copyright (c) 2013-2014 ForgeRock AS. All Rights Reserved
+#
</ins><span class="cx"> # The contents of this file are subject to the terms
</span><span class="cx"> # of the Common Development and Distribution License
</span><span class="cx"> # (the License). You may not use this file except in
</span><span class="lines">@@ -19,35 +20,70 @@
</span><span class="cx"> # with the fields enclosed by brackets [] replaced by
</span><span class="cx"> # your own identifying information:
</span><span class="cx"> # "Portions Copyrighted [year] [name of copyright \
owner]" </span><ins>+#
+
</ins><span class="cx"> groovy.connector.display=Scripted Groovy
</span><span class="cx"> groovy.poolable.connector.display=Scripted Poolable Groovy
</span><span class="cx">
</span><del>-clearTextPasswordToScript.display=Clear Text Password to Script
-clearTextPasswordToScript.help=On Authenticate/Create/Update operations, the \
password field is passed to the script. If this option is true (default), the \
password is passed in clear text. If false, the password is passed as a Guarded \
String. </del><ins>+#############################################################
+## SHARED PROPERTIES ##
+#############################################################
+
+# Operation Script Files
+groovy.operation.scripts=Operation Script Files
</ins><span class="cx"> authenticateScriptFileName.display=Authenticate Script \
filename </span><span class="cx"> authenticateScriptFileName.help=The name of the \
file used to perform the AUTHENTICATE operation. </span><span class="cx"> \
createScriptFileName.display=Create Script filename </span><span class="cx"> \
createScriptFileName.help=The name of the file used to perform the CREATE operation. \
</span><del>-updateScriptFileName.display=Update Script filename
-updateScriptFileName.help=The name of the file used to perform the UPDATE operation.
</del><span class="cx"> deleteScriptFileName.display=Delete Script filename
</span><span class="cx"> deleteScriptFileName.help=The name of the file used to \
perform the DELETE operation. \
</span><ins>+resolveUsernameScriptFileName.display=ResolveUsername Script filename \
+resolveUsernameScriptFileName.help=The name of the file used to perform the \
RESOLVE_USERNAME operation. +schemaScriptFileName.display=Schema Script filename
+schemaScriptFileName.help=The name of the file used to perform the SCHEMA operation.
+scriptOnResourceScriptFileName.display=ScriptOnResource Script filename
+scriptOnResourceScriptFileName.help=The name of the file used to perform the \
RUNSCRIPTONRESOURCE operation. </ins><span class="cx"> \
searchScriptFileName.display=Search Script filename </span><span class="cx"> \
searchScriptFileName.help=The name of the file used to perform the SEARCH operation. \
</span><span class="cx"> syncScriptFileName.display=Sync Script filename </span><span \
class="cx"> syncScriptFileName.help=The name of the file used to perform the SYNC \
operation. </span><del>-schemaScriptFileName.display=Schema Script filename
-schemaScriptFileName.help=The name of the file used to perform the SCHEMA operation.
</del><span class="cx"> testScriptFileName.display=Test Script filename
</span><span class="cx"> testScriptFileName.help=The name of the file used to perform \
the TEST operation. </span><ins>+updateScriptFileName.display=Update Script filename
+updateScriptFileName.help=The name of the file used to perform the UPDATE operation.
</ins><span class="cx">
</span><del>-classpath.display=N/A
-classpath.help=N/A
-scriptOnResourceScriptFileName.display=N/A
-scriptOnResourceScriptFileName.help=N/A
-scriptOnConnectorScriptFileName.display=N/A
-scriptOnConnectorScriptFileName.help=N/A
</del><ins>+groovy.engine=Groovy Engine configuration
</ins><span class="cx">
</span><ins>+# Groovy Engine configuration
+classpath.display=Classpath
+classpath.help=Classpath for use during compilation.
+debug.display=Debug
+debug.help=If true, debugging code should be activated
+disabledGlobalASTTransformations.display=Disabled Global AST Transformations
+disabledGlobalASTTransformations.help=Sets a list of global AST transformations \
which should not be loaded even if they are defined in \
META-INF/org.codehaus.groovy.transform.ASTTransformation files. By default, none is \
disabled. +minimumRecompilationInterval.display=Minimum Recompilation Interval
+minimumRecompilationInterval.help=Sets the minimum of time after a script can be \
recompiled. +recompileGroovySource.display=Recompile Groovy Source
+recompileGroovySource.help=If set to true recompilation is enabled
+scriptBaseClass.display=Script Base Class
+scriptBaseClass.help=Base class name for scripts (must derive from Script)
+sourceEncoding.display=Source Encoding
+sourceEncoding.help=Encoding for source files
+targetDirectory.display=Target Directory
+targetDirectory.help=Directory into which to write classes.
+tolerance.display=Tolerance
+tolerance.help=The error tolerance, which is the number of non-fatal errors (per \
unit) that should be tolerated before compilation is aborted. \
+verbose.display=Verbose +verbose.help=If true, the compiler should produce action \
information +warningLevel.display=Warning Level
+warningLevel.help=Warning Level of the compiler
+
+#############################################################
+
+
+clearTextPasswordToScript.display=Clear Text Password to Script
+clearTextPasswordToScript.help=On Authenticate/Create/Update operations, the \
password field is passed to the script. If this option is true (default), the \
password is passed in clear text. If false, the password is passed as a Guarded \
String. +
</ins><span class="cx"> DEBUG_INVOKE_AUTHENTICATE=Invoke Authenticate \
ObjectClass:{0}->{1} </span><span class="cx"> DEBUG_INVOKE_CREATE=Invoke Create \
ObjectClass:{0} </span><span class="cx"> DEBUG_INVOKE_DELETE=Invoke Delete \
ObjectClass:{0}->{1} </span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainresourcesorgforgerockopenicfconnectorsscriptedcrestMessagesproperties"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedcrest/Messages.properties \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedcrest/Messages.properties \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedcrest/Messages.properties 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+#
+# The contents of this file are subject to the terms
+# of the Common Development and Distribution License
+# (the License). You may not use this file except in
+# compliance with the License.
+#
+# You can obtain a copy of the License at
+# http://forgerock.org/license/CDDLv1.0.html
+# See the License for the specific language governing
+# permission and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL
+# Header Notice in each file and include the License file
+# at http://forgerock.org/license/CDDLv1.0.html
+# If applicable, add the following below the CDDL Header,
+# with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+
+groovy.crest.connector.display=Scripted CREST
+
+host.display=Example Host Property
+host.help=An example string configuration property
+remoteUser.display=Example Remote User Property
+remoteUser.help=An example string configuration property
+password.display=Example Password Property
+password.help=An example GuardedString property
+basic.group=Basic Configuration Properties
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainresourcesorgforgerockopenicfconnectorss \
criptedrestMessagespropertiesfromrev6504trunkconnectorsjavascriptedrestsrcmainresourcesorgforgerockopenicfconnectorsscriptedrestMessagesproperties"></a>
<div class="copfile"><h4>Copied: \
trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedrest/Messages.properties \
(from rev 6504, trunk/connectors/java/scriptedrest/src/main/resources/org/forgerock/openicf/connectors/scriptedrest/Messages.properties) \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedrest/Messages.properties \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedrest/Messages.properties 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+#
+# The contents of this file are subject to the terms
+# of the Common Development and Distribution License
+# (the License). You may not use this file except in
+# compliance with the License.
+#
+# You can obtain a copy of the License at
+# http://forgerock.org/license/CDDLv1.0.html
+# See the License for the specific language governing
+# permission and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL
+# Header Notice in each file and include the License file
+# at http://forgerock.org/license/CDDLv1.0.html
+# If applicable, add the following below the CDDL Header,
+# with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+
+groovy.rest.connector.display=Scripted REST
+
+
+host.display=Example Host Property
+host.help=An example string configuration property
+remoteUser.display=Example Remote User Property
+remoteUser.help=An example string configuration property
+password.display=Example Password Property
+password.help=An example GuardedString property
+basic.group=Basic Configuration Properties
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcmainresourcesorgforgerockopenicfconnectorss \
criptedsqlMessagespropertiesfromrev6504trunkconnectorsjavascriptedsqlsrcmainresourcesorgforgerockopenicfconnectorsscriptedsqlMessagesproperties"></a>
<div class="copfile"><h4>Copied: \
trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedsql/Messages.properties \
(from rev 6504, trunk/connectors/java/scriptedsql/src/main/resources/org/forgerock/openicf/connectors/scriptedsql/Messages.properties) \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedsql/Messages.properties \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/main/resources/org/forgerock/openicf/connectors/scriptedsql/Messages.properties 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,166 @@
</span><ins>+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+#
+# The contents of this file are subject to the terms
+# of the Common Development and Distribution License
+# (the License). You may not use this file except in
+# compliance with the License.
+#
+# You can obtain a copy of the License at
+# http://forgerock.org/license/CDDLv1.0.html
+# See the License for the specific language governing
+# permission and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL
+# Header Notice in each file and include the License file
+# at http://forgerock.org/license/CDDLv1.0.html
+# If applicable, add the following below the CDDL Header,
+# with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+
+groovy.sql.connector.display=Scripted SQL
+
+
+defaultAutoCommit.display=
+defaultAutoCommit.help=The default auto-commit state of connections created by this \
pool. If not set, default is JDBC driver default (If not set then the setAutoCommit \
method will not be called.) +
+defaultReadOnly.help=The default read-only state of connections created by this \
pool. If not set then the setReadOnly method will not be called. (Some drivers don't \
support read only mode, ex: Informix) +
+defaultTransactionIsolation.help=The default TransactionIsolation state of \
connections created by this pool. One of the following: NONE, READ_COMMITTED, \
READ_UNCOMMITTED, REPEATABLE_READ, SERIALIZABLE If not set, the method will not be \
called and it defaults to the JDBC driver. +
+defaultCatalog.help=The default catalog of connections created by this pool.
+
+driverClassName.help=The fully qualified Java class name of the JDBC driver to be \
used. The driver has to be accessible from the same classloader as tomcat-jdbc.jar +
+username.help=The connection username to be passed to our JDBC driver to establish a \
connection. Note that method DataSource.getConnection(username,password) by default \
will not use credentials passed into the method, but will use the ones configured \
here. See alternateUsernameAllowed property for more details. +
+password.help=The connection password to be passed to our JDBC driver to establish a \
connection. Note that method DataSource.getConnection(username,password) by default \
will not use credentials passed into the method, but will use the ones configured \
here. See alternateUsernameAllowed property for more details. +
+maxActive.help=The maximum number of active connections that can be allocated from \
this pool at the same time. The default value is 100 +
+maxIdle.help=The maximum number of connections that should be kept in the pool at \
all times. Default value is maxActive:100 Idle connections are checked periodically \
(if enabled) and connections that been idle for longer than \
minEvictableIdleTimeMillis will be released. (also see testWhileIdle) +
+minIdle.help=The minimum number of established connections that should be kept in \
the pool at all times. The connection pool can shrink below this number if validation \
queries fail. Default value is derived from initialSize:10 (also see testWhileIdle) +
+initialSize.help=The initial number of connections that are created when the pool is \
started. Default value is 10 +
+maxWait.help=The maximum number of milliseconds that the pool will wait (when there \
are no available connections) for a connection to be returned before throwing an \
exception. Default value is 30000 (30 seconds) +
+testOnBorrow.help=The indication of whether objects will be validated before being \
borrowed from the pool. If the object fails to validate, it will be dropped from the \
pool, and we will attempt to borrow another. NOTE - for a true value to have any \
effect, the validationQuery parameter must be set to a non-null string. In order to \
have a more efficient validation, see validationInterval. Default value is false +
+testOnReturn.help=The indication of whether objects will be validated before being \
returned to the pool. NOTE - for a true value to have any effect, the validationQuery \
parameter must be set to a non-null string. The default value is false. +
+testWhileIdle.help=The indication of whether objects will be validated by the idle \
object evictor (if any). If an object fails to validate, it will be dropped from the \
pool. NOTE - for a true value to have any effect, the validationQuery parameter must \
be set to a non-null string. The default value is false and this property has to be \
set in order for the pool cleaner/test thread is to run (also see \
timeBetweenEvictionRunsMillis) +
+validationQuery.help=The SQL query that will be used to validate connections from \
this pool before returning them to the caller. If specified, this query does not have \
to return any data, it just can't throw a SQLException. The default value is null. \
Example values are SELECT 1(mysql), select 1 from dual(oracle), SELECT 1(MS Sql \
Server) +
+validationQueryTimeout.help=The timeout in seconds before a connection validation \
queries fail. This works by calling java.sql.Statement.setQueryTimeout(seconds) on \
the statement that executes the validationQuery. The pool itself doesn't timeout the \
query, it is still up to the JDBC driver to enforce query timeouts. A value less than \
or equal to zero will disable this feature. The default value is -1. +
+validatorClassName.help=The name of a class which implements the \
org.apache.tomcat.jdbc.pool.Validator interface and provides a no-arg constructor \
(may be implicit). If specified, the class will be used to create a Validator \
instance which is then used instead of any validation query to validate connections. \
The default value is null. An example value is com.mycompany.project.SimpleValidator. \
+ +timeBetweenEvictionRunsMillis.help=The number of milliseconds to sleep between \
runs of the idle connection validation/cleaner thread. This value should not be set \
under 1 second. It dictates how often we check for idle, abandoned connections, and \
how often we validate idle connections. The default value is 5000 (5 seconds). +
+minEvictableIdleTimeMillis.help=The minimum amount of time an object may sit idle in \
the pool before it is eligible for eviction. The default value is 60000 (60 seconds). \
+ +accessToUnderlyingConnectionAllowed.help=Property not used. Access can be achieved \
by calling unwrap on the pooled connection. see javax.sql.DataSource interface, or \
call getConnection through reflection or cast the object as \
javax.sql.PooledConnection +
+removeAbandoned.help=Flag to remove abandoned connections if they exceed the \
removeAbandonedTimeout. If set to true a connection is considered abandoned and \
eligible for removal if it has been in use longer than the removeAbandonedTimeout \
Setting this to true can recover db connections from applications that fail to close \
a connection. See also logAbandoned The default value is false. +
+removeAbandonedTimeout.help=Timeout in seconds before an abandoned(in use) \
connection can be removed. The default value is 60 (60 seconds). The value should be \
set to the longest running query your applications might have. +
+logAbandoned.help=Flag to log stack traces for application code which abandoned a \
Connection. Logging of abandoned Connections adds overhead for every Connection \
borrow because a stack trace has to be generated. The default value is false. +
+connectionProperties.help=The connection properties that will be sent to our JDBC \
driver when establishing new connections. Format of the string must be \
[propertyName=property;]* NOTE - The "user" and "password" \
properties will be passed explicitly, so they do not need to be included here. The \
default value is null. +
+
+poolPreparedStatements.help=Property not used.
+
+maxOpenPreparedStatements.help=Property not used.
+
+numTestsPerEvictionRun.help=Property not used in tomcat-jdbc-pool.
+
+
+initSQL.help= A custom query to be run when a connection is first created. The \
default value is null. +
+jdbcInterceptors.help=A semicolon separated list of classnames extending \
org.apache.tomcat.jdbc.pool.JdbcInterceptor class. See Configuring JDBC interceptors \
below for more detailed description of syntaz and examples. These interceptors will \
be inserted as an interceptor into the chain of operations on a java.sql.Connection \
object. The default value is null. +
+#Predefined interceptors:
+#org.apache.tomcat.jdbc.pool.interceptor.
+#ConnectionState - keeps track of auto commit, read only, catalog and transaction \
isolation level. +#org.apache.tomcat.jdbc.pool.interceptor.
+#StatementFinalizer - keeps track of opened statements, and closes them when the \
connection is returned to the pool. +
+#More predefined interceptors are described in detail in the JDBC Interceptors \
section. +
+validationInterval.help=avoid excess validation, only run validation at most at this \
frequency - time in milliseconds. If a connection is due for validation, but has been \
validated previously within this interval, it will not be validated again. The \
default value is 30000 (30 seconds). +
+jmxEnabled.help=Register the pool with JMX or not. The default value is true.
+
+fairQueue.help=Set to true if you wish that calls to getConnection should be treated \
fairly in a true FIFO fashion. This uses the \
org.apache.tomcat.jdbc.pool.FairBlockingQueue implementation for the list of the idle \
connections. The default value is true. This flag is required when you want to use \
asynchronous connection retrieval. Setting this flag ensures that threads receive \
connections in the order they arrive. During performance tests, there is a very large \
difference in how locks and lock waiting is implemented. When fairQueue=true there is \
a decision making process based on what operating system the system is running. If \
the system is running on Linux (property os.name=Linux. To disable this Linux \
specific behavior and still use the fair queue, simply add the property \
org.apache.tomcat.jdbc.pool.FairBlockingQueue.ignoreOS=true to your system properties \
before the connection pool classes are loaded. +
+abandonWhenPercentageFull.help=Connections that have been abandoned (timed out) wont \
get closed and reported up unless the number of connections in use are above the \
percentage defined by abandonWhenPercentageFull. The value should be between 0-100. \
The default value is 0, which implies that connections are eligible for closure as \
soon as removeAbandonedTimeout has been reached. +
+maxAge.help=Time in milliseconds to keep this connection. When a connection is \
returned to the pool, the pool will check to see if the now - time-when-connected \
> maxAge has been reached, and if so, it closes the connection rather than \
returning it to the pool. The default value is 0, which implies that connections will \
be left open and no age check will be done upon returning the connection to the pool. \
+ +useEquals.help=Set to true if you wish the ProxyConnection class to use \
String.equals and set to false when you wish to use == when comparing method names. \
This property does not apply to added interceptors as those are configured \
individually. The default value is true. +
+suspectTimeout.help=Timeout value in seconds. Similar to to the \
removeAbandonedTimeout value but instead of treating the connection as abandoned, and \
potentially closing the connection, this simply logs the warning if logAbandoned is \
set to true. If this value is equal or less than 0, no suspect checking will be \
performed. Suspect checking only takes place if the timeout value is larger than 0 \
and the connection was not abandoned or if abandon check is disabled. If a connection \
is suspect a WARN message gets logged and a JMX notification gets sent once. +
+rollbackOnReturn.help=If autoCommit==false then the pool can terminate the \
transaction by calling rollback on the connection as it is returned to the pool \
Default value is false. +
+commitOnReturn.help=If autoCommit==false then the pool can complete the transaction \
by calling commit on the connection as it is returned to the pool If \
rollbackOnReturn==true then this attribute is ignored. Default value is false. +
+alternateUsernameAllowed.help=By default, the jdbc-pool will ignore the \
DataSource.getConnection(username,password) call, and simply return a previously \
pooled connection under the globally configured properties username and password, for \
performance reasons. The pool can however be configured to allow use of different \
credentials each time a connection is requested. To enable the functionality \
described in the DataSource.getConnection(username,password) call, simply set the \
property alternateUsernameAllowed to true. Should you request a connection with the \
credentials user1/password1 and the connection was previously connected using \
different user2/password2, the connection will be closed, and reopened with the \
requested credentials. This way, the pool size is still managed on a global level, \
and not on a per schema level. +
+dataSource.help=Inject a data source to the connection pool, and the pool will use \
the data source to retrieve connections instead of establishing them using the \
java.sql.Driver interface. This is useful when you wish to pool XA connections or \
connections established using a data source instead of a connection string. +
+dataSourceJNDI.help=The JNDI name for a data source to be looked up in JNDI and then \
used to establish connections to the database. See the dataSource attribute. Default \
value is null +
+useDisposableConnectionFacade.help=Set this to true if you wish to put a facade on \
your connection so that it cannot be reused after it has been closed. This prevents a \
thread holding on to a reference of a connection it has already called closed on, to \
execute queries on it. +
+logValidationErrors.help=Set this to true to log errors during the validation phase \
to the log file. If set to true, errors will be logged as SEVERE. Default value is \
false for backwards compatibility. +
+propagateInterruptState.help=Set this to true to propagate the interrupt state for a \
thread that has been interrupted (not clearing the interrupt state). Default value is \
false for backwards compatibility. +
+ignoreExceptionOnPreLoad.help=Flag whether ignore error of connection creation while \
initializing the pool. Set to true if you want to ignore error of connection creation \
while initializing the pool. Set to false if you want to fail the initialization of \
the pool by throwing exception. +
+
+
+
+name.blank=The Name attribute cannot be null or empty.
+pwd.blank=The Password attribute cannot be null or empty.
+invalid.jndi.entry=Invalid value in JNDI entry : ''{0}''.
+configuration.property.empty=Property ''{0}'' is empty.
+key.column.blank=Key column name configuration property is empty.
+pwd.column.blank=Password column name configuration property is empty.
+changelog.column.blank=Changelog column name configuration property is empty.
+table.blank=Table configuration property is empty.
+admin.user.blank=User configuration property is empty.
+admin.password.blank=Password configuration property is empty.
+host.blank=Host configuration property is empty.
+port.blank=Port configuration property is empty.
+database.blank=Database configuration property is empty.
+jdbc.template.blank=Configuration property JDBC Connection URL is empty.
+jdbc.driver.blank=Configuration property JDBC Driver is empty.
+jdbc.driver.not.found=JDBC Driver is not found on classpath.
+invalid.quoting=Invalid quoting ''{0}''.
+acount.object.class.required=Operation requires an 'Account' 'ObjectClass'.
+auth.op.not.supported=Authenticate operation is not supported.
+auth.op.failed=User ''{0}'' authentication failed!
+invalid.attribute.set=Invalid attributes set.
+uid.blank=Operation requires an valid Uid!
+result.handler.null=Result handler is null!
+passwd.column.eq.key.column=The password column should not be the same as key \
column. +passwd.column.eq.change.log.column=The password column should not be the \
same as changelog column. +key.column.eq.change.log.column=The key column should not \
be the same as changelog column. +query.invalid=Validate connection query ''{0}'' do \
not return a result set. +more.users.deleted=Delete account invalid, the uid ''{0}'' \
has more then one record. +invalid.sync.token.value=Sync token value is invalid.
+can.not.read=Can not read from the table or view ''{0}''.
+can.not.create=Can not create account ''{0}''.
+can.not.update=Can not update account ''{0}''.
+can.not.delete=Can not delete account ''{0}''.
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrcsitesitexml"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/site/site.xml (6508 => 6509)</h4> <pre \
class="diff"><span> <span class="info">--- \
trunk/connectors/java/scriptedcommon/src/site/site.xml 2014-04-14 21:18:24 UTC (rev \
6508)
+++ trunk/connectors/java/scriptedcommon/src/site/site.xml 2014-04-15 09:47:57 UTC \
(rev 6509) </span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> <menu name="ScriptedREST Core Docs">
</span><span class="cx"> <!--<item name="All Formats" \
href="docs.html" />--> </span><span class="cx"> \
<!--item name="Release Notes" \
href="./doc/release-notes/index.html" /--> </span><del>- \
<item name="Developer Guide" \
href="./doc/scriptedcommon-1.4.0.0-SNAPSHOT/index.html" /> </del><ins>+ \
<item name="Developer Guide" \
href="./doc/groovy-connector-1.4.0.0-SNAPSHOT/index.html" /> </ins><span \
class="cx"> </menu> </span><span class="cx">
</span><span class="cx"> <menu ref="reports"/>
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestconfigorgforgerockopenicfmiscscriptedco \
mmonScriptedConnectorBaseconfigconfiggroovyfromrev6504trunkconnectorsjavascriptedcommo \
nsrctestconfigorgforgerockopenicfconnectorsgroovyScriptedConnectorconfigconfiggroovy"></a>
<div class="copfile"><h4>Copied: \
trunk/connectors/java/scriptedcommon/src/test/config/org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase/config/config.groovy \
(from rev 6504, trunk/connectors/java/scriptedcommon/src/test/config/org.forgerock.openicf.connectors.groovy.ScriptedConnector/config/config.groovy) \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/config/org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase/config/config.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/config/org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase/config/config.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,91 @@
</span><ins>+/*
+ * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014. ForgeRock AS. All rights reserved.
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ */
+
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase
+import org.identityconnectors.common.security.GuardedString
+
+
+configuration {
+ clearTextPasswordToScript = false
+ authenticateScriptFileName = "AuthenticateScript.groovy"
+ createScriptFileName = "CreateScript.groovy"
+ deleteScriptFileName = "DeleteScript.groovy"
+ resolveUsernameScriptFileName = "ResolveUsernameScript.groovy"
+ schemaScriptFileName = "SchemaScript.groovy"
+ //scriptOnConnectorScriptFileName = "ScriptOnConnectorScript.groovy"
+ scriptOnResourceScriptFileName = "ScriptOnResourceScript.groovy"
+ searchScriptFileName = "SearchScript.groovy"
+ syncScriptFileName = "SyncScript.groovy"
+ testScriptFileName = "TestScript.groovy"
+ updateScriptFileName = "UpdateScript.groovy"
+
+ //warningLevel=WarningMessage.LIKELY_ERRORS
+ //sourceEncoding="UTF-8"
+ //targetDirectory=${project.build.directory}
+ //classpath=[${project.build.outputDirectory}]
+ //verbose=true
+ //debug=true
+ //tolerance=10
+ //scriptBaseClass=""
+ //recompileGroovySource=true
+ //minimumRecompilationInterval=100
+ //disabledGlobalASTTransformations=[]
+}
+
+environments {
+ GROOVY {
+ configuration {
+ classpath = \
[URLDecoder.decode(ScriptedConnectorBase.class.getResource("/groovy/").file, \
"UTF-8")] + scriptExtensions = ['groovy', 'java'] as String[]
+ }
+ }
+ CREST {
+ configuration {
+ classpath = \
[URLDecoder.decode(ScriptedConnectorBase.class.getResource("/crest/").file, \
"UTF-8")] + serviceAddress = new \
URI("http://localhost:8080/crest/") + login = "admin"
+ password = new GuardedString("Passw0rd".toCharArray())
+ }
+ }
+ REST {
+ configuration {
+ classpath = \
[URLDecoder.decode(ScriptedConnectorBase.class.getResource("/rest/").file, \
"UTF-8")] + serviceAddress = new \
URI("http://localhost:8080/rest/") + username = \
"admin" + password = new \
GuardedString("Passw0rd".toCharArray()) + }
+ }
+ SQL {
+ configuration {
+ classpath = \
[URLDecoder.decode(ScriptedConnectorBase.class.getResource("/sql/").file, \
"UTF-8")] + driverClassName = "org.h2.Driver"
+ validationQuery = "select 1"
+ url = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"
+ username = "sa"
+ password = "sa"
+ }
+ }
+}
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfconnectorsRESTTestBasejava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/RESTTestBase.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/RESTTestBase.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/RESTTestBase.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,177 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.eclipse.jetty.security.ConstraintMapping;
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.security.MappedLoginService;
+import org.eclipse.jetty.security.SecurityHandler;
+import org.eclipse.jetty.security.authentication.BasicAuthenticator;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.UserIdentity;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.util.security.Constraint;
+import org.eclipse.jetty.util.security.Credential;
+import org.forgerock.json.resource.servlet.HttpServlet;
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase;
+import org.identityconnectors.common.logging.Log;
+import org.identityconnectors.framework.api.APIConfiguration;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.api.ConnectorFacadeFactory;
+import org.identityconnectors.framework.spi.Connector;
+import org.identityconnectors.test.common.PropertyBag;
+import org.identityconnectors.test.common.TestHelpers;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+
+/**
+ * @author Laszlo Hordos
+ */
+public abstract class RESTTestBase {
+
+ /**
+ * Setup logging for the {@link RESTTestBase}.
+ */
+ private static final Log logger = Log.getLog(RESTTestBase.class);
+
+ private ConnectorFacade facade = null;
+ private Server server = null;
+
+ private SecurityHandler getSecurityHandler() throws IOException {
+ Constraint constraint = new Constraint(Constraint.__BASIC_AUTH, \
"user"); + constraint.setAuthenticate(true);
+
+ ConstraintMapping cm = new ConstraintMapping();
+ cm.setPathSpec("/*");
+ cm.setConstraint(constraint);
+
+ ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
+ sh.setAuthenticator(new BasicAuthenticator());
+ sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{cm}));
+
+ MappedLoginService loginService = new MappedLoginService() {
+
+ @Override
+ protected UserIdentity loadUser(String username) {
+ return null;
+ }
+
+ @Override
+ protected void loadUsers() throws IOException {
+ Credential credential = \
Credential.getCredential("Passw0rd"); + String[] roles = new \
String[]{"user"}; + putUser("admin", credential, \
roles); +
+ }
+ };
+ loginService.setName("user");
+ sh.setLoginService(loginService);
+ sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{cm}));
+
+ return sh;
+ }
+
+ @BeforeSuite
+ public void startServer() throws Exception {
+ System.out.append("Test port: \
").println(System.getProperty("jetty.http.port")); + // Create \
a basic jetty server object that will listen on port 8080. + // you can \
programmatically obtain it for use in test cases. + server = new Server(8080);
+
+ // Initializing the security handler
+ ServletContextHandler handler =
+ new ServletContextHandler(server, "/", \
ServletContextHandler.SESSIONS + | \
ServletContextHandler.SECURITY); +
+ // ADD SERVLET
+ // /rest/users/*
+ ServletHolder holder = handler.addServlet(HttpServlet.class, \
"/rest/users/*"); + \
holder.setInitParameter("connection-factory-class", + \
"org.forgerock.json.resource.servlet.MemoryBackendConnectionFactoryProvider");
+ holder.setInitParameter("uri-template", "");
+
+ // /rest/groups/*
+ holder = handler.addServlet(HttpServlet.class, "/rest/groups/*");
+ holder.setInitParameter("connection-factory-class",
+ "org.forgerock.json.resource.servlet.MemoryBackendConnectionFactoryProvider");
+ holder.setInitParameter("uri-template", "");
+
+ // /crest/users/*
+ holder = handler.addServlet(HttpServlet.class, "/crest/users/*");
+ holder.setInitParameter("connection-factory-class",
+ "org.forgerock.json.resource.servlet.MemoryBackendConnectionFactoryProvider");
+ holder.setInitParameter("uri-template", "");
+
+ // /crest/groups/*
+ holder = handler.addServlet(HttpServlet.class, "/crest/groups/*");
+ holder.setInitParameter("connection-factory-class",
+ "org.forgerock.json.resource.servlet.MemoryBackendConnectionFactoryProvider");
+ holder.setInitParameter("uri-template", "");
+
+ // SECURITY HANDLER
+ SecurityHandler sh = getSecurityHandler();
+ sh.setHandler(handler);
+
+ server.setHandler(sh);
+ server.start();
+ logger.info("Jetty Server Started");
+ }
+
+ @AfterSuite
+ public void stopServer() throws Exception {
+ server.stop();
+ logger.info("Jetty Server Stopped");
+ }
+
+
+ protected abstract ConnectorFacade getFacade();
+
+ protected ConnectorFacade getFacade(Class<? extends Connector> clazz, \
String environment) { + if (null == facade) {
+ facade = createConnectorFacade(clazz, environment);
+ }
+ return facade;
+ }
+
+ public static ConnectorFacade createConnectorFacade(Class<? extends \
Connector> clazz, + String \
environment) { + PropertyBag propertyBag =
+ TestHelpers.getProperties(ScriptedConnectorBase.class, environment);
+
+ APIConfiguration impl =
+ TestHelpers.createTestConfiguration(clazz, propertyBag, \
"configuration"); + impl.setProducerBufferSize(0);
+ impl.getResultsHandlerConfiguration().setEnableAttributesToGetSearchResultsHandler(false);
+ impl.getResultsHandlerConfiguration().setEnableCaseInsensitiveFilter(false);
+ impl.getResultsHandlerConfiguration().setEnableFilteredResultsHandler(false);
+ impl.getResultsHandlerConfiguration().setEnableNormalizingResultsHandler(false);
+
+ return ConnectorFacadeFactory.getInstance().newInstance(impl);
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfconnectorsScriptedCRESTConnectorTestjava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedCRESTConnectorTest.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedCRESTConnectorTest.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedCRESTConnectorTest.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.forgerock.openicf.connectors.scriptedcrest.ScriptedCRESTConnector;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * A NAME does ...
+ *
+ * @author Laszlo Hordos
+ */
+public class ScriptedCRESTConnectorTest extends RESTTestBase {
+
+ protected static final String TEST_NAME = "CREST";
+
+ protected ConnectorFacade getFacade() {
+ return getFacade(ScriptedCRESTConnector.class, TEST_NAME);
+ }
+
+ @Test
+ public void test() throws Exception {
+ final ConnectorFacade facade = getFacade();
+ facade.test();
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ final ConnectorFacade facade = getFacade();
+ Set<Attribute> createAttributes = new HashSet<Attribute>();
+ createAttributes.add(AttributeBuilder.build("userName", \
"doe")); + \
createAttributes.add(AttributeBuilder.buildCurrentPassword("Passw0rd".toCharArray()));
+
+ createAttributes.add(AttributeBuilder.build("givenName", \
"John")); + \
createAttributes.add(AttributeBuilder.build("sn", "Doe")); + \
createAttributes.add(AttributeBuilder.build("mail", \
"jdoe@example.com")); + \
createAttributes.add(AttributeBuilder.build("telephoneNumber", \
"1-555-555-1212")); +
+ createAttributes.add(AttributeBuilder.buildEnabled(true));
+
+ Uid uid1 = facade.create(ObjectClass.ACCOUNT, createAttributes, null);
+
+ Assert.assertEquals(uid1.getUidValue(), "0");
+ }
+
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfconnectorsScriptedRESTConnectorTestjava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedRESTConnectorTest.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedRESTConnectorTest.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedRESTConnectorTest.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,79 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors;
+
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.forgerock.openicf.connectors.scriptedrest.ScriptedRESTConnector;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * A NAME does ...
+ *
+ * @author Laszlo Hordos
+ */
+public class ScriptedRESTConnectorTest extends RESTTestBase {
+
+ protected static final String TEST_NAME = "REST";
+
+ protected ConnectorFacade getFacade() {
+ return getFacade(ScriptedRESTConnector.class, TEST_NAME);
+ }
+
+ @Test
+ public void testURI() throws Exception {
+ URI host = new URI("http://localhost:8080/openidm");
+ host.getAuthority();
+ }
+
+ @Test
+ public void test() throws Exception {
+ final ConnectorFacade facade = getFacade();
+ facade.test();
+ }
+
+ @Test(enabled = false)
+ public void testCreate() throws Exception {
+ final ConnectorFacade facade = getFacade();
+ Set<Attribute> createAttributes = new HashSet<Attribute>();
+ createAttributes.add(new Name("foo"));
+ createAttributes.add(AttributeBuilder.buildCurrentPassword("Passw0rd".toCharArray()));
+ createAttributes.add(AttributeBuilder.buildEnabled(true));
+
+ Uid uid1 = facade.create(ObjectClass.ACCOUNT, createAttributes, null);
+
+ Assert.assertEquals(uid1.getUidValue(), "foo");
+ }
+
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfconnectorsScriptedSQLConnectorTestjava"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedSQLConnectorTest.java \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedSQLConnectorTest.java \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/connectors/ScriptedSQLConnectorTest.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,129 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+package org.forgerock.openicf.connectors;
+
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.commons.io.IOUtils;
+import org.forgerock.openicf.connectors.scriptedsql.ScriptedSQLConnector;
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase;
+import org.identityconnectors.common.logging.Log;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.test.common.PropertyBag;
+import org.identityconnectors.test.common.TestHelpers;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.forgerock.openicf.connectors.RESTTestBase.createConnectorFacade;
+
+/**
+ * A NAME does ...
+ *
+ * @author Laszlo Hordos
+ */
+public class ScriptedSQLConnectorTest {
+
+ /**
+ * Setup logging for the {@link ScriptedSQLConnectorTest}.
+ */
+ private static final Log logger = Log.getLog(ScriptedSQLConnectorTest.class);
+
+ protected static final String TEST_NAME = "SQL";
+
+ private ConnectorFacade facadeInstance;
+
+ @BeforeClass
+ public void startServer() throws Exception {
+ Connection con = getConnection();
+ Statement stmt = con.createStatement();
+ try {
+ InputStream in = \
ScriptedSQLConnectorTest.class.getResourceAsStream("/sql/testDatabase.ddl");
+ Assert.assertNotNull(in);
+ stmt.execute(IOUtils.toString(in));
+ } finally {
+ stmt.close();
+ con.close();
+ }
+ }
+
+ @AfterClass
+ public void stopServer() throws Exception {
+ Connection con = getConnection();
+ Statement stmt = con.createStatement();
+ try {
+ stmt.execute("SHUTDOWN");
+ } finally {
+ stmt.close();
+ con.close();
+ }
+ }
+
+ @Test
+ public void testTest() throws Exception {
+ final ConnectorFacade facade = getFacade(TEST_NAME);
+ facade.test();
+ }
+
+ private Connection getConnection() throws ClassNotFoundException, SQLException {
+ PropertyBag propertyBag = \
TestHelpers.getProperties(ScriptedConnectorBase.class, TEST_NAME); +
+ String jdbcUrl = \
propertyBag.getStringProperty("configuration.url"); + \
Assert.assertNotNull(jdbcUrl); +
+ Class.forName("org.h2.Driver");
+ return DriverManager.getConnection(jdbcUrl, "sa", "sa");
+ }
+
+ protected ConnectorFacade getFacade(String environment) {
+ if (null == facadeInstance) {
+ facadeInstance = createConnectorFacade(ScriptedSQLConnector.class, \
environment); + }
+ return facadeInstance;
+ }
+
+ @Test
+ public void sampleTest() throws Exception {
+ Connection con = getConnection();
+ Statement stmt = con.createStatement();
+ try {
+ ResultSet rs = stmt.executeQuery("SELECT id, UID FROM Users");
+ while (rs.next()) {
+ String name = rs.getString("uid");
+ System.out.println(name);
+ }
+ } finally {
+ stmt.close();
+ con.close();
+ }
+ }
+
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestjavaorgforgerockopenicfmiscscriptedcommonScriptedConnectorTestjava"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnectorTest.java \
(6508 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnectorTest.java 2014-04-14 \
21:18:24 UTC (rev 6508)
+++ trunk/connectors/java/scriptedcommon/src/test/java/org/forgerock/openicf/misc/scriptedcommon/ScriptedConnectorTest.java 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -30,31 +30,45 @@
</span><span class="cx"> import java.util.MissingResourceException;
</span><span class="cx"> import java.util.Set;
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> import \
org.forgerock.openicf.connectors.groovy.ScriptedConnector; </span><span class="cx"> \
import org.identityconnectors.common.logging.Log; </span><span class="cx"> import \
org.identityconnectors.common.security.GuardedString; </span><del>-import \
org.identityconnectors.framework.api.APIConfiguration; </del><span class="cx"> import \
org.identityconnectors.framework.api.ConnectorFacade; </span><del>-import \
org.identityconnectors.framework.api.ConnectorFacadeFactory; </del><ins>+import \
org.identityconnectors.framework.common.exceptions.AlreadyExistsException; \
</ins><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.ConnectorSecurityException; \
</span><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException; \
</span><ins>+import org.identityconnectors.framework.common.exceptions.InvalidCredentialException;
+import org.identityconnectors.framework.common.exceptions.InvalidPasswordException;
+import org.identityconnectors.framework.common.exceptions.PermissionDeniedException;
+import org.identityconnectors.framework.common.exceptions.PreconditionFailedException;
+import org.identityconnectors.framework.common.exceptions.PreconditionRequiredException;
+import org.identityconnectors.framework.common.exceptions.RetryableException;
</ins><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.UnknownUidException; </span><span \
class="cx"> import org.identityconnectors.framework.common.objects.Attribute; \
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.AttributeBuilder; </span><ins>+import \
org.identityconnectors.framework.common.objects.AttributeUtil; </ins><span \
class="cx"> import org.identityconnectors.framework.common.objects.ConnectorObject; \
</span><span class="cx"> import org.identityconnectors.framework.common.objects.Name; \
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.ObjectClass; </span><ins>+import \
org.identityconnectors.framework.common.objects.OperationOptionsBuilder; +import \
org.identityconnectors.framework.common.objects.ResultsHandler; </ins><span \
class="cx"> import org.identityconnectors.framework.common.objects.Schema; \
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.ScriptContextBuilder; \
</span><ins>+import org.identityconnectors.framework.common.objects.SearchResult; \
+import org.identityconnectors.framework.common.objects.SortKey; </ins><span \
class="cx"> import org.identityconnectors.framework.common.objects.SyncDelta; \
</span><ins>+import org.identityconnectors.framework.common.objects.SyncDeltaType; \
</ins><span class="cx"> import \
org.identityconnectors.framework.common.objects.SyncResultsHandler; </span><span \
class="cx"> import org.identityconnectors.framework.common.objects.SyncToken; \
</span><span class="cx"> import org.identityconnectors.framework.common.objects.Uid; \
</span><del>-import org.identityconnectors.test.common.PropertyBag; \
</del><ins>+import org.identityconnectors.framework.common.objects.filter.FilterBuilder;
</ins><span class="cx"> import org.identityconnectors.test.common.TestHelpers;
</span><span class="cx"> import org.testng.Assert;
</span><span class="cx"> import org.testng.annotations.Test;
</span><span class="cx">
</span><ins>+import static \
org.forgerock.openicf.connectors.RESTTestBase.createConnectorFacade; +
</ins><span class="cx"> public class ScriptedConnectorTest {
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -62,69 +76,160 @@
</span><span class="cx"> */
</span><span class="cx"> private static final Log logger = \
Log.getLog(ScriptedConnectorTest.class); </span><span class="cx">
</span><del>- protected static final String testCase = "case1";
</del><ins>+ protected static final String TEST_NAME = "GROOVY";
+ private static final ObjectClass TEST = new ObjectClass("__TEST__");
+ private static final ObjectClass SAMPLE = new \
ObjectClass("__SAMPLE__"); </ins><span class="cx">
</span><span class="cx"> private ConnectorFacade facade;
</span><span class="cx">
</span><ins>+ // =======================================================================
+ // Authenticate Operation Test
+ // =======================================================================
+
</ins><span class="cx"> @Test(expectedExceptions = \
ConnectorSecurityException.class) </span><span class="cx"> public void \
testAuthenticate1() throws Exception { </span><del>- \
getFacade(testCase).authenticate(ObjectClass.ACCOUNT, \
"TEST1",
- new GuardedString("".toCharArray()), null);
</del><ins>+ getFacade(TEST_NAME).authenticate(TEST, "TEST1",
+ new GuardedString("Passw0rd".toCharArray()), null);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ @Test(expectedExceptions = InvalidCredentialException.class)
+ public void testAuthenticate2() throws Exception {
+ getFacade(TEST_NAME).authenticate(TEST, "TEST2",
+ new GuardedString("Passw0rd".toCharArray()), null);
+ }
+
+ @Test(expectedExceptions = InvalidPasswordException.class)
+ public void testAuthenticate3() throws Exception {
+ getFacade(TEST_NAME).authenticate(TEST, "TEST3",
+ new GuardedString("Passw0rd".toCharArray()), null);
+ }
+
+ @Test(expectedExceptions = PermissionDeniedException.class)
+ public void testAuthenticate4() throws Exception {
+ getFacade(TEST_NAME).authenticate(TEST, "TEST4",
+ new GuardedString("Passw0rd".toCharArray()), null);
+ }
+
</ins><span class="cx"> @Test
</span><span class="cx"> public void testAuthenticate5() throws Exception {
</span><del>- \
Assert.assertNotNull(getFacade(testCase).authenticate(ObjectClass.ACCOUNT, \
"TEST5",
- new GuardedString("Passw0rd".toCharArray()), null));
</del><ins>+ Assert.assertEquals(getFacade(TEST_NAME).authenticate(TEST, \
"TEST5", + new \
GuardedString("Passw0rd".toCharArray()), null).getUidValue(), \
"TEST5"); </ins><span class="cx"> }
</span><span class="cx">
</span><del>- @Test
</del><ins>+ @Test(expectedExceptions = UnknownUidException.class)
</ins><span class="cx"> public void testAuthenticate6() throws Exception {
</span><del>- \
Assert.assertNotNull(getFacade(testCase).authenticate(ObjectClass.ACCOUNT, \
"TEST6",
- new GuardedString("Passw0rd".toCharArray()), null));
</del><ins>+ getFacade(TEST_NAME).authenticate(TEST, "TEST6",
+ new GuardedString("Passw0rd".toCharArray()), null);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ // =======================================================================
+ // Create Operation Test
+ // =======================================================================
+
</ins><span class="cx"> @Test
</span><span class="cx"> public void testCreate() throws Exception {
</span><del>- Set<Attribute> createAttributes = new \
HashSet<Attribute>(1);
- createAttributes.add(new Name("1"));
- createAttributes.add(AttributeBuilder.build("email", \
"mail@example.com"));
- ConnectorFacade facade = getFacade(testCase);
</del><ins>+ Set<Attribute> createAttributes = \
getTestConnectorObject("Foo"); + ConnectorFacade facade = \
getFacade(TEST_NAME); </ins><span class="cx"> Uid uid = \
facade.create(ObjectClass.ACCOUNT, createAttributes, null); </span><span class="cx"> \
Assert.assertNotNull(uid); </span><span class="cx"> ConnectorObject co = \
facade.getObject(ObjectClass.ACCOUNT, uid, null); </span><span class="cx"> \
Assert.assertEquals(co.getUid(), uid); </span><span class="cx"> }
</span><span class="cx">
</span><ins>+ @Test(expectedExceptions = AlreadyExistsException.class)
+ public void testCreateTest1() throws Exception {
+ Set<Attribute> createAttributes = \
getTestConnectorObject("TEST1"); + ConnectorFacade facade = \
getFacade(TEST_NAME); + facade.create(TEST, createAttributes, null);
+ }
+
+ @Test(expectedExceptions = InvalidAttributeValueException.class)
+ public void testCreateTest2() throws Exception {
+ Set<Attribute> createAttributes = \
getTestConnectorObject("TEST2"); + ConnectorFacade facade = \
getFacade(TEST_NAME); + facade.create(TEST, createAttributes, null);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testCreateTest3() throws Exception {
+ Set<Attribute> createAttributes = \
getTestConnectorObject("TEST3"); + ConnectorFacade facade = \
getFacade(TEST_NAME); + facade.create(TEST, createAttributes, null);
+ }
+
+ @Test(expectedExceptions = RetryableException.class)
+ public void testCreateTest4() throws Exception {
+ Set<Attribute> createAttributes = \
getTestConnectorObject("TEST4"); + ConnectorFacade facade = \
getFacade(TEST_NAME); + facade.create(TEST, createAttributes, null);
+ }
+
+ @Test
+ public void testCreateTest5() throws Exception {
+ Set<Attribute> createAttributes = \
getTestConnectorObject("TEST5"); + ConnectorFacade facade = \
getFacade(TEST_NAME); + Uid uid = facade.create(TEST, createAttributes, null);
+ Assert.assertEquals(uid.getUidValue(), "TEST5");
+ }
+
+ // =======================================================================
+ // Delete Operation Test
+ // =======================================================================
+
</ins><span class="cx"> @Test(expectedExceptions = UnknownUidException.class)
</span><del>- public void testDelete() throws Exception {
- ConnectorFacade facade = getFacade(testCase);
- facade.delete(ObjectClass.ACCOUNT, new Uid("NON_EXIST"), null);
</del><ins>+ public void testDelete1() throws Exception {
+ ConnectorFacade facade = getFacade(TEST_NAME);
+ facade.delete(TEST, new Uid("TEST1"), null);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+
+ @Test(expectedExceptions = PreconditionFailedException.class)
+ public void testDelete4() throws Exception {
+ ConnectorFacade facade = getFacade(TEST_NAME);
+ facade.delete(TEST, new Uid("TEST4"), null);
+ }
+
+ @Test(expectedExceptions = PreconditionRequiredException.class)
+ public void testDelete5() throws Exception {
+ ConnectorFacade facade = getFacade(TEST_NAME);
+ facade.delete(TEST, new Uid("TEST5"), null);
+ }
+
+ // =======================================================================
+ // ResolveUsername Operation Test
+ // =======================================================================
+
</ins><span class="cx"> @Test
</span><span class="cx"> public void testResolveUsername() throws Exception {
</span><del>- ConnectorFacade facade = getFacade(testCase);
</del><ins>+ ConnectorFacade facade = getFacade(TEST_NAME);
</ins><span class="cx"> Uid uidAfter = \
facade.resolveUsername(ObjectClass.ACCOUNT, "TEST1", null); </span><span \
class="cx"> Assert.assertEquals(uidAfter.getUidValue(), "123"); \
</span><span class="cx"> } </span><span class="cx">
</span><span class="cx"> @Test(expectedExceptions = UnknownUidException.class)
</span><span class="cx"> public void testResolveUsername1() throws Exception {
</span><del>- ConnectorFacade facade = getFacade(testCase);
</del><ins>+ ConnectorFacade facade = getFacade(TEST_NAME);
</ins><span class="cx"> facade.resolveUsername(ObjectClass.ACCOUNT, \
"NON_EXIST", null); </span><span class="cx"> }
</span><span class="cx">
</span><ins>+ // =======================================================================
+ // Schema Operation Test
+ // =======================================================================
+
</ins><span class="cx"> @Test
</span><span class="cx"> public void testSchema() throws Exception {
</span><del>- ConnectorFacade facade = getFacade(testCase);
</del><ins>+ ConnectorFacade facade = getFacade(TEST_NAME);
</ins><span class="cx"> Schema schema = facade.schema();
</span><span class="cx"> \
Assert.assertNotNull(schema.findObjectClassInfo("__TEST__")); </span><span \
class="cx"> } </span><span class="cx">
</span><ins>+ // =======================================================================
+ // ScriptOnConnector Operation Test
+ // =======================================================================
+
</ins><span class="cx"> @Test
</span><span class="cx"> public void testScriptOnConnector() throws Exception {
</span><del>- ConnectorFacade facade = getFacade(testCase);
</del><ins>+ ConnectorFacade facade = getFacade(TEST_NAME);
</ins><span class="cx"> ScriptContextBuilder builder = new \
ScriptContextBuilder(); </span><span class="cx"> \
builder.setScriptLanguage("Groovy"); </span><span class="cx"> \
builder.setScriptText("return uid"); </span><span class="lines">@@ -133,9 \
+238,13 @@ </span><span class="cx"> \
Assert.assertEquals(facade.runScriptOnConnector(builder.build(), null), uid); \
</span><span class="cx"> } </span><span class="cx">
</span><ins>+ // =======================================================================
+ // ScriptOnResource Operation Test
+ // =======================================================================
+
</ins><span class="cx"> @Test
</span><span class="cx"> public void testScriptOnResource() throws Exception {
</span><del>- ConnectorFacade facade = getFacade(testCase);
</del><ins>+ ConnectorFacade facade = getFacade(TEST_NAME);
</ins><span class="cx"> ScriptContextBuilder builder = new \
ScriptContextBuilder(); </span><span class="cx"> \
builder.setScriptLanguage("SHELL"); </span><span class="cx"> \
builder.setScriptText("test"); </span><span class="lines">@@ -144,48 \
+253,241 @@ </span><span class="cx">
</span><span class="cx"> @Test(expectedExceptions = \
InvalidAttributeValueException.class) </span><span class="cx"> public void \
testScriptOnResourceFail() throws Exception { </span><del>- ConnectorFacade \
facade = getFacade(testCase); </del><ins>+ ConnectorFacade facade = \
getFacade(TEST_NAME); </ins><span class="cx"> ScriptContextBuilder builder = \
new ScriptContextBuilder(); </span><span class="cx"> \
builder.setScriptLanguage("BASH"); </span><span class="cx"> \
builder.setScriptText("test"); </span><span class="cx"> \
Assert.assertEquals(facade.runScriptOnResource(builder.build(), null), true); \
</span><span class="cx"> } </span><span class="cx">
</span><ins>+ // =======================================================================
+ // Search Operation Test
+ // =======================================================================
+
</ins><span class="cx"> @Test
</span><span class="cx"> public void testSearch() throws Exception {
</span><del>- ConnectorObject co = \
getFacade(testCase).getObject(ObjectClass.GROUP, new Uid("1"), null); \
</del><ins>+ ConnectorObject co = getFacade(TEST_NAME).getObject(SAMPLE, new \
Uid("1"), null); </ins><span class="cx"> Assert.assertNotNull(co);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @Test
</span><span class="cx"> public void testSearch1() throws Exception {
</span><del>- ConnectorFacade search = getFacade(testCase);
</del><ins>+ ConnectorFacade search = getFacade(TEST_NAME);
</ins><span class="cx"> List<ConnectorObject> result =
</span><span class="cx"> TestHelpers.searchToList(search, new \
ObjectClass("__EMPTY__"), null); </span><span class="cx"> \
Assert.assertTrue(result.isEmpty()); </span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @Test
</span><ins>+ public void testSearch2() throws Exception {
+ ConnectorFacade search = getFacade(TEST_NAME);
+ for (int i = 0; i < 100; i++) {
+ Set<Attribute> co = \
getTestConnectorObject(String.format("TEST%05d", i)); + \
co.add(AttributeBuilder.build("sortKey", i)); + \
search.create(ObjectClass.ACCOUNT, co, null); + }
+
+
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setPageSize(10);
+ builder.setSortKeys(new SortKey("sortKey", false));
+ SearchResult result = null;
+
+ final Set<ConnectorObject> resultSet = new \
HashSet<ConnectorObject>(); + int pageIndex = 0;
+
+ while ((result = search
+ .search(ObjectClass.ACCOUNT, \
FilterBuilder.startsWith(AttributeBuilder.build(Name.NAME, "TEST")), + \
new ResultsHandler() { + private int index = 101;
+
+ public boolean handle(ConnectorObject connectorObject) {
+ Integer idx = AttributeUtil.getIntegerValue(
+ \
connectorObject.getAttributeByName("sortKey")); + \
Assert.assertTrue(idx < index); + index = idx;
+ return resultSet.add(connectorObject);
+ }
+ }, builder.build()
+ )).getPagedResultsCookie() != null) {
+
+ builder = new OperationOptionsBuilder(builder.build());
+ builder.setPagedResultsCookie(result.getPagedResultsCookie());
+ Assert.assertEquals(resultSet.size(), 10 * ++pageIndex);
+ }
+ Assert.assertEquals(pageIndex, 9);
+ Assert.assertEquals(resultSet.size(), 100);
+ }
+
+ // =======================================================================
+ // Sync Operation Test
+ // =======================================================================
+
+ @Test
</ins><span class="cx"> public void testSync() throws Exception {
</span><del>- ConnectorFacade sync = getFacade(testCase);
</del><ins>+ final ConnectorFacade facade = getFacade(TEST_NAME);
</ins><span class="cx"> final List<SyncDelta> result = new \
ArrayList<SyncDelta>(); </span><del>- SyncToken lastToken = \
sync.sync(ObjectClass.ACCOUNT, null, new SyncResultsHandler() { </del><ins>+
+ SyncToken lastToken = facade.sync(ObjectClass.ACCOUNT, new SyncToken(0), new \
SyncResultsHandler() { </ins><span class="cx"> public boolean \
handle(SyncDelta delta) { </span><span class="cx"> return \
result.add(delta); </span><span class="cx"> }
</span><span class="cx"> }, null);
</span><del>- Assert.assertFalse(result.isEmpty());
</del><ins>+ Assert.assertEquals(lastToken.getValue(), 1);
+ Assert.assertEquals(result.size(), 1);
+ SyncDelta delta = result.remove(0);
+ Assert.assertEquals(delta.getDeltaType(), SyncDeltaType.CREATE);
+ Assert.assertEquals(delta.getObject().getAttributes().size(), 44);
+
+ lastToken = facade.sync(ObjectClass.ACCOUNT, lastToken, new \
SyncResultsHandler() { + public boolean handle(SyncDelta delta) {
+ return result.add(delta);
+ }
+ }, null);
+ Assert.assertEquals(lastToken.getValue(), 2);
+ Assert.assertEquals(result.size(), 1);
+ delta = result.remove(0);
+ Assert.assertEquals(delta.getDeltaType(), SyncDeltaType.UPDATE);
+
+
+ lastToken = facade.sync(ObjectClass.ACCOUNT, lastToken, new \
SyncResultsHandler() { + public boolean handle(SyncDelta delta) {
+ return result.add(delta);
+ }
+ }, null);
+ Assert.assertEquals(lastToken.getValue(), 3);
+ Assert.assertEquals(result.size(), 1);
+ delta = result.remove(0);
+ Assert.assertEquals(delta.getDeltaType(), SyncDeltaType.CREATE_OR_UPDATE);
+
+
+ lastToken = facade.sync(ObjectClass.ACCOUNT, lastToken, new \
SyncResultsHandler() { + public boolean handle(SyncDelta delta) {
+ return result.add(delta);
+ }
+ }, null);
+ Assert.assertEquals(lastToken.getValue(), 4);
+ Assert.assertEquals(result.size(), 1);
+ delta = result.remove(0);
+ Assert.assertEquals(delta.getDeltaType(), SyncDeltaType.UPDATE);
+ Assert.assertEquals(delta.getPreviousUid().getUidValue(), "001");
+
+
+ lastToken = facade.sync(ObjectClass.ACCOUNT, lastToken, new \
SyncResultsHandler() { + public boolean handle(SyncDelta delta) {
+ return result.add(delta);
+ }
+ }, null);
+ Assert.assertEquals(lastToken.getValue(), 5);
+ Assert.assertEquals(result.size(), 1);
+ delta = result.remove(0);
+ Assert.assertEquals(delta.getDeltaType(), SyncDeltaType.DELETE);
+
+
+ lastToken = facade.sync(ObjectClass.ACCOUNT, lastToken, new \
SyncResultsHandler() { + public boolean handle(SyncDelta delta) {
+ return result.add(delta);
+ }
+ }, null);
+ Assert.assertEquals(lastToken.getValue(), 10);
+ Assert.assertTrue(result.isEmpty());
+
+
+ lastToken = facade.sync(ObjectClass.ACCOUNT, lastToken, new \
SyncResultsHandler() { + public boolean handle(SyncDelta delta) {
+ return result.add(delta);
+ }
+ }, null);
+ Assert.assertEquals(lastToken.getValue(), 17);
+ Assert.assertEquals(result.size(), 4);
+ result.clear();
+
+ lastToken = facade.sync(ObjectClass.GROUP, new SyncToken(10), new \
SyncResultsHandler() { + public boolean handle(SyncDelta delta) {
+ return result.add(delta);
+ }
+ }, null);
+ Assert.assertEquals(lastToken.getValue(), 16);
+ Assert.assertEquals(result.size(), 3);
+
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ @Test
+ public void testSyncAll() throws Exception {
+ final ConnectorFacade facade = getFacade(TEST_NAME);
+ final List<SyncDelta> result = new ArrayList<SyncDelta>();
+
+ SyncToken lastToken = facade.sync(ObjectClass.ALL, new SyncToken(0), new \
SyncResultsHandler() { + public boolean handle(SyncDelta delta) {
+ return result.add(delta);
+ }
+ }, null);
+ Assert.assertEquals(lastToken.getValue(), 17);
+ Assert.assertEquals(result.size(), 7);
+ int index = 10;
+ for (SyncDelta delta : result) {
+ Assert.assertEquals(index++, delta.getToken().getValue());
+ if (((int) delta.getToken().getValue()) % 2 == 0) {
+ Assert.assertEquals(delta.getObject().getObjectClass(), \
ObjectClass.ACCOUNT); + } else {
+ Assert.assertEquals(delta.getObject().getObjectClass(), \
ObjectClass.GROUP); + }
+ }
+ }
+
+ @Test
+ public void testSyncSample() throws Exception {
+ final ConnectorFacade facade = getFacade(TEST_NAME);
+ final List<SyncDelta> result = new ArrayList<SyncDelta>();
+
+ SyncToken lastToken = facade.sync(SAMPLE, new SyncToken(0), new \
SyncResultsHandler() { + public boolean handle(SyncDelta delta) {
+ return result.add(delta);
+ }
+ }, null);
+ Assert.assertEquals(lastToken.getValue(), "SAMPLE");
+ Assert.assertEquals(result.size(), 2);
+ }
+
+ @Test
+ public void testSyncToken() throws Exception {
+ final ConnectorFacade facade = getFacade(TEST_NAME);
+
+ SyncToken lastToken = facade.getLatestSyncToken(ObjectClass.ACCOUNT);
+ Assert.assertEquals(lastToken.getValue(), 17);
+ lastToken = facade.getLatestSyncToken(ObjectClass.GROUP);
+ Assert.assertEquals(lastToken.getValue(), 16);
+ lastToken = facade.getLatestSyncToken(ObjectClass.ALL);
+ Assert.assertEquals(lastToken.getValue(), 17);
+ lastToken = facade.getLatestSyncToken(TEST);
+ Assert.assertEquals(lastToken.getValue(), 0);
+ lastToken = facade.getLatestSyncToken(SAMPLE);
+ Assert.assertEquals(lastToken.getValue(), "ANY OBJECT");
+ }
+
+ // =======================================================================
+ // Test Operation Test
+ // =======================================================================
+
</ins><span class="cx"> @Test(expectedExceptions = \
MissingResourceException.class) </span><span class="cx"> public void testTest() \
throws Exception { </span><del>- ConnectorFacade facade = getFacade(testCase);
</del><ins>+ ConnectorFacade facade = getFacade(TEST_NAME);
</ins><span class="cx"> facade.test();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ // =======================================================================
+ // Update Operation Test
+ // =======================================================================
+
+ @Test(expectedExceptions = UnknownUidException.class)
+ public void testDelete() throws Exception {
+ ConnectorFacade facade = getFacade(TEST_NAME);
+ facade.delete(ObjectClass.ACCOUNT, new Uid("NON_EXIST"), null);
+ }
+
</ins><span class="cx"> @Test(dependsOnMethods = "testCreate")
</span><span class="cx"> public void testUpdate() throws Exception {
</span><del>- ConnectorFacade facade = getFacade(testCase);
</del><ins>+ ConnectorFacade facade = getFacade(TEST_NAME);
</ins><span class="cx"> Set<Attribute> updateAttributes = new \
HashSet<Attribute>(1); </span><span class="cx"> \
updateAttributes.add(AttributeBuilder.build("email", \
"foo@example.com")); </span><span class="cx">
</span><span class="lines">@@ -193,23 +495,17 @@
</span><span class="cx"> Assert.assertEquals(uid.getUidValue(), \
"2"); </span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+ private Set<Attribute> getTestConnectorObject(String name) {
+ Set<Attribute> createAttributes = new HashSet<Attribute>(1);
+ createAttributes.add(new Name(name));
+ createAttributes.add(AttributeBuilder.build("email", name + \
"@example.com")); + return createAttributes;
+ }
+
</ins><span class="cx"> protected ConnectorFacade getFacade(String environment) {
</span><span class="cx"> if (null == facade) {
</span><del>-
- PropertyBag propertyBag =
- TestHelpers.getProperties(ScriptedConnector.class, environment);
-
- APIConfiguration impl =
- TestHelpers.createTestConfiguration(ScriptedConnector.class, \
propertyBag,
- "configuration");
- impl.setProducerBufferSize(0);
- impl.getResultsHandlerConfiguration().setEnableAttributesToGetSearchResultsHandler(
- false);
- impl.getResultsHandlerConfiguration().setEnableCaseInsensitiveFilter(false);
- impl.getResultsHandlerConfiguration().setEnableFilteredResultsHandler(false);
- impl.getResultsHandlerConfiguration().setEnableNormalizingResultsHandler(false);
-
- facade = ConnectorFacadeFactory.getInstance().newInstance(impl);
</del><ins>+ facade = createConnectorFacade(ScriptedConnector.class, \
environment); </ins><span class="cx"> }
</span><span class="cx"> return facade;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresources"></a>
<div class="propset"><h4>Property changes: \
trunk/connectors/java/scriptedcommon/src/test/resources</h4> <pre class="diff"><span>
</span></pre></div>
<a id="svnignore"></a>
<div class="addfile"><h4>Added: svn:ignore</h4></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestAuthenticateScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/AuthenticateScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/AuthenticateScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/AuthenticateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestCreateScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/CreateScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/CreateScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/CreateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,161 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+import org.forgerock.json.fluent.JsonValue
+import org.forgerock.json.resource.Connection
+import org.forgerock.json.resource.CreateRequest
+import org.forgerock.json.resource.QueryResult
+import org.forgerock.json.resource.Requests
+import org.forgerock.json.resource.Resource
+import org.forgerock.json.resource.RootContext
+import org.forgerock.openicf.connectors.scriptedcrest.ScriptedCRESTConfiguration
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.identityconnectors.common.Base64
+import org.identityconnectors.common.logging.Log
+import org.identityconnectors.common.security.GuardedByteArray
+import org.identityconnectors.common.security.GuardedString
+import org.identityconnectors.common.security.SecurityUtil
+import org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException
+import org.identityconnectors.framework.common.objects.Attribute
+import org.identityconnectors.framework.common.objects.AttributeBuilder
+import org.identityconnectors.framework.common.objects.AttributeInfo
+import org.identityconnectors.framework.common.objects.AttributeUtil
+import org.identityconnectors.framework.common.objects.AttributesAccessor
+import org.identityconnectors.framework.common.objects.Name
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.ObjectClassInfo
+import org.identityconnectors.framework.common.objects.OperationOptions
+import org.identityconnectors.framework.common.objects.OperationalAttributes
+import org.identityconnectors.framework.common.objects.Schema
+import org.identityconnectors.framework.common.objects.Uid
+import org.identityconnectors.framework.common.objects.filter.FilterBuilder
+
+def action = action as OperationType
+def createAttributes = attributes as Set<Attribute>
+def attributeAccessor = new AttributesAccessor(createAttributes);
+def configuration = configuration as ScriptedCRESTConfiguration
+def connection = connection as Connection
+def name = id as String
+def log = log as Log
+def objectClass = objectClass as ObjectClass
+def options = options as OperationOptions
+def schema = schema as Schema
+
+
+log.info("Entering " + action + " Script");
+
+ObjectClassInfo ocInfo = schema.findObjectClassInfo(objectClass.objectClassValue)
+if (null != ocInfo) {
+
+ def converter = { v ->
+ if (v instanceof GuardedString) {
+ return SecurityUtil.decrypt(v as GuardedString);
+ } else if (v instanceof GuardedByteArray) {
+ return Base64.encode(SecurityUtil.decrypt(v as GuardedByteArray));
+ } else if (v instanceof byte[]) {
+ return Base64.encode(v as byte[]);
+ } else {
+ return v
+ }
+ }
+ def user = [:]
+ for (AttributeInfo attributeInfo : ocInfo.attributeInfo) {
+ if (attributeInfo.is(Name.NAME)){
+ continue
+ }
+ Attribute attribute = attributeAccessor.find(attributeInfo.name);
+ if (attributeInfo.required && (null == attribute || null == \
attribute.value || attribute.value.size() == 0)) { + throw new \
InvalidAttributeValueException("Missing required attribute:" + \
attributeInfo.name); + }
+ if (!attributeInfo.multiValued && null != attribute && \
attribute?.value?.size() > 1) { + throw new \
InvalidAttributeValueException("Non multivalued attribute has multiple \
values:" + attributeInfo.name); + }
+
+ def value = null;
+ if (null != attribute) {
+ if (attributeInfo.multiValued) {
+ value = attribute.value.each converter
+ } else {
+ value = converter attribute.value.first()
+ }
+ }
+
+ user[attributeInfo.name] = value
+ }
+
+ CreateRequest request = Requests.newCreateRequest("users", name, new \
JsonValue(user)) + Resource resource = connection.create(new RootContext(), \
request) + return new Uid(resource.getId(), resource.getRevision())
+
+} else {
+ throw UnsupportedOperationException("Create operation of type:" + \
objectClass.objectClassValue) +}
+
+//switch (objectClass) {
+// case ObjectClass.ACCOUNT:
+// CRESTBuilder.create("users") { reg ->
+// newResourceId = "dsfd"
+// content {
+// userName '12'
+// givenName 'John'
+// sn 'Doe'
+// mail 'jdoe@example.com'
+// telephoneNumber '1-555-555-1212'
+// }
+// }.onSuccess{ response ->
+// new Uid(response.id, response.revision)
+// }.onFailure{ ex ->
+// throw ex;
+// }.execute(connection, null)
+//
+//
+//
+// def filter = FilterBuilder.equalTo(AttributeBuilder.build(Name.name, \
"123")) +//
+// CRESTBuilder.query("users") {
+// queryFilter = filter
+// }.onSuccess{ QueryResult response ->
+// while (response.pagedResultsCookie != null){
+// request.pagedResultsCookie = response.pagedResultsCookie
+// execute()
+// }
+// }.onFailure{ ex ->
+// throw ex;
+// }.execute(connection, new RootContext())
+
+// def queryResult = builder.query("users"){queryRequest ->
+//
+// }.execute(connection, context){ res ->
+// handler{
+// uid res.id, res.revision
+// res.content.each {
+//
+// }
+// }
+// }
+//
+// break
+// default:
+// throw UnsupportedOperationException("Create operation of type:" \
+ objectClass) +//}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestDeleteScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/DeleteScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/DeleteScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/DeleteScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestResolveUsernameScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/ResolveUsernameScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/ResolveUsernameScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/ResolveUsernameScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestSchemaScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/SchemaScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/SchemaScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/SchemaScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import org.forgerock.openicf.connectors.scriptedcrest.ScriptedCRESTConfiguration
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.OperationalAttributeInfos
+import org.identityconnectors.framework.common.objects.PredefinedAttributeInfos
+
+import static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.MULTIVALUED
+import static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.NOT_CREATABLE
+import static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.NOT_READABLE
+import static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.NOT_RETURNED_BY_DEFAULT
+import static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.NOT_UPDATEABLE
+import static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.REQUIRED
+
+def action = action as OperationType
+def configuration = configuration as ScriptedCRESTConfiguration
+def log = log as Log
+
+builder.schema({
+ objectClass {
+ type ObjectClass.ACCOUNT_NAME
+ attribute OperationalAttributeInfos.CURRENT_PASSWORD
+ attributes {
+ userName String.class, REQUIRED
+ givenName String.class, REQUIRED
+ sn String.class, REQUIRED
+ mail REQUIRED
+ telephoneNumber()
+ __NAME__()
+ }
+ }
+}
+)
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestScriptOnConnectorScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/ScriptOnConnectorScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/ScriptOnConnectorScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/ScriptOnConnectorScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestScriptOnResourceScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/ScriptOnResourceScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/ScriptOnResourceScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/ScriptOnResourceScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestSearchScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/SearchScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/SearchScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/SearchScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestSyncScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/SyncScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/SyncScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/SyncScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestTestScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/TestScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/TestScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/TestScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import groovy.json.JsonBuilder
+import org.forgerock.json.fluent.JsonValue
+import org.forgerock.json.resource.ActionRequest
+import org.forgerock.json.resource.Connection
+import org.forgerock.json.resource.Requests
+import org.forgerock.json.resource.RootContext
+import org.forgerock.openicf.connectors.scriptedcrest.ScriptedCRESTConfiguration
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+
+def action = action as OperationType
+def configuration = configuration as ScriptedCRESTConfiguration
+def connection = connection as Connection
+def log = log as Log
+
+log.info("This is TestScript")
+
+ActionRequest request = Requests.newActionRequest("users", \
"clear"); +JsonValue result = connection.action(new RootContext(), \
request); +
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestUpdateAttributeValuesScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/UpdateAttributeValuesScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/UpdateAttributeValuesScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/UpdateAttributeValuesScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcescrestUpdateScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/UpdateScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/crest/UpdateScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/crest/UpdateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovyAuthenticateScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/AuthenticateScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/AuthenticateScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/AuthenticateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -22,10 +22,11 @@
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><span class="cx">
</span><del>-
-import org.forgerock.openicf.misc.scriptedcommon.Logger
</del><ins>+import org.forgerock.openicf.misc.scriptedcommon.OperationType
</ins><span class="cx"> import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration </span><del>-import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase.Action \
</del><ins>+import org.identityconnectors.common.logging.Log +import \
org.identityconnectors.common.security.GuardedString +import \
org.identityconnectors.common.security.SecurityUtil </ins><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.ConnectorSecurityException \
</span><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.InvalidCredentialException \
</span><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.InvalidPasswordException \
</span><span class="lines">@@ -35,51 +36,45 @@ </span><span class="cx"> import \
org.identityconnectors.framework.common.objects.OperationOptions </span><span \
class="cx"> import org.identityconnectors.framework.common.objects.Uid </span><span \
class="cx"> </span><del>-def action = action as Action
</del><ins>+def action = action as OperationType
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><span class="cx"> def username = username as String
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx"> def objectClass = objectClass as ObjectClass
</span><span class="cx"> def options = options as OperationOptions
</span><del>-def password = password as Object;
</del><ins>+def password = password as GuardedString;
</ins><span class="cx">
</span><del>-if (objectClass.is(ObjectClass.ACCOUNT_NAME)) {
- if (username.equals("TEST1")) {
- throw new ConnectorSecurityException();
- } else if (username.equals("TEST2")) {
- throw new InvalidCredentialException();
- } else if (username.equals("TEST3")) {
- throw new InvalidPasswordException();
- } else if (username.equals("TEST4")) {
- throw new PermissionDeniedException();
- } else if (username.equals("TEST5")) {
- def clearPassword
- if (password instanceof Closure) {
- clearPassword = password()
- } else {
- clearPassword = password
</del><ins>+switch (objectClass) {
+ case ObjectClass.ACCOUNT:
+ throw UnsupportedOperationException(action.name() + " operation of \
type:" + objectClass) + break
+ case ObjectClass.GROUP:
+ throw UnsupportedOperationException(action.name() + " operation of \
type:" + objectClass) + break
+ case ObjectClass.ALL:
+ log.error("ICF Framework MUST reject this")
+ break
+ case TestHelper.TEST:
+ if (username.equals("TEST1")) {
+ throw new ConnectorSecurityException();
+ } else if (username.equals("TEST2")) {
+ throw new InvalidCredentialException();
+ } else if (username.equals("TEST3")) {
+ throw new InvalidPasswordException();
+ } else if (username.equals("TEST4")) {
+ throw new PermissionDeniedException();
+ } else if (username.equals("TEST5")) {
+ def clearPassword = SecurityUtil.decrypt(password)
+ if ("Passw0rd".equals(clearPassword)) {
+ return new Uid(username);
+ }
+ throw new InvalidPasswordException();
</ins><span class="cx"> }
</span><del>-
- if ("Passw0rd".equals(clearPassword)) {
- return new Uid(username);
- }
- throw new InvalidPasswordException();
- } else if (username.equals("TEST6")) {
- def clearPassword
- if (password instanceof Closure) {
- password({ out ->
- clearPassword = out
- })
- } else {
- clearPassword = password
- }
-
- if ("Passw0rd".equals(clearPassword)) {
- return new Uid(username);
- }
- throw new InvalidPasswordException();
- }
- throw new UnknownUidException();
-} else {
- throw UnsupportedOperationException("Authentication is not supported on \
" + objectClass); </del><ins>+ throw new UnknownUidException();
+ case TestHelper.SAMPLE:
+ throw UnsupportedOperationException(action.name() + " operation of \
type:" + objectClass) + break
+ default:
+ throw UnsupportedOperationException(action.name() + " operation of \
type:" + objectClass) </ins><span class="cx"> }
</span><ins>+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovyCreateScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/CreateScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/CreateScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/CreateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -22,21 +22,21 @@
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><span class="cx">
</span><del>-
</del><span class="cx"> import ObjectCacheLibrary
</span><span class="cx"> import \
org.forgerock.openicf.misc.scriptedcommon.ICFObjectBuilder as ICF </span><del>-import \
org.forgerock.openicf.misc.scriptedcommon.Logger </del><ins>+import \
org.identityconnectors.common.logging.Log +import \
org.forgerock.openicf.misc.scriptedcommon.OperationType </ins><span class="cx"> \
import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration \
</span><del>-import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase \
</del><span class="cx"> import \
org.identityconnectors.framework.common.objects.Attribute </span><span class="cx"> \
import org.identityconnectors.framework.common.objects.ObjectClass </span><span \
class="cx"> import org.identityconnectors.framework.common.objects.OperationOptions \
</span><ins>+import org.identityconnectors.framework.common.objects.Uid </ins><span \
class="cx"> </span><del>-def action = action as ScriptedConnectorBase.Action
-def createAttributes = attributes as Map<String, Attribute>
</del><ins>+def action = action as OperationType
+def createAttributes = attributes as Set<Attribute>
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><span class="cx"> def name = id as String
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx"> def objectClass = objectClass as ObjectClass
</span><span class="cx"> def options = options as OperationOptions
</span><span class="cx">
</span><span class="lines">@@ -49,10 +49,32 @@
</span><span class="cx"> return ObjectCacheLibrary.instance.create(ICF.co {
</span><span class="cx"> uid UUID.randomUUID().toString()
</span><span class="cx"> id name
</span><del>- attributes(createAttributes.values())
</del><ins>+ delegate.objectClass objectClass
+ attributes createAttributes
</ins><span class="cx"> })
</span><span class="cx"> break
</span><span class="cx"> case ObjectClass.GROUP:
</span><ins>+ return ObjectCacheLibrary.instance.create(ICF.co {
+ uid(UUID.randomUUID().toString())
+ id name
+ delegate.objectClass objectClass
+ attributes createAttributes
+ })
+ break
+ case ObjectClass.ALL:
+ log.error("ICF Framework MUST reject this")
+ break
+ case TestHelper.TEST:
+ Uid uid = new Uid(name, "0")
+ return TestHelper.exceptionTest(action, objectClass, uid)
+ break
+ case TestHelper.SAMPLE:
+ return ObjectCacheLibrary.instance.create(ICF.co {
+ uid UUID.randomUUID().toString()
+ id name
+ attributes(createAttributes)
+ })
+ break
</ins><span class="cx"> default:
</span><del>- throw UnsupportedOperationException("Create operation of \
type:" + objectClass) </del><ins>+ throw \
UnsupportedOperationException("Create operation of type:" + \
objectClass.objectClassValue) </ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovyDeleteScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/DeleteScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/DeleteScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/DeleteScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -22,18 +22,19 @@
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><span class="cx">
</span><del>-
</del><span class="cx"> import ObjectCacheLibrary
</span><del>-import org.forgerock.openicf.misc.scriptedcommon.Logger
</del><ins>+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
</ins><span class="cx"> import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration </span><del>-import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase.Action \
</del><ins>+import org.identityconnectors.framework.common.exceptions.ConnectorException
</ins><span class="cx"> import \
org.identityconnectors.framework.common.objects.ObjectClass </span><span class="cx"> \
import org.identityconnectors.framework.common.objects.OperationOptions \
</span><ins>+import org.identityconnectors.framework.common.objects.SyncToken \
</ins><span class="cx"> import org.identityconnectors.framework.common.objects.Uid \
</span><span class="cx"> </span><del>-def action = action as Action
</del><ins>+def action = action as OperationType
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx"> def objectClass = objectClass as ObjectClass
</span><span class="cx"> def options = options as OperationOptions
</span><span class="cx"> def uid = uid as Uid
</span><span class="lines">@@ -43,7 +44,18 @@
</span><span class="cx"> case ObjectClass.ACCOUNT:
</span><span class="cx"> ObjectCacheLibrary.instance.delete(objectClass, uid)
</span><span class="cx"> break
</span><ins>+ case ObjectClass.GROUP:
+ ObjectCacheLibrary.instance.delete(objectClass, uid)
+ break
+ case ObjectClass.ALL:
+ log.error("ICF Framework MUST reject this")
+ break
+ case TestHelper.TEST:
+ //Sample script for IDME-180:Support MVCC Revision attribute
+ TestHelper.exceptionTest(action, objectClass, uid)
+ break
+ case TestHelper.SAMPLE:
+ throw UnsupportedOperationException("Delete operation of type:" + \
objectClass) </ins><span class="cx"> default:
</span><del>- throw UnsupportedOperationException("Create operation of \
type:" + objectClass) </del><ins>+ throw \
UnsupportedOperationException("Delete operation of type:" + objectClass) \
</ins><span class="cx"> } </span><del>-
</del></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovyResolveUsernameScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/ResolveUsernameScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/ResolveUsernameScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/ResolveUsernameScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -1,11 +1,3 @@
</span><del>-import org.forgerock.openicf.misc.scriptedcommon.Logger
-import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
-import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase
-import org.identityconnectors.framework.common.exceptions.UnknownUidException
-import org.identityconnectors.framework.common.objects.ObjectClass
-import org.identityconnectors.framework.common.objects.OperationOptions
-import org.identityconnectors.framework.common.objects.Uid
-
</del><span class="cx"> /*
</span><span class="cx"> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
</span><span class="cx"> *
</span><span class="lines">@@ -30,10 +22,18 @@
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><span class="cx">
</span><del>-def action = action as ScriptedConnectorBase.Action
</del><ins>+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.framework.common.exceptions.UnknownUidException
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.OperationOptions
+import org.identityconnectors.framework.common.objects.Uid
+
+def action = action as OperationType
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><span class="cx"> def username = username as String
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx"> def objectClass = objectClass as ObjectClass
</span><span class="cx"> def options = options as OperationOptions
</span><span class="cx">
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovySchemaScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/SchemaScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/SchemaScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/SchemaScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -23,11 +23,13 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx">
</span><del>-
-
-import org.forgerock.openicf.misc.scriptedcommon.Logger
</del><ins>+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
</ins><span class="cx"> import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration </span><del>-import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase.Action \
</del><ins>+import org.identityconnectors.common.security.GuardedByteArray +import \
org.identityconnectors.common.security.GuardedString +import \
org.identityconnectors.framework.common.objects.AttributeInfo +import \
org.identityconnectors.framework.common.objects.AttributeInfoBuilder </ins><span \
class="cx"> import org.identityconnectors.framework.common.objects.ObjectClass \
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.OperationalAttributeInfos \
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.PredefinedAttributeInfos </span><span \
class="lines">@@ -39,9 +41,9 @@ </span><span class="cx"> import static \
org.identityconnectors.framework.common.objects.AttributeInfo.Flags.NOT_UPDATEABLE \
</span><span class="cx"> import static \
org.identityconnectors.framework.common.objects.AttributeInfo.Flags.REQUIRED \
</span><span class="cx"> </span><del>-def action = action as Action
</del><ins>+def action = action as OperationType
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx">
</span><span class="cx"> builder.schema({
</span><span class="cx"> objectClass {
</span><span class="lines">@@ -56,18 +58,80 @@
</span><span class="cx"> active Boolean.class, NOT_UPDATEABLE
</span><span class="cx"> lastModified NOT_UPDATEABLE, NOT_CREATABLE, \
NOT_RETURNED_BY_DEFAULT </span><span class="cx"> sureName()
</span><ins>+ passwordHistory String.class, MULTIVALUED, NOT_READABLE, \
NOT_RETURNED_BY_DEFAULT </ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> }
</span><span class="cx"> objectClass {
</span><span class="cx"> type '__TEST__'
</span><span class="cx"> container()
</span><span class="cx"> attributes {
</span><del>- username String.class, REQUIRED
- email REQUIRED, MULTIVALUED
- active Boolean.class, NOT_UPDATEABLE
- lastModified NOT_UPDATEABLE, NOT_CREATABLE, NOT_RETURNED_BY_DEFAULT
- sureName()
- password NOT_READABLE, NOT_RETURNED_BY_DEFAULT
</del><ins>+
+ // All possible attribute types
+
+ attributeString String.class
+ attributeStringMultivalue String.class, MULTIVALUED
+
+ attributelong Long.TYPE
+ attributelongMultivalue Long.TYPE, MULTIVALUED
+
+ attributeLong Long.class
+ attributeLongMultivalue Long.class, MULTIVALUED
+
+ attributechar Character.TYPE
+ attributecharMultivalue Character.TYPE, MULTIVALUED
+
+ attributeCharacter Character.class
+ attributeCharacterMultivalue Character.class, MULTIVALUED
+
+ attributedouble Double.TYPE
+ attributedoubleMultivalue Double.TYPE, MULTIVALUED
+
+ attributeDouble Double.class
+ attributeDoubleMultivalue Double.class, MULTIVALUED
+
+ attributefloat Float.TYPE
+ attributefloatMultivalue Float.TYPE, MULTIVALUED
+
+ attributeFloat Float.class
+ attributeFloatMultivalue Float.class, MULTIVALUED
+
+ attributeint Integer.TYPE
+ attributeintMultivalue Integer.TYPE, MULTIVALUED
+
+ attributeInteger Integer.class
+ attributeIntegerMultivalue Integer.class, MULTIVALUED
+
+ attributeboolean Boolean.TYPE
+ attributebooleanMultivalue Boolean.TYPE, MULTIVALUED
+
+ attributeBoolean Boolean.class
+ attributeBooleanMultivalue Boolean.class, MULTIVALUED
+
+ attribute Byte.TYPE
+ attributeByteMultivalue Byte.TYPE, MULTIVALUED
+
+ attributeByte Byte.class
+ attributeByteMultivalued Byte.class, MULTIVALUED
+
+ attributeByteArray byte[].class
+ attributeByteArrayMultivalue byte[].class, MULTIVALUED
+
+ attributeBigDecimal BigDecimal.class
+ attributeBigDecimalMultivalue BigDecimal.class, MULTIVALUED
+
+ attributeBigInteger BigInteger.class
+ attributeBigIntegerMultivalue BigInteger.class, MULTIVALUED
+
+ attributeGuardedByteArray GuardedByteArray.class
+ attributeGuardedByteArrayMultivalue GuardedByteArray.class, MULTIVALUED
+
+ attributeGuardedString GuardedString.class
+ attributeGuardedStringMultivalue GuardedString.class, MULTIVALUED
+
+ attributeMap Map.class
+ attributeMapMultivalue Map.class, MULTIVALUED
+
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovyScriptOnResourceScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/ScriptOnResourceScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/ScriptOnResourceScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/ScriptOnResourceScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -22,10 +22,9 @@
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><span class="cx">
</span><del>-
-import org.forgerock.openicf.misc.scriptedcommon.Logger
</del><ins>+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
</ins><span class="cx"> import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration </span><del>-import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase </del><span \
class="cx"> import org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException
</span><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.InvalidCredentialException \
</span><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.InvalidPasswordException \
</span><span class="lines">@@ -33,9 +32,9 @@ </span><span class="cx">
</span><span class="cx"> import static \
org.identityconnectors.common.security.SecurityUtil.decrypt </span><span class="cx">
</span><del>-def action = action as ScriptedConnectorBase.Action
</del><ins>+def action = action as OperationType
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx"> def options = options as OperationOptions
</span><span class="cx"> def scriptArguments = scriptArguments as Map
</span><span class="cx"> def scriptLanguage = scriptLanguage as String
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovySearchScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/SearchScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/SearchScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/SearchScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -22,12 +22,11 @@
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><span class="cx">
</span><del>-
</del><span class="cx"> import ObjectCacheLibrary
</span><span class="cx"> import \
org.forgerock.openicf.misc.scriptedcommon.ICFObjectBuilder as ICF </span><del>-import \
org.forgerock.openicf.misc.scriptedcommon.Logger </del><ins>+import \
org.identityconnectors.common.logging.Log +import \
org.forgerock.openicf.misc.scriptedcommon.OperationType </ins><span class="cx"> \
import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration \
</span><del>-import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase \
</del><span class="cx"> import \
org.identityconnectors.framework.common.objects.Attribute </span><span class="cx"> \
import org.identityconnectors.framework.common.objects.ConnectorObject </span><span \
class="cx"> import org.identityconnectors.framework.common.objects.ObjectClass \
</span><span class="lines">@@ -35,10 +34,10 @@ </span><span class="cx"> import \
org.identityconnectors.framework.common.objects.SearchResult </span><span class="cx"> \
import org.identityconnectors.framework.common.objects.filter.Filter </span><span \
class="cx"> </span><del>-def action = action as ScriptedConnectorBase.Action
</del><ins>+def action = action as OperationType
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><span class="cx"> def filter = filter as Filter
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx"> def objectClass = objectClass as ObjectClass
</span><span class="cx"> def options = options as OperationOptions
</span><span class="cx"> def EMPTY = new ObjectClass("__EMPTY__")
</span><span class="lines">@@ -51,6 +50,7 @@
</span><span class="cx"> // Handle the results
</span><span class="cx"> if (null != options.getPageSize()) {
</span><span class="cx"> // Paged Search
</span><ins>+ // Sample script for IDME-178
</ins><span class="cx"> final String pagedResultsCookie = \
options.getPagedResultsCookie(); </span><span class="cx"> String \
currentPagedResultsCookie = options.getPagedResultsCookie(); </span><span class="cx"> \
final Integer pagedResultsOffset = </span><span class="lines">@@ -99,11 +99,10 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- return new SearchResult()
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> break
</span><del>- case ObjectClass.GROUP:
</del><ins>+ case TestHelper.SAMPLE:
</ins><span class="cx"> handler(
</span><span class="cx"> ICF.co {
</span><span class="cx"> uid '12'
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovySyncScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/SyncScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/SyncScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/SyncScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -22,32 +22,206 @@
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><span class="cx">
</span><del>-
</del><span class="cx"> import \
org.forgerock.openicf.misc.scriptedcommon.ICFObjectBuilder as ICF </span><del>-import \
org.forgerock.openicf.misc.scriptedcommon.Logger </del><ins>+import \
org.identityconnectors.common.logging.Log +import \
org.forgerock.openicf.misc.scriptedcommon.OperationType </ins><span class="cx"> \
import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration \
</span><del>-import org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase.Action
</del><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.ConnectorException </span><span \
class="cx"> import org.identityconnectors.framework.common.objects.Attribute \
</span><span class="cx"> import \
org.identityconnectors.framework.common.objects.ObjectClass </span><span class="cx"> \
import org.identityconnectors.framework.common.objects.OperationOptions </span><span \
class="cx"> import org.identityconnectors.framework.common.objects.SyncToken \
</span><span class="cx"> </span><del>-def action = action as Action
</del><ins>+def action = action as OperationType
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx"> def objectClass = objectClass as ObjectClass
</span><del>-def options = options as OperationOptions
-def token = token as SyncToken
</del><span class="cx">
</span><span class="cx">
</span><span class="cx"> switch (action) {
</span><del>- case Action.SYNC:
- handler(
- ICF.delta {
- syncToken 12345
- UPDATE()
- previousUid '12'
</del><ins>+ case OperationType.SYNC:
+
+ def options = options as OperationOptions
+ def token = token as Object
+
+ switch (objectClass) {
+ case ObjectClass.ACCOUNT:
+ switch (token) {
+ case 0:
+ //CREATE See IDME-114
+ handler({
+ syncToken 1
+ CREATE()
+ object {
+ uid '001'
+ id 'foo'
+ TestHelper.connectorObjectTemplate.each { key, value \
-> + attribute key, value
+ }
+
+ }
+ })
+ return new SyncToken(1);
+ break;
+ case 1:
+ //UPDATE See IDME-114
+ handler({
+ syncToken 2
+ UPDATE()
+ object {
+ uid '001'
+ id 'foo'
+ TestHelper.connectorObjectTemplate.each { key, value \
-> + attribute key, value
+ }
+
+ }
+ })
+ return new SyncToken(2);
+ break;
+ case 2:
+ //UPDATE
+ handler({
+ syncToken 3
+ CREATE_OR_UPDATE()
+ object {
+ uid '001'
+ id 'foo'
+ TestHelper.connectorObjectTemplate.each { key, value \
-> + attribute key, value
+ }
+
+ }
+ })
+ return new SyncToken(3);
+ break;
+ case 3:
+ //RENAME
+ handler({
+ syncToken 4
+ UPDATE()
+ previousUid '001'
+ object {
+ uid '002'
+ id 'foo'
+ TestHelper.connectorObjectTemplate.each { key, value \
-> + attribute key, value
+ }
+
+ }
+ })
+ return new SyncToken(4);
+ break;
+ case 4:
+ //DELETE
+ handler({
+ syncToken 5
+ DELETE()
+ object {
+ uid '002'
+ id 'foo'
+ TestHelper.connectorObjectTemplate.each { key, value \
-> + attribute key, value
+ }
+
+ }
+ })
+ return new SyncToken(5);
+ break;
+ case 5..9:
+ //Empty change range: Sample script for IDME-179
+ log.ok("Sync empty change range")
+ return new SyncToken(10);
+ break;
+ case 10..16:
+ for (int i = 10; i <= 16; i = i + 2) {
+ handler({
+ syncToken i
+ CREATE_OR_UPDATE()
+ object {
+ uid '002'
+ id 'foo'
+ TestHelper.connectorObjectTemplate.each { key, \
value -> + attribute key, value
+ }
+
+ }
+ })
+ }
+ default:
+ return new SyncToken(17);
+ }
+ case ObjectClass.GROUP:
+ for (int i = 11; i <= 16; i = i + 2) {
+ handler({
+ syncToken i
+ CREATE_OR_UPDATE()
+ object {
+ uid 'group1'
+ id 'group1'
+ delegate.objectClass(ObjectClass.GROUP)
+ TestHelper.connectorObjectTemplate.each { key, value \
-> + attribute key, value
+ }
+
+ }
+ })
+ }
+ return new SyncToken(16);
+ case ObjectClass.ALL:
+ // Sample script for IDME-116
+ for (int i = 10; i <= 16; i++) {
+ handler({
+ syncToken i
+ CREATE_OR_UPDATE()
+ object {
+ if (i % 2 == 0) {
+ uid '002'
+ id 'foo'
+ delegate.objectClass ObjectClass.ACCOUNT
+ } else {
+ uid 'group1'
+ id 'group1'
+ delegate.objectClass ObjectClass.GROUP
+ }
+ TestHelper.connectorObjectTemplate.each { key, value \
-> + attribute key, value
+ }
+
+ }
+ })
+ }
+ return new SyncToken(17);
+ case TestHelper.SAMPLE:
+ handler(
+ ICF.delta {
+ syncToken 12345
+ UPDATE()
+ previousUid '12'
+ object {
+ uid '13'
+ id '13'
+ attribute {
+ name 'sureName'
+ value 'Foo'
+ }
+ attribute {
+ name 'lastName'
+ value 'Bar'
+ }
+ attribute {
+ name 'groups'
+ values 'Group1', 'Group2'
+ }
+ attribute 'active', true
+ attribute 'NULL'
+ }
+ }
+ )
+
+ handler({
+ syncToken 12346
+ CREATE()
</ins><span class="cx"> object {
</span><span class="cx"> uid '13'
</span><span class="cx"> id '13'
</span><span class="lines">@@ -65,44 +239,36 @@
</span><span class="cx"> }
</span><span class="cx"> attribute 'active', true
</span><span class="cx"> attribute 'NULL'
</span><ins>+ attributes(new Attribute('emails', [
+ [
+ "address" : \
"foo@example.com", + \
"type" : "home", + \
"customType": "", + \
"primary" : true] + ]))
</ins><span class="cx"> }
</span><del>- }
- )
</del><ins>+ })
+ return new SyncToken('SAMPLE')
+ break
+ default:
+ throw UnsupportedOperationException("Sync operation of \
type:" + objectClass) + }
</ins><span class="cx">
</span><del>- handler({
- syncToken 12346
- CREATE()
- object {
- uid '13'
- id '13'
- attribute {
- name 'sureName'
- value 'Foo'
- }
- attribute {
- name 'lastName'
- value 'Bar'
- }
- attribute {
- name 'groups'
- values 'Group1', 'Group2'
- }
- attribute 'active', true
- attribute 'NULL'
- attributes(new Attribute('emails', [
- [
- "address": "foo@example.com",
- "type": "home",
- "customType": "",
- "primary": true]
- ]))
- }
- })
-
- return new SyncToken('13')
- break
- case Action.GET_LATEST_SYNC_TOKEN:
- throw new UnsupportedOperationException()
</del><ins>+ case OperationType.GET_LATEST_SYNC_TOKEN:
+ switch (objectClass) {
+ case ObjectClass.ACCOUNT:
+ return new SyncToken(17);
+ case ObjectClass.GROUP:
+ return new SyncToken(16);
+ case ObjectClass.ALL:
+ return new SyncToken(17);
+ case TestHelper.TEST:
+ return new SyncToken(0);
+ case TestHelper.SAMPLE:
+ return new SyncToken("ANY OBJECT");
+ default:
+ throw UnsupportedOperationException("Sync operation of \
type:" + objectClass.objectClassValue) + }
</ins><span class="cx"> default:
</span><span class="cx"> throw new ConnectorException("SyncScript can \
not handle action:" + action.name()) </span><span class="cx"> }
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovyTestHelpergroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/TestHelper.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/TestHelper.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/TestHelper.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,195 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.identityconnectors.common.security.GuardedByteArray
+import org.identityconnectors.common.security.GuardedString
+import org.identityconnectors.framework.common.exceptions.AlreadyExistsException
+import org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException
+import org.identityconnectors.framework.common.exceptions.PreconditionFailedException
+import org.identityconnectors.framework.common.exceptions.PreconditionRequiredException
+import org.identityconnectors.framework.common.exceptions.RetryableException
+import org.identityconnectors.framework.common.exceptions.UnknownUidException
+import org.identityconnectors.framework.common.objects.NameUtil
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.Uid
+
+import java.nio.charset.Charset
+
+/**
+ *
+ */
+class TestHelper {
+
+ static final ObjectClass TEST = new \
ObjectClass(NameUtil.createSpecialName('TEST')) + static final ObjectClass SAMPLE \
= new ObjectClass(NameUtil.createSpecialName('SAMPLE')) +
+
+ static Uid exceptionTest(OperationType operation, ObjectClass objectClass, Uid \
uid) { + if ("TEST1".equals(uid.uidValue)) {
+ if (OperationType.CREATE.equals(operation)) {
+ throw new AlreadyExistsException(
+ "Object with Uid '${uid.uidValue}' and ObjectClass \
'${objectClass.objectClassValue}' already exists!").initUid(uid); + } \
else { + throw new UnknownUidException(uid, objectClass);
+ }
+ } else if ("TEST2".equals(uid.uidValue)) {
+ //ICF 1.4 Exception
+ if (OperationType.DELETE.equals(operation)) {
+ return uid;
+ } else {
+ throw new InvalidAttributeValueException();
+ }
+ } else if ("TEST3".equals(uid.uidValue)) {
+ //ICF 1.1 Exception
+ if (OperationType.DELETE.equals(operation)) {
+ return uid;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ } else if ("TEST4".equals(uid.uidValue)) {
+ if (OperationType.CREATE.equals(operation)) {
+ throw RetryableException.wrap("Created but some attributes are \
not set, call update with new 'uid'!", uid); + } else {
+ throw new PreconditionFailedException();
+ }
+ } else if ("TEST5".equals(uid.uidValue)) {
+ if (OperationType.CREATE.equals(operation)) {
+ return uid;
+ } else {
+ throw new PreconditionRequiredException();
+ }
+ }
+ return uid;
+ }
+
+ static Map<String, Objects> getConnectorObjectTemplate() {
+
+ return [
+ attributeString : "value",
+ attributeStringMultivalue : ["value1", \
"value2"] as String[], +
+ attributelongp : 11l,
+ attributelongpMultivalue : [12l, 13l] as long[],
+
+ attributeLong : 14 as Long,
+ attributeLongMultivalue : [15 as Long, 16 as Long] as \
Long[], +
+ attributechar : 'a' as char,
+ attributecharMultivalue : ['b' as char, 'c' as char] as \
char[], +
+ attributeCharacter : 'd' as Character,
+ attributeCharacterMultivalue : ['e' as Character, 'f' as \
Character] as Character[], +
+ attributedoublep : Double.MIN_NORMAL,
+ attributedoublepMultivalue : [Double.MIN_VALUE, \
Double.MAX_VALUE] as double[], +
+ attributeDouble : 17 as Double,
+ attributeDoubleMultivalue : [18 as Double, 19 as Double] as \
Double[], +
+ attributefloatp : 20F,
+ attributefloatpMultivalue : [21F, 22F] as float[],
+
+ attributeFloat : 23 as Float,
+ attributeFloatMultivalue : [24 as Float, 25 as Float] as \
Float[], +
+ attributeint : 26 as int,
+ attributeintMultivalue : [27 as int, 28 as int] as \
int[], +
+ attributeInteger : 29 as Integer,
+ attributeIntegerMultivalue : [30 as Integer, 31 as Integer] \
as Integer[], +
+ attributebooleanp : true as boolean,
+ attributebooleanpMultivalue : [true as boolean, false as \
boolean] as boolean[], +
+ attributeBoolean : false as Boolean,
+ attributeBooleanMultivalue : [true as Boolean, false as \
Boolean] as Boolean[], +
+ // Sample script for IDME-113
+ attributebytep : 48 as byte,
+ attributebytepMultivalue : [49 as byte, 50 as byte] as \
byte[], +
+ // Sample script for IDME-113
+ attributeByte : 51 as Byte,
+ attributeByteMultivalue : [52 as Byte, 53 as Byte] as \
Byte[], +
+ attributeByteArray : \
"array".getBytes(Charset.forName("UTF-8")), + \
attributeByteArrayMultivalue : \
["item1".getBytes(Charset.forName("UTF-8")), + \
"item2".getBytes(Charset.forName("UTF-8"))] as byte[][], +
+ attributeBigDecimal : BigDecimal.ONE,
+ attributeBigDecimalMultivalue : [BigDecimal.ZERO, \
BigDecimal.TEN] as BigDecimal[], +
+ attributeBigInteger : BigInteger.ONE,
+ attributeBigIntegerMultivalue : [BigInteger.ZERO, \
BigInteger.TEN] as BigInteger[], +
+ attributeGuardedByteArray : new \
GuardedByteArray("array".getBytes(Charset.forName("UTF-8"))), + \
attributeGuardedByteArrayMultivalue: [new \
GuardedByteArray("item1".getBytes(Charset.forName("UTF-8"))), + \
new GuardedByteArray("item2".getBytes(Charset.forName("UTF-8")))] \
+ as GuardedByteArray[], +
+ attributeGuardedString : new \
GuardedString("secret".toCharArray()), + \
attributeGuardedStringMultivalue : [new \
GuardedString("secret1".toCharArray()), + \
new GuardedString("secret1".toCharArray())] as GuardedString[], +
+ // Sample script for IDME-113
+ attributeMap : [
+ string : 'String',
+ number : 42,
+ trueOrFalse: true,
+ nullValue : null,
+ collection : ['item1', 'item2'],
+ object : [
+ key1: 'value1',
+ key2: 'value2'
+ ]
+ ],
+ attributeMapMultivalue : [
+ [
+ string : 'String',
+ number : 42,
+ trueOrFalse: true,
+ nullValue : null,
+ collection : ['item1', 'item2'],
+ object : [
+ key1: 'value1',
+ key2: 'value2'
+ ]
+ ],
+ [
+ string : 'String',
+ number : 43,
+ trueOrFalse: true,
+ nullValue : null,
+ collection : ['item1', 'item2'],
+ object : [
+ key1: 'value1',
+ key2: 'value2'
+ ]
+ ]
+ ] as Map[]
+ ]
+ }
+}
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovyTestScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/TestScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/TestScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/TestScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -22,16 +22,15 @@
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><span class="cx">
</span><del>-import org.forgerock.openicf.misc.scriptedcommon.Logger
</del><ins>+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
</ins><span class="cx"> import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration </span><del>-import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase.Action </del><span \
class="cx"> </span><del>-
-def action = action as Action
</del><ins>+def action = action as OperationType
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx">
</span><span class="cx">
</span><del>-log.infoLocale("TEST", "This is TestScript")
</del><ins>+log.info("This is TestScript")
</ins><span class="cx">
</span><span class="cx"> throw new MissingResourceException("Test Failed", \
action.name(), "") </span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesgroovyUpdateScriptgroovy"></a>
<div class="modfile"><h4>Modified: \
trunk/connectors/java/scriptedcommon/src/test/resources/groovy/UpdateScript.groovy \
(6504 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/case1/UpdateScript.groovy 2014-03-28 \
21:41:59 UTC (rev 6504)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/groovy/UpdateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -22,9 +22,9 @@
</span><span class="cx"> * "Portions Copyrighted [year] [name of copyright \
owner]" </span><span class="cx"> */
</span><span class="cx">
</span><del>-import org.forgerock.openicf.misc.scriptedcommon.Logger
</del><ins>+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
</ins><span class="cx"> import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration </span><del>-import \
org.forgerock.openicf.misc.scriptedcommon.ScriptedConnectorBase.Action </del><span \
class="cx"> import org.identityconnectors.framework.common.exceptions.ConnectorException
</span><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException \
</span><span class="cx"> import \
org.identityconnectors.framework.common.exceptions.PreconditionFailedException \
</span><span class="lines">@@ -35,38 +35,43 @@ </span><span class="cx"> import \
org.identityconnectors.framework.common.objects.OperationOptions </span><span \
class="cx"> import org.identityconnectors.framework.common.objects.Uid </span><span \
class="cx"> </span><del>-def action = action as Action
-def attributes = attributes as Map<String, Attribute>
</del><ins>+def action = action as OperationType
+def updateAttributes = attributes as Set<Attribute>
</ins><span class="cx"> def configuration = configuration as ScriptedConfiguration
</span><span class="cx"> def id = id as Attribute
</span><del>-def log = log as Logger
</del><ins>+def log = log as Log
</ins><span class="cx"> def objectClass = objectClass as ObjectClass
</span><span class="cx"> def options = options as OperationOptions
</span><span class="cx"> def uid = uid as Uid
</span><span class="cx">
</span><span class="cx">
</span><del>-log.debugLocale("scriptingLanguage.help", "Default \
Message") </del><ins>+log.ok("Default Message")
</ins><span class="cx">
</span><span class="cx"> switch (action) {
</span><del>- case Action.UPDATE:
- if (objectClass.is(ObjectClass.ACCOUNT_NAME)) {
- if ("TEST1".equals(uid.uidValue)) {
- throw new UnknownUidException(uid, objectClass);
- } else if ("TEST2".equals(uid.uidValue)) {
- throw new InvalidAttributeValueException();
- } else if ("TEST3".equals(uid.uidValue)) {
- throw new PreconditionFailedException();
- } else if ("TEST4".equals(uid.uidValue)) {
- throw new PreconditionRequiredException();
- }
- return uid
- } else {
- throw new UnsupportedOperationException("Unsupported Update -> \
" + objectClass) </del><ins>+ case OperationType.UPDATE:
+ switch (objectClass) {
+ case ObjectClass.ACCOUNT:
+ return uid
+ break
+ case ObjectClass.GROUP:
+ return uid
+ break
+ case ObjectClass.ALL:
+ log.error("ICF Framework MUST reject this")
+ break
+ case TestHelper.TEST:
+ //Sample script for IDME-180:Support MVCC Revision attribute
+ TestHelper.exceptionTest(action, objectClass, uid)
+ break
+ case TestHelper.SAMPLE:
+ throw UnsupportedOperationException("Update operation of \
type:" + objectClass) + default:
+ throw UnsupportedOperationException("Update operation of \
type:" + objectClass) </ins><span class="cx"> }
</span><span class="cx"> break
</span><del>- case Action.ADD_ATTRIBUTE_VALUES:
</del><ins>+ case OperationType.ADD_ATTRIBUTE_VALUES:
</ins><span class="cx"> throw new UnsupportedOperationException()
</span><del>- case Action.REMOVE_ATTRIBUTE_VALUES:
</del><ins>+ case OperationType.REMOVE_ATTRIBUTE_VALUES:
</ins><span class="cx"> throw new UnsupportedOperationException()
</span><span class="cx"> default:
</span><span class="cx"> throw new ConnectorException("UpdateScript can \
not handle action:" + action.name()) </span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestAuthenticateScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/AuthenticateScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/AuthenticateScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/AuthenticateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestCreateScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/CreateScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/CreateScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/CreateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestDeleteScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/DeleteScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/DeleteScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/DeleteScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestResolveUsernameScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/ResolveUsernameScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/ResolveUsernameScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/ResolveUsernameScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestSchemaScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/SchemaScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/SchemaScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/SchemaScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestScriptOnConnectorScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/ScriptOnConnectorScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/ScriptOnConnectorScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/ScriptOnConnectorScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestScriptOnResourceScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/ScriptOnResourceScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/ScriptOnResourceScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/ScriptOnResourceScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestSearchScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/SearchScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/SearchScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/SearchScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestSyncScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/SyncScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/SyncScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/SyncScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestTestScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/TestScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/TestScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/TestScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import groovyx.net.http.RESTClient
+import org.forgerock.openicf.connectors.scriptedrest.ScriptedRESTConfiguration
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+
+import static groovyx.net.http.ContentType.JSON
+import static groovyx.net.http.Method.POST
+
+def action = action as OperationType
+def configuration = configuration as ScriptedRESTConfiguration
+def connection = connection as RESTClient
+def log = log as Log
+
+connection.handler.failure = { resp ->
+ log.ok "Unexpected failure: ${resp.statusLine}"
+}
+
+def cleared = connection.post(
+ path: "/rest/users",
+ contentType: JSON,
+ requestContentType: JSON,
+ query: [
+ _action: "clear"
+ ],
+ body: 'null'
+)
+
+
+cleared = connection.request(POST, JSON) { req ->
+ uri.path = '/rest/users'
+ uri.query = [_action : 'clear']
+ send JSON, 'null'
+
+ //requestContentType = JSON
+ //body = 'null'
+
+ response.success = { resp, json ->
+ assert json.size() == 1
+ println "Query response: "
+ json.responseData.each() { key, value ->
+ log.debug " ${key} : ${value}"
+ }
+ }
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestUpdateAttributeValuesScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/UpdateAttributeValuesScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/UpdateAttributeValuesScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/UpdateAttributeValuesScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcesrestUpdateScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/UpdateScript.groovy (0 \
=> 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/rest/UpdateScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/rest/UpdateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlAuthenticateScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/AuthenticateScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/AuthenticateScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/AuthenticateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.OperationOptions
+
+def action = action as OperationType
+def configuration = configuration as ScriptedConfiguration
+def username = username as String
+def log = log as Log
+def objectClass = objectClass as ObjectClass
+def options = options as OperationOptions
+def password = password as Object;
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlCreateScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/CreateScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/CreateScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/CreateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.framework.common.objects.Attribute
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.OperationOptions
+
+def action = action as OperationType
+def createAttributes = attributes as Map<String, Attribute>
+def configuration = configuration as ScriptedConfiguration
+def name = id as String
+def log = log as Log
+def objectClass = objectClass as ObjectClass
+def options = options as OperationOptions
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlDeleteScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/DeleteScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/DeleteScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/DeleteScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.OperationOptions
+import org.identityconnectors.framework.common.objects.Uid
+
+def action = action as OperationType
+def configuration = configuration as ScriptedConfiguration
+def log = log as Log
+def objectClass = objectClass as ObjectClass
+def options = options as OperationOptions
+def uid = uid as Uid
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlResolveUsernameScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/ResolveUsernameScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/ResolveUsernameScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/ResolveUsernameScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.OperationOptions
+
+def action = action as OperationType
+def configuration = configuration as ScriptedConfiguration
+def username = username as String
+def log = log as Log
+def objectClass = objectClass as ObjectClass
+def options = options as OperationOptions
+
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlSchemaScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/SchemaScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/SchemaScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/SchemaScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+
+def action = action as OperationType
+def configuration = configuration as ScriptedConfiguration
+def log = log as Log
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlScriptOnResourceScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/ScriptOnResourceScript.groovy \
(0 => 6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/ScriptOnResourceScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/ScriptOnResourceScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.framework.common.objects.OperationOptions
+
+def action = action as OperationType
+def configuration = configuration as ScriptedConfiguration
+def log = log as Log
+def options = options as OperationOptions
+def scriptArguments = scriptArguments as Map
+def scriptLanguage = scriptLanguage as String
+def scriptText = scriptText as String
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlSearchScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/SearchScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/SearchScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/SearchScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.OperationOptions
+import org.identityconnectors.framework.common.objects.filter.Filter
+
+def action = action as OperationType
+def configuration = configuration as ScriptedConfiguration
+def filter = filter as Filter
+def log = log as Log
+def objectClass = objectClass as ObjectClass
+def options = options as OperationOptions
+def EMPTY = new ObjectClass("__EMPTY__")
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlSyncScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/SyncScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/SyncScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/SyncScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.OperationOptions
+import org.identityconnectors.framework.common.objects.SyncToken
+
+def action = action as OperationType
+def configuration = configuration as ScriptedConfiguration
+def log = log as Log
+def objectClass = objectClass as ObjectClass
+def options = options as OperationOptions
+def token = token as SyncToken
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlTestScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/TestScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/TestScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/TestScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+import groovy.sql.Sql
+import org.forgerock.openicf.connectors.scriptedsql.ScriptedSQLConfiguration
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+
+import java.sql.Connection
+
+
+def action = action as OperationType
+def configuration = configuration as ScriptedSQLConfiguration
+def connection = new Sql(connection as Connection)
+def log = log as Log
+
+
+log.info("This is TestScript")
+
+def rows = connection.rows("SELECT ID FROM INFORMATION_SCHEMA.TABLES WHERE \
TABLE_NAME = 'USERS' AND TABLE_TYPE = 'TABLE'") +assert rows.size() == 1
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqlUpdateScriptgroovy"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/UpdateScript.groovy (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/UpdateScript.groovy \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/UpdateScript.groovy 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+
+
+import org.identityconnectors.common.logging.Log
+import org.forgerock.openicf.misc.scriptedcommon.OperationType
+import org.forgerock.openicf.misc.scriptedcommon.ScriptedConfiguration
+import org.identityconnectors.framework.common.exceptions.ConnectorException
+import org.identityconnectors.framework.common.objects.Attribute
+import org.identityconnectors.framework.common.objects.ObjectClass
+import org.identityconnectors.framework.common.objects.OperationOptions
+import org.identityconnectors.framework.common.objects.Uid
+
+def action = action as OperationType
+def attributes = attributes as Map<String, Attribute>
+def configuration = configuration as ScriptedConfiguration
+def id = id as Attribute
+def log = log as Log
+def objectClass = objectClass as ObjectClass
+def options = options as OperationOptions
+def uid = uid as Uid
+
+
+log.ok("Default Message")
+
+switch (action) {
+ case OperationType.UPDATE:
+ throw new UnsupportedOperationException()
+ case OperationType.ADD_ATTRIBUTE_VALUES:
+ throw new UnsupportedOperationException()
+ case OperationType.REMOVE_ATTRIBUTE_VALUES:
+ throw new UnsupportedOperationException()
+ default:
+ throw new ConnectorException("UpdateScript can not handle action:" \
+ action.name()) +}
+
+
+
+
+
+
</ins></span></pre></div>
<a id="trunkconnectorsjavascriptedcommonsrctestresourcessqltestDatabaseddl"></a>
<div class="addfile"><h4>Added: \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/testDatabase.ddl (0 => \
6509)</h4> <pre class="diff"><span>
<span class="info">--- \
trunk/connectors/java/scriptedcommon/src/test/resources/sql/testDatabase.ddl \
(rev 0)
+++ trunk/connectors/java/scriptedcommon/src/test/resources/sql/testDatabase.ddl 2014-04-15 \
09:47:57 UTC (rev 6509) </span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+DROP TABLE IF EXISTS Users;
+DROP TABLE IF EXISTS Groups;
+DROP TABLE IF EXISTS Organizations;
+
+CREATE TABLE GROUPS
+(
+ ID INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
+ GID VARCHAR(32) NOT NULL,
+ NAME VARCHAR(32) DEFAULT '' NOT NULL,
+ DESCRIPTION VARCHAR(32),
+ TIMESTAMP TIMESTAMP
+);
+CREATE TABLE ORGANIZATIONS
+(
+ ID INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
+ NAME VARCHAR(32) DEFAULT '' NOT NULL,
+ DESCRIPTION VARCHAR(32),
+ TIMESTAMP TIMESTAMP
+);
+CREATE TABLE USERS
+(
+ ID INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
+ UID VARCHAR(32) NOT NULL,
+ FIRSTNAME VARCHAR(32) DEFAULT '' NOT NULL,
+ LASTNAME VARCHAR(32) DEFAULT '' NOT NULL,
+ DISPLAYNAME VARCHAR(64),
+ EMAIL VARCHAR(64),
+ EMPLOYEENUMBER VARCHAR(32),
+ EMPLOYEETYPE VARCHAR(32),
+ DESCRIPTION VARCHAR(64),
+ MOBILEPHONE VARCHAR(64),
+ TIMESTAMP TIMESTAMP
+);
+INSERT INTO Users(UID,FIRSTNAME,LASTNAME,DISPLAYNAME,EMAIL,EMPLOYEENUMBER,EMPLOYEETYPE,DESCRIPTION,MOBILEPHONE,TIMESTAMP) \
VALUES ('bob','Bob', 'Fleming','Bob \
Fleming','Bob.Fleming@example.com','100','employee','Employee Bob \
Fleming','123-456-789',CURRENT_TIMESTAMP); +INSERT INTO \
Users(UID,FIRSTNAME,LASTNAME,DISPLAYNAME,EMAIL,EMPLOYEENUMBER,EMPLOYEETYPE,DESCRIPTION,MOBILEPHONE,TIMESTAMP) \
VALUES ('rowley','Rowley','Birkin','Rowley \
Birkin','Rowley.Birkin@example.com','101','employee','Employee Rowley \
Birkin','345-234-543',CURRENT_TIMESTAMP); +INSERT INTO \
Users(UID,FIRSTNAME,LASTNAME,DISPLAYNAME,EMAIL,EMPLOYEENUMBER,EMPLOYEETYPE,DESCRIPTION,MOBILEPHONE,TIMESTAMP) \
VALUES ('louis','Louis', 'Balfour','Louis \
Balfour','Louis.Balfour@example.com','102','employee','Employee Louis \
Balfour','876-678-098',CURRENT_TIMESTAMP); +INSERT INTO \
Users(UID,FIRSTNAME,LASTNAME,DISPLAYNAME,EMAIL,EMPLOYEENUMBER,EMPLOYEETYPE,DESCRIPTION,MOBILEPHONE,TIMESTAMP) \
VALUES ('john','John', 'Smith','John \
Smith','John.Smith@example.com','103','employee','Employee John \
Smith','634-123-456',CURRENT_TIMESTAMP); +INSERT INTO \
Users(UID,FIRSTNAME,LASTNAME,DISPLAYNAME,EMAIL,EMPLOYEENUMBER,EMPLOYEETYPE,DESCRIPTION,MOBILEPHONE,TIMESTAMP) \
VALUES ('jdoe','John', 'Doe','John \
Doe','John.Doe@example.com','104','employee','Employee John \
Doe','125-785-645',CURRENT_TIMESTAMP); +INSERT INTO \
Users(UID,FIRSTNAME,LASTNAME,DISPLAYNAME,EMAIL,EMPLOYEENUMBER,EMPLOYEETYPE,DESCRIPTION,MOBILEPHONE,TIMESTAMP) \
VALUES ('chris','Chris', 'Crafty','Chris \
Crafty','Chris.Crafty@example.com','105','contractor','Employee Chris \
Crafty','888-666-555',CURRENT_TIMESTAMP); +
+INSERT INTO Groups(GID,NAME,DESCRIPTION,TIMESTAMP) VALUES ('100','admin','Admin \
group',CURRENT_TIMESTAMP); +INSERT INTO Groups(GID,NAME,DESCRIPTION,TIMESTAMP) VALUES \
('101','users','Users group',CURRENT_TIMESTAMP); +INSERT INTO \
Groups(GID,NAME,DESCRIPTION,TIMESTAMP) VALUES ('102','security','Security \
group',CURRENT_TIMESTAMP); +
+INSERT INTO Organizations(NAME,DESCRIPTION,TIMESTAMP) VALUES ('HR','HR \
organization',CURRENT_TIMESTAMP); +INSERT INTO \
Organizations(NAME,DESCRIPTION,TIMESTAMP) VALUES ('SALES','Sales \
organization',CURRENT_TIMESTAMP); +INSERT INTO \
Organizations(NAME,DESCRIPTION,TIMESTAMP) VALUES ('SUPPORT','Support \
organization',CURRENT_TIMESTAMP); +INSERT INTO \
Organizations(NAME,DESCRIPTION,TIMESTAMP) VALUES ('ENG','Engineering \
organization',CURRENT_TIMESTAMP); +INSERT INTO \
Organizations(NAME,DESCRIPTION,TIMESTAMP) VALUES ('OPERATIONS','Operations \
organization',CURRENT_TIMESTAMP); +
</ins></span></pre>
</div>
</div>
<div id="footer">Copyright (c) by ForgeRock. All rights reserved.</div>
</body>
</html>
_______________________________________________
Commitopenicf mailing list
Commitopenicf@forgerock.org
https://lists.forgerock.org/mailman/listinfo/commitopenicf
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic