Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-20937

eZRest v2: Possible to create content with several languages without defining the required fields for each lang

    XMLWordPrintable

Details

    • Aconcagua Sprint 1

    Description

      It is possible to create objects where mainLanguageCode and languageCode (in fields) do not match.
      For instance, given that both eng-GB, eng-US and fre-FR is defined in the system, it is currently possible to mix the all those language codes in one request:

      "mainLanguageCode": "eng-GB"
      

      and different languagecode for the fields:

      "field": [
      {
        "fieldDefinitionIdentifier": "name",
        "languageCode": "eng-US",
        "fieldValue": "This is an folder"
      },{
        "fieldDefinitionIdentifier": "short_name",
        "languageCode": "fre-FR",
        "fieldValue": ""
      },
      

      This will create a invalid object. So language codes needs to be validated better.

      Complete example :

      #################### - Client request BEGIN - #########################
      POST /api/ezp/v2/content/objects HTTP/1.1
      Host: ezpublish5.rhel61.qa.ez.local:8080
      User-Agent: eZ REST QA Tester
      Content-Length: 2287
      Accept:application/vnd.ez.api.Content+json
      Content-type:application/vnd.ez.api.ContentCreate+json
      Authorization: Basic YWRtaW46cHVibGlzaA==
      
      {
        "ContentCreate": {
          "ContentType": {
            "_href": "/content/types/1"
          },
          "mainLanguageCode": "eng-GB",
          "LocationCreate": {
            "ParentLocation": {
              "_href": "/content/locations/1/2"
            },
            "priority": "0",
            "hidden": "false",
            "sortField": "PATH",
            "sortOrder": "ASC"
          },
          "Section": {
            "_href": "/content/sections/1"
          },
          "alwaysAvailable": "true",
          "User": {
              "_href": "/user/users/14"
          },
          "modificationDate": "2012-09-30T12:30:00",
          "fields": {
            "field": [
              {
                "fieldDefinitionIdentifier": "name",
                "languageCode": "eng-US",
                "fieldValue": "This is an folder"
              },{
                "fieldDefinitionIdentifier": "short_name",
                "languageCode": "fre-FR",
                "fieldValue": ""
              },{
                "fieldDefinitionIdentifier": "short_description",
                "languageCode": "eng-GB",
                "fieldValue": {
                    "xml" : "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<section xmlns:image=\"http://ez.no/namespaces/ezpublish3/image/\" xmlns:xhtml=\"http://ez.no/namespaces/ezpublish3/xhtml/\" xmlns:custom=\"http://ez.no/namespaces/ezpublish3/custom/\"><paragraph xmlns:tmp=\"http://ez.no/namespaces/ezpublish3/temporary/\"></paragraph></section>\n"
                }
              },{
                "fieldDefinitionIdentifier": "description",
                "languageCode": "eng-GB",
                "fieldValue": {
                    "xml" : "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<section xmlns:image=\"http://ez.no/namespaces/ezpublish3/image/\" xmlns:xhtml=\"http://ez.no/namespaces/ezpublish3/xhtml/\" xmlns:custom=\"http://ez.no/namespaces/ezpublish3/custom/\"><paragraph xmlns:tmp=\"http://ez.no/namespaces/ezpublish3/temporary/\"></paragraph></section>\n"
                }
              },{
                "fieldDefinitionIdentifier": "show_children",
                "languageCode": "eng-GB",
                "fieldValue": true
              },{
                "fieldDefinitionIdentifier": "tags",
                "languageCode": "eng-GB",
                "fieldValue": []
              },{
                "fieldDefinitionIdentifier": "publish_date",
                "languageCode": "eng-GB",
                "fieldValue": {
                    "rfc850" : "",
                    "timestamp" : 0
                }
              }
            ]
          }
        }
      }
      
      
      ##################### - Client request END - ##########################
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            vidar.langseid@ibexa.co Vidar Langseid
            Votes:
            0 Vote for this issue
            Watchers:
            4 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 - 1 day, 3 hours, 15 minutes
                1d 3h 15m