com.dtolabs.rundeck.core.common
Class FrameworkProject

java.lang.Object
  extended by com.dtolabs.rundeck.core.common.FrameworkResource
      extended by com.dtolabs.rundeck.core.common.FrameworkResourceParent
          extended by com.dtolabs.rundeck.core.common.FrameworkProject
All Implemented Interfaces:
IFrameworkResource, IFrameworkResourceParent

public class FrameworkProject
extends FrameworkResourceParent

Represents a project in the framework. A project is a repository of installed managed entities organized by their type.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.dtolabs.rundeck.core.common.FrameworkResourceParent
FrameworkResourceParent.NoSuchResourceException
 
Field Summary
static java.lang.String ETC_DIR_NAME
           
static java.lang.String FRAMEWORK_RESOURCES_ALLOWED_URL_PREFIX
           
static java.lang.String NODES_XML
           
static java.lang.String PROJECT_RESOURCES_ALLOWED_URL_PREFIX
           
static java.lang.String PROJECT_RESOURCES_FILE_PROPERTY
           
static java.lang.String PROJECT_RESOURCES_FILEFORMAT_PROPERTY
           
static java.lang.String PROJECT_RESOURCES_URL_PROPERTY
           
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_NAME_REGEX
 
Constructor Summary
FrameworkProject(java.lang.String name, java.io.File basedir, IFrameworkProjectMgr resourceMgr)
          Constructor
FrameworkProject(java.lang.String name, java.io.File basedir, IFrameworkProjectMgr resourceMgr, java.util.Properties properties)
          Constructor
 
Method Summary
 boolean childCouldBeLoaded(java.lang.String name)
          Default implementation checks whether a subdir under the basedir exists with the specified name.
static FrameworkProject create(java.lang.String name, java.io.File projectsDir, IFrameworkProjectMgr resourceMgr)
          Create a new Depot object at the specified projects.directory
static FrameworkProject create(java.lang.String name, java.io.File projectsDir, IFrameworkProjectMgr resourceMgr, java.util.Properties properties)
          Create a new Depot object at the specified projects.directory
 IFrameworkResource createChild(java.lang.String resourceType)
          Create a new type and store it
static void createFileStructure(java.io.File projectDir)
          Creates the file structure for a project
static PropertyRetriever createProjectPropertyRetriever(java.io.File baseDir, java.io.File projectsBaseDir, java.lang.String projectName)
          Create a property retriever for a project given the framework basedir
static boolean exists(java.lang.String project, IFrameworkProjectMgr projectResourceMgr)
           
 boolean existsFrameworkType(java.lang.String name)
           
protected  void generateProjectPropertiesFile(boolean overwrite)
          Create project.properties file based on $RDECK_BASE/etc/project.properties
protected  void generateProjectPropertiesFile(boolean overwrite, java.util.Properties properties)
          Create project.properties file based on $RDECK_BASE/etc/project.properties
protected  void generateProjectPropertiesFile(boolean overwrite, java.util.Properties properties, boolean merge, java.util.Set<java.lang.String> removePrefixes)
          Create project.properties file based on $RDECK_BASE/etc/project.properties
 java.io.File getEtcDir()
          Gets the config dir for this project
 IFrameworkProjectMgr getFrameworkProjectMgr()
           
 INodeSet getNodeSet()
          Returns the set of nodes for the project
 java.lang.String getNodesResourceFilePath()
          Return specific nodes resources file path for the project, based on the framework.nodes.file.name property
 java.util.Map getProperties()
           
 java.lang.String getProperty(java.lang.String name)
          Return the property value by name
 java.io.File getPropertyFile()
           
 PropertyRetriever getPropertyRetriever()
          Return a PropertyRetriever interface for project-scoped properties
 java.util.ArrayList<java.lang.Exception> getResourceModelSourceExceptions()
          Return the set of exceptions produced by the last attempt to invoke all node providers
 boolean hasProperty(java.lang.String key)
           
static boolean isInstalled(FrameworkProject d)
          Checks if project is installed by checking if it's basedir directory exists.
 java.util.Collection listChildNames()
          Default implementation lists the subdirectory names and adds any existing child names
 java.util.List<java.util.Map> listResourceModelConfigurations()
          list the configurations of resource model providers.
 IFrameworkResource loadChild(java.lang.String name)
          Load a specified child by name, returning null if it does not exist
 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
 boolean updateNodesResourceFile()
          Conditionally update the nodes resources file if a URL source is defined for it and return true if the update process was invoked and succeeded
 void updateNodesResourceFile(java.io.File source)
          Update the resources file from a source file
 void updateNodesResourceFile(INodeSet nodeset)
          Update the resources file given an input Nodes set
 void updateNodesResourceFileFromUrl(java.lang.String providerURL, java.lang.String username, java.lang.String password)
          Update the nodes resources file from a specific URL, with BASIC authentication as provided or as defined in the URL's userInfo section.
 
