Class TikaPoweredMetadataExtracter

    • Field Detail

      • logger

        protected static org.apache.commons.logging.Log logger
      • KEY_DESCRIPTION

        protected static final java.lang.String KEY_DESCRIPTION
        See Also:
        Constant Field Values
      • documentSelector

        protected org.apache.tika.extractor.DocumentSelector documentSelector
    • Constructor Detail

      • TikaPoweredMetadataExtracter

        public TikaPoweredMetadataExtracter​(java.lang.String extractorContext,
                                            java.util.ArrayList<java.lang.String> supportedMimeTypes)
      • TikaPoweredMetadataExtracter

        public TikaPoweredMetadataExtracter​(java.util.ArrayList<java.lang.String> supportedMimeTypes)
      • TikaPoweredMetadataExtracter

        public TikaPoweredMetadataExtracter​(java.util.ArrayList<java.lang.String> supportedMimeTypes,
                                            java.util.ArrayList<java.lang.String> supportedEmbedMimeTypes)
      • TikaPoweredMetadataExtracter

        public TikaPoweredMetadataExtracter​(java.util.HashSet<java.lang.String> supportedMimeTypes)
      • TikaPoweredMetadataExtracter

        public TikaPoweredMetadataExtracter​(java.util.HashSet<java.lang.String> supportedMimeTypes,
                                            java.util.HashSet<java.lang.String> supportedEmbedMimeTypes)
      • TikaPoweredMetadataExtracter

        public TikaPoweredMetadataExtracter​(java.lang.String extractorContext,
                                            java.util.HashSet<java.lang.String> supportedMimeTypes,
                                            java.util.HashSet<java.lang.String> supportedEmbedMimeTypes)
    • Method Detail

      • getMetadataSeparator

        public java.lang.String getMetadataSeparator()
      • setMetadataSeparator

        public void setMetadataSeparator​(java.lang.String metadataSeparator)
      • buildSupportedMimetypes

        protected static java.util.ArrayList<java.lang.String> buildSupportedMimetypes​(java.lang.String[] explicitTypes,
                                                                                       org.apache.tika.parser.Parser... tikaParsers)
        Builds up a list of supported mime types by merging an explicit list with any that Tika also claims to support
      • getExtractorContext

        protected java.lang.String getExtractorContext()
        Gets context for the current implementation
        Returns:
        String value which determines current context
      • makeDate

        protected java.util.Date makeDate​(java.lang.String dateStr)
        Version which also tries the ISO-8601 formats (in order..), and similar formats, which Tika makes use of
        Overrides:
        makeDate in class AbstractMappingMetadataExtracter
      • getParser

        protected abstract org.apache.tika.parser.Parser getParser()
        Returns the correct Tika Parser to process the document. If you don't know which you want, use TikaAutoMetadataExtracter which makes use of the Tika auto-detection.
      • getEmbedder

        protected org.apache.tika.embedder.Embedder getEmbedder()
        Returns the Tika Embedder to modify the document.
        Returns:
        the Tika embedder
      • needHeaderContents

        protected boolean needHeaderContents()
        Do we care about the contents of the extracted header, or nothing at all?
      • extractSpecific

        protected java.util.Map<java.lang.String,​java.io.Serializable> extractSpecific​(org.apache.tika.metadata.Metadata metadata,
                                                                                             java.util.Map<java.lang.String,​java.io.Serializable> properties,
                                                                                             java.util.Map<java.lang.String,​java.lang.String> headers)
        Allows implementation specific mappings to be done.
      • getInputStream

        protected java.io.InputStream getInputStream​(org.alfresco.service.cmr.repository.ContentReader reader)
                                              throws java.io.IOException
        There seems to be some sort of issue with some downstream 3rd party libraries, and input streams that come from a ContentReader. This happens most often with JPEG and Tiff files. For these cases, buffer out to a local file if not already there
        Throws:
        java.io.IOException
      • setDocumentSelector

        public void setDocumentSelector​(org.apache.tika.extractor.DocumentSelector documentSelector)
        Sets the document selector, used for determining whether to parse embedded resources.
        Parameters:
        documentSelector -
      • getDocumentSelector

        protected org.apache.tika.extractor.DocumentSelector getDocumentSelector​(org.apache.tika.metadata.Metadata metadata,
                                                                                 java.lang.String targetMimeType)
        Gets the document selector, used for determining whether to parse embedded resources, null by default so parse all.
        Parameters:
        metadata -
        targetMimeType -
        Returns:
        the document selector
      • buildParseContext

        protected org.apache.tika.parser.ParseContext buildParseContext​(org.apache.tika.metadata.Metadata metadata,
                                                                        java.lang.String sourceMimeType)
        By default returns a new ParseContent
        Parameters:
        metadata -
        sourceMimeType -
        Returns:
        the parse context
      • extractRaw

        protected java.util.Map<java.lang.String,​java.io.Serializable> extractRaw​(org.alfresco.service.cmr.repository.ContentReader reader)
                                                                                 throws java.lang.Throwable
        Description copied from class: AbstractMappingMetadataExtracter
        Override to provide the raw extracted metadata values. An extracter should extract as many of the available properties as is realistically possible. Even if the default mapping doesn't handle all properties, it is possible for each instance of the extracter to be configured differently and more or less of the properties may be used in different installations.

        Raw values must not be trimmed or removed for any reason. Null values and empty strings are

        • Null: Removed
        • Empty String: Passed to the OverwritePolicy
        • Non Serializable: Converted to String or fails if that is not possible

        Properties extracted and their meanings and types should be thoroughly described in the class-level javadocs of the extracter implementation, for example:

         editor: - the document editor        -->  cm:author
         title:  - the document title         -->  cm:title
         user1:  - the document summary
         user2:  - the document description   -->  cm:description
         user3:  -
         user4:  -
         
        Specified by:
        extractRaw in class AbstractMappingMetadataExtracter
        Parameters:
        reader - the document to extract the values from. This stream provided by the reader must be closed if accessed directly.
        Returns:
        Returns a map of document property values keyed by property name.
        Throws:
        java.lang.Throwable - All exception conditions can be handled.
        See Also:
        AbstractMappingMetadataExtracter.getDefaultMapping()
      • embedInternal

        protected void embedInternal​(java.util.Map<java.lang.String,​java.io.Serializable> properties,
                                     org.alfresco.service.cmr.repository.ContentReader reader,
                                     org.alfresco.service.cmr.repository.ContentWriter writer)
                              throws java.lang.Throwable
        Description copied from class: AbstractMappingMetadataExtracter
        Override to embed metadata values. An extracter should embed as many of the available properties as is realistically possible. Even if the default mapping doesn't handle all properties, it is possible for each instance of the extracter to be configured differently and more or less of the properties may be used in different installations.
        Overrides:
        embedInternal in class AbstractMappingMetadataExtracter
        Parameters:
        properties - the metadata keys and values to embed in the content file
        reader - the reader for the original document. This stream provided by the reader must be closed if accessed directly.
        writer - the writer for the document to embed the values in. This stream provided by the writer must be closed if accessed directly.
        Throws:
        java.lang.Throwable - All exception conditions can be handled.
        See Also:
        AbstractMappingMetadataExtracter.getDefaultEmbedMapping()
      • extractSize

        protected java.lang.String extractSize​(java.lang.String sizeText)
        Exif metadata for size also returns the string "pixels" after the number value , this function will stop at the first non digit character found in the text
        Parameters:
        sizeText - string text
        Returns:
        the size value