Hello Stephan,
first of all I'm glad about your interest in Apache Syncope.
Analyzing your problem I do not think the issue could be creating users
from AnyObject workflow, maybe could be "how" the workflow is set in order
to create users.
Making some code changes could be easier to see the console with errors,
it's easy to create some misconfigurations. In order to solve you should
try to divide  if the problem is on Console side or Core side; in order to
know that you can see if you're able to make some operation via Swagger UI
on [syncope_base_url]/syncope/ (oh, I'm assuming you're using the latest
version 3 of Syncope).

I'm thinking about some misconfiguration seeing the status unset too, if
you can see from the vanilla Syncope with vanilla workflow the status is
always set.

In order to see some more information about the issue I think you can
increase the log level for sure for flowable and see if you have some
errors here.

It's too hard trying to solve without the real environment unfortunately,
this type of issue should be tried under my hands with your own code.

HTH
Best regards,
Lorenzo

Il giorno gio 11 lug 2024 alle ore 15:44 Feder, Stephan <
stephan.fe...@tu-darmstadt.de> ha scritto:

> Hello,
>
> while evaluating syncope a problem has come up: I want to create users
> from
> within anyObject workflow but it does not work as expected. In detail:
>
> I have implemented
>
> 1. a FlowableAnyObjectWorkflowAdapter which is based on the existing
> FlowableUserWorkflowAdapter,
>
> 2. a task for creating anyObjects which based on the existing Create task,
>
> 3. an anyType
>
> ---
> key: "myAny"
> kind: "ANY_OBJECT"
> classes: []
>
> 4. the task
>
> public class CreateUser extends FlowableServiceTask {
>
>      private final UserWorkflowAdapter userWorkflowAdapter;
>
>      public CreateUser(final UserWorkflowAdapter userWorkflowAdapter) {
>          this.userWorkflowAdapter = userWorkflowAdapter;
>      }
>
>      @Override
>      protected void doExecute(final DelegateExecution execution) {
>          userWorkflowAdapter.create(
>              new UserCR.Builder("/", "test").build(),
>              "creator",
>              "context"
>          );
>      }
> }
>
> for creating users and
>
> 5. a workflow for anyObjects (ids of edges are removed)
>
> <process id="anyObjectWorkflow" name="anyObjectWorkflow"
> isExecutable="true">
>    <startEvent id="startevent1" name="Start"
> flowable:formFieldValidation="true"/>
>    <sequenceFlow sourceRef="startevent1" targetRef="createAnyObject"/>
>    <serviceTask id="createAnyObject" name="Create AnyObject"
> flowable:delegateExpression="${createAnyObject}"/>
>    <sequenceFlow sourceRef="createAnyObject" targetRef="createUser"/>
>    <serviceTask id="createUser" name="Create User"
> flowable:delegateExpression="${createUser}"/>
>    <sequenceFlow sourceRef="createUser" targetRef="active"/>
>    <userTask id="active" name="Active"
> flowable:formFieldValidation="true"/>
>    <sequenceFlow sourceRef="active" targetRef="endevent1"/>
>    <endEvent id="endevent1" name="End"/>
> </process>
>
> which, on create, creates the anyObject and additionally a user and stops
> in a user task.
>
> In the console, adding an instance of anyType "myAny" completes
> successfully but afterwards the console becomes partially unusable:
>
> 1. Opening the realms view gives Unexpected RuntimeException
>
> Last cause: Unexpected character ('<' (code 60)): expected a valid value
> (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
>   at [Source:
> (org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit$AsyncWrappedOutputStream$7);
> line: 1, column: 2]
> WicketMessage: Error attaching this container for rendering:
> [WebMarkupContainer [Component id = body]]
>
> 2. Trying to log in I always get "Wrong username and/or password".
>
> This seems to by caused by
>
> DEBUG [IO-1 task-2] org.springframework.security.web.FilterChainProxy
>       : Secured GET /actuator/info/
> DEBUG [IO-1 task-2]
> ot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping : Mapped to
> Actuator web endpoint 'info'
> WARN [IO-1 task-2]
> work.web.servlet.mvc.support.DefaultHandlerExceptionResolver : Resolved
> [org.springframework.http.converter.HttpMessageNotWritableException: Could
> not write JSON: Null key for a Map not allowed in JSON (use a converting
> NullKeySerializer?); nested exception is
> com.fasterxml.jackson.databind.JsonMappingException: Null key for a Map not
> allowed in JSON (use a converting NullKeySerializer?) (through reference
> chain:
> java.util.Collections$UnmodifiableMap["numbers"]->org.apache.syncope.common.lib.info.NumbersInfo["usersByStatus"])]
>
> which in turn is caused by the user's status being null:
>
> {
>    "_class": "org.apache.syncope.common.lib.to.UserTO",
>    "key": "0190a1f1-4a18-7066-8783-278d63e87abd",
>    "type": "USER",
>    "realm": "/",
>    "username": "test",
>    "creator": "creator",
>    "creationDate": "2024-07-11T13:17:43.953038683Z",
>    "creationContext": "context",
>    "lastModifier": "creator",
>    "lastChangeDate": "2024-07-11T13:17:43.953038683Z",
>    "lastChangeContext": "context",
>    "dynRealms": [],
>    "status": null,
>    "auxClasses": [],
>    "plainAttrs": [],
>    "derAttrs": [],
>    "virAttrs": [],
>    "resources": [],
>    "password": null,
>    "token": null,
>    "tokenExpireTime": null,
>    "lastLoginDate": null,
>    "changePwdDate": null,
>    "failedLogins": 0,
>    "securityQuestion": null,
>    "securityAnswer": null,
>    "suspended": false,
>    "mustChangePassword": false,
>    "relationships": [],
>    "memberships": [],
>    "dynMemberships": [],
>    "roles": [],
>    "dynRoles": [],
>    "privileges": [],
>    "linkedAccounts": [],
>    "delegatingDelegations": [],
>    "delegatedDelegations": []
> }
>
> And in fact, the status is never set:
>
> WARN [IO-1 task-2]
> org.apache.syncope.core.flowable.impl.FlowableRuntimeUtils   : While
> setting user status: unexpected task number (0)
>
> So, what am I missing? Or is creating users from within anyObject workflow
> not supposed to work at all? Help would be appreciated.
>
> Best Regards
>
> Stephan
>
> --
> Stephan Feder, Senior Software-Entwickler
> Technische Universität Darmstadt
> Hochschulrechenzentrum, Alexanderstraße 2, 64283 Darmstadt
> Tel. +49 6151 16-71162
> https://www.hrz.tu-darmstadt.de/
>
>

-- 

-- 
Lorenzo Di Cola

Software Engineer @ Tirasa S.r.l.
Viale Vittoria Colonna, 97 - 65127 Pescara
Tel +39 0859116307 / FAX +39 0859111173http://www.tirasa.net

Apache Syncope Committer

Syncope PMC Member at The Apache Software Foundation

http://people.apache.org/phonebook.html?uid=loredicola

Reply via email to