You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "Ramachandran (Jira)" <ji...@apache.org> on 2022/09/15 16:20:00 UTC

[jira] [Comment Edited] (RANGER-2928) [Ranger Zone REST API] Resources data is missing in XML format

    [ https://issues.apache.org/jira/browse/RANGER-2928?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17605437#comment-17605437 ] 

Ramachandran edited comment on RANGER-2928 at 9/15/22 4:19 PM:
---------------------------------------------------------------

 
{code:java}
[
  {
    "id": 2,
    "isEnabled": true,
    "createdBy": "Admin",
    "updatedBy": "Admin",
    "createTime": 1663240837000,
    "updateTime": 1663244581000,
    "name": "test",
    "services": {
      "test": {
        "resources": [
          {
            "database": [
              "db",
              "db2"
            ],
            "column": [
              "col1",
              "col2"
            ],
            "table": [
              "table1",
              "table2"
            ]
          }
        ]
      }
    },
    "tagServices": [
      "test"
    ],
    "adminUsers": [
      "admin",
      "keyadmin"
    ],
    "adminUserGroups": [
      "public",
      "test"
    ],
    "auditUsers": [
      "admin",
      "keyadmin"
    ],
    "auditUserGroups": [
      "public",
      "test"
    ],
    "description": "test"
  }
] 
 {code}
 

The above mentioned json response populating resources correctly.

While using content-type is application/xml , we are facing issues 

During marshalling, the below is not getting mapped 
List<HashMap<String, List<String>>> resources;  

[https://github.com/apache/ranger/blob/master/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerSecurityZone.java#L135]

It seems we need to add XmlAdapter to convert between unmappable and mappable objects

Refer:
[http://blog.bdoughan.com/2010/07/xmladapter-jaxbs-secret-weapon.html]

I did a POC for this  via a standalone java project and attached it here [^RangerSecurityZoneServiceJAXBDemo.zip] cc >> [~madhan@apache.org]  [~abhayk]  [~rmani]


was (Author: JIRAUSER295265):
 
{code:java}
[
  {
    "id": 2,
    "isEnabled": true,
    "createdBy": "Admin",
    "updatedBy": "Admin",
    "createTime": 1663240837000,
    "updateTime": 1663244581000,
    "name": "test",
    "services": {
      "test": {
        "resources": [
          {
            "database": [
              "db",
              "db2"
            ],
            "column": [
              "col1",
              "col2"
            ],
            "table": [
              "table1",
              "table2"
            ]
          }
        ]
      }
    },
    "tagServices": [
      "test"
    ],
    "adminUsers": [
      "admin",
      "keyadmin"
    ],
    "adminUserGroups": [
      "public",
      "test"
    ],
    "auditUsers": [
      "admin",
      "keyadmin"
    ],
    "auditUserGroups": [
      "public",
      "test"
    ],
    "description": "test"
  }
] 
 {code}
 

The above mentioned json response populating resources correct.

While using content-type is application/xml , we are facing issues 

During marshalling, the below is not getting mapped 
List<HashMap<String, List<String>>> resources;  

[https://github.com/apache/ranger/blob/master/agents-common/src/main/java/org/apache/ranger/plugin/model/RangerSecurityZone.java#L135]

It seems we need to add XmlAdapter to convert between unmappable and mappable objects

Refer:
[http://blog.bdoughan.com/2010/07/xmladapter-jaxbs-secret-weapon.html]

I did a POC for this  via a standalone java project and attached it here [^RangerSecurityZoneServiceJAXBDemo.zip] cc >> [~madhan@apache.org]  [~abhayk]  [~rmani]

> [Ranger Zone REST API] Resources data is missing in XML format
> --------------------------------------------------------------
>
>                 Key: RANGER-2928
>                 URL: https://issues.apache.org/jira/browse/RANGER-2928
>             Project: Ranger
>          Issue Type: Improvement
>          Components: Ranger
>    Affects Versions: 2.1.0
>            Reporter: Abhishek Shukla
>            Priority: Minor
>              Labels: ranger
>         Attachments: RangerSecurityZoneServiceJAXBDemo.zip
>
>
> Observed that the following Ranger Zone API is missing resources in response section for XML format.
> https://<RANGER_HOST>:6182/service/public/v2/api/zones/
> {noformat}
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <rangerSecurityZones>
>     <rangerSecurityZone>
>         <id>2</id>
>         <isEnabled>true</isEnabled>
>         <createdBy>Admin</createdBy>
>         <updatedBy>Admin</updatedBy>
>         <createTime>2020-07-28T10:15:44Z</createTime>
>         <updateTime>2020-07-28T10:17:52Z</updateTime>
>         <name>test_zone_1</name>
>         <services>
>             <entry>
>                 <key>cm_ozone</key>
>                 <value>
>                     <resources/>
>                 </value>
>             </entry>
>             <entry>
>                 <key>cm_hdfs</key>
>                 <value>
>                     <resources/>
>                 </value>
>             </entry>
>         </services>
>         <adminUsers>admin</adminUsers>
>         <auditUserGroups>public</auditUserGroups>
>         <description></description>
>     </rangerSecurityZone>
> </rangerSecurityZones>{noformat}
>  
> While the same is present for JSON response.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)