Ejemplo n.º 1
0
 private DocumentViewer selectViewerForTemplate(BinaryResource binaryResource) {
   DocumentViewer selectedDocumentViewer = null;
   for (DocumentViewer documentViewer : documentViewers) {
     if (documentViewer.canRenderViewerTemplate(binaryResource)) {
       selectedDocumentViewer = documentViewer;
       break;
     }
   }
   return selectedDocumentViewer;
 }
Ejemplo n.º 2
0
  @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;
  }