Source:
<code>public Response getDocument( @Encoded @PathParam("sourceid") String encodedSourceId, @Encoded @PathParam("id") String encodedId, @QueryParam("transform") String transformerParam, @Context UriInfo uriInfo, @Context HttpServletRequest httpRequest) { try { Response.ResponseBuilder responseBuilder; String id = URLDecoder.decode(encodedId, CharEncoding.UTF_8); final BinaryContent content = catalogService.getDocument( encodedSourceId, encodedId, transformerParam, uriInfo.getAbsolutePath(), uriInfo.getQueryParameters(), httpRequest); if (content == null) { return Response.status(Status.NOT_FOUND) .entity("<pre>Unable to retrieve requested metacard.</pre>") .type(MediaType.TEXT_HTML) .build(); } LOGGER.debug("Read and transform complete, preparing response."); responseBuilder = Response.ok(content.getInputStream(), content.getMimeTypeValue()); responseBuilder.header(HEADER_ACCEPT_RANGES, BYTES); String filename = null; if (content instanceof Resource) { filename = ((Resource) content).getName(); } else { String fileExtension = catalogService.getFileExtensionForMimeType(content.getMimeTypeValue()); if (StringUtils.isNotBlank(fileExtension)) { <START> filename = id + fileExtension; <END> } } if (StringUtils.isNotBlank(filename)) { LOGGER.debug("filename: {}", filename); responseBuilder.header(HEADER_CONTENT_DISPOSITION, "inline; filename=\"" + filename + "\""); } long size = content.getSize(); if (size > 0) { responseBuilder.header(HEADER_CONTENT_LENGTH, size); } return responseBuilder.build(); } catch (CatalogException e) { return createBadRequestResponse(e.getMessage()); } catch (DataUsageLimitExceededException e) { return Response.status(Status.REQUEST_ENTITY_TOO_LARGE) .entity("<pre>" + e.getMessage() + "</pre>") .type(MediaType.TEXT_HTML) .build(); } catch (UnsupportedEncodingException e) { String exceptionMessage = "Unknown error occurred while processing request: "; LOGGER.info(exceptionMessage, e); throw new InternalServerErrorException(exceptionMessage); } }</code><technical_language>I this catch statement is needed UnsupportedEncodingException is caught catalog service implementation</technical_language>

Target:
public Response getDocument( @Encoded @PathParam("sourceid") String encodedSourceId, @Encoded @PathParam("id") String encodedId, @QueryParam("transform") String transformerParam, @Context UriInfo uriInfo, @Context HttpServletRequest httpRequest) { try { Response.ResponseBuilder responseBuilder; String id = URLDecoder.decode(encodedId, CharEncoding.UTF_8); final BinaryContent content = catalogService.getDocument( encodedSourceId, encodedId, transformerParam, uriInfo.getAbsolutePath(), uriInfo.getQueryParameters(), httpRequest); if (content == null) { return Response.status(Status.NOT_FOUND) .entity("<pre>Unable to retrieve requested metacard.</pre>") .type(MediaType.TEXT_HTML) .build(); } LOGGER.debug("Read and transform complete, preparing response."); responseBuilder = Response.ok(content.getInputStream(), content.getMimeTypeValue()); responseBuilder.header(HEADER_ACCEPT_RANGES, BYTES); setFileNameOnResponseBuilder(id, content, responseBuilder); long size = content.getSize(); if (size > 0) { responseBuilder.header(HEADER_CONTENT_LENGTH, size); } return responseBuilder.build(); } catch (CatalogServiceException e) { return createBadRequestResponse(e.getMessage()); } catch (DataUsageLimitExceededException e) { return Response.status(Status.REQUEST_ENTITY_TOO_LARGE) .entity("<pre>" + e.getMessage() + "</pre>") .type(MediaType.TEXT_HTML) .build(); } catch (UnsupportedEncodingException e) { String exceptionMessage = "Unknown error occurred while processing request: "; LOGGER.info(exceptionMessage, e); throw new InternalServerErrorException(exceptionMessage); } }