Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
astitva1905 authored Sep 7, 2023
1 parent 101a7d9 commit 1f4d2f5
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
47 changes: 47 additions & 0 deletions docs/developer/lib-class.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@startuml
class FilesResolver {
-filesService: IFilesService
+listDirectory(path: string): Promise<Project>
+readFile(path: string): Promise<Project>
}

interface IFilesService {
listDirectory(path: string): Promise<Project>
readFile(path: string): Promise<Project>
}

class FilesServiceFactory {
-configService: ConfigService
-gitlabFilesService: GitlabFilesService
-localFilesService: LocalFilesService
+create(): IFilesService
}

class GitlabFilesService {
-configService: ConfigService
-parseArguments(path: string): Promise<{ domain: string; parsedPath: string }>
-sendRequest(query: string): Promise<Project>
-executeQuery(path: string, getQuery: QueryFunction): Promise<Project>
+listDirectory(path: string): Promise<Project>
+readFile(path: string): Promise<Project>
}

class LocalFilesService {
-configService: ConfigService
-getFileStats(fullPath: string, file: string): Promise<Project>
+listDirectory(path: string): Promise<Project>
+readFile(path: string): Promise<Project>
}

class ConfigService {
+get(propertyPath: string): any
}

FilesResolver --> IFilesService: uses
IFilesService <|.. GitlabFilesService: implements
IFilesService <|.. LocalFilesService: implements
FilesServiceFactory --> IFilesService: creates
FilesServiceFactory --> ConfigService: uses
GitlabFilesService --> ConfigService: uses
LocalFilesService --> ConfigService: uses
@enduml
98 changes: 98 additions & 0 deletions docs/developer/lib-sequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@startuml
actor Client
actor Traefik
box "RAMS" #LightGreen
participant "FilesResolver" as FR
participant "FilesServiceFactory" as FSF
participant "ConfigService" as CS
participant "IFilesService" as IFS
participant "LocalFilesService" as LFS
participant "GitlabFilesService" as GFS
end box
database "Local File System" as FS
database "GitLab API" as GAPI

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
else MODE = GitLab
FSF -> FR : return filesService (GFS)
deactivate FSF

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

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

GFS -> GFS : parseArguments(path)
GFS -> GFS : executeQuery()

GFS -> CS : getConfiguration("GITLAB_API_URL", "GITLAB_TOKEN")
activate CS

CS --> GFS : return GitLab API URL and Token
deactivate CS

GFS -> GAPI : sendRequest()
alt GitLab API error
GAPI --> GFS : API error
GFS -> GFS : Throw new Error("Invalid query")
GFS --> IFS : Error
else Successful GitLab API operation
GAPI --> GFS : Return API response
GFS -> IFS : return Promise<Project>
end
deactivate GFS
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

0 comments on commit 1f4d2f5

Please sign in to comment.