esoe 1 month ago
parent
commit
b4e7a22c9b
  1. 3
      documentation/general/architecture.md
  2. BIN
      documentation/general/architecture.png
  3. 52
      documentation/general/architecture.puml
  4. 39
      documentation/general/usecase.puml
  5. 73
      documentation/storage/usecase.puml
  6. 1
      face/README.md
  7. 24
      storage/logs/teh.log
  8. BIN
      storage/logs/teh.log.2024-10-10.0.gz
  9. 15
      storage/src/main/java/gsp/technologies/storage/controllers/api/ApiController.java
  10. 20
      storage/src/main/java/gsp/technologies/storage/controllers/face/FaceController.java
  11. 40
      storage/src/main/java/gsp/technologies/storage/controllers/hello/HelloController.java
  12. 4
      storage/src/main/java/gsp/technologies/storage/models/xlsx/Xlsx.java
  13. 4
      storage/src/main/java/gsp/technologies/storage/services/FileService.java
  14. 13
      storage/src/main/java/gsp/technologies/storage/services/FileServiceImpl.java
  15. 13
      storage/src/main/java/gsp/technologies/storage/services/RemoteFilesService.java
  16. 11
      storage/src/main/resources/templates/hello.html
  17. 6
      storage/src/main/resources/templates/view-xlsx.html

3
documentation/general/architecture.md

@ -0,0 +1,3 @@
# Архитектура платформы teh
## диаграмма компонентов
![диаграмма компонентов](architecture.png)

BIN
documentation/general/architecture.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

52
documentation/general/architecture.puml

@ -0,0 +1,52 @@
@startuml
title "Архитектура платформы : teh"
skinparam componentStyle rectangle
allowmixing
left to right direction
component docker {
component environment {
component jvm
component maven
component git
}
component teh {
component source {
portin in81
portout out81
}
component storage {
portin in82
portout out82
}
component face {
portin in83
portout out83
}
component logger {
portin in85
portout out85
}
component base {
portout out5432
portin in5432
}
portin env
out81 --> in83 : "Данные СУБД\n в json-формате"
out82 --> in83 : "Данные файловой системы\n в json-формате"
out5432 --> in81 : "данные СУБД\n в виде персистентных объектов"
out81 --> in85 : "Логи исполнения\n кода приложения"
out82 --> in85 : "Логи исполнения\n кода приложения"
out83 --> in85 : "Логи исполнения\n кода приложения"
}
jvm --> env
maven --> env
git --> env
}
@enduml

39
documentation/general/usecase.puml

@ -0,0 +1,39 @@
@startuml
title "usecase: teh"
left to right direction
actor "Пользователь" as user
package "mainframe" {
frame "Статистика файлообменника (storage-stat)" {
usecase "Данные по видам и количеству размещенных на сервере документов"
usecase "Переход: к файлообменнику (storage)"
}
frame "Статистика хранилища данных (base-stat)" {
usecase "Просмотр данных реестра обученных"
usecase "Переход: к формированию отчетов"
}
}
package "storage" {
usecase "Переход: к mainframe"
usecase "Размещение в хранилище файлов" as upload
usecase "Скачивание файла с сервера" as download
usecase "Удаление файлов из хранилища" as delete
usecase "Просмотр списка файлов в хранилище" as list
usecase "Просмотр/получение сведений о файле" as info
usecase "Переход: к просмотру содержимого файла"
usecase "Переход: к формам экспорта данных"
}
package "view-xlsx" as viewXlsx{
usecase "Просмотр/получение содержимого файла (xlsx)" as view
usecase "Навигация по файлу"
usecase "Переход: к mainframe"
usecase "Переход: к storage"
}
user --> mainframe
user --> storage
user --> viewXlsx
@enduml

73
documentation/storage/usecase.puml

