Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pissirSmartHome
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
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
Alfredo Chissotti
pissirSmartHome
Commits
d410f5d5
Commit
d410f5d5
authored
2 years ago
by
Elisa Giglio
Browse files
Options
Downloads
Patches
Plain Diff
install
parent
8713a624
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
domainManager/src/code/InstallHandler.java
+14
-2
14 additions, 2 deletions
domainManager/src/code/InstallHandler.java
with
14 additions
and
2 deletions
domainManager/src/code/InstallHandler.java
+
14
−
2
View file @
d410f5d5
...
...
@@ -26,6 +26,7 @@ public class InstallHandler implements HttpHandler {
HttpsExchange
he
=
(
HttpsExchange
)
hex
;
String
requestMethod
=
he
.
getRequestMethod
();
// System.out.println(requestMethod);
if
(
requestMethod
.
compareToIgnoreCase
(
"options"
)
==
0
)
{
Helper
.
sendCors
(
he
,
200
);
...
...
@@ -45,6 +46,7 @@ public class InstallHandler implements HttpHandler {
JSONObject
j
=
null
;
try
{
j
=
new
JSONObject
(
body
);
String
dm
=
j
.
getString
(
"domain"
);
Dominio
d
=
DBC
.
getDom
(
dm
);
if
(
d
!=
null
)
{
...
...
@@ -93,11 +95,13 @@ public class InstallHandler implements HttpHandler {
}
JSONArray
arrServ
=
j
.
getJSONArray
(
"services"
);
// array con solo il nome dei servizi da installare
// System.out.println("arrServ = "+arrServ);
ArrayList
<
String
>
moduleHosts
=
new
ArrayList
<
String
>();
for
(
int
i
=
0
;
i
<
arrServ
.
length
();
i
++)
{
String
modul
=
arrServ
.
getString
(
i
);
String
modul
=
arrServ
.
getString
(
i
)
.
replace
(
"gpio"
,
"bbgpio"
).
replace
(
"arduino"
,
"AinDout_Arduino1wifi"
)
;
moduleHosts
.
addAll
(
DBC
.
insertService
(
domain
,
modul
));
}
// System.out.println("riga 105 moduleHost = " + moduleHosts);
// divido gli host in base al loro module
HashMap
<
String
,
ArrayList
<
String
>>
hostsMap
=
new
HashMap
<
String
,
ArrayList
<
String
>>();
for
(
String
mh
:
moduleHosts
)
{
...
...
@@ -112,13 +116,17 @@ public class InstallHandler implements HttpHandler {
hostsMap
.
put
(
module
,
hostsList
);
}
hostsList
.
add
(
host
);
// System.out.println("riga 120 modulo = "+ module + " host = "+ host);
}
// imposta correttamente l'array dei servizi
JSONArray
arrServiziFinale
=
new
JSONArray
();
for
(
int
i
=
0
;
i
<
arrServ
.
length
();
i
++)
{
JSONObject
row
=
new
JSONObject
();
String
mod
=
arrServ
.
getString
(
i
);
String
mod
=
arrServ
.
getString
(
i
).
replace
(
"gpio"
,
"bbgpio"
).
replace
(
"arduino"
,
"AinDout_Arduino1wifi"
);
// System.out.println("mod = "+mod + " indice = "+i);
ArrayList
<
String
>
ho
=
hostsMap
.
get
(
mod
);
// System.out.println(" riga 131 ho = "+ho);
for
(
String
h
:
ho
)
{
row
.
put
(
"host"
,
h
.
replace
(
"BB1"
,
"luci"
));
row
.
put
(
"service"
,
mod
);
...
...
@@ -126,10 +134,13 @@ public class InstallHandler implements HttpHandler {
arrServiziFinale
.
put
(
row
);
}
}
// System.out.println("riga 137 arrServiziFinale = "+arrServiziFinale);
j
.
put
(
"services"
,
arrServiziFinale
);
}
catch
(
SQLException
|
JSONException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e2
)
{
e2
.
printStackTrace
();
}
// ora bisogna fare la chiamata al CloudApp, non prima!
// effettuo chiamata a CloudAppManager
...
...
@@ -143,6 +154,7 @@ public class InstallHandler implements HttpHandler {
HttpURLConnection
con
=
Helper
.
sendMessageToCloudapp
(
"install"
,
j
.
toString
());
int
status
=
con
.
getResponseCode
();
// FIXME serve avere anche il content?
// String cloudappResponse = Helper.getResponseFromConnection(con);
con
.
disconnect
();
...
...
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