diff --git a/face/logs/teh.log b/face/logs/teh.log index 27b4982..b3954d1 100644 --- a/face/logs/teh.log +++ b/face/logs/teh.log @@ -1,3 +1,6 @@ -{"@timestamp":"2024-09-27T09:40:13.345331100Z","log.level":"INFO","process.pid":17820,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.face.FaceApplicationTests","message":"Starting FaceApplicationTests using Java 17.0.7 with PID 17820 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\face)","ecs.version":"8.11"} -{"@timestamp":"2024-09-27T09:40:13.351664600Z","log.level":"INFO","process.pid":17820,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.face.FaceApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-09-27T09:40:14.875525500Z","log.level":"INFO","process.pid":17820,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.face.FaceApplicationTests","message":"Started FaceApplicationTests in 2.023 seconds (process running for 3.114)","ecs.version":"8.11"} +{"@timestamp":"2024-10-07T09:46:40.606299400Z","log.level":"INFO","process.pid":12004,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.face.FaceApplicationTests","message":"Starting FaceApplicationTests using Java 17.0.7 with PID 12004 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\face)","ecs.version":"8.11"} +{"@timestamp":"2024-10-07T09:46:40.623448100Z","log.level":"INFO","process.pid":12004,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.face.FaceApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} +{"@timestamp":"2024-10-07T09:46:42.184170300Z","log.level":"INFO","process.pid":12004,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.face.FaceApplicationTests","message":"Started FaceApplicationTests in 2.021 seconds (process running for 3.086)","ecs.version":"8.11"} +{"@timestamp":"2024-10-07T09:57:48.533500500Z","log.level":"INFO","process.pid":24652,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.face.FaceApplicationTests","message":"Starting FaceApplicationTests using Java 17.0.7 with PID 24652 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\face)","ecs.version":"8.11"} +{"@timestamp":"2024-10-07T09:57:48.545487800Z","log.level":"INFO","process.pid":24652,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.face.FaceApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} +{"@timestamp":"2024-10-07T09:57:50.201333800Z","log.level":"INFO","process.pid":24652,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.face.FaceApplicationTests","message":"Started FaceApplicationTests in 2.165 seconds (process running for 3.184)","ecs.version":"8.11"} diff --git a/face/logs/teh.log.2024-09-27.0.gz b/face/logs/teh.log.2024-09-27.0.gz new file mode 100644 index 0000000..2ebe6f8 Binary files /dev/null and b/face/logs/teh.log.2024-09-27.0.gz differ diff --git a/face/src/main/java/gsp/technologies/face/controllers/mainframe/MainframeController.java b/face/src/main/java/gsp/technologies/face/controllers/face/v1/mainframe/MainframeController.java similarity index 66% rename from face/src/main/java/gsp/technologies/face/controllers/mainframe/MainframeController.java rename to face/src/main/java/gsp/technologies/face/controllers/face/v1/mainframe/MainframeController.java index 7f729f7..6eb2863 100644 --- a/face/src/main/java/gsp/technologies/face/controllers/mainframe/MainframeController.java +++ b/face/src/main/java/gsp/technologies/face/controllers/face/v1/mainframe/MainframeController.java @@ -1,4 +1,4 @@ -package gsp.technologies.face.controllers.mainframe; +package gsp.technologies.face.controllers.face.v1.mainframe; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.GetMapping; @Controller public class MainframeController { - @GetMapping("/mainframe") + @GetMapping("/face/v1/mainframe") public String mainframe(){ return "mainframe"; } diff --git a/storage/logs/teh.log b/storage/logs/teh.log index 564dca7..46f5913 100644 --- a/storage/logs/teh.log +++ b/storage/logs/teh.log @@ -1,44 +1,12 @@ -{"@timestamp":"2024-10-07T06:17:42.149368200Z","log.level":"INFO","process.pid":23304,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 23304 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:17:42.167178900Z","log.level":"INFO","process.pid":23304,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:17:43.318127400Z","log.level":"INFO","process.pid":23304,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:17:44.272225100Z","log.level":"INFO","process.pid":23304,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.597 seconds (process running for 3.701)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:46:48.074221100Z","log.level":"INFO","process.pid":21364,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 21364 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:46:48.080224400Z","log.level":"INFO","process.pid":21364,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:46:49.085866200Z","log.level":"INFO","process.pid":21364,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:46:49.935110700Z","log.level":"INFO","process.pid":21364,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.317 seconds (process running for 3.435)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:50:12.532607900Z","log.level":"INFO","process.pid":26440,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 26440 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:50:12.538493300Z","log.level":"INFO","process.pid":26440,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:50:13.645177Z","log.level":"INFO","process.pid":26440,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:50:14.502616900Z","log.level":"INFO","process.pid":26440,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.432 seconds (process running for 3.622)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:50:47.809359700Z","log.level":"INFO","process.pid":25352,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 25352 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:50:47.815104200Z","log.level":"INFO","process.pid":25352,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:50:48.695159500Z","log.level":"INFO","process.pid":25352,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T06:50:49.541079Z","log.level":"INFO","process.pid":25352,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.182 seconds (process running for 3.26)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T07:59:02.992260100Z","log.level":"INFO","process.pid":21624,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 21624 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T07:59:02.998266Z","log.level":"INFO","process.pid":21624,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T07:59:03.947325700Z","log.level":"INFO","process.pid":21624,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T07:59:04.860425700Z","log.level":"INFO","process.pid":21624,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.399 seconds (process running for 3.418)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T08:18:05.931201100Z","log.level":"INFO","process.pid":24520,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 24520 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T08:18:05.936209200Z","log.level":"INFO","process.pid":24520,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T08:18:06.990442400Z","log.level":"INFO","process.pid":24520,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T08:18:07.768393700Z","log.level":"INFO","process.pid":24520,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.29 seconds (process running for 3.384)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T08:23:00.031509500Z","log.level":"INFO","process.pid":25924,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 25924 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T08:23:00.037576800Z","log.level":"INFO","process.pid":25924,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T08:23:00.979830700Z","log.level":"INFO","process.pid":25924,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T08:23:01.862505100Z","log.level":"INFO","process.pid":25924,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.284 seconds (process running for 3.335)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:05:18.087110100Z","log.level":"INFO","process.pid":15996,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 15996 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:05:18.092199600Z","log.level":"INFO","process.pid":15996,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:05:19.225407400Z","log.level":"INFO","process.pid":15996,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:05:20.108054800Z","log.level":"INFO","process.pid":15996,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.537 seconds (process running for 3.699)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:07:17.978949800Z","log.level":"INFO","process.pid":14524,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 14524 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:07:17.984286200Z","log.level":"INFO","process.pid":14524,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:07:19.017424400Z","log.level":"INFO","process.pid":14524,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:07:19.882161300Z","log.level":"INFO","process.pid":14524,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.392 seconds (process running for 3.458)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:12:54.924473800Z","log.level":"INFO","process.pid":20144,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 20144 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:12:54.936749300Z","log.level":"INFO","process.pid":20144,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:12:55.942491700Z","log.level":"INFO","process.pid":20144,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:12:56.718191700Z","log.level":"INFO","process.pid":20144,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.411 seconds (process running for 3.658)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:22:32.467836Z","log.level":"INFO","process.pid":20576,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 20576 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:22:32.472831900Z","log.level":"INFO","process.pid":20576,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:22:33.343250900Z","log.level":"INFO","process.pid":20576,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} -{"@timestamp":"2024-10-07T09:22:34.226531500Z","log.level":"INFO","process.pid":20576,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.217 seconds (process running for 3.275)","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T05:48:48.071013600Z","log.level":"INFO","process.pid":5360,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 5360 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T05:48:48.083108600Z","log.level":"INFO","process.pid":5360,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T05:48:49.021430Z","log.level":"INFO","process.pid":5360,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T05:48:49.895543100Z","log.level":"INFO","process.pid":5360,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.251 seconds (process running for 3.281)","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T06:10:14.369765600Z","log.level":"INFO","process.pid":5140,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 5140 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T06:10:14.376062200Z","log.level":"INFO","process.pid":5140,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T06:10:15.441671200Z","log.level":"INFO","process.pid":5140,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T06:10:16.498992600Z","log.level":"INFO","process.pid":5140,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.565 seconds (process running for 3.659)","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T06:16:30.410659500Z","log.level":"INFO","process.pid":16080,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Starting StorageApplicationTests using Java 17.0.7 with PID 16080 (started by devuser in C:\\Users\\devuser\\Documents\\code\\teh\\storage)","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T06:16:30.416388500Z","log.level":"INFO","process.pid":16080,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"No active profile set, falling back to 1 default profile: \"default\"","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T06:16:31.402964900Z","log.level":"INFO","process.pid":16080,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.services.FileServiceImpl","message":"Создание директории root(), для хранения файлов: C:\\Users\\devuser\\Documents\\code\\teh\\storage\\uploads","ecs.version":"8.11"} +{"@timestamp":"2024-10-10T06:16:32.211194900Z","log.level":"INFO","process.pid":16080,"process.thread.name":"main","service.name":"face","service.version":"1","service.environment":"Production","service.node.name":"Primary","log.logger":"gsp.technologies.storage.StorageApplicationTests","message":"Started StorageApplicationTests in 2.244 seconds (process running for 3.327)","ecs.version":"8.11"} diff --git a/storage/logs/teh.log.2024-10-02.0.gz b/storage/logs/teh.log.2024-10-02.0.gz deleted file mode 100644 index 1bf8428..0000000 Binary files a/storage/logs/teh.log.2024-10-02.0.gz and /dev/null differ diff --git a/storage/logs/teh.log.2024-10-07.0.gz b/storage/logs/teh.log.2024-10-07.0.gz new file mode 100644 index 0000000..7b1adb6 Binary files /dev/null and b/storage/logs/teh.log.2024-10-07.0.gz differ diff --git a/storage/logs/teh.log.2024-10-08.0.gz b/storage/logs/teh.log.2024-10-08.0.gz new file mode 100644 index 0000000..e0619b0 Binary files /dev/null and b/storage/logs/teh.log.2024-10-08.0.gz differ diff --git a/storage/logs/teh.log.2024-10-09.0.gz b/storage/logs/teh.log.2024-10-09.0.gz new file mode 100644 index 0000000..a8e722e Binary files /dev/null and b/storage/logs/teh.log.2024-10-09.0.gz differ diff --git a/storage/src/main/java/gsp/technologies/storage/config/StorageConfig.java b/storage/src/main/java/gsp/technologies/storage/config/StorageConfig.java index 809f178..7d09f0e 100644 --- a/storage/src/main/java/gsp/technologies/storage/config/StorageConfig.java +++ b/storage/src/main/java/gsp/technologies/storage/config/StorageConfig.java @@ -1,13 +1,20 @@ package gsp.technologies.storage.config; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; @Configuration -@ConfigurationProperties(prefix = "storage") +@PropertySource("classpath:application.yaml") +@EnableConfigurationProperties +@ConfigurationProperties (prefix = "storage") public class StorageConfig { + // @Value("${storage.location}") private String location; + public String getLocation() { return location; } diff --git a/storage/src/main/java/gsp/technologies/storage/controllers/face/FaceController.java b/storage/src/main/java/gsp/technologies/storage/controllers/face/FaceController.java index b6c3a35..4c6a382 100644 --- a/storage/src/main/java/gsp/technologies/storage/controllers/face/FaceController.java +++ b/storage/src/main/java/gsp/technologies/storage/controllers/face/FaceController.java @@ -3,6 +3,7 @@ package gsp.technologies.storage.controllers.face; import java.io.File; import java.io.IOException; import java.net.URI; +import java.nio.file.Path; import java.util.List; import org.slf4j.Logger; @@ -32,6 +33,7 @@ import gsp.technologies.storage.controllers.api.ApiLink; import gsp.technologies.storage.models.FileMetadata; import gsp.technologies.storage.models.xlsx.Xlsx; import gsp.technologies.storage.models.xlsx.XlsxPage; +import gsp.technologies.storage.services.FileService; import jakarta.servlet.http.HttpServletResponse; @Controller @@ -39,9 +41,11 @@ import jakarta.servlet.http.HttpServletResponse; public class FaceController { private static final Logger LOG = LoggerFactory.getLogger(FaceController.class); private final WebClient client; + private final FileService fs; @Autowired - public FaceController(WebClient webClient) { + public FaceController(WebClient webClient, FileService fs) { + this.fs = fs; this.client = webClient; } @@ -184,20 +188,26 @@ public class FaceController { @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { LOG.info("GET /view"); - if (FileMetadata.ext(filename).toLowerCase().equals("xlsx")) { + Path relative = Path.of(filename); + // Path absolute = fs.absolute(relative); + FileMetadata meta = fs + .metaFromPath(relative); + + if (meta.getExtension().equals("xlsx")) { LOG.info("Файл {} является xlsx-файлом", filename); //преобразуем имя файла в путь - String path = client.get() - .uri(ApiLink.ROOT.full()) - .retrieve() - .bodyToMono(String.class) - .block(); + // String path = client.get() + // .uri(ApiLink.ROOT.full()) + // .retrieve() + // .bodyToMono(String.class) + // .block(); - path = path + File.separator + filename; - LOG.info("Путь к xlsx-файлу: {}", path); + // path = path + File.separator + filename; + // LOG.info("Путь к xlsx-файлу: {}", path); + // Path relative = Path.of(filename); // добавляем модель данные xlsx - Xlsx xlsx = new Xlsx(path); + Xlsx xlsx = new Xlsx(meta, fs); XlsxPage page = xlsx.page(pageSize, pageNumber); model.addAttribute("xlsx", page); diff --git a/storage/src/main/java/gsp/technologies/storage/models/FileMetadata.java b/storage/src/main/java/gsp/technologies/storage/models/FileMetadata.java index 9e952c7..b81a6d1 100644 --- a/storage/src/main/java/gsp/technologies/storage/models/FileMetadata.java +++ b/storage/src/main/java/gsp/technologies/storage/models/FileMetadata.java @@ -1,169 +1,72 @@ package gsp.technologies.storage.models; -import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.time.LocalDateTime; -import java.time.ZoneId; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; -import org.springframework.beans.factory.annotation.Value; -import lombok.AllArgsConstructor; -import lombok.Builder; + import lombok.Data; import lombok.NoArgsConstructor; + /** * Модель для хранения метаданных объектов файловой системы + * + * Пути: + * + * 1. rootPath - корневая директория, где размещено хранилище данных приложения + * rootPath = "/app/storage/uploads" + * rootPath устанавливается параметром "storage.location" properties.yaml файла + * + * 2. relativePath - относительный путь к файлу или директории на сервере + * relativePath = absolutePath.substring(rootPath.length()) + * relativaPath = "", пока не проработаны методы работы с директориями + * пока не реализованы методы работы с директориями + * + * 3. absolutePath - абсолютный путь к файлу или директории на сервере + * absolutePath = rootPath + relativePath + "имя файла или директории (name)" + * + * @see FileMetadataBuilder для инициализации объектов метаданных + * @see FileService для извлечения данных из файловой системы + * */ -@Builder -@AllArgsConstructor @NoArgsConstructor @Data public class FileMetadata { - private String path; // путь к файлу или директории на сервере - @Value("${storage.location}") - private String root; - // private String appPath; // путь к файлу или директории на клиенте + //имя файла private String name; + + //расширение + private String extension; + + //путь к корневому каталогу на сервере, где размещено хранилище данныхприложения + private Path rootPath; + + //путь относительно корневого каталога + private Path relativePath; + + //абсолютный путь к файлу или директории на сервере + private Path absolutePath; + + //размер файла в байтах private Long size; + + //дата создания файла или директории private LocalDateTime createdDate; + + //дата последнего изенения файла или директории private LocalDateTime lastModifiedDate; + + //пользователь - владелец файла или директории private String owner; - private String type; // file, directory + + //тип: файл или директория + private String type; + + //права доступа к файлу или директории private String permissions; - // private String group; - // private String checksum; - /** - * Конструктор для метаданных каталога, - * принимает путь к каталогу - * инициирует все поля - * - * @param path - */ - public FileMetadata(String path) { - this.path = path; - // this.appPath = initAppPath(path); - this.name = initName(path); - this.size = initSize(path); - this.createdDate = initCreatedDate(path); - this.lastModifiedDate = initLastModifiedDate(path); - this.owner = initOwner(path); - this.type = initType(path); - this.permissions = initPermissions(path); - } - /** - * Инициализирует путь к файлу или директории на клиенте - * @param path - * @return - */ - // public String initAppPath(String path) { - // return path.replace(root, ""); - // } - /** - * Инициализирует имя файла или директории. - * Если путь содержит слеш, возвращает подстроку после последнего слеша. - * В противном случае, возвращает исходный переданынй в метод путь. - * - * @param path путь к файлу или директории - * @return имя файла или директории - */ - public String initName(String path) { - // Индекс последнего слеша в пути - int lastSlashIndex = path.lastIndexOf('/'); - - // Если путь содержит слеш - if (lastSlashIndex != -1) { - // возвращает подстроку после последнего слеша - return path.substring(lastSlashIndex + 1); - } - // если путь не содержит слеш - else { - // Возвращает исходный переданынй в метод путь - return path; - } - } - /** - * Инициализирует размер файла - * @param path - * @return размер файла - */ - public Long initSize(String path) { - try { - return Files.size(Paths.get(path)); - } catch (IOException e) { - // System.out.println("FileMetadata.initSize :: Error reading file size: " + e.getMessage()); - return 0L; - } - } - - /** - * Инициализирует дату создания файла - * @param path - * @return дату создания файла - */ - public LocalDateTime initCreatedDate(String path) { - try { - return Files.getLastModifiedTime(Paths.get(path)).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); - } catch (IOException e) { - // System.out.println("FileMetadata.initCreatedDate :: Error reading created date: " + e.getMessage()); - return LocalDateTime.now(); - } - } - /** - * Инициализирует дату последнего изменения файла или директории - * @param path - * @return дата последнего изменения файла или директории - */ - public LocalDateTime initLastModifiedDate(String path) { - try { - return Files.getLastModifiedTime(Paths.get(path)).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); - } catch (IOException e) { - // System.out.println("FileMetadata.initLastModifiedDate :: Error reading last modified date: " + e.getMessage()); - return LocalDateTime.now(); - } - } - /** - * Инициализирует владельца файла или директории - * @param path - * @return - */ - public String initOwner(String path) { - try { - return Files.getOwner(Paths.get(path)).getName(); - } catch (IOException e) { - // System.out.println("FileMetadata.initOwner :: Error reading owner: " + e.getMessage()); - return ""; - } - } - /** - * Инициализирует тип объекта (файл или директория) - * - * @param path путь к файлу или директории - * @return тип объекта - */ - public String initType(String path) { - if (Files.isDirectory(Paths.get(path))) { - return "directory"; - } else { - return "file"; - } - } - /** - * Инициализирует права доступа файла или директории - * @param path - * @return права доступа файла или директории - */ - public String initPermissions(String path) { - try { - return Files.getPosixFilePermissions(Paths.get(path)).toString(); - } catch (IOException e) { - // System.out.println("FileMetadata.initPermissions :: Error reading permissions: " + e.getMessage()); - return ""; - } - } - + /** * Определение типа объекта (файл или директория) * @@ -172,55 +75,4 @@ public class FileMetadata { public boolean isDirectory() { return type.equals("directory"); } - /** - * Получение родительской директории.Если текущий объект является директорией, возвращает путь к родительской директории. - * @return метаданные родительской директории - */ - // public FileMetadata getParent() { - // if (path == null || path.isEmpty()) { - // return null; - // } - - // int lastSlashIndex = path.lastIndexOf('/'); - // if (lastSlashIndex == -1) { - // return null; - // } - // return new FileMetadata(path.substring(0, lastSlashIndex)); - // } - - /** - * Возвращает список дочерних файлов и директорий в текущей директории. - * Если текущая директория не является директорией, возвращает пустой список. - * - * @return список дочерних файлов и директорий - */ - public List getChildren() { - List children = Collections.emptyList(); - if (path != null - && !path.isEmpty() - && path != "") { - try { - Path dirPath = Paths.get(path); - // Размещаем каждый файл в директории в качестве объекта FileMetadata - // и собераем их в список - children = Files.list(dirPath) - .map(p -> new FileMetadata(p.toString())) - .collect(Collectors.toList()); - } catch (IOException e) { - // System.out.println("Error reading directory: " + e.getMessage()); - // System.out.println("Path: " + path); - } - } - return children; - } - public static String ext(String filename){ - if (filename == null || filename.isEmpty()) { - return ""; - } - int lastDotIndex = filename.lastIndexOf('.'); - if (lastDotIndex == -1) { - return ""; - } - return filename.substring(lastDotIndex + 1); - } } diff --git a/storage/src/main/java/gsp/technologies/storage/models/xlsx/Xlsx.java b/storage/src/main/java/gsp/technologies/storage/models/xlsx/Xlsx.java index eb6d9b2..02eb28b 100644 --- a/storage/src/main/java/gsp/technologies/storage/models/xlsx/Xlsx.java +++ b/storage/src/main/java/gsp/technologies/storage/models/xlsx/Xlsx.java @@ -3,6 +3,7 @@ package gsp.technologies.storage.models.xlsx; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -16,19 +17,25 @@ import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import gsp.technologies.storage.models.FileMetadata; +import gsp.technologies.storage.services.FileService; public class Xlsx { private static final Logger LOG = LoggerFactory.getLogger(Xlsx.class); private FileMetadata metadata; - public Xlsx(FileMetadata metadata) { + @Autowired + private FileService fs; + + public Xlsx(FileMetadata metadata, FileService fs) { this.metadata = metadata; + this.fs = fs; } public Xlsx(String path){ - this.metadata = new FileMetadata(path); + this.metadata = fs.metaFromPath(Paths.get(path)); } public XlsxPage page(int pageSize, int pageNumber) { @@ -109,10 +116,10 @@ public class Xlsx { return map; } - File file = new File(metadata.getPath()); + File file = metadata.getAbsolutePath().toFile(); LOG.info("размер файла: " + metadata.getSize()); LOG.info("Страница: " + pageNumber); - try (FileInputStream is = new FileInputStream(metadata.getPath())) { + try (FileInputStream is = new FileInputStream(file)) { XSSFWorkbook wb = new XSSFWorkbook(file); XSSFSheet sheet = wb.getSheetAt(0); @@ -145,7 +152,7 @@ public class Xlsx { */ public Integer totalLines() { int count = 0; - try (FileInputStream is = new FileInputStream(metadata.getPath())) { + try (FileInputStream is = new FileInputStream(metadata.getAbsolutePath().toFile())) { XSSFWorkbook wb = new XSSFWorkbook(is); XSSFSheet sheet = wb.getSheetAt(0); // count = sheet.getLastRowNum(); diff --git a/storage/src/main/java/gsp/technologies/storage/models/xlsx/XlsxCell.java b/storage/src/main/java/gsp/technologies/storage/models/xlsx/XlsxCell.java index cc0254a..4fb0b8e 100644 --- a/storage/src/main/java/gsp/technologies/storage/models/xlsx/XlsxCell.java +++ b/storage/src/main/java/gsp/technologies/storage/models/xlsx/XlsxCell.java @@ -5,6 +5,7 @@ import org.apache.poi.ss.usermodel.DateUtil; import gsp.technologies.storage.util.Stringer; import lombok.Data; +import lombok.NoArgsConstructor; @@ -13,6 +14,7 @@ import lombok.Data; * TODO: убрать не нужные поля */ @Data +@NoArgsConstructor public class XlsxCell { private String content; //содержимое ячейки private String type;// STRING, NUMERIC, BOOLEAN, FORMULA @@ -51,48 +53,6 @@ public class XlsxCell { this.type = type; } - // @Override - // public int hashCode() { - // final int prime = 31; - // int result = 1; - // result = prime * result + ((content == null) ? 0 : content.hashCode()); - // result = prime * result + ((type == null) ? 0 : type.hashCode()); - // return result; - // } - - // @Override - // public boolean equals(Object obj) { - // if (this == obj) - // return true; - // if (obj == null) - // return false; - // if (getClass() != obj.getClass()) - // return false; - // XlsxCell other = (XlsxCell) obj; - // if (content == null) { - // if (other.content != null) - // return false; - // } else if (!content.equals(other.content)) - // return false; - // if (type == null) { - // if (other.type != null) - // return false; - // } else if (!type.equals(other.type)) - // return false; - // return true; - // } - - // @Override - // public String toString() { - // return "XlsxCell [content=" + content + ", type=" + type + "]"; - // } - - /** - * - */ - public XlsxCell() { - } - /** * @param content * @param textColor diff --git a/storage/src/main/java/gsp/technologies/storage/services/FileService.java b/storage/src/main/java/gsp/technologies/storage/services/FileService.java index a2706a9..dec9f49 100644 --- a/storage/src/main/java/gsp/technologies/storage/services/FileService.java +++ b/storage/src/main/java/gsp/technologies/storage/services/FileService.java @@ -1,6 +1,7 @@ package gsp.technologies.storage.services; import java.nio.file.Path; +import java.time.LocalDateTime; import java.util.List; import org.springframework.core.io.Resource; @@ -25,4 +26,17 @@ public interface FileService { Resource loadAsResource(String filename); List store(MultipartFile[] files); FileMetadata store(MultipartFile file); + String filename(Path path); + String extansion(Path path); + Long size(Path path); + // Path path(String name); + Path absolute(Path relative); + LocalDateTime created(Path path); + LocalDateTime modified(Path path); + String owner(Path path); + String type(Path path); + String permissions(Path path); + List children(Path path); + FileMetadata parent(Path path); + FileMetadata metaFromPath(Path relative); } \ No newline at end of file diff --git a/storage/src/main/java/gsp/technologies/storage/services/FileServiceImpl.java b/storage/src/main/java/gsp/technologies/storage/services/FileServiceImpl.java index 85d2fb9..692c451 100644 --- a/storage/src/main/java/gsp/technologies/storage/services/FileServiceImpl.java +++ b/storage/src/main/java/gsp/technologies/storage/services/FileServiceImpl.java @@ -8,9 +8,14 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.BasicFileAttributes; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,12 +26,11 @@ import org.springframework.web.multipart.MultipartFile; import gsp.technologies.storage.config.StorageConfig; import gsp.technologies.storage.models.FileMetadata; -import gsp.technologies.storage.models.xlsx.XlsxPage; import jakarta.annotation.PostConstruct; @Service public class FileServiceImpl implements FileService { - private static final Logger LOG = LoggerFactory.getLogger(FileServiceImpl.class); + private static final Logger log = LoggerFactory.getLogger(FileServiceImpl.class); private final Path storageLocation; public FileServiceImpl(StorageConfig config) { @@ -43,12 +47,12 @@ public class FileServiceImpl implements FileService { public void init() { try { // Создание директории для хранения файлов, если она не существует - LOG.info("Создание директории root(), для хранения файлов: {}", storageLocation); + log.info("Создание директории root(), для хранения файлов: {}", storageLocation); Files.createDirectories(storageLocation); } catch (IOException e) { // Печатает в консоль сообщение об ошибке при создании директории // System.out.println("Ошибка создания директории для хранения файлов: " + e.getMessage()); - LOG.info("Директория {}, уже существует: {}", storageLocation, e.getMessage()); + log.info("Директория {}, уже существует: {}", storageLocation, e.getMessage()); } } @@ -60,7 +64,7 @@ public class FileServiceImpl implements FileService { */ @Override public List listFiles(Path path) { - return new FileMetadata(path.toString()).getChildren(); + return children(path); } /** @@ -71,8 +75,9 @@ public class FileServiceImpl implements FileService { */ @Override public List listFiles(String path) { - return new FileMetadata(path).getChildren(); + return children(Paths.get(path)); } + /** * Загрузка файла в указанный путь в директории хранения * Если файл уже существует, возвращает null @@ -187,6 +192,7 @@ public class FileServiceImpl implements FileService { System.out.println("Ошибка создания директории: " + e.getMessage()); } } + /** * Удаляет директорию с указанным именем. * Если директория не существует, ничего не делает. @@ -210,11 +216,10 @@ public class FileServiceImpl implements FileService { System.out.println("Ошибка удаления директории: " + e.getMessage()); } } - @Override - public Path root() { - return this.storageLocation; - } - + + /** + * + */ @Override public Resource loadAsResource(String filename) { try { @@ -226,7 +231,7 @@ public class FileServiceImpl implements FileService { else { // throw new Exception( // "Could not read file: " + filename); - System.err.println("Could not read file: " + filename); + System.err.println("Ошибка чтения файла: " + filename); } } catch (MalformedURLException e) { @@ -247,7 +252,7 @@ public class FileServiceImpl implements FileService { catch (IOException e) { System.out.println("Не удалось сохранить файл " + file.getOriginalFilename()); } - return new FileMetadata(file.getOriginalFilename()); + return metaFromPath(Path.of(file.getOriginalFilename())); } @Override @@ -258,4 +263,152 @@ public class FileServiceImpl implements FileService { } return metadata; } + + /** + * Методы извленения метаданных из файловой системы + */ + + /** + * Извлечение имени файла из пути + * @param path + * @return + */ + @Override + public String filename(Path path) { + return path.getFileName().toString(); + } + + @Override + public String extansion(Path path) { + String pathString = path.toString(); + if (path == null || pathString.isEmpty()) { + return ""; + } + int lastDotIndex = pathString.lastIndexOf('.'); + if (lastDotIndex == -1) { + return ""; + } + return pathString.substring(lastDotIndex + 1); + } + + /** + * Получаем корневую директорию хранения файлов + */ + @Override + public Path root() { + return this.storageLocation; + } + + public Path absolute(Path relative) { + return root().resolve(relative); + } + + /** + * Получаем размер файла в байтах + * @param path + * @return + */ + @Override + public Long size(Path path) { + File file = path.toFile(); + return file.length(); + } + + /** + * Получаем дату создания файла + * @param path + * @return LocalDateTime время создания, если получилось извлечь из метаданных, + * иначе LocalDateTime.now() + */ + public LocalDateTime created(Path path) { + BasicFileAttributes attributes; + + try { + attributes = Files.readAttributes(path, BasicFileAttributes.class); + return Instant.ofEpochMilli(attributes.creationTime().toMillis()).atZone(ZoneId.systemDefault()).toLocalDateTime(); + } catch (IOException e) { + log.error("Не удалось получить метаданные для файла {}", filename(path)); + return LocalDateTime.now(); + } + } + + /** + * Получаем дату изменения файла + * @param path + * @return LocalDateTime время изменения, если получилось извлечь из метаданных, + * иначе LocalDateTime.now() + */ + public LocalDateTime modified(Path path){ + BasicFileAttributes attributes; + try { + attributes = Files.readAttributes(path, BasicFileAttributes.class); + return Instant.ofEpochMilli(attributes.lastModifiedTime().toMillis()).atZone(ZoneId.systemDefault()).toLocalDateTime(); + } catch (IOException e) { + log.error("Не удалось получить метаданные для файла {}", filename(path)); + return LocalDateTime.now(); + } + } + public String owner(Path path){ + try { + return Files.getOwner(path).getName(); + } catch (IOException e) { + log.error("Не удалось получить метаданные для файла {}", filename(path)); + return ""; + } + } + + public String type(Path path){ + if (Files.isDirectory(path)) return "directory"; + if (Files.isRegularFile(path)) return "file"; + return null; + } + + + public String permissions(Path path){ + try { + return Files.getPosixFilePermissions(path).toString(); + } catch (IOException e) { + log.error("Не удалось получить метаданные для файла {}", filename(path)); + return ""; + } + } + + /** + * Возвращает список дочерних файлов и директорий в текущей директории. + * Если текущая директория не является директорией, возвращает пустой список. + */ + public List children(Path path){ + List list = List.of(); + try { + list = Files.list(path) + .map(p -> metaFromPath(p.getFileName())) + .collect(Collectors.toList()); + } catch (IOException e) { + log.error("Не удалось получить метаданные для файла {}", filename(path)); + } + return list; + } + + public FileMetadata parent(Path path){ + return metaFromPath(path.getParent()); + } + + public FileMetadata metaFromPath(Path relative) { + log.info("Создаем объект FileMetadata для пути {}", relative.toString()); + FileMetadata meta = new FileMetadata(); + Path absolute = this.absolute(relative); + + meta.setName(filename(relative)); + meta.setExtension(extansion(relative)); + meta.setRootPath(root()); + meta.setRelativePath(relative); + meta.setAbsolutePath(absolute); + meta.setSize(size(absolute)); + meta.setCreatedDate(created(absolute)); + meta.setLastModifiedDate(modified(absolute)); + meta.setOwner(owner(absolute)); + meta.setType(type(absolute)); + meta.setPermissions(permissions(absolute)); + return meta; + } } \ No newline at end of file diff --git a/storage/src/main/resources/templates/mainframe.html b/storage/src/main/resources/templates/mainframe.html index 3210ff8..25da438 100644 --- a/storage/src/main/resources/templates/mainframe.html +++ b/storage/src/main/resources/templates/mainframe.html @@ -38,7 +38,7 @@ - + @@ -55,11 +55,14 @@ \ No newline at end of file diff --git a/storage/src/main/resources/templates/view-xlsx.html b/storage/src/main/resources/templates/view-xlsx.html index 1bae415..8786776 100644 --- a/storage/src/main/resources/templates/view-xlsx.html +++ b/storage/src/main/resources/templates/view-xlsx.html @@ -28,13 +28,17 @@ name: + + extension: + + path: - + root: - + size: