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 InputStreamapplyXsltTransformation(Request request, InputStream is)Apply XSLT transformation.CollectionSetcollect(CollectionAgent agent, XmlDataCollection collection, Map<String,Object> parameters)Collect.protected abstract voidfillCollectionSet(String urlString, Request request, CollectionAgent agent, CollectionSetBuilder builder, XmlSource source)Fill collection set.protected voidfillCollectionSet(CollectionAgent agent, CollectionSetBuilder builder, XmlSource source, Document doc)Fill collection set.BlobStoregetBlobStore()protected ResourcegetCollectionResource(CollectionAgent agent, String instance, String resourceType, Date timestamp)Gets the collection resource.ResourceStorageDaogetResourceStorageDao()RrdRepositorygetRrdRepository()Gets the RRD repository.StringgetServiceName()Gets the service name.protected DategetTimeStamp(Document doc, XPath xpath, XmlGroup group)Gets the time stamp.protected DocumentgetXmlDocument(InputStream is, Request request)Gets the XML document.protected DocumentgetXmlDocument(String urlString, Request request)Gets the XML document.RequestparseRequest(NodeDao nodeDao, Request unformattedRequest, CollectionAgent agent, Integer collectionStep, Map<String,String> parameters)Parses the request.protected static StringparseString(String reference, String unformattedString, OnmsNode node, String ipAddress, Integer collectionStep, Map<String,String> parameters)Parses the string.StringparseUrl(NodeDao nodeDao, String unformattedUrl, CollectionAgent agent, Integer collectionStep, Map<String,String> parameters)Parses the URL.protected InputStreampreProcessHtml(Request request, InputStream is)Pre-process HTML.protected abstract voidprocessXmlResource(CollectionSetBuilder builder, Resource collectionResource, String resourceTypeName, String group)Process XML resource.voidsetBlobStore(BlobStore blobStore)voidsetResourceStorageDao(ResourceStorageDao resourceStorageDao)voidsetRrdRepository(RrdRepository rrdRepository)Sets the RRD repository.voidsetServiceName(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: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 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: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, 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:
parseUrlin 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:
parseRequestin 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.
-
-