private DocumentViewer selectViewerForTemplate(BinaryResource binaryResource) { DocumentViewer selectedDocumentViewer = null; for (DocumentViewer documentViewer : documentViewers) { if (documentViewer.canRenderViewerTemplate(binaryResource)) { selectedDocumentViewer = documentViewer; break; } } return selectedDocumentViewer; }
@Override public String getHtmlForViewer(BinaryResource binaryResource, String uuid) { String template; DocumentViewer documentViewerSelected = selectViewerForTemplate(binaryResource); try { if (documentViewerSelected != null) { template = documentViewerSelected.renderHtmlForViewer(binaryResource, uuid); } else { template = getDefaultTemplate(binaryResource, uuid); } } catch (Exception e) { LOGGER.log(Level.INFO, null, e); template = new StringBuilder() .append("<p>") .append("Can't render ") .append(binaryResource.getName()) .append("</p>") .toString(); } return template; }