REST Web Service

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

REST Web Service

Tech
Dear experts,

we are trying to configure a REST Web Service, but we don't how it
should be deployed.

We found in the /test directory some groovy script to Create/Update/etc,
but we don't understand in a real environment where these script should
be copied before compiling.

Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: REST Web Service

ilgrosso
Administrator
On 20/03/2017 15:45, Tech wrote:
> Dear experts,
>
> we are trying to configure a REST Web Service, but we don't how it
> should be deployed.
>
> We found in the /test directory some groovy script to
> Create/Update/etc, but we don't understand in a real environment where
> these script should be copied before compiling.

Hi,
both the Scripted REST [1] and the Scripted SQL [2] connector bundles
share the same approach: the actual implementation of the ConnId
operations (e.g. the child classes of [3], as CREATE, UPDATE, DELETE,
SEARCH, SYNC, AUTHENTICATE, ...) is delegated to individual Groovy scripts.

The immediate benefit of this approach is that you can adapt the actual
logic for dealing with a specific REST service or a given database, thus
achieving the maximum flexibility; the downside is that you need to code
the scripts, and this requires some skills.

You can find some samples of scripts for the REST connector in the folder

core/src/test/resources/rest

of your generated Maven project, or at [4], and scripts for the Scripted
SQL connector in the folder

core/src/test/resources/scriptedsql

of your generated Maven project, or at [5].
As you can easily figure out, the actual script content only makes sense
when dealing with the specific REST service / database they were
designed for, e.g. [6] and [7] respectively.

An important feature for speeding up the development of these scripts is
the 'Reload Script On Execution' connector property: when set to true,
each script is reloaded and recompiled every time it is called, e.g.
every time that the corresponding ConnId operation is invoked by Syncope.
In this way one can immediately check if the script is running fine or
find out errors.
Please do not forge to disable this property once running in production!

Finally, consider that each script can be passed - in the connector
configuration - either as actual content or as absolute file path: this
is the reason why there are "Create Script" and "Create Script
Filename", "Update Script" and "Update Script Filename", etc.

Hope this clarifies.
Regards.

[1] https://connid.atlassian.net/wiki/display/BASE/REST
[2] https://connid.atlassian.net/wiki/display/BASE/Scripted+SQL
[3]
http://connid.tirasa.net/apidocs/1.4/org/identityconnectors/framework/spi/operations/SPIOperation.html
[4]
https://github.com/apache/syncope/tree/2_0_X/fit/core-reference/src/test/resources/rest
[5]
https://github.com/apache/syncope/tree/2_0_X/fit/core-reference/src/test/resources/scriptedsql
[6]
https://github.com/apache/syncope/blob/2_0_X/fit/build-tools/src/main/java/org/apache/syncope/fit/buildtools/cxf/UserService.java
[7]
https://github.com/apache/syncope/blob/2_0_X/fit/build-tools/src/main/resources/testdb.sql#L46-L51

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Member at The Apache Software Foundation
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
http://home.apache.org/~ilgrosso/

Reply | Threaded
Open this post in threaded view
|

Re: REST Web Service

Tech
Hello Francesco,

thanks for the reply, and actually the tips of the
ReloadScriptOnExecution was really useful to debug the code.

Regards




On 21.03.17 08:59, Francesco Chicchiriccò wrote:

> On 20/03/2017 15:45, Tech wrote:
>> Dear experts,
>>
>> we are trying to configure a REST Web Service, but we don't how it
>> should be deployed.
>>
>> We found in the /test directory some groovy script to
>> Create/Update/etc, but we don't understand in a real environment
>> where these script should be copied before compiling.
>
> Hi,
> both the Scripted REST [1] and the Scripted SQL [2] connector bundles
> share the same approach: the actual implementation of the ConnId
> operations (e.g. the child classes of [3], as CREATE, UPDATE, DELETE,
> SEARCH, SYNC, AUTHENTICATE, ...) is delegated to individual Groovy
> scripts.
>
> The immediate benefit of this approach is that you can adapt the
> actual logic for dealing with a specific REST service or a given
> database, thus achieving the maximum flexibility; the downside is that
> you need to code the scripts, and this requires some skills.
>
> You can find some samples of scripts for the REST connector in the folder
>
> core/src/test/resources/rest
>
> of your generated Maven project, or at [4], and scripts for the
> Scripted SQL connector in the folder
>
> core/src/test/resources/scriptedsql
>
> of your generated Maven project, or at [5].
> As you can easily figure out, the actual script content only makes
> sense when dealing with the specific REST service / database they were
> designed for, e.g. [6] and [7] respectively.
>
> An important feature for speeding up the development of these scripts
> is the 'Reload Script On Execution' connector property: when set to
> true, each script is reloaded and recompiled every time it is called,
> e.g. every time that the corresponding ConnId operation is invoked by
> Syncope.
> In this way one can immediately check if the script is running fine or
> find out errors.
> Please do not forge to disable this property once running in production!
>
> Finally, consider that each script can be passed - in the connector
> configuration - either as actual content or as absolute file path:
> this is the reason why there are "Create Script" and "Create Script
> Filename", "Update Script" and "Update Script Filename", etc.
>
> Hope this clarifies.
> Regards.
>
> [1] https://connid.atlassian.net/wiki/display/BASE/REST
> [2] https://connid.atlassian.net/wiki/display/BASE/Scripted+SQL
> [3]
> http://connid.tirasa.net/apidocs/1.4/org/identityconnectors/framework/spi/operations/SPIOperation.html
> [4]
> https://github.com/apache/syncope/tree/2_0_X/fit/core-reference/src/test/resources/rest
> [5]
> https://github.com/apache/syncope/tree/2_0_X/fit/core-reference/src/test/resources/scriptedsql
> [6]
> https://github.com/apache/syncope/blob/2_0_X/fit/build-tools/src/main/java/org/apache/syncope/fit/buildtools/cxf/UserService.java
> [7]
> https://github.com/apache/syncope/blob/2_0_X/fit/build-tools/src/main/resources/testdb.sql#L46-L51
>

