Class AbstractXmlCollectionHandler
- java.lang.Object
-
- org.opennms.protocols.xml.collector.AbstractXmlCollectionHandler
-
- All Implemented Interfaces:
XmlCollectionHandler
- Direct Known Subclasses:
AbstractJsonCollectionHandler
,AbstractVTDXmlCollectionHandler
,DefaultXmlCollectionHandler
,HttpCollectionHandler
,Sftp3gppXmlCollectionHandler
public abstract class AbstractXmlCollectionHandler extends Object implements XmlCollectionHandler
The Abstract Class XML Collection Handler.All XmlCollectionHandler should extend this class.
- Author:
- Alejandro Galue
-
-
Constructor Summary
Constructors Constructor Description AbstractXmlCollectionHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected InputStream
applyXsltTransformation(Request request, InputStream is)
Apply XSLT transformation.CollectionSet
collect(CollectionAgent agent, XmlDataCollection collection, Map<String,Object> parameters)
Collect.protected abstract void
fillCollectionSet(String urlString, Request request, CollectionAgent agent, CollectionSetBuilder builder, XmlSource source)
Fill collection set.protected void
fillCollectionSet(CollectionAgent agent, CollectionSetBuilder builder, XmlSource source, Document doc)
Fill collection set.BlobStore
getBlobStore()
protected Resource
getCollectionResource(CollectionAgent agent, String instance, String resourceType, Date timestamp)
Gets the collection resource.ResourceStorageDao
getResourceStorageDao()
RrdRepository
getRrdRepository()
Gets the RRD repository.String
getServiceName()
Gets the service name.protected Date
getTimeStamp(Document doc, XPath xpath, XmlGroup group)
Gets the time stamp.protected Document
getXmlDocument(InputStream is, Request request)
Gets the XML document.protected Document
getXmlDocument(String urlString, Request request)
Gets the XML document.Request
parseRequest(NodeDao nodeDao, Request unformattedRequest, CollectionAgent agent, Integer collectionStep, Map<String,String> parameters)
Parses the request.protected static String
parseString(String reference, String unformattedString, OnmsNode node, String ipAddress, Integer collectionStep, Map<String,String> parameters)
Parses the string.String
parseUrl(NodeDao nodeDao, String unformattedUrl, CollectionAgent agent, Integer collectionStep, Map<String,String> parameters)
Parses the URL.protected InputStream
preProcessHtml(Request request, InputStream is)
Pre-process HTML.protected abstract void
processXmlResource(CollectionSetBuilder builder, Resource collectionResource, String resourceTypeName, String group)
Process XML resource.void
setBlobStore(BlobStore blobStore)
void
setResourceStorageDao(ResourceStorageDao resourceStorageDao)
void
setRrdRepository(RrdRepository rrdRepository)
Sets the RRD repository.void
setServiceName(String serviceName)
Sets the service name associated with this Collection Handler.
-
-
-
Method Detail
-
getResourceStorageDao
public ResourceStorageDao getResourceStorageDao()
-
setResourceStorageDao
public void setResourceStorageDao(ResourceStorageDao resourceStorageDao)
-
getBlobStore
public BlobStore getBlobStore()
-
setBlobStore
public void setBlobStore(BlobStore blobStore)
-
setServiceName
public void setServiceName(String serviceName)
Description copied from interface:XmlCollectionHandler
Sets the service name associated with this Collection Handler.- Specified by:
setServiceName
in interfaceXmlCollectionHandler
- Parameters:
serviceName
- the new service name
-
setRrdRepository
public void setRrdRepository(RrdRepository rrdRepository)
Description copied from interface:XmlCollectionHandler
Sets the RRD repository.- Specified by:
setRrdRepository
in interfaceXmlCollectionHandler
- Parameters:
rrdRepository
- the new RRD repository
-
getServiceName
public String getServiceName()
Gets the service name.- Returns:
- the service name
-
getRrdRepository
public RrdRepository getRrdRepository()
Gets the RRD repository.- Returns:
- the RRD repository
-
collect
public CollectionSet collect(CollectionAgent agent, XmlDataCollection collection, Map<String,Object> parameters) throws CollectionException
Description copied from interface:XmlCollectionHandler
Collect.- Specified by:
collect
in interfaceXmlCollectionHandler
- Parameters:
agent
- the collection agentcollection
- the XML collection configurationparameters
- the collector parameters- Returns:
- the XML collection set
- Throws:
CollectionException
- the collection exception
-
fillCollectionSet
protected void fillCollectionSet(CollectionAgent agent, CollectionSetBuilder builder, XmlSource source, Document doc) throws XPathExpressionException, ParseException
Fill collection set.- Parameters:
agent
- the agentcollectionSet
- the collection setsource
- the sourcedoc
- the doc- Throws:
XPathExpressionException
- the x path expression exceptionParseException
- the parse exception
-
fillCollectionSet
protected abstract void fillCollectionSet(String urlString, Request request, CollectionAgent agent, CollectionSetBuilder builder, XmlSource source) throws Exception
Fill collection set.- Parameters:
urlString
- the URL stringrequest
- the requestagent
- the collection agentcollectionSet
- the collection setsource
- the XML source- Throws:
Exception
- the exception
-
processXmlResource
protected abstract void processXmlResource(CollectionSetBuilder builder, Resource collectionResource, String resourceTypeName, String group)
Process XML resource.- Parameters:
collectionResource
- the collection resourceattribGroupType
- the attribute group type
-
getCollectionResource
protected Resource getCollectionResource(CollectionAgent agent, String instance, String resourceType, Date timestamp)
Gets the collection resource.- Parameters:
agent
- the collection agentinstance
- the resource instanceresourceType
- the resource typetimestamp
- the timestamp- Returns:
- the collection resource
-
getTimeStamp
protected Date getTimeStamp(Document doc, XPath xpath, XmlGroup group) throws XPathExpressionException
Gets the time stamp.- Parameters:
doc
- the docxpath
- the xpathgroup
- the group- Returns:
- the time stamp
- Throws:
XPathExpressionException
- the x path expression exception
-
parseUrl
public String parseUrl(NodeDao nodeDao, String unformattedUrl, CollectionAgent agent, Integer collectionStep, Map<String,String> parameters) throws IllegalArgumentException
Parses the URL.Additional placeholders:
- step, The Collection Step in seconds
- Specified by:
parseUrl
in interfaceXmlCollectionHandler
- Parameters:
unformattedUrl
- the unformatted URLagent
- the collection agentcollectionStep
- the collection step (in seconds)parameters
- the service parameters- Returns:
- the string
- Throws:
IllegalArgumentException
- the illegal argument exception
-
parseRequest
public Request parseRequest(NodeDao nodeDao, Request unformattedRequest, CollectionAgent agent, Integer collectionStep, Map<String,String> parameters) throws IllegalArgumentException
Parses the request.- Specified by:
parseRequest
in interfaceXmlCollectionHandler
- Parameters:
unformattedRequest
- the unformatted requestagent
- the agentcollectionStep
- the collection stepparameters
- the service parameters- Returns:
- the request
- Throws:
IllegalArgumentException
- the illegal argument exception
-
parseString
protected static String parseString(String reference, String unformattedString, OnmsNode node, String ipAddress, Integer collectionStep, Map<String,String> parameters) throws IllegalArgumentException
Parses the string.Valid placeholders are:
- ipAddr|ipAddress, The Node IP Address
- step, The Collection Step in seconds
- nodeId, The Node ID
- nodeLabel, The Node Label
- foreignId, The Node Foreign ID
- foreignSource, The Node Foreign Source
- Any asset property defined on the node.
- Parameters:
reference
- the referenceunformattedString
- the unformatted stringnode
- the nodeipAddress
- the IP addresscollectionStep
- the collection stepparameters
- the service parameters- Returns:
- the string
- Throws:
IllegalArgumentException
- the illegal argument exception
-
getXmlDocument
protected Document getXmlDocument(String urlString, Request request) throws Exception
Gets the XML document.- Parameters:
urlString
- the URL stringrequest
- the request- Returns:
- the XML document
- Throws:
Exception
- the exception
-
getXmlDocument
protected Document getXmlDocument(InputStream is, Request request) throws Exception
Gets the XML document.- Parameters:
is
- the input streamrequest
- the request- Returns:
- the XML document
- Throws:
Exception
- the exception
-
applyXsltTransformation
protected InputStream applyXsltTransformation(Request request, InputStream is) throws Exception
Apply XSLT transformation.- Parameters:
request
- the requestis
- the input stream- Returns:
- the input stream
- Throws:
Exception
- the exception
-
preProcessHtml
protected InputStream preProcessHtml(Request request, InputStream is) throws IOException
Pre-process HTML.- Parameters:
request
- the requestis
- the input stream- Returns:
- the updated input stream
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
-