Class MetadataResource

java.lang.Object
org.apache.tika.server.core.resource.MetadataResource
Direct Known Subclasses:
XMPMetadataResource

@Path("/meta") public class MetadataResource extends Object
  • Constructor Details

    • MetadataResource

      public MetadataResource(TikaResource tikaResource)
    • MetadataResource

      protected MetadataResource()
      For subclasses the service loader constructs; see TikaResourceAware.
  • Method Details

    • getTikaResource

      protected TikaResource getTikaResource()
      For subclasses in other modules; they need it for request contexts and metadata.
    • setTikaResource

      protected void setTikaResource(TikaResource tikaResource)
    • getMetadataFromMultipart

      @POST @Consumes("multipart/form-data") @Produces({"application/json","text/csv;charset=UTF-8"}) @Path("form") public jakarta.ws.rs.core.Response getMetadataFromMultipart(org.apache.cxf.jaxrs.ext.multipart.Attachment att, @Context jakarta.ws.rs.core.UriInfo info) throws Exception
      Throws:
      Exception
    • getMetadataWithConfig

      @POST @Consumes("multipart/form-data") @Produces({"application/json","text/csv;charset=UTF-8"}) @Path("config") public jakarta.ws.rs.core.Response getMetadataWithConfig(List<org.apache.cxf.jaxrs.ext.multipart.Attachment> attachments, @Context jakarta.ws.rs.core.HttpHeaders httpHeaders) throws Exception
      Multipart endpoint with per-request ParseContext configuration. Accepts two parts: "file" (the document) and "config" (JSON configuration with parseContext).
      Throws:
      Exception
    • getMetadata

      @PUT @Produces({"application/json","text/csv;charset=UTF-8"}) public jakarta.ws.rs.core.Response getMetadata(InputStream is, @Context jakarta.ws.rs.core.HttpHeaders httpHeaders, @Context jakarta.ws.rs.core.UriInfo info) throws Exception
      Throws:
      Exception
    • getMetadataField

      @PUT @Path("{field}") @Produces({"application/json","text/csv;charset=UTF-8","text/plain;charset=UTF-8"}) public jakarta.ws.rs.core.Response getMetadataField(InputStream is, @Context jakarta.ws.rs.core.HttpHeaders httpHeaders, @Context jakarta.ws.rs.core.UriInfo info, @PathParam("field") String field) throws Exception
      Get a specific metadata field. If the document parses successfully but the specific metadata field was not found, a
      invalid reference
      javax.ws.rs.core.Response.Status#NOT_FOUND
      is returned. Unlike the other /meta endpoints, a bare field value has no envelope to embed a container-level exception in, so that case is thrown (422) instead.

      Note that this method handles multivalue fields and returns possibly more metadata value than requested.

      If you want XMP, you must be careful to specify the exact XMP key. For example, "Author" will return nothing, but "dc:creator" will return the correct value.

      Parameters:
      is - inputstream
      httpHeaders - httpheaders
      info - info
      field - the tika metadata field name
      Returns:
      one of
      invalid reference
      javax.ws.rs.core.Response.Status#OK
      or
      invalid reference
      javax.ws.rs.core.Response.Status#NOT_FOUND
      Throws:
      Exception
    • parseMetadata

      protected Metadata parseMetadata(TikaInputStream tis, Metadata metadata, jakarta.ws.rs.core.MultivaluedMap<String,String> httpHeaders, ParseContext context) throws Exception
      Parses via the shared pipes-backed PipesParser, stopping at the container document (SkipEmbeddedDocumentSelector) with content capture off ("ignore" handler) -- metadata only, matching /meta's contract. Set unconditionally so per-request config can't turn content capture back on. A container-level exception is embedded in CONTAINER_EXCEPTION here, not thrown; getMetadataField throws instead since it returns a bare scalar with nowhere to embed it.
      Throws:
      Exception