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 java.lang.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 java.io.InputStreamapplyXsltTransformation(Request request, java.io.InputStream is)Apply XSLT transformation.CollectionSetcollect(CollectionAgent agent, XmlDataCollection collection, java.util.Map<java.lang.String,java.lang.Object> parameters)Collect.protected abstract voidfillCollectionSet(java.lang.String urlString, Request request, CollectionAgent agent, CollectionSetBuilder builder, XmlSource source)Fill collection set.protected voidfillCollectionSet(CollectionAgent agent, CollectionSetBuilder builder, XmlSource source, org.w3c.dom.Document doc)Fill collection set.BlobStoregetBlobStore()protected ResourcegetCollectionResource(CollectionAgent agent, java.lang.String instance, java.lang.String resourceType, java.util.Date timestamp)Gets the collection resource.ResourceStorageDaogetResourceStorageDao()RrdRepositorygetRrdRepository()Gets the RRD repository.java.lang.StringgetServiceName()Gets the service name.protected java.util.DategetTimeStamp(org.w3c.dom.Document doc, javax.xml.xpath.XPath xpath, XmlGroup group)Gets the time stamp.protected org.w3c.dom.DocumentgetXmlDocument(java.io.InputStream is, Request request)Gets the XML document.protected org.w3c.dom.DocumentgetXmlDocument(java.lang.String urlString, Request request)Gets the XML document.RequestparseRequest(NodeDao nodeDao, Request unformattedRequest, CollectionAgent agent, java.lang.Integer collectionStep, java.util.Map<java.lang.String,java.lang.String> parameters)Parses the request.protected static java.lang.StringparseString(java.lang.String reference, java.lang.String unformattedString, OnmsNode node, java.lang.String ipAddress, java.lang.Integer collectionStep, java.util.Map<java.lang.String,java.lang.String> parameters)Parses the string.java.lang.StringparseUrl(NodeDao nodeDao, java.lang.String unformattedUrl, CollectionAgent agent, java.lang.Integer collectionStep, java.util.Map<java.lang.String,java.lang.String> parameters)Parses the URL.protected java.io.InputStreampreProcessHtml(Request request, java.io.InputStream is)Pre-process HTML.protected abstract voidprocessXmlResource(CollectionSetBuilder builder, Resource collectionResource, java.lang.String resourceTypeName, java.lang.String group)Process XML resource.voidsetBlobStore(BlobStore blobStore)voidsetResourceStorageDao(ResourceStorageDao resourceStorageDao)voidsetRrdRepository(RrdRepository rrdRepository)Sets the RRD repository.voidsetServiceName(java.lang.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(java.lang.String serviceName)
Description copied from interface:XmlCollectionHandlerSets the service name associated with this Collection Handler.- Specified by:
setServiceNamein interfaceXmlCollectionHandler- Parameters:
serviceName- the new service name
-
setRrdRepository
public void setRrdRepository(RrdRepository rrdRepository)
Description copied from interface:XmlCollectionHandlerSets the RRD repository.- Specified by:
setRrdRepositoryin interfaceXmlCollectionHandler- Parameters:
rrdRepository- the new RRD repository
-
getServiceName
public java.lang.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, java.util.Map<java.lang.String,java.lang.Object> parameters) throws CollectionException
Description copied from interface:XmlCollectionHandlerCollect.- Specified by:
collectin 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, org.w3c.dom.Document doc) throws javax.xml.xpath.XPathExpressionException, java.text.ParseException
Fill collection set.- Parameters:
agent- the agentcollectionSet- the collection setsource- the sourcedoc- the doc- Throws:
javax.xml.xpath.XPathExpressionException- the x path expression exceptionjava.text.ParseException- the parse exception
-
fillCollectionSet
protected abstract void fillCollectionSet(java.lang.String urlString, Request request, CollectionAgent agent, CollectionSetBuilder builder, XmlSource source) throws java.lang.ExceptionFill collection set.- Parameters:
urlString- the URL stringrequest- the requestagent- the collection agentcollectionSet- the collection setsource- the XML source- Throws:
java.lang.Exception- the exception
-
processXmlResource
protected abstract void processXmlResource(CollectionSetBuilder builder, Resource collectionResource, java.lang.String resourceTypeName, java.lang.String group)
Process XML resource.- Parameters:
collectionResource- the collection resourceattribGroupType- the attribute group type
-
getCollectionResource
protected Resource getCollectionResource(CollectionAgent agent, java.lang.String instance, java.lang.String resourceType, java.util.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 java.util.Date getTimeStamp(org.w3c.dom.Document doc, javax.xml.xpath.XPath xpath, XmlGroup group) throws javax.xml.xpath.XPathExpressionExceptionGets the time stamp.- Parameters:
doc- the docxpath- the xpathgroup- the group- Returns:
- the time stamp
- Throws:
javax.xml.xpath.XPathExpressionException- the x path expression exception
-
parseUrl
public java.lang.String parseUrl(NodeDao nodeDao, java.lang.String unformattedUrl, CollectionAgent agent, java.lang.Integer collectionStep, java.util.Map<java.lang.String,java.lang.String> parameters) throws java.lang.IllegalArgumentException
Parses the URL.Additional placeholders:
- step, The Collection Step in seconds
- Specified by:
parseUrlin interfaceXmlCollectionHandler- Parameters:
unformattedUrl- the unformatted URLagent- the collection agentcollectionStep- the collection step (in seconds)parameters- the service parameters- Returns:
- the string
- Throws:
java.lang.IllegalArgumentException- the illegal argument exception
-
parseRequest
public Request parseRequest(NodeDao nodeDao, Request unformattedRequest, CollectionAgent agent, java.lang.Integer collectionStep, java.util.Map<java.lang.String,java.lang.String> parameters) throws java.lang.IllegalArgumentException
Parses the request.- Specified by:
parseRequestin interfaceXmlCollectionHandler- Parameters:
unformattedRequest- the unformatted requestagent- the agentcollectionStep- the collection stepparameters- the service parameters- Returns:
- the request
- Throws:
java.lang.IllegalArgumentException- the illegal argument exception
-
parseString
protected static java.lang.String parseString(java.lang.String reference, java.lang.String unformattedString, OnmsNode node, java.lang.String ipAddress, java.lang.Integer collectionStep, java.util.Map<java.lang.String,java.lang.String> parameters) throws java.lang.IllegalArgumentExceptionParses 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:
java.lang.IllegalArgumentException- the illegal argument exception
-
getXmlDocument
protected org.w3c.dom.Document getXmlDocument(java.lang.String urlString, Request request) throws java.lang.ExceptionGets the XML document.- Parameters:
urlString- the URL stringrequest- the request- Returns:
- the XML document
- Throws:
java.lang.Exception- the exception
-
getXmlDocument
protected org.w3c.dom.Document getXmlDocument(java.io.InputStream is, Request request) throws java.lang.ExceptionGets the XML document.- Parameters:
is- the input streamrequest- the request- Returns:
- the XML document
- Throws:
java.lang.Exception- the exception
-
applyXsltTransformation
protected java.io.InputStream applyXsltTransformation(Request request, java.io.InputStream is) throws java.lang.Exception
Apply XSLT transformation.- Parameters:
request- the requestis- the input stream- Returns:
- the input stream
- Throws:
java.lang.Exception- the exception
-
preProcessHtml
protected java.io.InputStream preProcessHtml(Request request, java.io.InputStream is) throws java.io.IOException
Pre-process HTML.- Parameters:
request- the requestis- the input stream- Returns:
- the updated input stream
- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
-