summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2017-08-14 14:16:15 +0200
committerHarald Musum <musum@oath.com>2017-08-14 14:16:15 +0200
commit178a54b4cf77a5068bc26909fad85e0859142605 (patch)
tree7c6babc9fcae5ecbcf4925037f3ec8da742a3bbe /node-repository
parent079aa085416f76b4d19fbaaaad1c05e2ea508ba9 (diff)
Simplify now that path suffixes are not used anymore
(and fix test that errounesly had path sufix)
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 6d6f52aa831..2ca5014f4ee 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
@@ -194,13 +194,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 dd2b64a7854..ed9ee6893a8 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
@@ -174,7 +174,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",