INTO-CPS-Association/DTaaS

View on GitHub
docs/developer/servers/lib/lib-sequence.puml

Summary

Maintainability
Test Coverage
@startuml
actor Client
actor Traefik
box "Library Microservice" #LightGreen
participant "FilesResolver" as FR
participant "FilesServiceFactory" as FSF
participant "ConfigService" as CS
participant "IFilesService" as IFS
participant "LocalFilesService" as LFS
end box
database "Local File System" as FS

Client -> Traefik : HTTP request
Traefik -> FR : GraphQL query
activate FR

FR -> FSF : create()
activate FSF

FSF -> CS : getConfiguration("MODE")
activate CS

CS --> FSF : return configuration value
deactivate CS

alt MODE = Local
  FSF -> FR : return filesService (LFS)
  deactivate FSF

  FR -> IFS : listDirectory(path) or readFile(path)
  activate IFS

  IFS -> LFS : listDirectory(path) or readFile(path)
  activate LFS

  LFS -> CS : getConfiguration("LOCAL_PATH")
  activate CS

  CS --> LFS : return local path
  deactivate CS

  LFS -> FS : Access filesystem
  alt Filesystem error
    FS --> LFS : Filesystem error
    LFS -> LFS : Throw new InternalServerErrorException
    LFS --> IFS : Error
  else Successful file operation
    FS --> LFS : Return filesystem data
    LFS -> IFS : return Promise<Project>
  end
  deactivate LFS
end

alt Error thrown
  IFS -> FR : return Error
  deactivate IFS
  FR -> Traefik : return Error
  Traefik -> Client : HTTP error response
else Successful operation
  IFS -> FR : return Promise<Project>
  deactivate IFS
  FR -> Traefik : return Promise<Project>
  Traefik -> Client : HTTP response
end

deactivate FR
@enduml