Skip to content

Commit

Permalink
Fix sonarlint warnings and format code
Browse files Browse the repository at this point in the history
  • Loading branch information
juanluisrp committed Dec 1, 2023
1 parent 787d617 commit 6f38b55
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jeeves.server.context.ServiceContext;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.SearchHit;
import org.fao.geonet.api.ApiUtils;
import org.fao.geonet.api.exception.FeatureNotEnabledException;
import org.fao.geonet.api.tools.i18n.LanguageUtils;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.domain.InspireAtomFeed;
Expand Down Expand Up @@ -108,7 +110,6 @@ public class AtomSearch {
@ApiResponse(responseCode = "204", description = "Not authenticated.")
})
@ResponseStatus(OK)
@ResponseBody
public Element feeds(
@Parameter(
description = "fileIdentifier",
Expand All @@ -123,7 +124,7 @@ public Element feeds(

if (!inspireEnable) {
Log.info(Geonet.ATOM, "Inspire is disabled");
throw new Exception("Inspire is disabled");
throw new FeatureNotEnabledException("Inspire is disabled");
}

List<String> datasetIdentifiers;
Expand All @@ -144,7 +145,8 @@ public Element feeds(
// Retrieve the datasets related to the service metadata
datasetIdentifiers = InspireAtomUtil.extractRelatedDatasetsIdentifiers(schema, md, dm);

String datasets = datasetIdentifiers.stream().collect(Collectors.joining("\",\"", "\"", "\""));
String datasets = datasetIdentifiers.stream().map(StringEscapeUtils::escapeJson)
.collect(Collectors.joining("\",\"", "\"", "\""));

datasetIdentifiersFilter = String.format(", {\"terms\": {\n" +
" \"resourceIdentifier.code\": [%s]\n" +
Expand Down Expand Up @@ -206,7 +208,6 @@ public Element feeds(
@ApiResponse(responseCode = "204", description = "Not authenticated.")
})
@ResponseStatus(OK)
@ResponseBody
public String feedsAsHtml(
@Parameter(
description = "fileIdentifier",
Expand All @@ -218,7 +219,7 @@ public String feedsAsHtml(
Element feeds = feeds(fileIdentifier, request);

Locale locale = languageUtils.parseAcceptLanguage(request.getLocales());
String language = isoLanguagesMapper.iso639_2T_to_iso639_2B(locale.getISO3Language());
String language = IsoLanguagesMapper.iso639_2T_to_iso639_2B(locale.getISO3Language());
language = XslUtil.twoCharLangCode(language, "eng").toLowerCase();

return new XsltResponseWriter(null, "atom-feeds")
Expand Down

0 comments on commit 6f38b55

Please sign in to comment.