Hi all,
I try to import profiles with Java (before porting it to Python) and it didn’t work.
I use the following code :
CommandAPI commandAPI = TenantAPIAccessor.getCommandAPI(apiSession); byte[] profilesImport = Files.readAllBytes(Paths.get("../release/Profile_Data.xml")); String profiles = new String(profilesImport); Map<String,Serializable> parameters = new HashMap<>(); parameters.put("xmlContent", profiles.getBytes()); System.out.println("### Import profiles"); Serializable result = commandAPI.execute("importProfilesCommand", parameters); System.out.println(result);
To upload an xml file which has just been exported from another Bonita instance and contains several profiles:
`
<profiles:profiles xmlns:profiles=“http://www.bonitasoft.org/ns/profile/6.1”>
Chargé des études
…
…
`
The output looks like this:
(raw output from the logs:
- client-side:
11:21:52.228 [main] DEBUG org.apache.http.headers - << HTTP/1.1 200 OK 11:21:52.228 [main] DEBUG org.apache.http.headers - << Server: Apache-Coyote/1.1 11:21:52.228 [main] DEBUG org.apache.http.headers - << Content-Type: application/json;charset=UTF-8 11:21:52.228 [main] DEBUG org.apache.http.headers - << Transfer-Encoding: chunked 11:21:52.228 [main] DEBUG org.apache.http.headers - << Date: Tue, 12 Sep 2017 09:21:51 GMT 11:21:52.228 [main] DEBUG org.apache.http.impl.client.DefaultHttpClient - Connection can be kept alive indefinitely 11:21:52.228 [main] DEBUG org.apache.http.wire - << "2a[\r][\n]" 11:21:52.228 [main] DEBUG org.apache.http.wire - << "<object-stream>[\n]" 11:21:52.228 [main] DEBUG org.apache.http.wire - << " <list/>[\n]" 11:21:52.228 [main] DEBUG org.apache.http.wire - << "</object-stream>"
- server side:
2017-09-12 09:21:51.769 +0000 FINEST: com.bonitasoft.engine.api.impl.ServerAPIExt THREAD_ID=43 | HOSTNAME=ip-10-196-76-232 | TENANT_ID=1 | End Server API call org.bonitasoft.engine.api.CommandAPI execute
)
And the profiles are not loaded, there is only the default ones after this command:
mysql> select * from profile; +----------+-----+-----------+-----------------+------------------------------------------------------------------------------------------------------------------------------+---------------+-----------+----------------+---------------+ | tenantId | id | isDefault | name | description | creationDate | createdBy | lastUpdateDate | lastUpdatedBy | +----------+-----+-----------+-----------------+------------------------------------------------------------------------------------------------------------------------------+---------------+-----------+----------------+---------------+ | 1 | 110 | 1 | Administrator | The administrator can install a process, manage the organization, and handle some errors (for example, by replaying a task). | 1505208111599 | -1 | 1505208111599 | -1 | | 1 | 111 | 1 | Process manager | The Process manager can supervise designated processes, and manage cases and tasks of those processes. | 1505208111646 | -1 | 1505208111646 | -1 | | 1 | 112 | 1 | User | The user can view and perform tasks and can start a new case of a process. | 1505208111657 | -1 | 1505208111657 | -1 | +----------+-----+-----------+-----------------+------------------------------------------------------------------------------------------------------------------------------+---------------+-----------+----------------+---------------+
So could someone enlighten me on what is missing in my code ?
Thanks in advance for any hint,
Best regards,
Ludo