[SOLVED] How to update user with API Identity

Hi ,
I can not update a user’s data with the API Identity .
Here is my code :

import org.bonitasoft.engine.api.IdentityAPI;
import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.identity.UserUpdater;


aUser instanciation…

UserUpdater updateDescriptor = new UserUpdater();
updateDescriptor.setJobTitle(“test”);

try {

IdentityAPI identityAPI = apiAccessor.getIdentityAPI();
//The id is correctly recovered
identityAPI.updateUser(Long.parseLong(aUser.get("id")), updateDescriptor);

}
catch (Exception e) {

logger.severe(e.printStackTrace());

}

There are no errors at runtime or in the logs but the update doesn’t work (I see nothing in organisation menu).

What is the problem?

I Thank you in advance for your solutions. :slight_smile:

Nobody has solution?
Thanks

Can you please share the whole process (.bos file)? That would help to understand where the “aUser” come from.

Also e.printStackTrace() return void, so you will get nothing in the log file. Stack trace will be sent to System.err that might be configured differently based on your application server, Operating System…

If you want to see the log message you should use (assuming you are using Java Util Logging): log(Level.SEVERE, "Some custom message", e)

Thanks for your answer.
The process

The Zip contains the .bos file. It’s not the same example, but the problem is the same : The update doesn’t work. I use “log(Level.SEVERE, “xxx”, e)” but I have no errors.

Hi,

It seems that your process use a specific organization. Can you include in the .bos file your custom organization so testing becomes easier?

Thanks

Sorry, you can get it here

I just did a test and everything seems to run fine.
I can see that user custom metadata are updated with the “supervisor” user id (information available on the detailed view of a user under “other” section).

Note that in the process you shared you don’t use any UserUpdaterand you don’t change any job title.
Maybe you didn’t share the example that match your description?

It’s strange, to me the field “supervisor” is not update in the organization.I look in the sub-menu “Custom” because I don’t see the “other” menu, but it’s probably the same, right ?

Indeed I indicated that it was not the same example but the problem was the same: no error but no change.

Can you confirm that you look the organization information in the Portal and not in the Studio? “Custom” let me think you are in the Studio because it is named “Other” in the Portal.

An organization can be defined in the Studio and will be stored in the Studio workspace until it is published on Bonita Portal. When published organization will be store in Bonita Engine database. So you end up with two copies of the organization: the one stored in the Studio workspace and the one store in Bonita Engine. When you run your process and call the API you modify the organization stored in Bonita Engine. You can view information of this copy of the organization using Portal administrator view.

Ah ok you teach me that subtlety … Indeed the organization is modified on the database Bonita Engine.
The question then is, how to publish the changes made on the Bonita Engine database to the Studio workspace ? So that the changes are taken into account in the execution of another process.

From Studio “administrator” view you can go to “Organization” → “Import / Export” and click on the button “Export”.

You will get an XML file with organization content as stored by Bonita Engine.

In the Studio you can import the organization stored in the XML file using “Organization” → “Import…” menu.

Ok thank you for your help, thanks to you I found out something important. :slight_smile:

Just to make sure: now everything is running as you expect?