Class MetadataResource
java.lang.Object
org.apache.tika.server.core.resource.MetadataResource
- Direct Known Subclasses:
XMPMetadataResource
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFor subclasses the service loader constructs; seeTikaResourceAware.MetadataResource(TikaResource tikaResource) -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.core.ResponsegetMetadata(InputStream is, jakarta.ws.rs.core.HttpHeaders httpHeaders, jakarta.ws.rs.core.UriInfo info) jakarta.ws.rs.core.ResponsegetMetadataField(InputStream is, jakarta.ws.rs.core.HttpHeaders httpHeaders, jakarta.ws.rs.core.UriInfo info, String field) Get a specific metadata field.jakarta.ws.rs.core.ResponsegetMetadataFromMultipart(org.apache.cxf.jaxrs.ext.multipart.Attachment att, jakarta.ws.rs.core.UriInfo info) jakarta.ws.rs.core.ResponsegetMetadataWithConfig(List<org.apache.cxf.jaxrs.ext.multipart.Attachment> attachments, jakarta.ws.rs.core.HttpHeaders httpHeaders) Multipart endpoint with per-request ParseContext configuration.protected TikaResourceFor subclasses in other modules; they need it for request contexts and metadata.protected MetadataparseMetadata(TikaInputStream tis, Metadata metadata, jakarta.ws.rs.core.MultivaluedMap<String, String> httpHeaders, ParseContext context) 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.protected voidsetTikaResource(TikaResource tikaResource)
-
Constructor Details
-
MetadataResource
-
MetadataResource
protected MetadataResource()For subclasses the service loader constructs; seeTikaResourceAware.
-
-
Method Details
-
getTikaResource
For subclasses in other modules; they need it for request contexts and metadata. -
setTikaResource
-
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, ais 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.invalid reference
javax.ws.rs.core.Response.Status#NOT_FOUND- Parameters:
is- inputstreamhttpHeaders- httpheadersinfo- infofield- the tika metadata field name- Returns:
- one of
or
invalid reference
javax.ws.rs.core.Response.Status#OKinvalid 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 ExceptionParses 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
-