Merge pull request 'Fix API publisher to update scopes including already existing roles' (#224) from pasindu/device-mgt-core:Bug10322 into master

Reviewed-on: community/device-mgt-core#224
mssqldbscriptfix
Amalka Subasinghe 1 year ago
commit 64cb1be253

@ -513,8 +513,15 @@ public class APIPublisherServiceImpl implements APIPublisherService {
if (scopeObj.getString("name").equals(scopeMapping[2] != null ? if (scopeObj.getString("name").equals(scopeMapping[2] != null ?
StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) {
scope.setId(scopeObj.getString("id")); scope.setId(scopeObj.getString("id"));
// Including already existing roles
JSONArray existingRolesArray = (JSONArray) scopeObj.get("bindings");
for (int j = 0; j < existingRolesArray.length(); j++) {
roleString = roleString + "," + existingRolesArray.get(j);
}
} }
} }
scope.setRoles(roleString);
if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) { if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) {
publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope); publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope);

Loading…
Cancel
Save