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.StringETC_DIR_NAMEstatic java.lang.StringNODES_XMLstatic java.net.URIPROJECT_ATTR_URIstatic java.lang.StringPROJECT_RESOURCES_MERGE_NODE_ATTRIBUTESstatic java.lang.StringPROP_FILENAMEstatic java.lang.StringRESOURCES_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.booleanchildCouldBeLoaded(java.lang.String name)static FrameworkProjectcreate(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 voidcreateFileStructure(java.io.File projectDir)Creates the file structure for a projectbooleandeleteFileResource(java.lang.String path)static booleanexists(java.lang.String project, IFrameworkProjectMgr projectResourceMgr)booleanexistsDirResource(java.lang.String path)booleanexistsFileResource(java.lang.String path)protected voidgenerateProjectPropertiesFile(boolean overwrite, java.util.Properties properties, boolean addDefault)java.util.DategetConfigCreatedTime()java.util.DategetConfigLastModifiedTime()java.io.FilegetEtcDir()Gets the config dir for this projectIFrameworkProjectMgrgetFrameworkProjectMgr()IProjectInfogetInfo()INodeSetgetNodeSet()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.FilegetProjectEtcDir(java.io.File baseDir)Get the etc dir from the basedirIProjectNodesgetProjectNodes()java.util.Map<java.lang.String,java.lang.String>getProjectProperties()static java.io.FilegetProjectPropertyFile(java.io.File baseDir)Get the project property file from the basedirjava.util.Map<java.lang.String,java.lang.String>getProperties()java.lang.StringgetProperty(java.lang.String name)java.util.ArrayList<java.lang.Throwable>getResourceModelSourceExceptions()booleanhasProperty(java.lang.String key)static booleanisInstalled(FrameworkProject d)Checks if project is installed by checking if it's basedir directory exists.static booleanisProjectEnvironment(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.longloadFileResource(java.lang.String path, java.io.OutputStream output)Read a file at a path for the projectvoidmergeProjectProperties(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 setvoidsetProjectNodesFactory(IProjectNodesFactory projectNodesFactory)voidsetProjectProperties(java.util.Properties properties)Set the project properties file contents exactlylongstoreFileResource(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:
getInfoin 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:
getPropertyin interfaceIRundeckProject- Specified by:
getPropertyin interfaceIRundeckProjectConfig- Parameters:
name- property name- Returns:
- the property value by name
-
hasProperty
public boolean hasProperty(java.lang.String key)
- Specified by:
hasPropertyin interfaceIRundeckProject- Specified by:
hasPropertyin 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:
getPropertiesin interfaceIRundeckProject- Specified by:
getPropertiesin interfaceIRundeckProjectConfig- Returns:
- the merged properties available for the project
-
getProjectProperties
public java.util.Map<java.lang.String,java.lang.String> getProjectProperties()
- Specified by:
getProjectPropertiesin interfaceIRundeckProject- Specified by:
getProjectPropertiesin interfaceIRundeckProjectConfig- Returns:
- the direct properties set for the project
-
getConfigLastModifiedTime
public java.util.Date getConfigLastModifiedTime()
- Specified by:
getConfigLastModifiedTimein interfaceIRundeckProject- Specified by:
getConfigLastModifiedTimein interfaceIRundeckProjectConfig- Returns:
- last modified time for configuration in epoch time
-
getConfigCreatedTime
public java.util.Date getConfigCreatedTime()
- Specified by:
getConfigCreatedTimein interfaceIRundeckProject- Specified by:
getConfigCreatedTimein 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:
listResourceModelConfigurationsin 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:
getNodeSetin interfaceIRundeckProject- Returns:
- an instance of
INodeSet - Throws:
NodeFileParserException- on parse error
-
createFileStructure
public static void createFileStructure(java.io.File projectDir) throws java.io.IOExceptionCreates 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:
existsFileResourcein interfaceIRundeckProject- Parameters:
path- path relative to the project- Returns:
- true if it exists
-
existsDirResource
public boolean existsDirResource(java.lang.String path)
- Specified by:
existsDirResourcein 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:
listDirPathsin 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:
deleteFileResourcein 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.IOExceptionDescription copied from interface:IRundeckProjectStore a file at a path for the project- Specified by:
storeFileResourcein 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.IOExceptionDescription copied from interface:IRundeckProjectRead a file at a path for the project- Specified by:
loadFileResourcein 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:
mergeProjectPropertiesin 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:
setProjectPropertiesin 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:
getProjectNodesin interfaceIRundeckProject- Returns:
- the project nodes interface
-
setProjectNodesFactory
public void setProjectNodesFactory(IProjectNodesFactory projectNodesFactory)
-
-