Skip to content

Commit

Permalink
Merge branch 'springdoc_remove_accept_header' of https://github.com/i…
Browse files Browse the repository at this point in the history
…anwallen/core-geonetwork into springdoc_remove_accept_header
  • Loading branch information
ianwallen committed Feb 20, 2024
2 parents 0b535bc + 085f52e commit 1cbee75
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public void exportAsMef(
Log.info(Geonet.MEF, "Current record(s) in selection: " + uuidList.size());

ServiceContext context = ApiUtils.createServiceContext(request);
String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT))?"application/x-gn-mef-2-zip":request.getHeader(HttpHeaders.ACCEPT);
String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT)) ? "application/x-gn-mef-2-zip" : request.getHeader(HttpHeaders.ACCEPT);
MEFLib.Version version = MEFLib.Version.find(acceptHeader);
if (version == MEFLib.Version.V1) {
throw new IllegalArgumentException("MEF version 1 only support one record. Use the /records/{uuid}/formatters/zip to retrieve that format");
Expand Down
30 changes: 15 additions & 15 deletions services/src/main/java/org/fao/geonet/api/records/MetadataApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public synchronized void setApplicationContext(ApplicationContext context) {
@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(type = "string")),
@Content(mediaType = MediaType.APPLICATION_XML_VALUE, schema = @Schema(type = "string")),
@Content(mediaType = MediaType.APPLICATION_XHTML_XML_VALUE, schema = @Schema(type = "string"))
})
})
})
public String getRecord(
@Parameter(description = API_PARAM_RECORD_UUID,
Expand All @@ -185,7 +185,7 @@ public String getRecord(
throw new NotAllowedException(ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_VIEW);
}

String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT))?MediaType.APPLICATION_XML_VALUE:request.getHeader(HttpHeaders.ACCEPT);
String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT)) ? MediaType.APPLICATION_XML_VALUE : request.getHeader(HttpHeaders.ACCEPT);
List<String> accept = Arrays.asList(acceptHeader.split(","));

String defaultFormatter = "xsl-view";
Expand Down Expand Up @@ -246,12 +246,12 @@ public ResponseEntity<String> getRecordPermalink(
@RequestMapping(value = "/{metadataUuid}/formatters/json",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE
)
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Return the record.",
content = @Content(schema = @Schema(type = "string", format = "binary"))),
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_VIEW)
})
})
@ResponseBody
public Object getRecordAsJson(
@Parameter(
Expand Down Expand Up @@ -291,7 +291,7 @@ public Object getRecordAsJson(
@RequestMapping(value = "/{metadataUuid}/formatters/xml",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_XML_VALUE
)
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Return the record.",
content = @Content(schema = @Schema(type = "string", format = "binary"))),
Expand Down Expand Up @@ -340,19 +340,19 @@ public Object getRecordAsXml(
/**
* Get records based on media type.
*
* @param metadataUuid Record UUID.
* @param addSchemaLocation Add XSD schema location based on standard configuration (see schema-ident.xml).
* @param metadataUuid Record UUID.
* @param addSchemaLocation Add XSD schema location based on standard configuration (see schema-ident.xml).
* @param increasePopularity Increase record popularity
* @param withInfo Add geonet:info details
* @param attachment Download as a file
* @param approved Download the approved version
* @param response object
* @param request object
* @param mediaType Supports xml or json - default to xml if the media type is not known.
* @param withInfo Add geonet:info details
* @param attachment Download as a file
* @param approved Download the approved version
* @param response object
* @param request object
* @param mediaType Supports xml or json - default to xml if the media type is not known.
* @return It will the object
* @throws Exception if record not found of permissions denied.
*/
private Object getRecordAs(
private Object getRecordAs(
String metadataUuid,
boolean addSchemaLocation,
boolean increasePopularity,
Expand Down Expand Up @@ -514,7 +514,7 @@ void getRecordAsZip(
Path stylePath = dataDirectory.getWebappDir().resolve(Geonet.Path.SCHEMAS);
Path file = null;
ServiceContext serviceContext = ApiUtils.createServiceContext(request);
String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT))?"application/x-gn-mef-2-zip":request.getHeader(HttpHeaders.ACCEPT);
String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT)) ? "application/x-gn-mef-2-zip" : request.getHeader(HttpHeaders.ACCEPT);
MEFLib.Version version = MEFLib.Version.find(acceptHeader);
try {
if (version == MEFLib.Version.V1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void getRecordFormattedBy(

Locale locale = languageUtils.parseAcceptLanguage(servletRequest.getLocales());

String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT))?MediaType.TEXT_HTML_VALUE:request.getHeader(HttpHeaders.ACCEPT);
String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT)) ? MediaType.TEXT_HTML_VALUE : request.getHeader(HttpHeaders.ACCEPT);

// TODO :
// if text/html > xsl_view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ private Object getKeyword(
) throws Exception {
final String SEPARATOR = ",";
ServiceContext context = ApiUtils.createServiceContext(request);
String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT))?MediaType.APPLICATION_XML_VALUE:request.getHeader(HttpHeaders.ACCEPT);
String acceptHeader = StringUtils.isBlank(request.getHeader(HttpHeaders.ACCEPT)) ? MediaType.APPLICATION_XML_VALUE : request.getHeader(HttpHeaders.ACCEPT);
boolean isJson = MediaType.APPLICATION_JSON_VALUE.equals(acceptHeader);

// Search thesaurus by name (as facet key only contains the name of the thesaurus)
Expand Down

0 comments on commit 1cbee75

Please sign in to comment.