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
04bfcc8f
Commit
04bfcc8f
authored
Jul 07, 2020
by
legoc
Browse files
version 1.0.7
parent
7d6f7c59
Changes
2
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
04bfcc8f
...
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
nomadmail
</artifactId>
<version>
1.0.
4
</version>
<version>
1.0.
6
</version>
<name>
NomadMail
</name>
<description>
Helper application to use Nomad server to send mails from VMs
</description>
...
...
@@ -43,7 +43,7 @@
<dependency>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
nomadcommandsystem
</artifactId>
<version>
4.0.2
6
</version>
<version>
4.0.2
7
</version>
</dependency>
</dependencies>
...
...
src/main/java/fr/ill/ics/mail/MailSender.java
View file @
04bfcc8f
...
...
@@ -17,11 +17,12 @@
*/
package
fr.ill.ics.mail
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.File
NotFoundException
;
import
java.io.File
Reader
;
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
;
...
...
@@ -34,7 +35,8 @@ import fr.ill.ics.util.exception.ExitException;
public
class
MailSender
{
private
String
mailContent
;
private
String
mailContentFile
;
private
static
final
String
VIRTUAL_HOME
=
"virtualHome"
;
public
static
void
main
(
String
[]
args
)
{
int
exitCode
=
0
;
...
...
@@ -84,16 +86,42 @@ public class MailSender {
System
.
exit
(
1
);
}
mailContent
=
args
[
0
];
mailContent
File
=
args
[
0
];
}
private
static
String
readFile
(
File
file
)
throws
IOException
{
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
file
));
String
line
=
null
;
StringBuilder
stringBuilder
=
new
StringBuilder
();
String
ls
=
System
.
getProperty
(
"line.separator"
);
while
((
line
=
reader
.
readLine
())
!=
null
)
{
stringBuilder
.
append
(
line
);
stringBuilder
.
append
(
ls
);
}
reader
.
close
();
return
stringBuilder
.
toString
();
}
private
void
run
()
{
System
.
out
.
println
(
"Sending "
+
mailContent
);
String
mailContent
=
""
;
try
{
mailContent
=
readFile
(
new
File
(
mailContentFile
));
System
.
out
.
println
(
"Sending "
+
mailContent
);
SessionManager
.
getInstance
(
CommandZoneWrapper
.
SERVER_ID
).
sendCrashMail
(
mailContent
);
SessionManager
.
getInstance
(
CommandZoneWrapper
.
SERVER_ID
).
sendCrashMail
(
mailContent
);
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Cannot send mail"
);
e
.
printStackTrace
();
}
}
private
String
getInstrumentName
(
String
endpoint
)
{
int
pos1
=
endpoint
.
lastIndexOf
(
'/'
);
...
...
@@ -123,7 +151,10 @@ public class MailSender {
System
.
out
.
println
(
"nomadServerEndpoint = "
+
nomadServerEndpoint
);
System
.
out
.
println
(
"instrument = "
+
instrumentName
);
ConfigManager
.
initInstance
(
null
);
String
virtualHomeValue
=
System
.
getProperty
(
VIRTUAL_HOME
);
System
.
out
.
println
(
VIRTUAL_HOME
+
" = "
+
virtualHomeValue
);
ConfigManager
.
initInstance
(
virtualHomeValue
);
SessionManager
.
getInstance
(
CommandZoneWrapper
.
SERVER_ID
).
setSessionInformation
(
""
,
""
,
instrumentName
);
...
...
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