public class XmlContentImporter extends AbstractLogEnabled implements ContentImporter, Serviceable
Modifier and Type | Field and Description |
---|---|
private ContentTypesHelper |
_cTypeHelper |
private DOMParser |
_domParser |
private XPathProcessor |
_xPathProcessor |
Constructor and Description |
---|
XmlContentImporter() |
Modifier and Type | Method and Description |
---|---|
private void |
_importMetadata(ModifiableCompositeMetadata contentNode,
MetadataDefinition metaDef,
Node domNode) |
private void |
_importMetadata(ModifiableWebContent content,
Node domNode) |
private void |
_setMetadata(ModifiableCompositeMetadata contentNode,
MetadataDefinition metaDef,
Node domNode) |
private void |
_setRepeater(ModifiableCompositeMetadata meta,
RepeaterDefinition repeaterDef,
Node domNode) |
private String[] |
getMetadataValues(MetadataDefinition metaDef,
Node domNode) |
String[] |
getMimeTypes()
Returns all mime types handled by this importer.
|
private Document |
getXmlDocFromFile(File file) |
void |
importContent(File file,
ModifiableWebContent content,
Map<String,String> params)
Extracts file content and populates the given
Content . |
protected Date |
parseDate(String value)
Parse a String value as a Date.
Allowed formats: yyyy-MM-dd yyyy-MM-dd'T'HH:mm:ss.SSSZZ |
protected Date |
parseDate(String value,
boolean throwException)
Parse a String value as a Date.
Allowed formats: yyyy-MM-dd yyyy-MM-dd'T'HH:mm:ss.SSSZZ |
void |
postTreatment(ModifiablePage page,
Content content,
File file)
Post treatment after import process
|
protected String |
serializeNode(Node node)
Serialize a XML node as a String.
|
void |
service(ServiceManager manager) |
protected void |
setBinaryMetadata(ModifiableCompositeMetadata meta,
MetadataDefinition metaDef,
String value)
Set a file metadata.
|
protected void |
setBooleanMetadata(ModifiableCompositeMetadata meta,
MetadataDefinition metaDef,
String[] values)
Set a boolean metadata.
|
protected void |
setCompositeMetadata(ModifiableCompositeMetadata meta,
MetadataDefinition metaDef,
Node domNode)
Set a composite metadata.
|
protected void |
setDateMetadata(ModifiableCompositeMetadata meta,
MetadataDefinition metaDef,
String[] values)
Set a date or datetime metadata.
|
protected void |
setDoubleMetadata(ModifiableCompositeMetadata meta,
MetadataDefinition metaDef,
String[] values)
Set a double metadata.
|
protected void |
setGeocodeMetadata(ModifiableCompositeMetadata meta,
MetadataDefinition metaDef,
String latitude,
String longitude)
Set a geocode metadata.
|
protected void |
setLongMetadata(ModifiableCompositeMetadata meta,
MetadataDefinition metaDef,
String[] values)
Set a long metadata.
|
protected void |
setRichTextMetadata(ModifiableCompositeMetadata meta,
Node domNode,
String name)
Set a RichText metadata.
|
private void |
setStringMetadata(ModifiableCompositeMetadata meta,
MetadataDefinition metaDef,
String[] values) |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
private DOMParser _domParser
private XPathProcessor _xPathProcessor
private ContentTypesHelper _cTypeHelper
public XmlContentImporter()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void importContent(File file, ModifiableWebContent content, Map<String,String> params) throws IOException
ContentImporter
Content
.
Typical usage is to provide a newly created empty Content.importContent
in interface ContentImporter
file
- the source.content
- the Content
to be populated.params
- in/out params to set and get additional data to and from the importer.IOException
- if an error occurs processing the stream.public String[] getMimeTypes()
ContentImporter
getMimeTypes
in interface ContentImporter
public void postTreatment(ModifiablePage page, Content content, File file) throws IOException
ContentImporter
postTreatment
in interface ContentImporter
page
- The created pagecontent
- The created contentfile
- The imported fileIOException
- if an error occurredprivate Document getXmlDocFromFile(File file) throws FileNotFoundException, UnsupportedEncodingException, IOException
private void _importMetadata(ModifiableWebContent content, Node domNode) throws IOException
IOException
private void _importMetadata(ModifiableCompositeMetadata contentNode, MetadataDefinition metaDef, Node domNode) throws IOException
IOException
private void _setRepeater(ModifiableCompositeMetadata meta, RepeaterDefinition repeaterDef, Node domNode) throws IOException
IOException
private void _setMetadata(ModifiableCompositeMetadata contentNode, MetadataDefinition metaDef, Node domNode) throws IOException
IOException
private String[] getMetadataValues(MetadataDefinition metaDef, Node domNode)
private void setStringMetadata(ModifiableCompositeMetadata meta, MetadataDefinition metaDef, String[] values)
protected void setBooleanMetadata(ModifiableCompositeMetadata meta, MetadataDefinition metaDef, String[] values)
meta
- the metadata holder.metaDef
- the metadata definition.values
- the metadata values.protected void setLongMetadata(ModifiableCompositeMetadata meta, MetadataDefinition metaDef, String[] values)
meta
- the metadata holder.metaDef
- the metadata definition.values
- the metadata values.protected void setDoubleMetadata(ModifiableCompositeMetadata meta, MetadataDefinition metaDef, String[] values)
meta
- the metadata holder.metaDef
- the metadata definition.values
- the metadata values.protected void setDateMetadata(ModifiableCompositeMetadata meta, MetadataDefinition metaDef, String[] values)
meta
- the metadata holder.metaDef
- the metadata definition.values
- the metadata values.protected Date parseDate(String value)
value
- the String value.null
if the value can't be parsed.protected Date parseDate(String value, boolean throwException)
value
- the String value.throwException
- true to throw an exception if the value can't be parsed, false to return null.null
if the value can't be parsed and throwException is false.protected void setGeocodeMetadata(ModifiableCompositeMetadata meta, MetadataDefinition metaDef, String latitude, String longitude)
meta
- the metadata holder.metaDef
- the metadata definition.latitude
- the geocode latitude as a String.longitude
- the geocode longitude as a String.protected void setCompositeMetadata(ModifiableCompositeMetadata meta, MetadataDefinition metaDef, Node domNode) throws IOException
meta
- the metadata holder.domNode
- the metadata DOM node.metaDef
- the metadata definition.IOException
- If an error occurresprotected void setBinaryMetadata(ModifiableCompositeMetadata meta, MetadataDefinition metaDef, String value)
meta
- the metadata holder.metaDef
- The metadata definitionvalue
- The valueprotected void setRichTextMetadata(ModifiableCompositeMetadata meta, Node domNode, String name) throws IOException
meta
- the metadata holder.domNode
- the metadata node.name
- the metadata name.IOException
- if an error occurs.protected String serializeNode(Node node) throws TransformerException
node
- the node.TransformerException
- if an error occurs.