Package com.dtolabs.rundeck.core.common
Class FrameworkProject
- java.lang.Object
-
- com.dtolabs.rundeck.core.common.FrameworkResource
-
- com.dtolabs.rundeck.core.common.FrameworkProject
-
- All Implemented Interfaces:
IFrameworkResource
,IRundeckProject
,IRundeckProjectConfig
public class FrameworkProject extends FrameworkResource implements IRundeckProject
Represents a project in the framework. A project is a repository of installed managed entities organized by their type.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ETC_DIR_NAME
static java.lang.String
NODES_XML
static java.net.URI
PROJECT_ATTR_URI
static java.lang.String
PROJECT_RESOURCES_MERGE_NODE_ATTRIBUTES
static java.lang.String
PROP_FILENAME
static java.lang.String
RESOURCES_SOURCE_PROP_PREFIX
-
Fields inherited from class com.dtolabs.rundeck.core.common.FrameworkResource
VALID_RESOURCE_DESCRIPTION_CHARSET_REGEX, VALID_RESOURCE_DESCRIPTION_REGEX, VALID_RESOURCE_NAME_CHARSET_REGEX, VALID_RESOURCE_NAME_REGEX
-
-
Constructor Summary
Constructors Constructor Description FrameworkProject(java.lang.String name, java.io.File basedir, IFilesystemFramework filesystemFramework, IFrameworkProjectMgr resourceMgr, IRundeckProjectConfig projectConfig, IRundeckProjectConfigModifier projectConfigModifier)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Set<com.dtolabs.rundeck.core.authorization.Attribute>
authorizationEnvironment(java.lang.String project)
Creates an authorization environment for a project.boolean
childCouldBeLoaded(java.lang.String name)
static FrameworkProject
create(java.lang.String name, java.io.File projectsDir, IFilesystemFramework filesystemFramework, IFrameworkProjectMgr resourceMgr, java.util.function.Supplier<ResourceFormatGeneratorService> getResourceFormatGeneratorService, java.util.function.Supplier<ResourceModelSourceService> getResourceModelSourceService)
static void
createFileStructure(java.io.File projectDir)
Creates the file structure for a projectboolean
deleteFileResource(java.lang.String path)
static boolean
exists(java.lang.String project, IFrameworkProjectMgr projectResourceMgr)
boolean
existsDirResource(java.lang.String path)
boolean
existsFileResource(java.lang.String path)
protected void
generateProjectPropertiesFile(boolean overwrite, java.util.Properties properties, boolean addDefault)
java.util.Date
getConfigCreatedTime()
java.util.Date
getConfigLastModifiedTime()
java.io.File
getEtcDir()
Gets the config dir for this projectIFrameworkProjectMgr
getFrameworkProjectMgr()
IProjectInfo
getInfo()
INodeSet
getNodeSet()
Returns the set of nodes for the projectstatic java.util.Optional<java.lang.String>
getProjectEnvironment(java.util.Set<com.dtolabs.rundeck.core.authorization.Attribute> env)
static java.io.File
getProjectEtcDir(java.io.File baseDir)
Get the etc dir from the basedirIProjectNodes
getProjectNodes()
java.util.Map<java.lang.String,java.lang.String>
getProjectProperties()
static java.io.File
getProjectPropertyFile(java.io.File baseDir)
Get the project property file from the basedirjava.util.Map<java.lang.String,java.lang.String>
getProperties()
java.lang.String
getProperty(java.lang.String name)
java.util.ArrayList<java.lang.Throwable>
getResourceModelSourceExceptions()
boolean
hasProperty(java.lang.String key)
static boolean
isInstalled(FrameworkProject d)
Checks if project is installed by checking if it's basedir directory exists.static boolean
isProjectEnvironment(java.util.Set<com.dtolabs.rundeck.core.authorization.Attribute> env)
java.util.Collection<java.lang.String>
listChildNames()
java.util.List<java.lang.String>
listDirPaths(java.lang.String path)
java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
listResourceModelConfigurations()
list the configurations of resource model providers.long
loadFileResource(java.lang.String path, java.io.OutputStream output)
Read a file at a path for the projectvoid
mergeProjectProperties(java.util.Properties properties, java.util.Set<java.lang.String> removePrefixes)
Update the project properties file by setting updating the given properties, and removing any properties that have a prefix in the removePrefixes setvoid
setProjectNodesFactory(IProjectNodesFactory projectNodesFactory)
void
setProjectProperties(java.util.Properties properties)
Set the project properties file contents exactlylong
storeFileResource(java.lang.String path, java.io.InputStream input)
Store a file at a path for the project-
Methods inherited from class com.dtolabs.rundeck.core.common.FrameworkResource
existsSubdir, getBaseDir, getLogger, getName, getSubdir, listSubdirNames, listSubdirs, removeSubDir, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.dtolabs.rundeck.core.common.IRundeckProject
getName, isEnabled
-
-
-
-
Field Detail
-
PROP_FILENAME
public static final java.lang.String PROP_FILENAME
- See Also:
- Constant Field Values
-
ETC_DIR_NAME
public static final java.lang.String ETC_DIR_NAME
- See Also:
- Constant Field Values
-
NODES_XML
public static final java.lang.String NODES_XML
- See Also:
- Constant Field Values
-
RESOURCES_SOURCE_PROP_PREFIX
public static final java.lang.String RESOURCES_SOURCE_PROP_PREFIX
- See Also:
- Constant Field Values
-
PROJECT_RESOURCES_MERGE_NODE_ATTRIBUTES
public static final java.lang.String PROJECT_RESOURCES_MERGE_NODE_ATTRIBUTES
- See Also:
- Constant Field Values
-
PROJECT_ATTR_URI
public static final java.net.URI PROJECT_ATTR_URI
-
-
Constructor Detail
-
FrameworkProject
public FrameworkProject(java.lang.String name, java.io.File basedir, IFilesystemFramework filesystemFramework, IFrameworkProjectMgr resourceMgr, IRundeckProjectConfig projectConfig, IRundeckProjectConfigModifier projectConfigModifier)
Constructor- Parameters:
name
- Name of the projectbasedir
- the base directory for the DepotresourceMgr
- managerprojectConfig
- config
-
-
Method Detail
-
authorizationEnvironment
public static java.util.Set<com.dtolabs.rundeck.core.authorization.Attribute> authorizationEnvironment(java.lang.String project)
Creates an authorization environment for a project.- Parameters:
project
- project name- Returns:
- environment to evaluate authorization for a project
-
isProjectEnvironment
public static boolean isProjectEnvironment(java.util.Set<com.dtolabs.rundeck.core.authorization.Attribute> env)
-
getProjectEnvironment
public static java.util.Optional<java.lang.String> getProjectEnvironment(java.util.Set<com.dtolabs.rundeck.core.authorization.Attribute> env)
-
getInfo
public IProjectInfo getInfo()
- Specified by:
getInfo
in interfaceIRundeckProject
-
getProjectEtcDir
public static java.io.File getProjectEtcDir(java.io.File baseDir)
Get the etc dir from the basedir
-
getProjectPropertyFile
public static java.io.File getProjectPropertyFile(java.io.File baseDir)
Get the project property file from the basedir
-
getProperty
public java.lang.String getProperty(java.lang.String name)
- Specified by:
getProperty
in interfaceIRundeckProject
- Specified by:
getProperty
in interfaceIRundeckProjectConfig
- Parameters:
name
- property name- Returns:
- the property value by name
-
hasProperty
public boolean hasProperty(java.lang.String key)
- Specified by:
hasProperty
in interfaceIRundeckProject
- Specified by:
hasProperty
in interfaceIRundeckProjectConfig
- Parameters:
key
- property name- Returns:
- true if present, false otherwise
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
- Specified by:
getProperties
in interfaceIRundeckProject
- Specified by:
getProperties
in interfaceIRundeckProjectConfig
- Returns:
- the merged properties available for the project
-
getProjectProperties
public java.util.Map<java.lang.String,java.lang.String> getProjectProperties()
- Specified by:
getProjectProperties
in interfaceIRundeckProject
- Specified by:
getProjectProperties
in interfaceIRundeckProjectConfig
- Returns:
- the direct properties set for the project
-
getConfigLastModifiedTime
public java.util.Date getConfigLastModifiedTime()
- Specified by:
getConfigLastModifiedTime
in interfaceIRundeckProject
- Specified by:
getConfigLastModifiedTime
in interfaceIRundeckProjectConfig
- Returns:
- last modified time for configuration in epoch time
-
getConfigCreatedTime
public java.util.Date getConfigCreatedTime()
- Specified by:
getConfigCreatedTime
in interfaceIRundeckProject
- Specified by:
getConfigCreatedTime
in interfaceIRundeckProjectConfig
- Returns:
- creation time for configuration in epoch time
-
listResourceModelConfigurations
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> listResourceModelConfigurations()
list the configurations of resource model providers.- Specified by:
listResourceModelConfigurations
in interfaceIRundeckProject
- Returns:
- a list of maps containing:
- type - provider type name
- props - configuration properties
-
create
public static FrameworkProject create(java.lang.String name, java.io.File projectsDir, IFilesystemFramework filesystemFramework, IFrameworkProjectMgr resourceMgr, java.util.function.Supplier<ResourceFormatGeneratorService> getResourceFormatGeneratorService, java.util.function.Supplier<ResourceModelSourceService> getResourceModelSourceService)
- Parameters:
getResourceFormatGeneratorService
-getResourceModelSourceService
-name
- project nameprojectsDir
- projects dirresourceMgr
- resourcemanager- Returns:
- Create a new Project object at the specified projects.directory
-
childCouldBeLoaded
public boolean childCouldBeLoaded(java.lang.String name)
-
listChildNames
public java.util.Collection<java.lang.String> listChildNames()
-
getFrameworkProjectMgr
public IFrameworkProjectMgr getFrameworkProjectMgr()
-
exists
public static boolean exists(java.lang.String project, IFrameworkProjectMgr projectResourceMgr)
-
getEtcDir
public java.io.File getEtcDir()
Gets the config dir for this project- Returns:
- etc directory
-
getNodeSet
public INodeSet getNodeSet() throws NodeFileParserException
Returns the set of nodes for the project- Specified by:
getNodeSet
in interfaceIRundeckProject
- Returns:
- an instance of
INodeSet
- Throws:
NodeFileParserException
- on parse error
-
createFileStructure
public static void createFileStructure(java.io.File projectDir) throws java.io.IOException
Creates the file structure for a project- Parameters:
projectDir
- The project base directory- Throws:
java.io.IOException
- on io error
-
existsFileResource
public boolean existsFileResource(java.lang.String path)
- Specified by:
existsFileResource
in interfaceIRundeckProject
- Parameters:
path
- path relative to the project- Returns:
- true if it exists
-
existsDirResource
public boolean existsDirResource(java.lang.String path)
- Specified by:
existsDirResource
in interfaceIRundeckProject
- Parameters:
path
- path relative to the project- Returns:
- true if it is a directory
-
listDirPaths
public java.util.List<java.lang.String> listDirPaths(java.lang.String path)
- Specified by:
listDirPaths
in interfaceIRundeckProject
- Parameters:
path
- path relative to the project- Returns:
- list of paths within the directory
-
deleteFileResource
public boolean deleteFileResource(java.lang.String path)
- Specified by:
deleteFileResource
in interfaceIRundeckProject
- Parameters:
path
- path relative to the project- Returns:
- true if it is deleted, false if it was not deleted
-
storeFileResource
public long storeFileResource(java.lang.String path, java.io.InputStream input) throws java.io.IOException
Description copied from interface:IRundeckProject
Store a file at a path for the project- Specified by:
storeFileResource
in interfaceIRundeckProject
- Parameters:
path
- path relative to the projectinput
- input- Throws:
java.io.IOException
- if an IO error occurs
-
loadFileResource
public long loadFileResource(java.lang.String path, java.io.OutputStream output) throws java.io.IOException
Description copied from interface:IRundeckProject
Read a file at a path for the project- Specified by:
loadFileResource
in interfaceIRundeckProject
- Parameters:
path
- path relative to the projectoutput
- output- Returns:
- length of data loaded
- Throws:
java.io.IOException
- if an IO error occurs
-
generateProjectPropertiesFile
protected void generateProjectPropertiesFile(boolean overwrite, java.util.Properties properties, boolean addDefault)
-
mergeProjectProperties
public void mergeProjectProperties(java.util.Properties properties, java.util.Set<java.lang.String> removePrefixes)
Update the project properties file by setting updating the given properties, and removing any properties that have a prefix in the removePrefixes set- Specified by:
mergeProjectProperties
in interfaceIRundeckProject
- Parameters:
properties
- new properties to put in the fileremovePrefixes
- prefixes of properties to remove from the file
-
setProjectProperties
public void setProjectProperties(java.util.Properties properties)
Set the project properties file contents exactly- Specified by:
setProjectProperties
in interfaceIRundeckProject
- Parameters:
properties
- new properties to use in the file
-
isInstalled
public static boolean isInstalled(FrameworkProject d)
Checks if project is installed by checking if it's basedir directory exists.- Parameters:
d
- Depot object to check.- Returns:
- true if project exists
-
getResourceModelSourceExceptions
public java.util.ArrayList<java.lang.Throwable> getResourceModelSourceExceptions()
- Returns:
- the set of exceptions produced by the last attempt to invoke all node providers
-
getProjectNodes
public IProjectNodes getProjectNodes()
- Specified by:
getProjectNodes
in interfaceIRundeckProject
- Returns:
- the project nodes interface
-
setProjectNodesFactory
public void setProjectNodesFactory(IProjectNodesFactory projectNodesFactory)
-
-