Source:
public void createTable(HttpServletRequest request, HttpServletResponse response) throws IOException, ParserConfigurationException, TransformerException, ZebedeeException { Session session = Root.zebedee.getSessions().get(request); com.github.onsdigital.zebedee.model.Collection collection = Collections.getCollection(request); String uri = request.getParameter("uri"); CollectionReader collectionReader = new ZebedeeCollectionReader(Root.zebedee, collection, session); if (StringUtils.isBlank(uri)) { throw new BadRequestException("Please provide a URI"); } Path path = collection.find(uri); if (path == null) { throw new NotFoundException("URI not found in collection: " + uri); } if (Files.isDirectory(path)) { throw new BadRequestException("URI does not specify a file"); } if (StringUtils.equalsIgnoreCase("json", FilenameUtils.getExtension(path.toString()))) { response.setContentType("application/json"); } else { String contentType = Files.probeContentType(path); response.setContentType(contentType); } try (Resource resource = collectionReader.getResource(uri)) { TableModifications modifications = getTableModifications(request); Node table = XlsToHtmlConverter.convertToHtmlPageWithModifications(resource.getData(), modifications); String output = XlsToHtmlConverter.docToString(table); org.apache.commons.io.IOUtils.copy(new StringReader(output), response.getOutputStream()); getCollectionHistoryDao().saveCollectionHistoryEvent(collection, session, COLLECTION_TABLE_CREATED, tableCreated(uri, modifications)); Audit.Event.COLLECTION_TABLE_CREATED .parameters() .host(request) .collection(collection) .user(session.email) .log(); } }

Target:
public void createTable(HttpServletRequest request, HttpServletResponse response) throws IOException, ParserConfigurationException, TransformerException, ZebedeeException { Session session = Root.zebedee.getSessions().get(request); com.github.onsdigital.zebedee.model.Collection collection = Collections.getCollection(request); String uri = request.getParameter("uri"); CollectionReader collectionReader = new ZebedeeCollectionReader(Root.zebedee, collection, session); if (StringUtils.isBlank(uri)) { throw new BadRequestException("Please provide a URI"); } Path path = collection.find(uri); if (path == null) { throw new NotFoundException("URI not found in collection: " + uri); } if (Files.isDirectory(path)) { throw new BadRequestException("URI does not specify a file"); } if (StringUtils.equalsIgnoreCase("json", FilenameUtils.getExtension(path.toString()))) { response.setContentType("application/json"); } else { String contentType = Files.probeContentType(path); response.setContentType(contentType); } try ( Resource resource = collectionReader.getResource(uri); InputStream inputStream = resource.getData() ) { TableModifications modifications = getTableModifications(request); Node table = XlsToHtmlConverter.convertToHtmlPageWithModifications(inputStream, modifications); String output = XlsToHtmlConverter.docToString(table); org.apache.commons.io.IOUtils.copy(new StringReader(output), response.getOutputStream()); getCollectionHistoryDao().saveCollectionHistoryEvent(collection, session, COLLECTION_TABLE_CREATED, tableCreated(uri, modifications)); Audit.Event.COLLECTION_TABLE_CREATED .parameters() .host(request) .collection(collection) .user(session.email) .log(); } }