From bb87abe9d60d8764602a8acc73750c5ad3b38052 Mon Sep 17 00:00:00 2001
From: Sara Bertocco <sara.bertocco@inaf.it>
Date: Tue, 2 Feb 2021 18:21:05 +0100
Subject: [PATCH] working on re-engineering due to task #3635 - Refactoring:
 create NodeUtils class

---
 .../inaf/oats/vospace/BaseNodeController.java | 25 ++++++++++---------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/main/java/it/inaf/oats/vospace/BaseNodeController.java b/src/main/java/it/inaf/oats/vospace/BaseNodeController.java
index 62bd026..a9661a1 100644
--- a/src/main/java/it/inaf/oats/vospace/BaseNodeController.java
+++ b/src/main/java/it/inaf/oats/vospace/BaseNodeController.java
@@ -1,5 +1,6 @@
 package it.inaf.oats.vospace;
 
+import it.inaf.oats.vospace.datamodel.NodeUtils;
 import javax.servlet.http.HttpServletRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -8,20 +9,20 @@ public abstract class BaseNodeController {
     @Autowired
     private HttpServletRequest servletRequest;
 
-    /**
-     * Slash is a special character in defining REST endpoints and trying to
-     * define a PathVariable containing slashes doesn't work, so the endpoint
-     * has been defined using "/nodes/**" instead of "/nodes/{path}" and the
-     * path is extracted manually parsing the request URL.
-     */
+    
     protected String getPath() {
+        
         String requestURL = servletRequest.getRequestURL().toString();
-        String[] split = requestURL.split("/nodes/");
+        
+        return NodeUtils.getPathFromRequestURLString(requestURL);
+        
+    }
+    
+    
+
+    protected String getParentPath(String path) {
 
-        String path = "/";
-        if (split.length == 2) {
-            path += split[1];
-        }
-        return path;
+        return NodeUtils.getParentPath(path);
     }
+    
 }
-- 
GitLab