public class XPathMetadataExtracter extends AbstractMappingMetadataExtracter implements NamespaceContext
When an instance of this extracter is configured, XPath statements should be provided to extract all the available metadata. The implementation is sensitive to what is actually requested by the configured mapping and will only perform the queries necessary to fulfill the requirements.
To summarize, there are two configurations required for this class:
AbstractMappingMetadataExtracter.setMappingProperties(java.util.Properties)
.
setXpathMappingProperties(Properties).
All values are extracted as text values and therefore all XPath statements must evaluate to a node that can be rendered as text.
AbstractMappingMetadataExtracter.setMappingProperties(Properties)
,
setXpathMappingProperties(Properties)
MetadataExtracter.OverwritePolicy
Modifier and Type | Field and Description |
---|---|
static String[] |
SUPPORTED_MIMETYPES |
MEGABYTE_SIZE, metadataExtracterConfig, NAMESPACE_PROPERTY_PREFIX, PROPERTY_COMPONENT_EMBED, PROPERTY_COMPONENT_EXTRACT, PROPERTY_PREFIX_METADATA
Constructor and Description |
---|
XPathMetadataExtracter()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
protected Map<String,Serializable> |
extractRaw(org.alfresco.service.cmr.repository.ContentReader reader)
Override to provide the raw extracted metadata values.
|
protected Map<String,Set<org.alfresco.service.namespace.QName>> |
getDefaultMapping()
It is not possible to have any default mappings, but something has to be returned.
|
String |
getNamespaceURI(String prefix) |
String |
getPrefix(String namespaceURI) |
Iterator |
getPrefixes(String namespaceURI) |
protected void |
init()
Provides a hook point for implementations to perform initialization.
|
protected Map<String,Serializable> |
processDocument(Document document)
Executes all the necessary XPath statements to extract values.
|
protected void |
readXPathMappingProperties(Properties xpathMappingProperties)
A utility method to convert mapping properties to the Map form.
|
void |
setXpathMappingProperties(Properties xpathMappingProperties)
Set the properties file that maps document properties to the XPath statements
necessary to retrieve them.
|
checkIsEmbedSupported, checkIsSupported, embed, embedInternal, extract, extract, extract, filterSystemProperties, getBeanName, getDefaultEmbedMapping, getEmbedMapping, getExecutorService, getLimits, getMapping, getMimetypeService, isEmbeddingSupported, isSupported, makeDate, newRawMap, putRawValue, readEmbedMappingProperties, readEmbedMappingProperties, readGlobalEmbedMappingProperties, readGlobalExtractMappingProperties, readMappingProperties, readMappingProperties, register, setApplicationContext, setBeanName, setDictionaryService, setEmbedMapping, setEmbedMappingProperties, setEnableStringTagging, setExecutorService, setFailOnTypeConversion, setInheritDefaultEmbedMapping, setInheritDefaultMapping, setMapping, setMappingProperties, setMetadataExtracterConfig, setMimetypeLimits, setMimetypeService, setOverwritePolicy, setProperties, setRegistry, setSupportedDateFormats, setSupportedEmbedMimetypes, setSupportedMimetypes
public static String[] SUPPORTED_MIMETYPES
public String getNamespaceURI(String prefix)
getNamespaceURI
in interface NamespaceContext
public String getPrefix(String namespaceURI)
getPrefix
in interface NamespaceContext
public Iterator getPrefixes(String namespaceURI)
getPrefixes
in interface NamespaceContext
public void setXpathMappingProperties(Properties xpathMappingProperties)
The Xpath mapping is of the form:
# Namespaces prefixes namespace.prefix.my=http://www....com/alfresco/1.0 # Mapping editor=/my:example-element/@cm:editor title=/my:example-element/text()
protected void init()
AbstractMappingMetadataExtracter
default mappings
will be requested during
initialization.init
in class AbstractMappingMetadataExtracter
protected Map<String,Set<org.alfresco.service.namespace.QName>> getDefaultMapping()
getDefaultMapping
in class AbstractMappingMetadataExtracter
AbstractMappingMetadataExtracter.setInheritDefaultMapping(boolean inherit)
protected Map<String,Serializable> extractRaw(org.alfresco.service.cmr.repository.ContentReader reader) throws Throwable
AbstractMappingMetadataExtracter
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
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: -
extractRaw
in class AbstractMappingMetadataExtracter
reader
- the document to extract the values from. This stream provided by
the reader must be closed if accessed directly.Throwable
- All exception conditions can be handled.AbstractMappingMetadataExtracter.getDefaultMapping()
protected Map<String,Serializable> processDocument(Document document) throws Throwable
Throwable
protected void readXPathMappingProperties(Properties xpathMappingProperties)
Copyright © 2005–2017 Alfresco Software. All rights reserved.