[jira] [Comment Edited] (RANGER-4112) Update servicedef by name results in 400 status code while the same request works with update servicedef using id

2023-02-28 Thread Ramachandran (Jira)


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

Ramachandran edited comment on RANGER-4112 at 2/28/23 10:35 AM:


[~pradeep]  My bad somehow this case i missed while doing testing 

This logic needs to be changed 

if(serviceDef.getId() == null)

{             serviceDef.setId(id);         }

else if(!serviceDef.getId().equals(id))

{             throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST , 
"serviceDef Id mismatch", true);         }

into 

if (serviceDef.getId() == null) {
serviceDef.setId(id);
else if(StringUtils.isBlank(serviceDef.getName()) && 
!serviceDef.getId().equals(id)) {
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST , 
"serviceDef Id mismatch", true);
}

something like this 

When the serviceDef contains the serviceDefName 

 

!Screenshot 2023-02-28 at 3.21.18 PM.png!


was (Author: JIRAUSER295265):
[~pradeep]  My bad somehow this case i missed while doing testing 

This logic needs to be changed 

if(serviceDef.getId() == null) {
            serviceDef.setId(id);
        } else if(!serviceDef.getId().equals(id)) {
            throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST , 
"serviceDef Id mismatch", true);
        }

into 

if (serviceDef.getId() == null) {
serviceDef.setId(id);
{color:#de350b}} else if(StringUtils.isBlank(serviceDef.getName()) && 
!serviceDef.getId().equals(id)) {{color}
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST , 
"serviceDef Id mismatch", true);
}

something like this 

When the serviceDef contains the serviceDefName 

 

!Screenshot 2023-02-28 at 3.21.18 PM.png!

> Update servicedef by name results in 400 status code while the same request 
> works with update servicedef using id
> -
>
> Key: RANGER-4112
> URL: https://issues.apache.org/jira/browse/RANGER-4112
> Project: Ranger
>  Issue Type: Bug
>  Components: Ranger
>Affects Versions: 3.0.0, 2.4.0
>Reporter: Abhishek
>Assignee: Pradeep Agrawal
>Priority: Major
> Fix For: 3.0.0, 2.4.0
>
> Attachments: Screenshot 2023-02-28 at 3.21.18 PM.png
>
>
> {color:#172b4d}If a PUT request is made to update the servicedef by id 
> (BASE_URL/service/public/v2/api/servicedef/id), the request passes,{color}
> {color:#172b4d}but if the same PUT request is made to update the servicedef 
> by name (BASE_URL/service/public/v2/api/servicedef/name/\{servicedef_name}), 
> then it results in 400 Bad request.{color}



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


[jira] [Comment Edited] (RANGER-4112) Update servicedef by name results in 400 status code while the same request works with update servicedef using id

2023-02-28 Thread Pradeep Agrawal (Jira)


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

Pradeep Agrawal edited comment on RANGER-4112 at 2/28/23 4:56 PM:
--

[~ramackri] : 
in the updateServiceDefByName() : def id is passed null here : 
[https://github.com/apache/ranger/blob/master/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIsv2.java#L281]
 
While updatePolicyByName() is passing the policy id from here 
[https://github.com/apache/ranger/blob/master/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIsv2.java#L570]

 

Is this intentional or any specific case which i can not see from here. 


was (Author: pradeep.agrawal):
[~ramackri] : 
in the updateServiceDefByName() : def id is passed null here : 
[https://github.com/apache/ranger/blob/master/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIsv2.java#L281]
 
While updatePolicyByName() is passing the policy id from here 
[https://github.com/apache/ranger/blob/master/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIsv2.java#L570]

> Update servicedef by name results in 400 status code while the same request 
> works with update servicedef using id
> -
>
> Key: RANGER-4112
> URL: https://issues.apache.org/jira/browse/RANGER-4112
> Project: Ranger
>  Issue Type: Bug
>  Components: Ranger
>Affects Versions: 3.0.0, 2.4.0
>Reporter: Abhishek
>Assignee: Pradeep Agrawal
>Priority: Major
> Fix For: 3.0.0, 2.4.0
>
> Attachments: 
> 0001-RANGER-4112-Update-servicedef-by-name-results-in-400.patch, Screenshot 
> 2023-02-28 at 3.21.18 PM.png
>
>
> {color:#172b4d}If a PUT request is made to update the servicedef by id 
> (BASE_URL/service/public/v2/api/servicedef/id), the request passes,{color}
> {color:#172b4d}but if the same PUT request is made to update the servicedef 
> by name (BASE_URL/service/public/v2/api/servicedef/name/\{servicedef_name}), 
> then it results in 400 Bad request.{color}



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