@ -0,0 +1,73 @@
@startuml
title "USECASE: teh.storage"
allowmixing
left to right direction
' пользователи
actor "Пользователь" as user
actor "Стороний сервис" as service
' возможности использования
usecase "получение сведений о корневой директории" as getRoot
usecase "Загрузка файла на сервер" as upload
usecase "Загрузка файлов на сервер пакетом" as uploads
usecase "Скачивание файла с сервера" as download
usecase "Удаление файла с сервера" as delete
usecase "Просмотр/получение перечня файлов на сервере" as list
usecase "Просмотр/получение сведений о файле" as fileInfo
usecase "Настройка параметров просмотра файла (xlsx)" as setParams
usecase "Просмотр/получение содержимого файла (xlsx)" as viewXlsx
' FACE
user --> upload
user --> uploads
user --> download
user --> delete
user --> list
user --> fileInfo
user --> setParams
user --> viewXlsx
' REST API
upload <-- service : "POST /api/v1/files/store"
uploads <-- service : "POST /api/v1/files/store-multiple"
download <-- service : "GET /api/v1/files/download"
delete <-- service : "DELETE /api/v1/files/delete"
list <-- service : "GET /api/v1/files"
fileInfo <-- service : "получаем с пусой страницей xlsxPage"
viewXlsx <-- service : "GET /api/v1/files/xlsx"
getRoot <-- service : "GET /api/v1/root"
json "Сведения о файле" as fileMetadata {
"name":"наименование файла",
"extension":["xlsx", "pdf", "..."],
"rootPath": "/app/storage/uploads",
"relativePath":"/filename.xlsx",
"absolutePath":"/app/storage/uploads/filename.xlsx",
"size":"размер файла в байтах",
"createdDate":"время создания файла",
"lastModifiedDate":"время последнего изменения файла",
"owner":"пользователь - владелец файла",
"type": "файл или директория",
"permissions": "права, установленные файлу на сервере"
}
json "Содержимое файла" as page {
"content":"выборка данных xlsx",
"metadata":"FileMetadata",
"pageSize": "размер страницы",
"pageNumber": "номер страницы",
"offset": "смещение",
"headerLine": "номер строки с заголовками",
"last": "является ли последней страницей",
"first": "является ли первой страницей",
"hasNext": "имеется ли следующая страница",
"hasPrevious": "имеется ли предыдущая страница",
"totalLines": "всего строк в xlsx-файле",
"totalColumns": "всего столбцов",
"totalPages": "всего страниц"
}
fileInfo --{ fileMetadata
viewXlsx --{ page
@enduml

1
face/README.md

@ -0,0 +1 @@
# teh.face

24
storage/logs/teh.log

@ -1,12 +1,12 @@
{"@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-11T06:10:07.994244Z","log.level":"INFO","process.pid":13084,"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 13084 (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-11T06:10:08.012254100Z","log.level":"INFO","process.pid":13084,"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-11T06:10:08.913700800Z","log.level":"INFO","process.pid":13084,"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-11T06:10:09.780682400Z","log.level":"INFO","process.pid":13084,"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.237 seconds (process running for 3.3)","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-11T06:35:21.950719700Z","log.level":"INFO","process.pid":8196,"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 8196 (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-11T06:35:21.956727800Z","log.level":"INFO","process.pid":8196,"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-11T06:35:22.854946600Z","log.level":"INFO","process.pid":8196,"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-11T06:35:23.702006500Z","log.level":"INFO","process.pid":8196,"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.194 seconds (process running for 3.32)","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-11T07:10:32.899864600Z","log.level":"INFO","process.pid":6096,"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 6096 (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-11T07:10:32.906864100Z","log.level":"INFO","process.pid":6096,"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-11T07:10:33.959310800Z","log.level":"INFO","process.pid":6096,"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"} {"@timestamp":"2024-10-11T07:10:34.884139900Z","log.level":"INFO","process.pid":6096,"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.442 seconds (process running for 3.562)","ecs.version":"8.11"}

BIN
storage/logs/teh.log.2024-10-10.0.gz

Binary file not shown.

15
storage/src/main/java/gsp/technologies/storage/controllers/api/ApiController.java

@ -2,6 +2,7 @@ package gsp.technologies.storage.controllers.api;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -146,16 +147,10 @@ public class ApiController {
LOG.info("pageNumber: {}", pageNumber); LOG.info("pageNumber: {}", pageNumber);
LOG.info("pageSize: {}", pageSize); LOG.info("pageSize: {}", pageSize);
try { Path relative = Paths.get(filename);
String path = fs.loadAsResource(filename).getFile().getPath(); Xlsx xlsx = fs.xlsx(relative);
XlsxPage page = xlsx.page(Integer.parseInt(pageSize), Integer.parseInt(pageNumber));
Xlsx xlsx = new Xlsx(path); return ResponseEntity.ok(page);
XlsxPage page = xlsx.page(Integer.parseInt(pageSize), Integer.parseInt(pageNumber));
return ResponseEntity.ok(page);
} catch (IOException e) {
LOG.info("Error: {}", e.getMessage());
return ResponseEntity.badRequest().body(null);
}
} }
/** /**

20
storage/src/main/java/gsp/technologies/storage/controllers/face/FaceController.java

@ -189,25 +189,13 @@ public class FaceController {
LOG.info("GET /view"); LOG.info("GET /view");
Path relative = Path.of(filename); Path relative = Path.of(filename);
// Path absolute = fs.absolute(relative); FileMetadata meta = fs.meta(relative);
FileMetadata meta = fs
.metaFromPath(relative);
//обработка xlsx файла
if (meta.getExtension().equals("xlsx")) { if (meta.getExtension().equals("xlsx")) {
LOG.info("Файл {} является xlsx-файлом", filename); LOG.info("Файл {} является xlsx-файлом", filename);
//преобразуем имя файла в путь
// String path = client.get()
// .uri(ApiLink.ROOT.full())
// .retrieve()
// .bodyToMono(String.class)
// .block();
// path = path + File.separator + filename; Xlsx xlsx = fs.xlsx(relative);
// LOG.info("Путь к xlsx-файлу: {}", path);
// Path relative = Path.of(filename);
// добавляем модель данные xlsx
Xlsx xlsx = new Xlsx(meta, fs);
XlsxPage page = xlsx.page(pageSize, pageNumber); XlsxPage page = xlsx.page(pageSize, pageNumber);
model.addAttribute("xlsx", page); model.addAttribute("xlsx", page);
@ -215,7 +203,7 @@ public class FaceController {
return "view-xlsx"; return "view-xlsx";
} }
//возвращаем пользователя на главную страницу //в остальных случаях возвращаем пользователя на главную страницу
LOG.info("Файл {} не является xlsx-файлом. Возвращаем пользователя на главную страницу", filename); LOG.info("Файл {} не является xlsx-файлом. Возвращаем пользователя на главную страницу", filename);
return FaceLink.MAINFRAME.redirect(); return FaceLink.MAINFRAME.redirect();
} }

40
storage/src/main/java/gsp/technologies/storage/controllers/hello/HelloController.java

@ -1,52 +1,20 @@
package gsp.technologies.storage.controllers.hello; package gsp.technologies.storage.controllers.hello;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
// import ru.molokoin.storagers.model.Document;
// import ru.molokoin.storagers.model.XlsxCell;
// import ru.molokoin.storagers.model.XlsxMultipartDocument;
// import ru.molokoin.storagers.service.StorageServiceFace;
/** /**
* контроллер, для отрабтки тестов, * контроллер, для отрабтки тестов,
* выводит страницу с информацией о сервисе пользователю * выводит страницу с информацией о сервисе пользователю
*/ */
@Controller @Controller
public class HelloController { public class HelloController {
/** private static final Logger log = LoggerFactory.getLogger(HelloController.class);
* получаем в переменную root
* значение свойства storage.location
* из файла application.yaml
*/
// private StorageServiceFace storage;
/**
* Конструктор контроллера, дня инициализации объекта хранилища
* - передается интерфейс
* @param storage
*/
// public HelloController(StorageServiceFace storage){
// this.storage = storage;
// }
@GetMapping("/hello") @GetMapping("/hello")
public String hello(){ public String hello(){
// System.out.println("storageRS/hello-controller# " + "передача пользователю шаблона hello.html"); log.info("GET /hello");
// System.out.println("storageRS/hello-controller#(из config): " + storage.root());
// System.out.println("Загружено документов: " + storage.list().size());
System.out.println("Перечень загруженных документов:");
// int i = 1;
// for (Document doc : storage.list()) {
// XlsxMultipartDocument parts = new XlsxMultipartDocument(doc);
// System.out.println("Document#" + i + ": " + doc.getPath() + "(size#" + doc.getSize() + ")" + " ### lines: " + parts.getLineCount());
// for (XlsxCell c: parts.line(i-1)) {
// System.out.println(c.getContent());
// }
// parts.close();
// System.out.println("---------------------");
// i++;
// }
return "hello"; return "hello";
} }
} }

4
storage/src/main/java/gsp/technologies/storage/models/xlsx/Xlsx.java

@ -34,10 +34,6 @@ public class Xlsx {
this.fs = fs; this.fs = fs;
} }
public Xlsx(String path){
this.metadata = fs.metaFromPath(Paths.get(path));
}
public XlsxPage page(int pageSize, int pageNumber) { public XlsxPage page(int pageSize, int pageNumber) {
return XlsxPage.builder() return XlsxPage.builder()
.pageSize(pageSize) .pageSize(pageSize)

4
storage/src/main/java/gsp/technologies/storage/services/FileService.java

@ -9,6 +9,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import gsp.technologies.storage.models.FileMetadata; import gsp.technologies.storage.models.FileMetadata;
import gsp.technologies.storage.models.xlsx.Xlsx;
public interface FileService { public interface FileService {
// List<FileMetadata> listFiles(String path, Boolean recursive); // List<FileMetadata> listFiles(String path, Boolean recursive);
@ -38,5 +39,6 @@ public interface FileService {
String permissions(Path path); String permissions(Path path);
List<FileMetadata> children(Path path); List<FileMetadata> children(Path path);
FileMetadata parent(Path path); FileMetadata parent(Path path);
FileMetadata metaFromPath(Path relative); FileMetadata meta(Path relative);
Xlsx xlsx(Path relative);
} }

13
storage/src/main/java/gsp/technologies/storage/services/FileServiceImpl.java

@ -26,6 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
import gsp.technologies.storage.config.StorageConfig; import gsp.technologies.storage.config.StorageConfig;
import gsp.technologies.storage.models.FileMetadata; import gsp.technologies.storage.models.FileMetadata;
import gsp.technologies.storage.models.xlsx.Xlsx;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
@Service @Service
@ -252,7 +253,7 @@ public class FileServiceImpl implements FileService {
catch (IOException e) { catch (IOException e) {
System.out.println("Не удалось сохранить файл " + file.getOriginalFilename()); System.out.println("Не удалось сохранить файл " + file.getOriginalFilename());
} }
return metaFromPath(Path.of(file.getOriginalFilename())); return meta(Path.of(file.getOriginalFilename()));
} }
@Override @Override
@ -381,7 +382,7 @@ public class FileServiceImpl implements FileService {
List<FileMetadata> list = List.of(); List<FileMetadata> list = List.of();
try { try {
list = Files.list(path) list = Files.list(path)
.map(p -> metaFromPath(p.getFileName())) .map(p -> meta(p.getFileName()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} catch (IOException e) { } catch (IOException e) {
log.error("Не удалось получить метаданные для файла {}", filename(path)); log.error("Не удалось получить метаданные для файла {}", filename(path));
@ -390,10 +391,10 @@ public class FileServiceImpl implements FileService {
} }
public FileMetadata parent(Path path){ public FileMetadata parent(Path path){
return metaFromPath(path.getParent()); return meta(path.getParent());
} }
public FileMetadata metaFromPath(Path relative) { public FileMetadata meta(Path relative) {
log.info("Создаем объект FileMetadata для пути {}", relative.toString()); log.info("Создаем объект FileMetadata для пути {}", relative.toString());
FileMetadata meta = new FileMetadata(); FileMetadata meta = new FileMetadata();
Path absolute = this.absolute(relative); Path absolute = this.absolute(relative);
@ -411,4 +412,8 @@ public class FileServiceImpl implements FileService {
meta.setPermissions(permissions(absolute)); meta.setPermissions(permissions(absolute));
return meta; return meta;
} }
public Xlsx xlsx(Path relative){
return new Xlsx(meta(relative), this);
}
} }

13
storage/src/main/java/gsp/technologies/storage/services/RemoteFilesService.java

@ -9,7 +9,6 @@ import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.util.UriBuilder;
import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
@ -50,17 +49,6 @@ public class RemoteFilesService {
.block(); .block();
} }
// public void uploadFile(String originalFilename, byte[] bytes) {
// System.out.println("originalFilename: " + originalFilename);
// System.out.println("bytes.length: " + bytes.length);
// client.post()
// .uri(filesURL + "/" + originalFilename)
// .body(Mono.just(bytes), byte[].class)
// .retrieve()
// .toBodilessEntity()
// .block();
// }
public void uploadFile(MultipartFile file) { public void uploadFile(MultipartFile file) {
System.out.println("RemoteFilesService#uploadFile(): OK"); System.out.println("RemoteFilesService#uploadFile(): OK");
UriComponents uriComponents; UriComponents uriComponents;
@ -102,7 +90,6 @@ public class RemoteFilesService {
.retrieve() .retrieve()
.toBodilessEntity() .toBodilessEntity()
.block(); .block();
} }
public Resource loadAsResource(String filename) { public Resource loadAsResource(String filename) {

11
storage/src/main/resources/templates/hello.html

@ -9,6 +9,17 @@ xmlns:th="http://www.thymeleaf.org">
<script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script> <script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script>
</head> </head>
<body> <body>
<h1>TEST: moodle links</h1>
https://ruphp.com/moodle-accept.html
<form action="https://egspt.ru/login/index.php" method="post">
<input type="hidden" name="username" value="nikuliniv2">
<input type="hidden" name="password" value="Psalm-6912">
<input type="hidden" name="logintoken" value="">
<input type="submit" value="login">
</form>
<hr>
<h1>hello-page</h1>
<zero-md th:src="@{/content/md/hello.md}"></zero-md> <zero-md th:src="@{/content/md/hello.md}"></zero-md>
</body> </body>
</html> </html>

6
storage/src/main/resources/templates/view-xlsx.html

@ -33,9 +33,13 @@
<td th:text="${xlsx.metadata.extension}"></td> <td th:text="${xlsx.metadata.extension}"></td>
</tr> </tr>
<tr> <tr>
<td>path:</td> <td>absolutePath:</td>
<td th:text="${xlsx.metadata.absolutePath}"></td> <td th:text="${xlsx.metadata.absolutePath}"></td>
</tr> </tr>
<tr>
<td>relativePath:</td>
<td th:text="${xlsx.metadata.relativePath}"></td>
</tr>
<tr> <tr>
<td>root:</td> <td>root:</td>
<td th:text="${xlsx.metadata.rootPath}"></td> <td th:text="${xlsx.metadata.rootPath}"></td>

Loading…
Cancel
Save