Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadMail
Commits
7d6f7c59
Commit
7d6f7c59
authored
Jul 03, 2020
by
legoc
Browse files
Version 1.0.4: use session.properties
parent
eb525c24
Changes
2
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
7d6f7c59
...
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
nomadmail
</artifactId>
<version>
1.0.
3
</version>
<version>
1.0.
4
</version>
<name>
NomadMail
</name>
<description>
Helper application to use Nomad server to send mails from VMs
</description>
...
...
src/main/java/fr/ill/ics/mail/MailSender.java
View file @
7d6f7c59
...
...
@@ -17,6 +17,12 @@
*/
package
fr.ill.ics.mail
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
fr.ill.ics.bridge.LoginManager
;
import
fr.ill.ics.bridge.command.CommandZoneWrapper
;
import
fr.ill.ics.cameo.Application
;
...
...
@@ -88,9 +94,39 @@ public class MailSender {
SessionManager
.
getInstance
(
CommandZoneWrapper
.
SERVER_ID
).
sendCrashMail
(
mailContent
);
}
private
String
getInstrumentName
(
String
endpoint
)
{
int
pos1
=
endpoint
.
lastIndexOf
(
'/'
);
int
pos2
=
endpoint
.
lastIndexOf
(
':'
);
return
endpoint
.
substring
(
pos1
+
1
,
pos2
);
}
private
boolean
connectToNomadServer
()
{
String
sessionPropertiesFile
=
ConfigManager
.
NOMADENDPOINT_DIRECTORY
+
ConfigManager
.
FILE_SEPARATOR
+
ConfigManager
.
NOMADENDPOINT_FILE
;
Properties
sessionProperties
=
new
Properties
();
try
{
FileInputStream
inputStream
=
new
FileInputStream
(
sessionPropertiesFile
);
sessionProperties
.
load
(
inputStream
);
inputStream
.
close
();
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Error while reading session properties."
);
}
String
nomadServerEndpoint
=
sessionProperties
.
getProperty
(
"nomadServerEndpoint"
);
String
instrumentName
=
getInstrumentName
(
nomadServerEndpoint
);
System
.
out
.
println
(
"nomadServerEndpoint = "
+
nomadServerEndpoint
);
System
.
out
.
println
(
"instrument = "
+
instrumentName
);
ConfigManager
.
initInstance
(
null
);
SessionManager
.
getInstance
(
CommandZoneWrapper
.
SERVER_ID
).
setSessionInformation
(
""
,
""
,
instrumentName
);
String
[]
cameoArgs
=
{
ConfigManager
.
getInstance
().
getServerEndpoint
()
+
":nomadmail"
};
Application
.
This
.
init
(
cameoArgs
);
ServerInstance
.
getInstance
().
init
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment