summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2017-08-24 08:55:02 +0200
committerGitHub <noreply@github.com>2017-08-24 08:55:02 +0200
commit0a18dd0db8045b8a6745b34d13c74b05fadd532c (patch)
tree3ac6badcc70875aef34f5334b641b16d23ebf423 /node-repository
parent9992b6f710cf5f9e049f2a96850b1699da38cf27 (diff)
parent178a54b4cf77a5068bc26909fad85e0859142605 (diff)
Merge pull request #3094 from vespa-engine/hmusum/simplify-node-from-request
Simplify now that path suffixes are not used anymore
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java7
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java2
2 files changed, 2 insertions, 7 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java
index 594983be698..db75894673e 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/v2/NodesApiHandler.java
@@ -196,13 +196,8 @@ public class NodesApiHandler extends LoggingRequestHandler {
}
private Node nodeFromRequest(HttpRequest request) {
- // TODO: The next 4 lines can be a oneliner when updateNodeAttribute is removed (as we won't allow path suffixes)
String path = request.getUri().getPath();
- String prefixString = "/nodes/v2/node/";
- int beginIndex = path.indexOf(prefixString) + prefixString.length();
- int endIndex = path.indexOf("/", beginIndex);
- if (endIndex < 0) endIndex = path.length(); // path ends by ip
- String hostname = path.substring(beginIndex, endIndex);
+ String hostname = path.substring(path.lastIndexOf("/"));
return nodeRepository.getNode(hostname).orElseThrow(() ->
new NotFoundException("No node found with hostname " + hostname));
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java
index 00595d5b833..deb3378679c 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java
@@ -176,7 +176,7 @@ public class RestApiTest {
assertResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com",
Utf8.toBytes("{\"currentRestartGeneration\": 1}"), Request.Method.PATCH),
"{\"message\":\"Updated host4.yahoo.com\"}");
- assertResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com/currentRebootGeneration",
+ assertResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com",
Utf8.toBytes("{\"currentRebootGeneration\": 1}"), Request.Method.PATCH),
"{\"message\":\"Updated host4.yahoo.com\"}");
assertResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com",