Class FileResourceModelSource
- java.lang.Object
-
- com.dtolabs.rundeck.core.resources.BaseFileResourceModelSource
-
- com.dtolabs.rundeck.core.resources.FileResourceModelSource
-
- All Implemented Interfaces:
Configurable,ResourceModelSource,WriteableModelSource
public class FileResourceModelSource extends BaseFileResourceModelSource implements Configurable
FileResourceModelSource extendsBaseFileResourceModelSourceto provide an optionally editable Model source using a local file system path.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileResourceModelSource.Configuration
-
Field Summary
-
Fields inherited from class com.dtolabs.rundeck.core.resources.BaseFileResourceModelSource
framework, nodeSet
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(FileResourceModelSource.Configuration configuration)Configure the Sourcevoidconfigure(java.util.Properties configs)Configure the object with the configuration properties.protected java.lang.StringgetDocumentFileExtension()protected longgetLastModified()protected java.lang.StringgetResourceFormat()java.lang.StringgetSourceDescription()booleanhasData()booleanisDataWritable()protected booleanisSupportsLastModified()java.io.InputStreamopenFileDataInputStream()static INodeSetparseFile(java.io.File file, Framework framework, java.lang.String project)Utility method to directly parse the nodes from a filestatic INodeSetparseFile(java.io.File file, java.lang.String format, Framework framework, java.lang.String project)Utility method to directly parse the nodes from a fileprotected booleanshouldGenerateServerNode()java.lang.StringtoString()longwriteFileData(java.io.InputStream dataStream)Write the file data from the inputstream to the backing store-
Methods inherited from class com.dtolabs.rundeck.core.resources.BaseFileResourceModelSource
getNodes, getNodes, getResourceFormatParser, getSourceType, getSyntaxMimeType, getWriteable, readData, writeData, writeFileData
-
-
-
-
Method Detail
-
configure
public void configure(java.util.Properties configs) throws ConfigurationExceptionDescription copied from interface:ConfigurableConfigure the object with the configuration properties.- Specified by:
configurein interfaceConfigurable- Parameters:
configs- the properties to use- Throws:
ConfigurationException- if there is an invalid configuration
-
configure
public void configure(FileResourceModelSource.Configuration configuration) throws ConfigurationException
Configure the Source- Parameters:
configuration- configuration- Throws:
ConfigurationException- on config error
-
writeFileData
public long writeFileData(java.io.InputStream dataStream) throws java.io.IOExceptionDescription copied from class:BaseFileResourceModelSourceWrite the file data from the inputstream to the backing store- Specified by:
writeFileDatain classBaseFileResourceModelSource- Parameters:
dataStream- input stream- Returns:
- bytes writen
- Throws:
java.io.IOException
-
openFileDataInputStream
public java.io.InputStream openFileDataInputStream() throws java.io.IOException, ResourceModelSourceException- Specified by:
openFileDataInputStreamin classBaseFileResourceModelSource- Returns:
- an input stream that reads the data from the backing store
- Throws:
java.io.IOExceptionResourceModelSourceException
-
hasData
public boolean hasData()
- Specified by:
hasDatain interfaceWriteableModelSource- Returns:
- true if the call to
WriteableModelSource.readData(OutputStream)is expected to succeed.
-
isSupportsLastModified
protected boolean isSupportsLastModified()
- Overrides:
isSupportsLastModifiedin classBaseFileResourceModelSource- Returns:
- true if the underlying data set supports a "last modified" timestamp which should be used to determine whether the nodes data should be reloaded or cached data can be used
-
getLastModified
protected long getLastModified()
- Overrides:
getLastModifiedin classBaseFileResourceModelSource- Returns:
- last modified unix timestamp, or -1 if not available
-
getResourceFormat
protected java.lang.String getResourceFormat()
- Specified by:
getResourceFormatin classBaseFileResourceModelSource- Returns:
- the name of the supported ResourceFormatParser provider, or null if the file extension is used
-
getDocumentFileExtension
protected java.lang.String getDocumentFileExtension()
- Specified by:
getDocumentFileExtensionin classBaseFileResourceModelSource- Returns:
- the file extension of the document, or the
BaseFileResourceModelSource.getResourceFormat()must be used.
-
getSourceDescription
public java.lang.String getSourceDescription()
- Specified by:
getSourceDescriptionin interfaceWriteableModelSource- Returns:
- optional description of the source
-
isDataWritable
public boolean isDataWritable()
- Overrides:
isDataWritablein classBaseFileResourceModelSource- Returns:
- true if the model source is writable, false if the data should not be modified with
BaseFileResourceModelSource.writeData(InputStream)
-
shouldGenerateServerNode
protected boolean shouldGenerateServerNode()
- Overrides:
shouldGenerateServerNodein classBaseFileResourceModelSource- Returns:
- true if the node set should always include the local server node data
-
parseFile
public static INodeSet parseFile(java.io.File file, Framework framework, java.lang.String project) throws ResourceModelSourceException, ConfigurationException
Utility method to directly parse the nodes from a file- Parameters:
file- fileframework- fwkproject- project name- Returns:
- nodes
- Throws:
ResourceModelSourceException- if an error occursConfigurationException- if a configuration error occurs
-
parseFile
public static INodeSet parseFile(java.io.File file, java.lang.String format, Framework framework, java.lang.String project) throws ResourceModelSourceException, ConfigurationException
Utility method to directly parse the nodes from a file- Parameters:
file- fileformat- specified formatframework- fwkproject- project name- Returns:
- nodes
- Throws:
ResourceModelSourceException- if an error occursConfigurationException- if a configuration error occurs
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-