Skip to content

Commit

Permalink
Update rundeckapp to remove use of node type property
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Mar 21, 2011
1 parent 4d8dbfb commit 5d291d8
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class NodesXMLParser implements NodeFileParser, ResourceXMLReceiver {
* Parse the project.xml formatted file and fill in the nodes found
*/
public void parse() throws NodeFileParserException {
final ResourceXMLParser resourceXMLParser = new ResourceXMLParser(false, file);
final ResourceXMLParser resourceXMLParser = new ResourceXMLParser(file);
//parse both node and settings
resourceXMLParser.setReceiver(this);
// long start = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public class ResourceXMLConstants {
/**
* Public identifier for Project document 1.0 dtd
*/
public static final String DTD_PROJECT_DOCUMENT_2_0_EN =
"-//DTO Labs Inc.//DTD Resources Document 2.0//EN";
public static final String DTD_PROJECT_DOCUMENT_1_0_EN =
"-//DTO Labs Inc.//DTD Resources Document 1.0//EN";
/**
* resources path to project.dtd file
*/
public static final String PROJECT_DTD_RESOURCE_PATH = "com/dtolabs/shared/resources/project20.dtd";
public static final String PROJECT_DTD_RESOURCE_PATH = "com/dtolabs/shared/resources/project.dtd";
public static final String COMMON_DESCRIPTION = "description";
public static final String COMMON_NAME = "name";
public static final String COMMON_TAGS = "tags";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
public class ResourceXMLParser {
static Logger log4j = Logger.getLogger(ResourceXMLParser.class.getName());

private boolean validate;
private File file;
private ResourceXMLReceiver receiver;
public static final String DEFAULT_ENTITY_XPATH = NODE_ENTITY_TAG ;
Expand All @@ -66,11 +65,9 @@ public class ResourceXMLParser {
/**
* Constructor for the ResourceXMLParser
*
* @param validate if true, perform DTD validation. If false, do not.
* @param file source file
*/
public ResourceXMLParser(final boolean validate, final File file) {
this.validate = validate;
public ResourceXMLParser(final File file) {
this.file = file;
}

Expand Down Expand Up @@ -114,7 +111,7 @@ public void parse() throws ResourceXMLParserException, FileNotFoundException {
public static EntityResolver createEntityResolver() {
return new EntityResolver() {
public InputSource resolveEntity(final String publicId, final String systemId) {
if (publicId.equals(DTD_PROJECT_DOCUMENT_2_0_EN)) {
if (publicId.equals(DTD_PROJECT_DOCUMENT_1_0_EN)) {
final InputStream in = ResourceXMLParser.class.getClassLoader().getResourceAsStream(
PROJECT_DTD_RESOURCE_PATH);
if (null != in) {
Expand Down
2 changes: 2 additions & 0 deletions core/src/test/com/dtolabs/rundeck/core/common/test-nodes1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
~ limitations under the License.
-->

<!DOCTYPE project PUBLIC
"-//DTO Labs Inc.//DTD Resources Document 1.0//EN" "project.dtd">
<project>
<node name="test1" type="SubNode" description="this is the test1 node" tags="boring,priority1"
hostname="host1.local"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.HashSet;

public class TestResourceXMLParser extends TestCase {
File dnefile1;
Expand Down Expand Up @@ -67,19 +65,19 @@ public static void main(String args[]) {
public void testParse() throws Exception {
{//test file that does not exist
try {
ResourceXMLParser resourceXMLParser= new ResourceXMLParser(true,dnefile1);
ResourceXMLParser resourceXMLParser= new ResourceXMLParser(dnefile1);
resourceXMLParser.parse();
fail("Should have thrown an Exception");
} catch (FileNotFoundException e) {
assertNotNull(e);
}
}
{ //test basic file without receiver
ResourceXMLParser resourceXMLParser= new ResourceXMLParser(false,testfile1);
ResourceXMLParser resourceXMLParser= new ResourceXMLParser(testfile1);
resourceXMLParser.parse();
}
{ //test basic file with receiver
ResourceXMLParser resourceXMLParser= new ResourceXMLParser(false,testfile1);
ResourceXMLParser resourceXMLParser= new ResourceXMLParser(testfile1);
final ArrayList<ResourceXMLParser.Entity> items = new ArrayList<ResourceXMLParser.Entity>();
final boolean[] resourceParsedCalled = new boolean[]{false};
final boolean[] resourcesParsed = new boolean[]{false};
Expand All @@ -100,7 +98,7 @@ public void resourcesParsed(ResourceXMLParser.EntitySet entities) {
assertEquals("Wrong size", 1, items.size());
}
{ //test basic file with receiver, return false from resourceParsed
ResourceXMLParser resourceXMLParser = new ResourceXMLParser(true, testfile1);
ResourceXMLParser resourceXMLParser = new ResourceXMLParser(testfile1);
final ArrayList<ResourceXMLParser.Entity> items = new ArrayList<ResourceXMLParser.Entity>();
final boolean[] resourceParsedCalled = new boolean[]{false};
final boolean[] resourcesParsed = new boolean[]{false};
Expand All @@ -127,7 +125,7 @@ public void resourcesParsed(ResourceXMLParser.EntitySet entities) {
***************/

{ //test attributes of node
ResourceXMLParser resourceXMLParser = new ResourceXMLParser(false, testfile2);
ResourceXMLParser resourceXMLParser = new ResourceXMLParser(testfile2);
final ArrayList<ResourceXMLParser.Entity> items = new ArrayList<ResourceXMLParser.Entity>();
final boolean[] resourceParsedCalled = new boolean[]{false};
final boolean[] resourcesParsed = new boolean[]{false};
Expand Down
8 changes: 4 additions & 4 deletions rundeckapp/grails-app/views/framework/_nodeDetailsSimple.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<table width="300px">

<g:each in="${['hostname','osFamily','osArch','osVersion','osName','type','username']}" var="key">
<g:each in="${['hostname','osFamily','osArch','osVersion','osName','username']}" var="key">
<g:if test="${!exclude || !exclude.contains(key)}">
<tr><td class="key"><g:message code="${'node.metadata.'+key}"/></td>
<td class="value">${node[key]?.encodeAsHTML()}</td></tr>
Expand All @@ -20,11 +20,11 @@
<td style="vertical-align:top">
<g:if test="${node.settings}">
<table width="300px">
<tr><th colspan="2" style="font-size:9pt;">Settings</th></tr>
<g:each var="setting" in="${node.settings.keySet()}">
<tr><th colspan="2" style="font-size:9pt;">Attributes</th></tr>
<g:each var="setting" in="${node.attributes.keySet()}">
<tr>
<td class="key setting">${setting.encodeAsHTML()}:</td>
<td class="setting Value">${node.settings[setting]?.encodeAsHTML()}</td>
<td class="setting Value">${node.attributes[setting]?.encodeAsHTML()}</td>
</tr>
</g:each>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<!--&raquo; history-->
%{--</g:link>--}%
<tr id="${ukey}node_detail_${i}" class="detail_content nodedetail" style="display:none">
<td colspan="4"><g:render template="nodeDetailsSimple" model="[node:node,key:ukey+'_'+node.nodename+'_key',projects:nodedata.projects,exclude:['type','username','hostname','tags']]"/></td>
<td colspan="4"><g:render template="nodeDetailsSimple" model="[node:node,key:ukey+'_'+node.nodename+'_key',projects:nodedata.projects,exclude:['username','hostname','tags']]"/></td>
</tr>
</g:if>
<g:else>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!DOCTYPE project PUBLIC
"-//DTO Labs Inc.//DTD Resources Document 1.0//EN" "project.dtd">
<project>
<node name="testnode1" type="Node" description="this is the testnode1 node" tags="boring,priority1"
<node name="testnode1" description="this is the testnode1 node" tags="boring,priority1"
hostname="localhost"
osArch="i386"
osFamily="unix"
Expand All @@ -27,7 +27,7 @@
>

</node>
<node name="testnode2" type="Node" description=" registered Node asdf" tags="boring"
<node name="testnode2" description=" registered Node asdf" tags="boring"
hostname="testnode2"
osArch="x86"
osFamily="windows"
Expand Down

0 comments on commit 5d291d8

Please sign in to comment.