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

REST API does not allow nullifying all properties in a complex

    XMLWordPrintable

    Details

    • Release Notes Summary:
      REST API allows to set properties in a complex to null.
    • Backlog priority:
      800
    • Team:
      PLATFORM
    • Sprint:
      nxplatform 11.1.19, nxplatform 11.1.20, nxplatform 11.1.21, nxplatform 11.1.22
    • Story Points:
      3

      Description

      1. in Studio create a custom document type customSchemaDoc with a custom schema containing a complex including 3 String properties
      2. generate forms in Designer for the document type
      3. install Nuxeo
      4. create a document of type customSchemaDoc
      5. set values for the 3 properties in the complex field (val1, val2, val3)
      6. through REST try to set the properties as null (see the mycustomschema:myComplexThing section):
        curl -u Administrator:Administrator -X PUT \
          http://localhost:8080/nuxeo/api/v1/id/d59d8b39-17bc-4caa-9602-0d5a7b667fd7 \
          -H 'Cache-Control: no-cache' \
          -H 'Content-Type: application/json' \
          -H 'X-NXproperties: *' \
          -H 'uid: Administrator' \
          -d '{
            "entity-type": "document",
            "repository": "default",
            "uid": "d59d8b39-17bc-4caa-9602-0d5a7b667fd7",
            "path": "/default-domain/workspaces/testWorkspace23423/mytestdoccplx",
            "type": "customSchemaDoc",
            "state": "project",
            "properties": {
                "dc:description": "truc muche description",
                "mycustomschema:myComplexThing" : {
                    "myAttrBla1" : null,
                    "myAttrBla2" : null,
                    "myAttrBla3" : null
                }
            }
        }'|json_pp
        

        This does not work and displays the following:

        {
           "state" : "project",
           "facets" : [],
           "isCheckedOut" : true,
           "changeToken" : "20-0",
           "uid" : "d59d8b39-17bc-4caa-9602-0d5a7b667fd7",
           "title" : "mytestdoccplx",
           "properties" : {
              "dc:lastContributor" : "Administrator",
              "common:icon" : null,
              "uid:minor_version" : 0,
              "dc:modified" : "2018-07-02T13:32:50.124Z",
              "dc:nature" : null,
              "dc:title" : "mytestdoccplx",
              "uid:uid" : null,
              "dc:created" : "2018-07-02T12:58:54.027Z",
              "dc:issued" : null,
              "mycustomschema:myComplexThing" : {
                 "myAttrBla1" : "val1",
                 "myAttrBla3" : "val3",
                 "myAttrBla2" : "val2"
              },
              "dc:creator" : "Administrator",
              "dc:source" : null,
              "uid:major_version" : 0,
              "dc:format" : null,
              "dc:description" : "truc muche description",
              "common:icon-expanded" : null,
              "dc:publisher" : null,
              "dc:language" : null,
              "dc:contributors" : [
                 "Administrator"
              ],
              "dc:expired" : null,
              "dc:rights" : null,
              "dc:coverage" : null,
              "dc:subjects" : [],
              "dc:valid" : null
           },
           "isProxy" : false,
           "repository" : "default",
           "entity-type" : "document",
           "isVersion" : false,
           "lastModified" : "2018-07-02T13:32:50.124Z",
           "parentRef" : "a1858390-ee7d-4b5d-bdd0-5971ea8a3714",
           "path" : "/default-domain/workspaces/testWorkspace23423/mytestdoccplx",
           "type" : "customSchemaDoc"
        }
        
      7. Now try the same with at least one value and the rest set to null:
        curl -u Administrator:Administrator -X PUT \
          http://localhost:8080/nuxeo/api/v1/id/d59d8b39-17bc-4caa-9602-0d5a7b667fd7 \
          -H 'Cache-Control: no-cache' \
          -H 'Content-Type: application/json' \
          -H 'X-NXproperties: *' \
          -H 'uid: Administrator' \
          -d '{
            "entity-type": "document",
            "repository": "default",
            "uid": "d59d8b39-17bc-4caa-9602-0d5a7b667fd7",
            "path": "/default-domain/workspaces/testWorkspace23423/mytestdoccplx",
            "type": "customSchemaDoc",
            "state": "project",
            "properties": {
                "dc:description": "truc muche description",
                "mycustomschema:myComplexThing" : {
                    "myAttrBla1" : "hop",
                    "myAttrBla2" : null,
                    "myAttrBla3" : null
                }
            }
        }'|json_pp
        

        This works as expected:

        {
           "path" : "/default-domain/workspaces/testWorkspace23423/mytestdoccplx",
           "isVersion" : false,
           "repository" : "default",
           "type" : "customSchemaDoc",
           "title" : "mytestdoccplx",
           "state" : "project",
           "parentRef" : "a1858390-ee7d-4b5d-bdd0-5971ea8a3714",
           "changeToken" : "21-0",
           "isProxy" : false,
           "uid" : "d59d8b39-17bc-4caa-9602-0d5a7b667fd7",
           "isCheckedOut" : true,
           "properties" : {
              "dc:creator" : "Administrator",
              "dc:valid" : null,
              "common:icon" : null,
              "dc:title" : "mytestdoccplx",
              "uid:major_version" : 0,
              "dc:publisher" : null,
              "dc:description" : "truc muche description",
              "dc:coverage" : null,
              "common:icon-expanded" : null,
              "dc:expired" : null,
              "dc:source" : null,
              "uid:minor_version" : 0,
              "dc:lastContributor" : "Administrator",
              "dc:contributors" : [
                 "Administrator"
              ],
              "dc:modified" : "2018-07-02T13:34:02.324Z",
              "uid:uid" : null,
              "dc:issued" : null,
              "dc:created" : "2018-07-02T12:58:54.027Z",
              "dc:subjects" : [],
              "dc:format" : null,
              "dc:rights" : null,
              "mycustomschema:myComplexThing" : {
                 "myAttrBla1" : "hop",
                 "myAttrBla2" : null,
                 "myAttrBla3" : null
              },
              "dc:language" : null,
              "dc:nature" : null
           },
           "lastModified" : "2018-07-02T13:34:02.324Z",
           "entity-type" : "document",
           "facets" : []
        }
        

      Expected behavior: all the values should be updated even if the new values are all null.

      This issue happens with the WebUI.

      Note: it seems one value must not be null to make this work.
      Note 2: package is attached for faster reproduction.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 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