ArafatKhan2198 commented on code in PR #5517:
URL: https://github.com/apache/ozone/pull/5517#discussion_r1544578194


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/handlers/EntityHandler.java:
##########
@@ -256,7 +280,52 @@ public static String[] parseRequestPath(String path) {
     return names;
   }
 
-  private static String normalizePath(String path) {
+  /**
+   * Splits an object store path into volume, bucket, and key name components.
+   *
+   * This method parses a path of the format "/volumeName/bucketName/keyName",
+   * including paths with additional '/' characters within the key name. It's
+   * designed for object store paths where the first three '/' characters
+   * separate the root, volume and bucket names from the key name.
+   *
+   * @param path The object store path to parse, starting with a slash.
+   * @return A String array with three elements: volume name, bucket name, and
+   * key name, or {null} if the path format is invalid.
+   */
+  public static String[] parseObjectStorePath(String path) {
+    // Removing the leading slash for correct splitting
+    path = path.substring(1);
+
+    // Splitting the modified path by "/", limiting to 3 parts
+    String[] parts = path.split("/", 3);

Review Comment:
   Done!



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/handlers/EntityHandler.java:
##########
@@ -256,7 +280,52 @@ public static String[] parseRequestPath(String path) {
     return names;
   }
 
-  private static String normalizePath(String path) {
+  /**
+   * Splits an object store path into volume, bucket, and key name components.
+   *
+   * This method parses a path of the format "/volumeName/bucketName/keyName",
+   * including paths with additional '/' characters within the key name. It's
+   * designed for object store paths where the first three '/' characters
+   * separate the root, volume and bucket names from the key name.
+   *
+   * @param path The object store path to parse, starting with a slash.
+   * @return A String array with three elements: volume name, bucket name, and
+   * key name, or {null} if the path format is invalid.
+   */
+  public static String[] parseObjectStorePath(String path) {
+    // Removing the leading slash for correct splitting
+    path = path.substring(1);
+
+    // Splitting the modified path by "/", limiting to 3 parts
+    String[] parts = path.split("/", 3);
+
+    // Checking if we correctly obtained 3 parts after removing the leading 
slash
+    if (parts.length <= 3) {
+      return parts;
+    } else {
+      return null;
+    }
+  }
+
+  /**
+   * Normalizes a given path based on the specified bucket layout.
+   *
+   * This method adjusts the path according to the bucket layout.
+   * For {OBJECT_STORE Layout}, it normalizes the path up to the bucket level
+   * using OmUtils.normalizePathUptilBucket. For other layouts, it

Review Comment:
   Done!



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/handlers/EntityHandler.java:
##########
@@ -256,7 +280,52 @@ public static String[] parseRequestPath(String path) {
     return names;
   }
 
-  private static String normalizePath(String path) {
+  /**
+   * Splits an object store path into volume, bucket, and key name components.
+   *
+   * This method parses a path of the format "/volumeName/bucketName/keyName",
+   * including paths with additional '/' characters within the key name. It's
+   * designed for object store paths where the first three '/' characters
+   * separate the root, volume and bucket names from the key name.
+   *
+   * @param path The object store path to parse, starting with a slash.
+   * @return A String array with three elements: volume name, bucket name, and
+   * key name, or {null} if the path format is invalid.
+   */
+  public static String[] parseObjectStorePath(String path) {
+    // Removing the leading slash for correct splitting
+    path = path.substring(1);
+
+    // Splitting the modified path by "/", limiting to 3 parts
+    String[] parts = path.split("/", 3);
+
+    // Checking if we correctly obtained 3 parts after removing the leading 
slash
+    if (parts.length <= 3) {
+      return parts;
+    } else {
+      return null;
+    }
+  }
+
+  /**
+   * Normalizes a given path based on the specified bucket layout.
+   *
+   * This method adjusts the path according to the bucket layout.
+   * For {OBJECT_STORE Layout}, it normalizes the path up to the bucket level
+   * using OmUtils.normalizePathUptilBucket. For other layouts, it
+   * normalizes the entire path, including the key, using
+   * OmUtils.normalizeKey, and does not preserve any trailing slashes.
+   * The normalized path will always be prefixed with OM_KEY_PREFIX to ensure 
it
+   * is consistent with the expected format for object storage paths in Ozone.
+   *
+   * @param path
+   * @param bucketLayout
+   * @return A normalized path
+   */
+  private static String normalizePath(String path, BucketLayout bucketLayout) {
+    if (bucketLayout == BucketLayout.OBJECT_STORE) {
+      return OM_KEY_PREFIX + OmUtils.normalizePathUptilBucket(path);

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to