You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@syncope.apache.org by Francesco Chicchiriccò <il...@apache.org> on 2018/08/13 07:58:40 UTC

Re: user SUSPEND and REACTIVATE bulk operations are not propagated

Hi,
resurrecting this old thread just to notify that you might want to try 
the brand new Batch Operations, available with upcoming Syncope 2.1.1:

https://ci.apache.org/projects/syncope/2_1_X/reference-guide.html#batch

Regards.

On 31/05/2018 15:15, Francesco Chicchiriccò wrote:
> On 31/05/2018 10:48, Alexander Tsvetkov wrote:
>> Hi all,
>> Recently I realised that SUSPEND and REACTIVATE bulk operations on 
>> User are not propagated. This happen because of in AbstractAnyService
>>
>>  case SUSPEND:
>>                 if (logic instanceof UserLogic) {
>>                     for (String key : bulkAction.getTargets()) {
>>                         StatusPatch statusPatch = new 
>> StatusPatch.Builder().key(key).
>> type(StatusPatchType.SUSPEND).
>>                                 onSyncope(true).
>>                                 build();
>>
>>                         try {
>>                             result.getResults().put(
>>                                     ((UserLogic) logic).
>> status(statusPatch, isNullPriorityAsync()).getEntity().getKey(),
>> BulkActionResult.Status.SUCCESS);
>>                         } catch (Exception e) {
>>                             LOG.error("Error performing suspend for 
>> user {}", key, e);
>> result.getResults().put(key, BulkActionResult.Status.FAILURE);
>>                         }
>>                     }
>>                 } else {
>>                     throw new BadRequestException();
>>                 }
>>                 break;
>>
>> when we create StatusPatch, we don't set Resources to it.
>>
>> Questions:
>> 1. Is there any way to propagate SUSPEND and REACTIVATE bulk operations?
>> 2. Was it implemented intentionally or I should create a bug for this 
>> in jira?
>
> Hi Alexander,
> the snippet above appears to be taken from [1]: the only way to 
> trigger it is by invoking the REST service [2], e.g.
>
> POST /users/bulk
>
> with payload [3].
>
> As you can see, the payload class bears minimum information, being 
> meant to cover all possible bulk actions.
> In order to specify which resource(s) should be considered when 
> suspending or re-activating an user, however, further input is needed.
> I don't see how to allow to provide such further input without making 
> the method and payload design confused, in the general case.
>
> You can, however, add a new dedicated REST endpoint in your own 
> project to cover such need; some indications are provided in [4].
>
> Regards.
>
> [1] 
> https://github.com/apache/syncope/blob/2_0_X/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/AbstractAnyService.java#L353-L374
> [2] 
> https://github.com/apache/syncope/blob/2_0_X/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/AnyService.java#L290
> [3] 
> https://github.com/apache/syncope/blob/2_0_X/common/lib/src/main/java/org/apache/syncope/common/lib/to/BulkAction.java
> [4] http://blog.tirasa.net/add-rest-endpoints-to-apache-syncope-2.0.html

-- 
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/