Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-22739

Always return a directory entry id as a String

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9.3
    • Component/s: Directory, Rest API
    • Upgrade notes:
      Hide

      The DirectoryEntryJsonWriter now set an id field with the directory entry id as a String.
      This is used to retrieve the directory entry when updating an entry through the REST API.
      The old code relying on the id field in the properties still works.

      Show
      The DirectoryEntryJsonWriter now set an id field with the directory entry id as a String. This is used to retrieve the directory entry when updating an entry through the REST API. The old code relying on the id field in the properties still works.
    • Sprint:
      nxfit 9.3.1
    • Story Points:
      5

      Description

      Directory configured with an integer id field and auto-increment option returns its id as a number instead of a String.

      As all the Directory API is based on String id, an entry cannot be updated from the REST API.

      When retrieved from the REST API:
      GET /nuxeo/api/v1/directory/oauth2Tokens/3

      ...
      properties: { 
        id: 3,
        clientId: 'test-client',
        expirationTimeMilliseconds: 3600000
        ...
      }
      

      Updating it with the following (by using the id from the previous call):
      PUT /nuxeo/api/v1/directory/oauth2Tokens/3

      properties: { 
        id: 3,
        clientId: 'another client',
        expirationTimeMilliseconds: 0
        ...
      }
      

      Will lead to the following exception:

      java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
      	at org.nuxeo.ecm.restapi.server.jaxrs.directory.DirectoryEntryObject$1.run(DirectoryEntryObject.java:82)
      	at org.nuxeo.ecm.restapi.server.jaxrs.directory.DirectoryEntryObject$1.run(DirectoryEntryObject.java:75)
      	at org.nuxeo.ecm.restapi.server.jaxrs.directory.DirectorySessionRunner.withDirectorySession(DirectorySessionRunner.java:33)
      	at org.nuxeo.ecm.restapi.server.jaxrs.directory.DirectoryEntryObject.doUpdateEntry(DirectoryEntryObject.java:75)
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 5 hours
                  5h