Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2594

Issues with rest API and non-primitive property values


    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.6.0.Final
    • Fix Version/s: 5.1.0.Final
    • Component/s: API, Search
    • Labels:


      I've been playing around with modeshape, mostly hitting the rest API. I've discovered two problems with the results which i get from the rest API. In both cases, i'm making an ajax request (via jquery if its relevant) and accepting json.

      First case (custom properties of objects):
      consider a node which have the following custom properties:

      property1: "some string"
      property2: { subObjectProperty1: "some string2", ...}

      If i GET this node, the json which is returned to me is something like the following:

      "property1": "some string",
      "property2": "{\"subObjectProperty1\":\"some string2\"...}",

      the first property is what i would expect but not the second one. For the second, i'd expect the json to treat property two value as an object, not a string value ie

      "property2": { "subObjectProperty1": "some string2"....},

      this isn't that big of a deal as i can cleanup the code on the client side. it's fairly predictable. I looked into the modeshape source for a bit but the error seems like it may perhaps be with the json library which modeshape uses.

      Second case (query over property which is array):
      Consider that I have a node with a property as follows:

      "property1": ["value1", "value2"]

      If i invoke a GET on the rest API, i will get the expected JSON. However, if i return this column as a part of a query, I only get the first value. say i select the query as so:

      SELECT property1 from [nt:unstructured] WHERE [jcr:path] = '(put the path here)'. 

      The resulting row will have the following json:

      "rows":[{"property1":"value1", "mode:uri"...}]

      as you can see, it does not return an array but rather a string value with the first element in the array. Digging into the code, RestQueryHandler.createRestRow gets the values for individual rows. it eventually calls .getString on the value which in fact returns just a string of the first element and not a string of the full array or anything else.

      The first issue is only slightly annoying. The second is actually problematic as I can't use the query functionality to retrieve node properties which are arrays. If i need these values, i'm forced to execute the query to get the relevant nodes and then perform an actual GET on each one.

        Gliffy Diagrams




              • Assignee:
                hchiorean Horia Chiorean
                mfed Michael Federici
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: