diff --git a/notes-service/src/main/java/org/exoplatform/wiki/service/rest/NotesRestService.java b/notes-service/src/main/java/org/exoplatform/wiki/service/rest/NotesRestService.java index c3bc3e5dd..05905a1c5 100644 --- a/notes-service/src/main/java/org/exoplatform/wiki/service/rest/NotesRestService.java +++ b/notes-service/src/main/java/org/exoplatform/wiki/service/rest/NotesRestService.java @@ -1362,14 +1362,17 @@ public Response searchData(@Context public Response getAvailableLanguages(@Context UriInfo uriInfos, @QueryParam("lang") String lang - ) throws Exception { + ) { try { Set locales = LocaleContextInfoUtils.getSupportedLocales(); - List localesList = new ArrayList(locales); + List localesList = new ArrayList<>(locales); JSONArray localesJSON = new JSONArray(); Locale currentLocal= Locale.ENGLISH; if (!lang.isEmpty()){ - currentLocal = Arrays.stream(Locale.getAvailableLocales()).filter(local -> local.getLanguage().equals(lang)).findAny().get(); + Optional opLocal = Arrays.stream(Locale.getAvailableLocales()).filter(local -> local.getLanguage().equals(lang)).findAny(); + if (opLocal.isPresent()) { + currentLocal = opLocal.get(); + } } for (Locale locale : localesList) { JSONObject object = new JSONObject(); diff --git a/notes-webapp/src/main/webapp/javascript/eXo/wiki/notesService.js b/notes-webapp/src/main/webapp/javascript/eXo/wiki/notesService.js index 845b7f146..986affa06 100644 --- a/notes-webapp/src/main/webapp/javascript/eXo/wiki/notesService.js +++ b/notes-webapp/src/main/webapp/javascript/eXo/wiki/notesService.js @@ -53,7 +53,7 @@ export function getNoteById(noteId,lang,source,type,owner,withChildren) { url=`${url}${getSeparator(url)}noteBookOwner=${owner}`; } if (withChildren){ url=`${url}${getSeparator(url)}withChildren=${withChildren}`; - }if (lang){ + } if (lang){ url=`${url}${getSeparator(url)}lang=${lang}`; } return fetch(url, {