Fix duplicate scope publishing issue

remotes/1721272053111006915/tmp_refs/heads/master
Rajitha Kumara 11 months ago
parent c0ecb841e0
commit 041c84a45f

@ -456,17 +456,19 @@ public class APIPublisherServiceImpl implements APIPublisherService {
Scope scope = new Scope(); Scope scope = new Scope();
for (DefaultPermission defaultPermission: defaultPermissions.getDefaultPermissions()) { for (DefaultPermission defaultPermission: defaultPermissions.getDefaultPermissions()) {
//todo check whether scope is available or not if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo,
ScopeMapping scopeMapping = defaultPermission.getScopeMapping(); defaultPermission.getScopeMapping().getKey())) {
ScopeMapping scopeMapping = defaultPermission.getScopeMapping();
List<String> bindings = new ArrayList<>(
Arrays.asList(scopeMapping.getDefaultRoles().split(","))); List<String> bindings = new ArrayList<>(
bindings.add(ADMIN_ROLE_KEY); Arrays.asList(scopeMapping.getDefaultRoles().split(",")));
scope.setName(scopeMapping.getKey()); bindings.add(ADMIN_ROLE_KEY);
scope.setDescription(scopeMapping.getName()); scope.setName(scopeMapping.getKey());
scope.setDisplayName(scopeMapping.getName()); scope.setDescription(scopeMapping.getName());
scope.setBindings(bindings); scope.setDisplayName(scopeMapping.getName());
publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); scope.setBindings(bindings);
publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope);
}
} }
} catch (BadRequestException | UnexpectedResponseException | APIServicesException e) { } catch (BadRequestException | UnexpectedResponseException | APIServicesException e) {
log.error("Error occurred while adding default scopes"); log.error("Error occurred while adding default scopes");

Loading…
Cancel
Save