Reply | Threaded
Open this post in threaded view
|

Re: REST Web Service

Tech
We are still working on the Rest connector.

Modifying the CreateScript.groovy we inserted some log and we detected
that we are not able to retrieve any id information.

 From the logs we have the feeling that the "
node.set("key",node.textNode(id)) " is not able to retrieve any value:
we can read the information about the user like firstname, surname, etc,
but we get a UnsupportedOperationException when we try to run the key =
node.get(¨key¨).textValue();
where the key is "null" and we are not able to correctly create the
value key.

We want to mention that we are not able yet to arrive to contact the
REST ws, we still need to get out from Syncope.

Thanks





On 29.03.17 20:34, Tech wrote:

> Hello Francesco,
>
> thanks for the reply, and actually the tips of the
> ReloadScriptOnExecution was really useful to debug the code.
>
> Regards
>
>
>
>
> On 21.03.17 08:59, Francesco Chicchiriccò wrote:
>> On 20/03/2017 15:45, Tech wrote:
>>> Dear experts,
>>>
>>> we are trying to configure a REST Web Service, but we don't how it
>>> should be deployed.
>>>
>>> We found in the /test directory some groovy script to
>>> Create/Update/etc, but we don't understand in a real environment
>>> where these script should be copied before compiling.
>>
>> Hi,
>> both the Scripted REST [1] and the Scripted SQL [2] connector bundles
>> share the same approach: the actual implementation of the ConnId
>> operations (e.g. the child classes of [3], as CREATE, UPDATE, DELETE,
>> SEARCH, SYNC, AUTHENTICATE, ...) is delegated to individual Groovy
>> scripts.
>>
>> The immediate benefit of this approach is that you can adapt the
>> actual logic for dealing with a specific REST service or a given
>> database, thus achieving the maximum flexibility; the downside is
>> that you need to code the scripts, and this requires some skills.
>>
>> You can find some samples of scripts for the REST connector in the
>> folder
>>
>> core/src/test/resources/rest
>>
>> of your generated Maven project, or at [4], and scripts for the
>> Scripted SQL connector in the folder
>>
>> core/src/test/resources/scriptedsql
>>
>> of your generated Maven project, or at [5].
>> As you can easily figure out, the actual script content only makes
>> sense when dealing with the specific REST service / database they
>> were designed for, e.g. [6] and [7] respectively.
>>
>> An important feature for speeding up the development of these scripts
>> is the 'Reload Script On Execution' connector property: when set to
>> true, each script is reloaded and recompiled every time it is called,
>> e.g. every time that the corresponding ConnId operation is invoked by
>> Syncope.
>> In this way one can immediately check if the script is running fine
>> or find out errors.
>> Please do not forge to disable this property once running in production!
>>
>> Finally, consider that each script can be passed - in the connector
>> configuration - either as actual content or as absolute file path:
>> this is the reason why there are "Create Script" and "Create Script
>> Filename", "Update Script" and "Update Script Filename", etc.
>>
>> Hope this clarifies.
>> Regards.
>>
>> [1] https://connid.atlassian.net/wiki/display/BASE/REST
>> [2] https://connid.atlassian.net/wiki/display/BASE/Scripted+SQL
>> [3]
>> http://connid.tirasa.net/apidocs/1.4/org/identityconnectors/framework/spi/operations/SPIOperation.html
>> [4]
>> https://github.com/apache/syncope/tree/2_0_X/fit/core-reference/src/test/resources/rest
>> [5]
>> https://github.com/apache/syncope/tree/2_0_X/fit/core-reference/src/test/resources/scriptedsql
>> [6]
>> https://github.com/apache/syncope/blob/2_0_X/fit/build-tools/src/main/java/org/apache/syncope/fit/buildtools/cxf/UserService.java
>> [7]
>> https://github.com/apache/syncope/blob/2_0_X/fit/build-tools/src/main/resources/testdb.sql#L46-L51
>>
>