Methods inherited from class com.dtolabs.rundeck.core.common.FrameworkResourceParent
existsChild, existsChildResourceDirectory, getChild, getChildren, initialize, listChildren, remove
 
Methods inherited from class com.dtolabs.rundeck.core.common.FrameworkResource
getBaseDir, getLogger, getName, getParent, isValid, storeProperties, 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.IFrameworkResource
getBaseDir, getName, getParent, isValid
 

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

PROJECT_RESOURCES_URL_PROPERTY

public static final java.lang.String PROJECT_RESOURCES_URL_PROPERTY
See Also:
Constant Field Values

PROJECT_RESOURCES_FILE_PROPERTY

public static final java.lang.String PROJECT_RESOURCES_FILE_PROPERTY
See Also:
Constant Field Values

PROJECT_RESOURCES_FILEFORMAT_PROPERTY

public static final java.lang.String PROJECT_RESOURCES_FILEFORMAT_PROPERTY
See Also:
Constant Field Values

PROJECT_RESOURCES_ALLOWED_URL_PREFIX

public static final java.lang.String PROJECT_RESOURCES_ALLOWED_URL_PREFIX
See Also:
Constant Field Values

FRAMEWORK_RESOURCES_ALLOWED_URL_PREFIX

public static final java.lang.String FRAMEWORK_RESOURCES_ALLOWED_URL_PREFIX
See Also:
Constant Field Values

RESOURCES_SOURCE_PROP_PREFIX

public static final java.lang.String RESOURCES_SOURCE_PROP_PREFIX
See Also:
Constant Field Values
Constructor Detail

FrameworkProject

public FrameworkProject(java.lang.String name,
                        java.io.File basedir,
                        IFrameworkProjectMgr resourceMgr)
Constructor

Parameters:
name - Name of the project
basedir - the base directory for the Depot

FrameworkProject

public FrameworkProject(java.lang.String name,
                        java.io.File basedir,
                        IFrameworkProjectMgr resourceMgr,
                        java.util.Properties properties)
Constructor

Parameters:
name - Name of the project
basedir - the base directory for the Depot
Method Detail

createProjectPropertyRetriever

public static PropertyRetriever createProjectPropertyRetriever(java.io.File baseDir,
                                                               java.io.File projectsBaseDir,
                                                               java.lang.String projectName)
Create a property retriever for a project given the framework basedir

Parameters:
baseDir - the framework basedir
projectsBaseDir -
projectName -
Returns:

listResourceModelConfigurations

public java.util.List<java.util.Map> listResourceModelConfigurations()
list the configurations of resource model providers. 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,
                                          IFrameworkProjectMgr resourceMgr)
    Create a new Depot object at the specified projects.directory

    Parameters:
    name -
    projectsDir -
    resourceMgr -
    Returns:

    create

    public static FrameworkProject create(java.lang.String name,
                                          java.io.File projectsDir,
                                          IFrameworkProjectMgr resourceMgr,
                                          java.util.Properties properties)
    Create a new Depot object at the specified projects.directory

    Parameters:
    name -
    projectsDir -
    resourceMgr -
    Returns:

    loadChild

    public IFrameworkResource loadChild(java.lang.String name)
    Description copied from interface: IFrameworkResourceParent
    Load a specified child by name, returning null if it does not exist

    Returns:

    childCouldBeLoaded

    public boolean childCouldBeLoaded(java.lang.String name)
    Description copied from class: FrameworkResourceParent
    Default implementation checks whether a subdir under the basedir exists with the specified name. (Calls FrameworkResourceParent.existsChildResourceDirectory(String)) Should be overridden by subtypes if this is not the desired behavior.

    Specified by:
    childCouldBeLoaded in interface IFrameworkResourceParent
    Overrides:
    childCouldBeLoaded in class FrameworkResourceParent
    Returns:

    listChildNames

    public java.util.Collection listChildNames()
    Description copied from class: FrameworkResourceParent
    Default implementation lists the subdirectory names and adds any existing child names

    Specified by:
    listChildNames in interface IFrameworkResourceParent
    Overrides:
    listChildNames in class FrameworkResourceParent
    Returns:
    A Collection of Strings

    createChild

    public IFrameworkResource createChild(java.lang.String resourceType)
    Create a new type and store it

    Specified by:
    createChild in interface IFrameworkResourceParent
    Overrides:
    createChild in class FrameworkResourceParent
    Parameters:
    resourceType -
    Returns:

    getPropertyFile

    public java.io.File getPropertyFile()

    getFrameworkProjectMgr

    public IFrameworkProjectMgr getFrameworkProjectMgr()

    exists

    public static boolean exists(java.lang.String project,
                                 IFrameworkProjectMgr projectResourceMgr)

    existsFrameworkType

    public boolean existsFrameworkType(java.lang.String name)

    getEtcDir

    public java.io.File getEtcDir()
    Gets the config dir for this project

    Returns:
    etc directory

    getNodesResourceFilePath

    public java.lang.String getNodesResourceFilePath()
    Return specific nodes resources file path for the project, based on the framework.nodes.file.name property

    Returns:

    getNodeSet

    public INodeSet getNodeSet()
                        throws NodeFileParserException
    Returns the set of nodes for the project

    Returns:
    an instance of INodeSet
    Throws:
    NodeFileParserException

    updateNodesResourceFile

    public boolean updateNodesResourceFile()
                                    throws UpdateUtils.UpdateException
    Conditionally update the nodes resources file if a URL source is defined for it and return true if the update process was invoked and succeeded

    Returns:
    true if the update succeeded, false if it was not performed
    Throws:
    UpdateUtils.UpdateException - if an error occurs while trying to update the resources file

    updateNodesResourceFileFromUrl

    public void updateNodesResourceFileFromUrl(java.lang.String providerURL,
                                               java.lang.String username,
                                               java.lang.String password)
                                        throws UpdateUtils.UpdateException
    Update the nodes resources file from a specific URL, with BASIC authentication as provided or as defined in the URL's userInfo section.

    Parameters:
    providerURL - URL to retrieve resources file definition
    username - username or null
    password - or null
    Throws:
    UpdateUtils.UpdateException - if an error occurs during the update process

    updateNodesResourceFile

    public void updateNodesResourceFile(java.io.File source)
                                 throws UpdateUtils.UpdateException
    Update the resources file from a source file

    Parameters:
    source - the source file
    Throws:
    UpdateUtils.UpdateException - if an error occurs while trying to update the resources file

    updateNodesResourceFile

    public void updateNodesResourceFile(INodeSet nodeset)
                                 throws UpdateUtils.UpdateException
    Update the resources file given an input Nodes set

    Throws:
    UpdateUtils.UpdateException - if an error occurs while trying to update the resources file or generate nodes

    getProperty

    public java.lang.String getProperty(java.lang.String name)
    Return the property value by name

    Parameters:
    name -
    Returns:

    hasProperty

    public boolean hasProperty(java.lang.String key)

    getProperties

    public java.util.Map getProperties()

    getPropertyRetriever

    public PropertyRetriever getPropertyRetriever()
    Return a PropertyRetriever interface for project-scoped properties


    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

    generateProjectPropertiesFile

    protected void generateProjectPropertiesFile(boolean overwrite)
    Create project.properties file based on $RDECK_BASE/etc/project.properties

    Parameters:
    overwrite - Overwrite existing properties file

    generateProjectPropertiesFile

    protected void generateProjectPropertiesFile(boolean overwrite,
                                                 java.util.Properties properties)
    Create project.properties file based on $RDECK_BASE/etc/project.properties

    Parameters:
    overwrite - Overwrite existing properties file

    generateProjectPropertiesFile

    protected void generateProjectPropertiesFile(boolean overwrite,
                                                 java.util.Properties properties,
                                                 boolean merge,
                                                 java.util.Set<java.lang.String> removePrefixes)
    Create project.properties file based on $RDECK_BASE/etc/project.properties

    Parameters:
    overwrite - Overwrite existing properties file
    properties - properties to use
    merge - if true, merge existing properties that are not replaced
    removePrefixes - set of property prefixes to remove from original

    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

    Parameters:
    properties - new properties to put in the file
    removePrefixes - prefixes of properties to remove from 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.Exception> getResourceModelSourceExceptions()
    Return the set of exceptions produced by the last attempt to invoke all node providers