public abstract class BaseFileResourceModelSource extends java.lang.Object implements ResourceModelSource, WriteableModelSource
A base class for a Writeable ResourceModelSource that supports the Rundeck parser formats.
This class maintains cached Nodes data, and a "last modified" timestamp can be used to determine
if cached or fresh data should be returned. Subclasses can define the specific
ResourceFormat to use, either by returning a provider name from getResourceFormat(), a
file extension from getDocumentFileExtension() or overridding getResourceFormatParser()
directly.
Methods implementing WriteableModelSource are provided, but can be overridden.
This class is meant to serve as a base class for a ResourceModelSource similar to the FileResourceModelSource
where the backend is similar to a file system.
Abstract methods which should be implemented:
getResourceFormat()getDocumentFileExtension()writeFileData(long, InputStream)openFileDataInputStream()Methods which can be overridden:
| Modifier and Type | Field and Description |
|---|---|
protected Framework |
framework |
protected NodeSetImpl |
nodeSet |
| Constructor and Description |
|---|
BaseFileResourceModelSource(Framework framework) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract java.lang.String |
getDocumentFileExtension() |
protected long |
getLastModified() |
INodeSet |
getNodes() |
INodeSet |
getNodes(ResourceFormatParser parser)
Returns a
INodeSet object conatining the nodes config data. |
protected abstract java.lang.String |
getResourceFormat() |
protected ResourceFormatParser |
getResourceFormatParser()
Uses the result of
getResourceFormat() or getDocumentFileExtension() to
retrieve a ResourceFormatParser. |
SourceType |
getSourceType() |
java.lang.String |
getSyntaxMimeType() |
WriteableModelSource |
getWriteable() |
boolean |
isDataWritable() |
protected boolean |
isSupportsLastModified() |
abstract java.io.InputStream |
openFileDataInputStream() |
long |
readData(java.io.OutputStream sink)
read current data into the sink
|
protected boolean |
shouldGenerateServerNode() |
long |
writeData(java.io.InputStream data)
Writes the data to a temp file, and attempts to parser it, then if successful it will
call
writeFileData(long, InputStream) to invoke the sub class |
abstract long |
writeFileData(java.io.InputStream tempStream)
Write the file data from the inputstream to the backing store
|
protected long |
writeFileData(long length,
java.io.InputStream tempStream)
Write the file data from the inputstream to the backing store, this implementation calls
writeFileData(InputStream) but can be overridden |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSourceDescription, hasDataprotected Framework framework
protected NodeSetImpl nodeSet
public BaseFileResourceModelSource(Framework framework)
public java.lang.String getSyntaxMimeType()
getSyntaxMimeType in interface WriteableModelSourceprotected ResourceFormatParser getResourceFormatParser() throws ResourceModelSourceException
getResourceFormat() or getDocumentFileExtension() to
retrieve a ResourceFormatParser.ResourceModelSourceExceptionprotected abstract java.lang.String getResourceFormat()
protected abstract java.lang.String getDocumentFileExtension()
getResourceFormat() must be used.public long writeData(java.io.InputStream data)
throws java.io.IOException,
ResourceModelSourceException
writeFileData(long, InputStream) to invoke the sub classwriteData in interface WriteableModelSourcedata - datajava.io.IOException - if an IO error occursResourceModelSourceException - if an error occurs parsing the data.public abstract long writeFileData(java.io.InputStream tempStream)
throws java.io.IOException
tempStream - input streamjava.io.IOExceptionprotected long writeFileData(long length,
java.io.InputStream tempStream)
throws java.io.IOException
writeFileData(InputStream) but can be overriddenlength - data lengthtempStream - input streamjava.io.IOExceptionpublic abstract java.io.InputStream openFileDataInputStream()
throws java.io.IOException,
ResourceModelSourceException
java.io.IOExceptionResourceModelSourceExceptionpublic long readData(java.io.OutputStream sink)
throws java.io.IOException,
ResourceModelSourceException
WriteableModelSourcereadData in interface WriteableModelSourcejava.io.IOExceptionResourceModelSourceExceptionpublic SourceType getSourceType()
getSourceType in interface ResourceModelSourceWriteableModelSourcepublic boolean isDataWritable()
writeData(InputStream)protected boolean shouldGenerateServerNode()
protected boolean isSupportsLastModified()
protected long getLastModified()
public WriteableModelSource getWriteable()
getWriteable in interface ResourceModelSourcepublic INodeSet getNodes() throws ResourceModelSourceException
getNodes in interface ResourceModelSourceResourceModelSourceExceptionpublic INodeSet getNodes(ResourceFormatParser parser) throws ResourceModelSourceException
INodeSet object conatining the nodes config data.parser - model parserINodeSetResourceModelSourceException - on error