From 55cb8f0f6326e4578b1cead349bbde417307c713 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Tue, 7 Dec 2021 10:42:09 -0500 Subject: [PATCH 1/5] Added in metadata path and the appropriate returns. Also modified the global directory to include the created dates and ccsid codes. Signed-off-by: Alexandra Drazilov --- mock/server.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/mock/server.py b/mock/server.py index d2a3f212b..048e8e4e9 100644 --- a/mock/server.py +++ b/mock/server.py @@ -1,4 +1,4 @@ -# +# # This program and the accompanying materials are # made available under the terms of the Eclipse Public License v2.0 which accompanies # this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html @@ -103,14 +103,20 @@ def genVolserId(): global_directory = { "permissions": 777, "type": "folder", + "createdAt": "1999-06-02T12:35:07", + "ccsid": 37, "contents": { "folder1": { "permissions": 777, "type": "folder", + "createdAt": "1998-08-02T17:49:22", + "ccsid": 37, "contents": { "file1": { "permissions": 777, "type": "file", + "createdAt": "2021-06-02T12:35:07", + "ccsid": 37, "contents": { "raw": "This is file1", "b64": "VGhpcyBpcyBmaWxlMQ==" @@ -119,10 +125,14 @@ def genVolserId(): "folderA": { "permissions": 777, "type": "folder", + "createdAt": "2021-10-03T09:55:24", + "ccsid": 37, "contents": { "fileA": { "permissions": 777, "type": "file", + "createdAt": "2021-10-03T09:55:24", + "ccsid": 37, "contents": { "raw": "This is fileA", "b64": "VGhpcyBpcyBmaWxlQQ==" @@ -135,11 +145,15 @@ def genVolserId(): "folder2": { "permissions": 777, "type": "folder", + "createdAt": "2021-10-03T09:55:24", + "ccsid": 37, "contents": {} }, "file1": { "permissions": 777, "type": "file", + "createdAt": "2021-10-03T09:55:24", + "ccsid": 37, "contents": { "raw": "This is file1", "b64": "VGhpcyBpcyBmaWxlMQ==" @@ -148,6 +162,8 @@ def genVolserId(): "file2": { "permissions": 777, "type": "file", + "createdAt": "2021-10-03T09:55:24", + "ccsid": 37, "contents": { "raw": "Goodbye", "b64": "VGhpcyBpcyBmaWxlMg==" @@ -156,6 +172,8 @@ def genVolserId(): "noPermissions": { "permissions": 0, "type": "file", + "createdAt": "2021-10-03T09:55:24", + "ccsid": 37, "contents": { "raw": "You should not be able to read this", "b64": "WW91IHNob3VsZCBub3QgYmUgYWJsZSB0byByZWFkIHRoaXM=" @@ -535,6 +553,42 @@ def unixfile_copy(subpath): dir = dir["contents"][newNames[i]] return {"msg": "File Successfully Copied"} +@app.route('/unixfile/metaData/', methods=['GET']) +def unixfile_metaData(subpath): + if request.method == 'GET': + directory = global_directory["contents"] + metaData = { + "path": subpath, + "directory": True, + "size": 0, + "ccsid": 0, + "createdAt": "", + "mode": 0 + } + if(subpath is None or subpath == ""): + return {'error': 'File/Directory could not be opened or does not exist.'}, 404 + subpath = subpath.split("/") + currPath = directory + #Go to the folder above the final dest and return if the path DNE + for x in range(0, len(subpath)-1): + if (subpath[x] not in currPath): + return {'error': 'File/Directory could not be opened or does not exist.'}, 404 + currPath = currPath[subpath[x]]["contents"] + dest = subpath[len(subpath)-1] + #Check if the dest is in the final path and return if the path DNE + if (dest not in currPath): + return {'error': 'File/Directory could not be opened or does not exist.'}, 404 + currPath = currPath[dest] + metaData["size"] = len(currPath["contents"]) + #Set the file specific metadata + if(currPath["type"] == "file"): + metaData["directory"] = False + metaData["size"] = len(currPath["contents"]["raw"]) + metaData["mode"] = currPath["permissions"] + metaData["createdAt"] = currPath["createdAt"] + metaData["ccsid"] = currPath["ccsid"] + return metaData, 200 + if __name__ == '__main__': app.run(debug=True) From db06a6f41fcb47f49ecd5b2f9a6d546858ad4f23 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Tue, 7 Dec 2021 10:43:50 -0500 Subject: [PATCH 2/5] Removed random line in the beginning Signed-off-by: Alexandra Drazilov --- mock/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mock/server.py b/mock/server.py index 048e8e4e9..f26108ae7 100644 --- a/mock/server.py +++ b/mock/server.py @@ -1,4 +1,3 @@ -# # This program and the accompanying materials are # made available under the terms of the Eclipse Public License v2.0 which accompanies # this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html From 9d8b925374ed908f91bc1690df290f38353b836d Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Tue, 7 Dec 2021 10:44:29 -0500 Subject: [PATCH 3/5] Added back in random line Signed-off-by: Alexandra Drazilov --- mock/server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mock/server.py b/mock/server.py index f26108ae7..048e8e4e9 100644 --- a/mock/server.py +++ b/mock/server.py @@ -1,3 +1,4 @@ +# # This program and the accompanying materials are # made available under the terms of the Eclipse Public License v2.0 which accompanies # this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html From 90a3b3e732eee8b9cceae23c05e167c2c7b56fc4 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Tue, 7 Dec 2021 10:45:00 -0500 Subject: [PATCH 4/5] Added in blank space Signed-off-by: Alexandra Drazilov --- mock/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mock/server.py b/mock/server.py index 048e8e4e9..96e9a0844 100644 --- a/mock/server.py +++ b/mock/server.py @@ -1,4 +1,4 @@ -# +# # This program and the accompanying materials are # made available under the terms of the Eclipse Public License v2.0 which accompanies # this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html From 2b0624cc5369ae3979f07e2866a01b82c9ab8b22 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Mon, 20 Dec 2021 22:23:44 -0500 Subject: [PATCH 5/5] Changed unixFile/contents to reflect new createdAt date Signed-off-by: Alexandra Drazilov --- mock/server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mock/server.py b/mock/server.py index 96e9a0844..be06391db 100644 --- a/mock/server.py +++ b/mock/server.py @@ -224,7 +224,7 @@ def unix_contents(subpath): "directory": True if global_directory['contents'][key]['type'] == "folder" else False, "size": 9, "ccsid": 0, - "createdAt": "2018-11-03T14:18:27", + "createdAt": global_directory['contents'][key]['createdAt'], "mode": 777 } ) @@ -248,7 +248,7 @@ def unix_contents(subpath): "directory": True if directory['contents'][key]['type'] == "folder" else False, "size": 9, "ccsid": 0, - "createdAt": "2018-11-03T14:18:27", + "createdAt": directory['contents'][key]['createdAt'], "mode": 777 } )