On 19/03/2015 22:00, John Ellinwood wrote:
Sorry, problem including the rest of the log:

Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Unique index or primary key violation: "U_MMBRSHP_SYNCOPEUSER_ID_INDEX_C ON PUBLIC.MEMBERSHIP(SYNCOPEUSER_ID, SYNCOPEROLE_ID) VALUES (101, 100, 151)"; SQL statement: INSERT INTO PUBLIC.Membership (ID, CREATIONDATE, CREATOR, LASTCHANGEDATE, LASTMODIFIER, SYNCOPEUSER_ID, SYNCOPEROLE_ID) VALUES (?, ?, ?, ?, ?, ?, ?) [23505-185] {prepstmnt 1618806582 INSERT INTO PUBLIC.Membership (ID, CREATIONDATE, CREATOR, LASTCHANGEDATE, LASTMODIFIER, SYNCOPEUSER_ID, SYNCOPEROLE_ID) VALUES (?, ?, ?, ?, ?, ?, ?)} [code=23505, state=23505]

I also can't add or remove roles through the UI now. I can't delete the user either.

On Thu, Mar 19, 2015 at 4:56 PM, John Ellinwood <[email protected] <mailto:[email protected]>> wrote:

    I am trying to use the rest api for syncope.  I'm trying this on
    syncope 1.2.2.  My rest client is Jersey, but this happens just
    using RestClient from Firefox as well.


    I have a user, "user1" id 101.
    I have a roles.  "role1" id 100

    Request:
      POST http://localhost:9080/syncope/rest/users/101
      {"id":101,"membershipsToAdd":[{"role":100}]}
    Response
      200 Succes

    Request:
      POST http://localhost:9080/syncope/rest/users/101
      {"id":101,"membershipsToRemove":[100]}
    Response
      200 Success

    Request:
      POST http://localhost:9080/syncope/rest/users/101
      {"id":101,"membershipsToAdd":[{"role":100}]}
    Response
      409 Conflict, DataIntegrityViolation. The transaction has been
    rolled back. See the nested exception for details on the errors
    that occurred.

    Log:
    ...Caused by: org.apache.openjpa.lib.jdbc.ReportinSQLException:
    Unique index or pimary key violation:
    "U_MMBRSHP_SYNCOPEUSER_ID_INDEX_C ON PUBLIC.


Hi John,
I've performed the same operations using Syncope client API (which are CXF-based) and everything worked flawlessly.
I assume you are using some 1.2.X release.

Here's the detail:

 1. created an user (id 103) and a role (id 100) via admin console

2. run the following code snippet in my sample Syncope client application [1] (placed it after the "*do* something" comment on App#main)

        MembershipMod membMod = new MembershipMod();
        membMod.setRole(100);

        UserMod userMod = new UserMod();
        userMod.setId(103);
        userMod.getMembershipsToAdd().add(membMod);

        Response response = userService.update(userMod.getId(), userMod);
        Assert.assertEquals(200, response.getStatus());

        userMod.getMembershipsToAdd().clear();
        userMod.getMembershipsToRemove().add(100L);
        response = userService.update(userMod.getId(), userMod);
        Assert.assertEquals(200, response.getStatus());

        userMod.getMembershipsToRemove().clear();
        userMod.getMembershipsToAdd().add(membMod);
        response = userService.update(userMod.getId(), userMod);
        Assert.assertEquals(200, response.getStatus());

FYI, here's the generated HTTP calls and responses: [2]

HTH
Regards.

[1] https://github.com/ilgrosso/syncopeRestClient
[2] https://paste.apache.org/a4iq

--
Francesco Chicchiriccò

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

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/

Reply via email to