|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter
org.alfresco.repo.content.metadata.xml.XPathMetadataExtracter
public class XPathMetadataExtracter
An extracter that pulls values from XML documents using configurable XPath statements. It is not possible to list a default set of mappings - this is down to the configuration only.
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)
,
XPathMetadataExtracter.setXpathMappingProperties(Properties)
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.alfresco.repo.content.metadata.MetadataExtracter |
---|
MetadataExtracter.OverwritePolicy |
Field Summary | |
---|---|
static java.lang.String[] |
SUPPORTED_MIMETYPES
|
Fields inherited from class org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter |
---|
NAMESPACE_PROPERTY_PREFIX, supportedDateFormats |
Constructor Summary | |
---|---|
XPathMetadataExtracter()
Default constructor |
Method Summary | |
---|---|
protected java.util.Map |
extractRaw(org.alfresco.service.cmr.repository.ContentReader reader)
Override to provide the raw extracted metadata values. |
protected java.util.Map |
getDefaultMapping()
It is not possible to have any default mappings, but something has to be returned. |
java.lang.String |
getNamespaceURI(java.lang.String prefix)
|
java.lang.String |
getPrefix(java.lang.String namespaceURI)
|
java.util.Iterator |
getPrefixes(java.lang.String namespaceURI)
|
protected void |
init()
Provides a hook point for implementations to perform initialization. |
protected java.util.Map |
processDocument(org.w3c.dom.Document document)
Executes all the necessary XPath statements to extract values. |
protected void |
readXPathMappingProperties(java.util.Properties xpathMappingProperties)
A utility method to convert mapping properties to the Map form. |
void |
setXpathMappingProperties(java.util.Properties xpathMappingProperties)
Set the properties file that maps document properties to the XPath statements necessary to retrieve them. |
Methods inherited from class org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter |
---|
checkIsSupported, extract, extract, extract, filterSystemProperties, getExtractionTime, getMapping, getMimetypeService, getReliability, isSupported, makeDate, newRawMap, putRawValue, readMappingProperties, readMappingProperties, register, setDictionaryService, setFailOnTypeConversion, setInheritDefaultMapping, setMapping, setMappingProperties, setMimetypeService, setOverwritePolicy, setOverwritePolicy, setRegistry, setSupportedDateFormats, setSupportedMimetypes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String[] SUPPORTED_MIMETYPES
Constructor Detail |
---|
public XPathMetadataExtracter()
Method Detail |
---|
public java.lang.String getNamespaceURI(java.lang.String prefix)
getNamespaceURI
in interface javax.xml.namespace.NamespaceContext
public java.lang.String getPrefix(java.lang.String namespaceURI)
getPrefix
in interface javax.xml.namespace.NamespaceContext
public java.util.Iterator getPrefixes(java.lang.String namespaceURI)
getPrefixes
in interface javax.xml.namespace.NamespaceContext
public void setXpathMappingProperties(java.util.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 java.util.Map getDefaultMapping()
getDefaultMapping
in class AbstractMappingMetadataExtracter
AbstractMappingMetadataExtracter.setInheritDefaultMapping(boolean inherit)
protected java.util.Map extractRaw(org.alfresco.service.cmr.repository.ContentReader reader) throws java.lang.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
OverwritePolicy
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.
java.lang.Throwable
AbstractMappingMetadataExtracter.getDefaultMapping()
protected java.util.Map processDocument(org.w3c.dom.Document document) throws java.lang.Throwable
java.lang.Throwable
protected void readXPathMappingProperties(java.util.Properties xpathMappingProperties)
AbstractMappingMetadataExtracter.setMappingProperties(Properties)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |