Skip to content

Commit

Permalink
Framework property method tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Apr 1, 2011
1 parent ed59231 commit 1a827b2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
3 changes: 1 addition & 2 deletions core/src/java/com/dtolabs/rundeck/core/cli/ExecTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.dtolabs.rundeck.core.dispatcher.QueuedItemResult;
import com.dtolabs.rundeck.core.execution.*;
import com.dtolabs.rundeck.core.execution.commands.ExecCommand;
import com.dtolabs.rundeck.core.execution.commands.InterpreterResult;
import com.dtolabs.rundeck.core.execution.commands.ScriptFileCommand;
import com.dtolabs.rundeck.core.execution.script.ScriptfileUtils;
import com.dtolabs.rundeck.core.utils.*;
Expand Down Expand Up @@ -495,7 +494,7 @@ public ExecutionListener getExecutionListener() {
public ExecutionListener getExecutionListener(BuildListener blistener) {

final String logformat;
if (getFramework().existsProperty(ExecTool.FRAMEWORK_LOG_RUNDECK_EXEC_CONSOLE_FORMAT)) {
if (getFramework().hasProperty(ExecTool.FRAMEWORK_LOG_RUNDECK_EXEC_CONSOLE_FORMAT)) {
logformat = getFramework().getProperty(ExecTool.FRAMEWORK_LOG_RUNDECK_EXEC_CONSOLE_FORMAT);
} else {
logformat = null;
Expand Down
28 changes: 26 additions & 2 deletions core/src/java/com/dtolabs/rundeck/core/common/Framework.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,34 @@ public String getProperty(final String name) {
}


public boolean existsProperty(final String key) {
/**
* Return true if the property exists
*/
public boolean hasProperty(final String key) {
return lookup.hasProperty(key);
}

/**
* Return true if the property is set for the project or the framework
*/
public boolean hasProjectProperty(final String key, final String project) {
final FrameworkProject frameworkProject = getFrameworkProjectMgr().getFrameworkProject(project);
return frameworkProject.hasProperty(key) || hasProperty(key);
}
/**
* Return the property value for the key from the project or framework properties if it exists, otherwise
* return null.
*/
public String getProjectProperty(final String key, final String project) {
final FrameworkProject frameworkProject = getFrameworkProjectMgr().getFrameworkProject(project);
if(frameworkProject.hasProperty(key)) {
return frameworkProject.getProperty(key);
}else if(hasProperty(key)) {
return getProperty(key);
}
return null;
}


public IPropertyLookup getPropertyLookup() {
return lookup;
Expand Down Expand Up @@ -709,7 +733,7 @@ public boolean isLocalNode(INodeDesc node) {
*/
public boolean isServerNode() {
String serverNode = null;
if (existsProperty("framework.server.name")) {
if (hasProperty("framework.server.name")) {
serverNode = getProperty("framework.server.name");
}
if (null!=serverNode && serverNode.equals(getPropertyLookup().getProperty("framework.node.name"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public String getNodesResourceFilePath() {
}
final Framework framework = projectResourceMgr.getFramework();
final String s;
if(framework.existsProperty(Framework.NODES_RESOURCES_FILE_PROP)){
if(framework.hasProperty(Framework.NODES_RESOURCES_FILE_PROP)){
return new File(getEtcDir(), framework.getProperty(Framework.NODES_RESOURCES_FILE_PROP)).getAbsolutePath();
}else{
return new File(getEtcDir(), NODES_XML).getAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testConstruction() {

final Framework framework = Framework.getInstance(getBaseDir(), getFrameworkProjectsBase());
assertNotNull("Framework.getInstance returned null", framework);
assertTrue("framework.node.hostname property was not set", framework.existsProperty("framework.node.hostname"));
assertTrue("framework.node.hostname property was not set", framework.hasProperty("framework.node.hostname"));
assertEquals("basedir did not match: " + framework.getBaseDir().getAbsolutePath(), new File(
getBaseDir()).getAbsolutePath(),
framework.getBaseDir().getAbsolutePath());
Expand Down

0 comments on commit 1a827b2

Please sign in to comment.