Source:
<code>private DirectoryListing generateDirectoryListing(Path relativePath, List<Path> contentPaths, UriComponentsBuilder directoryLinkBuilder, UriComponentsBuilder fileLinkBuilder) throws IOException { DirectoryListing listing = new DirectoryListing(); listing.setLink(uriBuilder.getCurrentRequestURL()); for (Path contentPath : contentPaths) { FileContent file = new FileContent(contentPath.getFileName().toString()); Map<String, Object> fileAttributes = Files.readAttributes(contentPath, "*"); file.setStorageId((String) fileAttributes.get(RepositoryFileAttributeType.STORAGE_ID.getName())); file.setRepositoryId((String) fileAttributes.get(RepositoryFileAttributeType.REPOSITORY_ID.getName())); file.setArtifactPath((String) fileAttributes.get(RepositoryFileAttributeType.ARTIFACT_PATH.getName())); file.setLastModified(new Date(((FileTime) fileAttributes.get("lastModifiedTime")).toMillis())); file.setSize((Long) fileAttributes.get("size")); if (file.getArtifactPath() == null) { file.setArtifactPath(sanitizedPath(relativePath.toString() + "/" + file.getName())); } UriComponentsBuilder builder = null; if (Boolean.TRUE.equals(fileAttributes.get("isDirectory"))) { builder = UriComponentsBuilder.fromUriString(directoryLinkBuilder.toUriString()); listing.getDirectories().add(file); } else { <START> if(fileLinkBuilder != null) <END> { builder = UriComponentsBuilder.fromUriString(fileLinkBuilder.toUriString()); } listing.getFiles().add(file); } if(builder != null) { URL url = builder.path("/" + file.getArtifactPath()) .build() .toUri() .toURL(); file.setUrl(url); } } return listing; }</code><technical_language>Cosmetic: suggestion if (fileLinkBuilder != null)</technical_language>

Target:
private DirectoryListing generateDirectoryListing(Path relativePath, List<Path> contentPaths, UriComponentsBuilder directoryLinkBuilder, UriComponentsBuilder fileLinkBuilder) throws IOException { DirectoryListing listing = new DirectoryListing(); listing.setLink(uriBuilder.getCurrentRequestUrl()); for (Path contentPath : contentPaths) { FileContent file = new FileContent(contentPath.getFileName().toString()); Map<String, Object> fileAttributes = Files.readAttributes(contentPath, "*"); file.setStorageId((String) fileAttributes.get(RepositoryFileAttributeType.STORAGE_ID.getName())); file.setRepositoryId((String) fileAttributes.get(RepositoryFileAttributeType.REPOSITORY_ID.getName())); file.setArtifactPath((String) fileAttributes.get(RepositoryFileAttributeType.ARTIFACT_PATH.getName())); file.setLastModified(new Date(((FileTime) fileAttributes.get("lastModifiedTime")).toMillis())); file.setSize((Long) fileAttributes.get("size")); if (file.getArtifactPath() == null) { file.setArtifactPath(sanitizedPath(relativePath.toString() + "/" + file.getName())); } UriComponentsBuilder builder = null; if (Boolean.TRUE.equals(fileAttributes.get("isDirectory"))) { builder = UriComponentsBuilder.fromUriString(directoryLinkBuilder.toUriString()); listing.getDirectories().add(file); } else { if (fileLinkBuilder != null) { builder = UriComponentsBuilder.fromUriString(fileLinkBuilder.toUriString()); } listing.getFiles().add(file); } if (builder != null) { URL url = builder.path("/" + file.getArtifactPath()) .build() .toUri() .toURL(); file.setUrl(url); } } return listing; }