/*
   * (non-Javadoc)
   * @see org.alfresco.repo.rendition.executer.AbstractRenderingEngine#render(org.alfresco.repo.rendition.executer.AbstractRenderingEngine.RenderingContext)
   */
  @Override
  protected void render(RenderingContext context) {
    ContentReader contentReader = context.makeContentReader();
    String sourceMimeType = contentReader.getMimetype();

    // Check that Tika supports the supplied file
    AutoDetectParser p = new AutoDetectParser(tikaConfig);
    MediaType sourceMediaType = MediaType.parse(sourceMimeType);
    if (!p.getParsers().containsKey(sourceMediaType)) {
      throw new RenditionServiceException(
          "Source mime type of "
              + sourceMimeType
              + " is not supported by Tika for HTML conversions");
    }

    // Make the HTML Version using Tika
    // This will also extract out any images as found
    generateHTML(p, context);
  }
Example #2
0
  /** Prints all the known media types, aliases and matching parser classes. */
  private void displaySupportedTypes() {
    AutoDetectParser parser = new AutoDetectParser();
    MediaTypeRegistry registry = parser.getMediaTypeRegistry();
    Map<MediaType, Parser> parsers = parser.getParsers();

    for (MediaType type : registry.getTypes()) {
      System.out.println(type);
      for (MediaType alias : registry.getAliases(type)) {
        System.out.println("  alias:     " + alias);
      }
      MediaType supertype = registry.getSupertype(type);
      if (supertype != null) {
        System.out.println("  supertype: " + supertype);
      }
      Parser p = parsers.get(type);
      if (p != null) {
        System.out.println("  parser:    " + p.getClass().getName());
      }
    }
  }