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:
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(InputStream) to invoke the sub class |
abstract long |
writeFileData(java.io.InputStream tempStream)
Write the file data from the inputstream to the backing store
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSourceDescription, hasData
protected Framework framework
protected NodeSetImpl nodeSet
public BaseFileResourceModelSource(Framework framework)
public java.lang.String getSyntaxMimeType()
getSyntaxMimeType
in interface WriteableModelSource
protected ResourceFormatParser getResourceFormatParser() throws ResourceModelSourceException
getResourceFormat()
or getDocumentFileExtension()
to
retrieve a ResourceFormatParser.ResourceModelSourceException
protected 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(InputStream)
to invoke the sub classwriteData
in interface WriteableModelSource
data
- 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.IOException
public abstract java.io.InputStream openFileDataInputStream() throws java.io.IOException, ResourceModelSourceException
java.io.IOException
ResourceModelSourceException
public long readData(java.io.OutputStream sink) throws java.io.IOException, ResourceModelSourceException
WriteableModelSource
readData
in interface WriteableModelSource
java.io.IOException
ResourceModelSourceException
public SourceType getSourceType()
getSourceType
in interface ResourceModelSource
WriteableModelSource
public boolean isDataWritable()
writeData(InputStream)
protected boolean shouldGenerateServerNode()
protected boolean isSupportsLastModified()
protected long getLastModified()
public WriteableModelSource getWriteable()
getWriteable
in interface ResourceModelSource
public INodeSet getNodes() throws ResourceModelSourceException
getNodes
in interface ResourceModelSource
ResourceModelSourceException
public INodeSet getNodes(ResourceFormatParser parser) throws ResourceModelSourceException
INodeSet
object conatining the nodes config data.parser
- model parserINodeSet
ResourceModelSourceException
- on error