Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SR2-projet2-VANDEWAETER-DIAF
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabio Vandewaeter
SR2-projet2-VANDEWAETER-DIAF
Commits
7775930f
Commit
7775930f
authored
3 weeks ago
by
Fabio Vandewaeter
Browse files
Options
Downloads
Patches
Plain Diff
fix commande tree
parent
97c35c7d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/fil/sr2/projet2/CommandLineInterface.java
+18
-19
18 additions, 19 deletions
src/main/java/fil/sr2/projet2/CommandLineInterface.java
src/main/java/fil/sr2/projet2/FlopBoxClient.java
+2
-4
2 additions, 4 deletions
src/main/java/fil/sr2/projet2/FlopBoxClient.java
with
20 additions
and
23 deletions
src/main/java/fil/sr2/projet2/CommandLineInterface.java
+
18
−
19
View file @
7775930f
...
@@ -331,6 +331,8 @@ public class CommandLineInterface {
...
@@ -331,6 +331,8 @@ public class CommandLineInterface {
try
{
try
{
JsonNode
tree
=
client
.
fetchFtpTree
(
alias
,
path
);
JsonNode
tree
=
client
.
fetchFtpTree
(
alias
,
path
);
// System.out.println(objectMapper.readTree(response.body()));
System
.
out
.
println
(
tree
+
"\n"
);
displayTree
(
tree
,
0
);
displayTree
(
tree
,
0
);
System
.
out
.
println
(
"Arborescence récupérée avec succès."
);
System
.
out
.
println
(
"Arborescence récupérée avec succès."
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -348,28 +350,25 @@ public class CommandLineInterface {
...
@@ -348,28 +350,25 @@ public class CommandLineInterface {
private
void
displayTree
(
JsonNode
node
,
int
level
)
{
private
void
displayTree
(
JsonNode
node
,
int
level
)
{
String
indent
=
" "
.
repeat
(
level
);
String
indent
=
" "
.
repeat
(
level
);
// Affichage des dossiers
// Affichage des éléments dans 'children'
if
(
node
.
has
(
"directories"
)
&&
node
.
get
(
"directories"
).
isArray
())
{
if
(
node
.
has
(
"children"
)
&&
node
.
get
(
"children"
).
isArray
())
{
for
(
JsonNode
dir
:
node
.
get
(
"directories"
))
{
for
(
JsonNode
child
:
node
.
get
(
"children"
))
{
String
dirName
=
dir
.
get
(
"name"
).
asText
();
String
childName
=
child
.
get
(
"name"
).
asText
();
System
.
out
.
println
(
indent
+
"📁 "
+
dirName
);
boolean
isDirectory
=
child
.
get
(
"isDirectory"
).
asBoolean
();
// Si on a des informations sur le contenu du dossier
if
(
isDirectory
)
{
if
(
dir
.
has
(
"content"
))
{
System
.
out
.
println
(
indent
+
"📁 "
+
childName
);
displayTree
(
dir
.
get
(
"content"
),
level
+
1
);
// Si le répertoire a des enfants, on les affiche aussi
if
(
child
.
has
(
"children"
))
{
displayTree
(
child
,
level
+
1
);
}
}
else
{
// Si c'est un fichier
long
fileSize
=
0
;
// Si le size est disponible, vous pouvez l'ajouter
System
.
out
.
println
(
indent
+
"📄 "
+
childName
+
" ("
+
formatSize
(
fileSize
)
+
")"
);
}
}
}
}
}
}
// Affichage des fichiers
if
(
node
.
has
(
"files"
)
&&
node
.
get
(
"files"
).
isArray
())
{
for
(
JsonNode
file
:
node
.
get
(
"files"
))
{
String
fileName
=
file
.
get
(
"name"
).
asText
();
long
fileSize
=
file
.
has
(
"size"
)
?
file
.
get
(
"size"
).
asLong
()
:
0
;
System
.
out
.
println
(
indent
+
"📄 "
+
fileName
+
" ("
+
formatSize
(
fileSize
)
+
")"
);
}
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
src/main/java/fil/sr2/projet2/FlopBoxClient.java
+
2
−
4
View file @
7775930f
...
@@ -205,7 +205,7 @@ public class FlopBoxClient {
...
@@ -205,7 +205,7 @@ public class FlopBoxClient {
String
encodedPath
=
path
.
isEmpty
()
?
""
:
"/"
+
path
;
String
encodedPath
=
path
.
isEmpty
()
?
""
:
"/"
+
path
;
HttpRequest
request
=
HttpRequest
.
newBuilder
()
HttpRequest
request
=
HttpRequest
.
newBuilder
()
.
uri
(
URI
.
create
(
flopboxUrl
+
"/ftps/list/"
+
alias
+
encodedPath
+
"/"
))
.
uri
(
URI
.
create
(
flopboxUrl
+
"/ftps/list/"
+
alias
+
encodedPath
))
.
header
(
"Authorization"
,
"Bearer "
+
authToken
)
.
header
(
"Authorization"
,
"Bearer "
+
authToken
)
.
header
(
"X-FTP-User"
,
ftpUser
)
.
header
(
"X-FTP-User"
,
ftpUser
)
.
header
(
"X-FTP-Pass"
,
ftpPassword
)
.
header
(
"X-FTP-Pass"
,
ftpPassword
)
...
@@ -214,9 +214,7 @@ public class FlopBoxClient {
...
@@ -214,9 +214,7 @@ public class FlopBoxClient {
HttpResponse
<
String
>
response
=
httpClient
.
send
(
request
,
HttpResponse
.
BodyHandlers
.
ofString
());
HttpResponse
<
String
>
response
=
httpClient
.
send
(
request
,
HttpResponse
.
BodyHandlers
.
ofString
());
System
.
out
.
println
(
URI
.
create
(
flopboxUrl
+
"/ftps/list/"
+
alias
+
encodedPath
+
"/"
));
System
.
out
.
println
(
URI
.
create
(
flopboxUrl
+
"/ftps/list/"
+
alias
+
encodedPath
));
System
.
out
.
println
(
response
);
System
.
out
.
println
(
objectMapper
.
readTree
(
response
.
body
()));
if
(
response
.
statusCode
()
!=
200
)
{
if
(
response
.
statusCode
()
!=
200
)
{
throw
new
IOException
(
"Erreur lors de la récupération de l'arborescence: "
+
response
.
statusCode
());
throw
new
IOException
(
"Erreur lors de la récupération de l'arborescence: "
+
response
.
statusCode
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment