Skip to content

Commit

Permalink
Add editUrl, remoteUrl attributes of node element in project.dtd, upd…
Browse files Browse the repository at this point in the history
…ate parser and tests. Add link to editUrl in node view in rundeckapp
  • Loading branch information
gschueler committed Oct 15, 2010
1 parent 8c5451d commit 238cef3
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 1 deletion.
18 changes: 18 additions & 0 deletions core/src/java/com/dtolabs/rundeck/core/common/NodesXMLParser.java
Expand Up @@ -111,6 +111,24 @@ private void fillNode(final ResourceXMLParser.Entity entity, final NodeEntryImpl
node.getSettings().put(setting.getName(), setting.getProperty(SETTING_VALUE));
}
}

if(null!=entity.getProperty(NODE_EDIT_URL)){
//use attributes for other node data

if (null == node.getAttributes()) {
node.setAttributes(new HashMap<String, String>());
}
node.getAttributes().put(NODE_EDIT_URL, entity.getProperty(NODE_EDIT_URL));
}
if(null != entity.getProperty(NODE_REMOTE_URL)){
//use attributes for other node data

if (null == node.getAttributes()) {
node.setAttributes(new HashMap<String, String>());
}
node.getAttributes().put(NODE_REMOTE_URL, entity.getProperty(NODE_REMOTE_URL));
}

}

public void resourcesParsed(final ResourceXMLParser.EntitySet entities) {
Expand Down
Expand Up @@ -81,6 +81,8 @@ public class ResourceXMLConstants {
public static final String NODE_OS_NAME = "osName";
public static final String NODE_OS_VERSION = "osVersion";
public static final String NODE_USERNAME = "username";
public static final String NODE_EDIT_URL = "editUrl";
public static final String NODE_REMOTE_URL = "remoteUrl";
/**
* attributes of "node" nodes
*/
Expand All @@ -91,6 +93,8 @@ public class ResourceXMLConstants {
NODE_OS_NAME,
NODE_OS_VERSION,
NODE_USERNAME,
NODE_EDIT_URL,
NODE_REMOTE_URL
};
public static final String SETTING_TYPE = "settingType";
public static final String SETTING_VALUE = "settingValue";
Expand Down
2 changes: 2 additions & 0 deletions core/src/java/com/dtolabs/shared/resources/project.dtd
Expand Up @@ -142,6 +142,8 @@
hostname CDATA #IMPLIED
username CDATA #IMPLIED
tags CDATA #IMPLIED
editUrl CDATA #IMPLIED
remoteUrl CDATA #IMPLIED
>

<!ELEMENT resources (resource+)>
Expand Down
Expand Up @@ -23,6 +23,7 @@
* $Id$
*/

import com.dtolabs.shared.resources.ResourceXMLConstants;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
Expand Down Expand Up @@ -169,4 +170,28 @@ public void testParseSettings() throws Exception {
assertEquals("set4val", node2.getSettings().get("set4"));
}
}
public void testParseEditRemoteUrl() throws Exception {

{
final nodeReceiver receiver = new nodeReceiver();
nodesXMLParser = new NodesXMLParser(xmlfile3, receiver);
nodesXMLParser.parse();
assertEquals("wrong number of nodes parsed", 3, receiver.map.size());

INodeEntry node0 = receiver.map.get("testnode1");
assertNotNull(node0.getAttributes());
assertEquals("TestEditUrl1", node0.getAttributes().get(ResourceXMLConstants.NODE_EDIT_URL));
assertNull(node0.getAttributes().get(ResourceXMLConstants.NODE_REMOTE_URL));

INodeEntry node1 = receiver.map.get("testnode2");
assertNotNull(node1.getAttributes());
assertEquals("TestRemoteUrl2", node1.getAttributes().get(ResourceXMLConstants.NODE_REMOTE_URL));
assertNull(node1.getAttributes().get(ResourceXMLConstants.NODE_EDIT_URL));

INodeEntry node2 = receiver.map.get("testnode3");
assertNotNull(node2.getAttributes());
assertEquals("TestEditUrl3", node2.getAttributes().get(ResourceXMLConstants.NODE_EDIT_URL));
assertEquals("TestRemoteUrl3", node2.getAttributes().get(ResourceXMLConstants.NODE_REMOTE_URL));
}
}
}
4 changes: 4 additions & 0 deletions core/src/test/com/dtolabs/rundeck/core/common/test-nodes3.xml
Expand Up @@ -24,6 +24,7 @@
osName="Mac OS X"
osVersion="10.5.1"
username="username1"
editUrl="TestEditUrl1"
>

</node>
Expand All @@ -33,6 +34,7 @@
osFamily="windows"
osName="Windows XP"
osVersion="5.1"
remoteUrl="TestRemoteUrl2"
>
<resources>
<resource name="set1" type="Setting"/>
Expand All @@ -45,6 +47,8 @@
osFamily="solaris"
osName="Solaris Something"
osVersion="3.7"
editUrl="TestEditUrl3"
remoteUrl="TestRemoteUrl3"
>

<resources>
Expand Down
Expand Up @@ -281,7 +281,7 @@ public void resourcesParsed(ResourceXMLParser.EntitySet entities) {
assertEquals("wrong node type", "node", entity.getResourceType());
assertEquals("wrong name", "node1", entity.getName());
assertEquals("wrong type", "Node1", entity.getType());
assertEquals("wrong properties size", 8, entity.getProperties().size());
assertEquals("wrong properties size", 10, entity.getProperties().size());
assertEquals("wrong resources size", 0, entity.getResources().size());
assertEquals("wrong referrers size", 0, entity.getReferrers().size());
assertNull("wrong transforms ", entity.getTransforms());
Expand All @@ -293,6 +293,8 @@ public void resourcesParsed(ResourceXMLParser.EntitySet entities) {
assertEquals("wrong value", "osFamily1", entity.getProperty(ResourceXMLConstants.NODE_OS_FAMILY));
assertEquals("wrong value", "osName1", entity.getProperty(ResourceXMLConstants.NODE_OS_NAME));
assertEquals("wrong value", "osVersion1", entity.getProperty(ResourceXMLConstants.NODE_OS_VERSION));
assertEquals("wrong value", "EditURL", entity.getProperty(ResourceXMLConstants.NODE_EDIT_URL));
assertEquals("wrong value", "RemoteURL", entity.getProperty(ResourceXMLConstants.NODE_REMOTE_URL));
}

{ //test attributes of xpath="setting"
Expand Down
Expand Up @@ -24,6 +24,8 @@
osArch="osArch1"
osVersion="osVersion1"
username="username1"
editUrl="EditURL"
remoteUrl="RemoteURL"
>

</node>
Expand Down
4 changes: 4 additions & 0 deletions rundeckapp/grails-app/views/framework/_nodes.gsp
Expand Up @@ -48,6 +48,10 @@
${node.description}
</span>

<g:if test="${node.attributes?.editUrl}">
<a href="${node.attributes?.editUrl}" target="_new">Edit...</a>
</g:if>

<g:if test="${expanddetail}">
<g:link controller="reports" action="index" params="${[nodeFilter:node.nodename]}" title="View Events for Node ${node.nodename}">
&raquo; events
Expand Down

0 comments on commit 238cef3

Please sign in to comment.