You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@manifoldcf.apache.org by "Andrzej Bialecki (JIRA)" <ji...@apache.org> on 2010/09/07 12:58:32 UTC

[jira] Created: (CONNECTORS-99) REST API serialization inconsistency

REST API serialization inconsistency
------------------------------------

                 Key: CONNECTORS-99
                 URL: https://issues.apache.org/jira/browse/CONNECTORS-99
             Project: Apache Connectors Framework
          Issue Type: Bug
          Components: API
         Environment: ACF trunk.
            Reporter: Andrzej Bialecki 


There is some inconsistency in REST APIs that makes the returned values more difficult to process than necessary. It boils down to the fact that lists of values are serialized into JSON arrays only when there is more than 1 element on the list, but they are serialized into plain JSON objects when there is 0 or 1 element on the list. Example:

* listings of jobs, connectors, connections, repositories etc. all suffer from this symptom:

{code}
* 1 element:
  {"job":{"id":"1283811504796","description":"job 1" ...
* 2 elements:
  {"job":[{"id":"1283811504796","description":"job 1" ...
{code}

* nested elements, such as e.g. job metadata:

{code}
1 element:
  "metadata":{"_value_":"","_attribute_name":"jobKey1","_attribute_value":"jobVal1"}
2 elements:
  "metadata":[{"_value_":"","_attribute_name":"jobKey1","_attribute_value":"jobVal1"},{"_value_":"","_attribute_name":"jobKey2","_attribute_value":"jobVal2"}]
{code}

In my opinion, in all the above cases the API should always return a JSON array for those elements that can occur with cardinality > 1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CONNECTORS-99) REST API serialization inconsistency

Posted by "Karl Wright (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONNECTORS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906772#action_12906772 ] 

Karl Wright commented on CONNECTORS-99:
---------------------------------------

I could be wrong, but I don't think this represents an actual bug, just a wish.

Internally, the requests and responses for the API are converted to a node structure.  The node structure is actually based on XML rather than on json, because it was originally used for configuration and specification objects stored as XML in the database for connections and jobs.  This is actually germane, because in the API world these objects must be transmitted to and from ACF via the API.

The internal XML-like object therefore has no way of specifying that some family of nodes should always be treated as an array, while another node is always just going to appear once.  XML intrinsically does not have this ability, except through the DTD mechanism.  So we are left with either making all nodes become arrays (which I rather suspect people would find completely unacceptable), or using the intelligent approach that is the current implementation.


> REST API serialization inconsistency
> ------------------------------------
>
>                 Key: CONNECTORS-99
>                 URL: https://issues.apache.org/jira/browse/CONNECTORS-99
>             Project: Apache Connectors Framework
>          Issue Type: Bug
>          Components: API
>         Environment: ACF trunk.
>            Reporter: Andrzej Bialecki 
>
> There is some inconsistency in REST APIs that makes the returned values more difficult to process than necessary. It boils down to the fact that lists of values are serialized into JSON arrays only when there is more than 1 element on the list, but they are serialized into plain JSON objects when there is 0 or 1 element on the list. Example:
> * listings of jobs, connectors, connections, repositories etc. all suffer from this symptom:
> {code}
> * 1 element:
>   {"job":{"id":"1283811504796","description":"job 1" ...
> * 2 elements:
>   {"job":[{"id":"1283811504796","description":"job 1" ...
> {code}
> * nested elements, such as e.g. job metadata:
> {code}
> 1 element:
>   "metadata":{"_value_":"","_attribute_name":"jobKey1","_attribute_value":"jobVal1"}
> 2 elements:
>   "metadata":[{"_value_":"","_attribute_name":"jobKey1","_attribute_value":"jobVal1"},{"_value_":"","_attribute_name":"jobKey2","_attribute_value":"jobVal2"}]
> {code}
> In my opinion, in all the above cases the API should always return a JSON array for those elements that can occur with cardinality > 1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CONNECTORS-99) REST API serialization inconsistency

Posted by "Andrzej Bialecki (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONNECTORS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906799#action_12906799 ] 

Andrzej Bialecki  commented on CONNECTORS-99:
---------------------------------------------

Yes, it's a wish :) I can live with the way things are, and I can always check whether it's a naked object or an array... it's just not too friendly for the client. At least it would be good to document this behavior.

> REST API serialization inconsistency
> ------------------------------------
>
>                 Key: CONNECTORS-99
>                 URL: https://issues.apache.org/jira/browse/CONNECTORS-99
>             Project: Apache Connectors Framework
>          Issue Type: Wish
>          Components: API
>         Environment: ACF trunk.
>            Reporter: Andrzej Bialecki 
>            Priority: Minor
>
> There is some inconsistency in REST APIs that makes the returned values more difficult to process than necessary. It boils down to the fact that lists of values are serialized into JSON arrays only when there is more than 1 element on the list, but they are serialized into plain JSON objects when there is 0 or 1 element on the list. Example:
> * listings of jobs, connectors, connections, repositories etc. all suffer from this symptom:
> {code}
> * 1 element:
>   {"job":{"id":"1283811504796","description":"job 1" ...
> * 2 elements:
>   {"job":[{"id":"1283811504796","description":"job 1" ...
> {code}
> * nested elements, such as e.g. job metadata:
> {code}
> 1 element:
>   "metadata":{"_value_":"","_attribute_name":"jobKey1","_attribute_value":"jobVal1"}
> 2 elements:
>   "metadata":[{"_value_":"","_attribute_name":"jobKey1","_attribute_value":"jobVal1"},{"_value_":"","_attribute_name":"jobKey2","_attribute_value":"jobVal2"}]
> {code}
> In my opinion, in all the above cases the API should always return a JSON array for those elements that can occur with cardinality > 1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CONNECTORS-99) REST API serialization inconsistency

Posted by "Karl Wright (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONNECTORS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Wright updated CONNECTORS-99:
----------------------------------

    Issue Type: Wish  (was: Bug)
      Priority: Minor  (was: Major)

> REST API serialization inconsistency
> ------------------------------------
>
>                 Key: CONNECTORS-99
>                 URL: https://issues.apache.org/jira/browse/CONNECTORS-99
>             Project: Apache Connectors Framework
>          Issue Type: Wish
>          Components: API
>         Environment: ACF trunk.
>            Reporter: Andrzej Bialecki 
>            Priority: Minor
>
> There is some inconsistency in REST APIs that makes the returned values more difficult to process than necessary. It boils down to the fact that lists of values are serialized into JSON arrays only when there is more than 1 element on the list, but they are serialized into plain JSON objects when there is 0 or 1 element on the list. Example:
> * listings of jobs, connectors, connections, repositories etc. all suffer from this symptom:
> {code}
> * 1 element:
>   {"job":{"id":"1283811504796","description":"job 1" ...
> * 2 elements:
>   {"job":[{"id":"1283811504796","description":"job 1" ...
> {code}
> * nested elements, such as e.g. job metadata:
> {code}
> 1 element:
>   "metadata":{"_value_":"","_attribute_name":"jobKey1","_attribute_value":"jobVal1"}
> 2 elements:
>   "metadata":[{"_value_":"","_attribute_name":"jobKey1","_attribute_value":"jobVal1"},{"_value_":"","_attribute_name":"jobKey2","_attribute_value":"jobVal2"}]
> {code}
> In my opinion, in all the above cases the API should always return a JSON array for those elements that can occur with cardinality > 1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.