use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ScopeSettingsDTO in project carbon-apimgt by wso2.
the class SystemScopesApiServiceImpl method systemScopesScopeNameGet.
public Response systemScopesScopeNameGet(String scope, String username, MessageContext messageContext) throws APIManagementException {
ScopeSettingsDTO scopeSettingsDTO = new ScopeSettingsDTO();
APIAdmin apiAdmin = new APIAdminImpl();
String decodedScope = new String(Base64.getDecoder().decode(scope));
boolean existence;
if (username == null) {
existence = apiAdmin.isScopeExists(RestApiCommonUtil.getLoggedInUsername(), decodedScope);
if (existence) {
scopeSettingsDTO.setName(decodedScope);
} else {
throw new APIManagementException("Scope Not Found. Scope : " + decodedScope, ExceptionCodes.SCOPE_NOT_FOUND);
}
} else {
existence = apiAdmin.isScopeExistsForUser(username, decodedScope);
if (existence) {
scopeSettingsDTO.setName(decodedScope);
} else {
throw new APIManagementException("User does not have scope. Username : " + username + " Scope : " + decodedScope, ExceptionCodes.SCOPE_NOT_FOUND_FOR_USER);
}
}
return Response.ok().entity(scopeSettingsDTO).build();
}
Aggregations