Source:
public Object browseLogsDirectory(@PathVariable("path") Optional<String> path, ModelMap model, @RequestHeader(value = HttpHeaders.ACCEPT, required = false) String acceptHeader) { logger.debug("Requested directory listing of logs {}/logs/{}", ROOT_CONTEXT, path.orElse("")); try { Path logsBaseDir = Paths.get(propertiesBooter.getLogsDirectory()); Path requestedLogPath = Paths.get(logsBaseDir.toString(), path.orElse("")); logger.debug("Requested directory listing of path: resolved to [{}]", path, requestedLogPath); if (!Files.exists(requestedLogPath)) { return getNotFoundResponseEntity("Requested path does not exist!", acceptHeader); } if (!Files.isDirectory(requestedLogPath)) { return getBadRequestResponseEntity("Requested path is not a directory!", acceptHeader); } UriComponentsBuilder baseBuilder = uriBuilder.getBuilder(ROOT_CONTEXT); DirectoryListing directoryListing = directoryListingService.fromPath(baseBuilder.cloneBuilder().path("/browse"), baseBuilder.cloneBuilder().path("/download"), logsBaseDir, requestedLogPath); if (acceptHeader != null && acceptHeader.contains(MediaType.APPLICATION_JSON_VALUE)) { return ResponseEntity.ok(objectMapper.writer().writeValueAsString(directoryListing)); } boolean showBack = path.isPresent() && !StringUtils.isBlank(path.get()); String backPath = null; if(showBack) { backPath = uriBuilder.getBuilder() .path(Paths.get(getCurrentRequestURI()).getParent().toString()) .build() .toUriString(); } model.addAttribute("backPath", backPath); model.addAttribute("currentPath", getCurrentRequestURI()); model.addAttribute("directories", directoryListing.getDirectories()); model.addAttribute("files", directoryListing.getFiles()); return new ModelAndView("directoryListing", model); } catch (Exception e) { String message = "Attempt to browse logs failed. Check server logs for more information."; return getExceptionResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR, message, e, acceptHeader); } }

Target:
public Object browseLogsDirectory(@PathVariable("path") Optional<String> path, ModelMap model, @RequestHeader(value = HttpHeaders.ACCEPT, required = false) String acceptHeader) { logger.debug("Requested directory listing of logs {}/logs/{}", ROOT_CONTEXT, path.orElse("")); try { Path logsBaseDir = Paths.get(propertiesBooter.getLogsDirectory()); Path requestedLogPath = Paths.get(logsBaseDir.toString(), path.orElse("")); logger.debug("Requested directory listing of path: resolved to [{}]", path, requestedLogPath); if (!Files.exists(requestedLogPath)) { return getNotFoundResponseEntity("Requested path does not exist!", acceptHeader); } if (!Files.isDirectory(requestedLogPath)) { return getBadRequestResponseEntity("Requested path is not a directory!", acceptHeader); } UriComponentsBuilder baseBuilder = uriBuilder.getBuilder(ROOT_CONTEXT); DirectoryListing directoryListing = directoryListingService.fromPath(baseBuilder.cloneBuilder().path("/browse"), baseBuilder.cloneBuilder().path("/download"), logsBaseDir, requestedLogPath); if (acceptHeader != null && acceptHeader.contains(MediaType.APPLICATION_JSON_VALUE)) { return ResponseEntity.ok(objectMapper.writer().writeValueAsString(directoryListing)); } boolean showBack = path.isPresent() && !StringUtils.isBlank(path.get()); String backPath = null; if (showBack) { backPath = uriBuilder.getBuilder() .path(Paths.get(getCurrentRequestUri()).getParent().toString()) .build() .toUriString(); } model.addAttribute("backPath", backPath); model.addAttribute("currentPath", getCurrentRequestUri()); model.addAttribute("directories", directoryListing.getDirectories()); model.addAttribute("files", directoryListing.getFiles()); return new ModelAndView("directoryListing", model); } catch (Exception e) { String message = "Attempt to browse logs failed. Check server logs for more information."; return getExceptionResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR, message, e, acceptHeader); } }