Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadMail
Commits
53798a0f
Commit
53798a0f
authored
Oct 19, 2020
by
yannick legoc
Browse files
Modified args
parent
c132ddd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
53798a0f
...
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
nomadmail
</artifactId>
<version>
1.0.
9
</version>
<version>
1.
1
0.
0
</version>
<name>
NomadMail
</name>
<description>
Helper application to use Nomad server to send mails from VMs
</description>
...
...
@@ -41,10 +41,21 @@
<dependencies>
<dependency>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
nomadcommandsystem
</artifactId>
<version>
4.0.33
</version>
</dependency>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
cameo-api
</artifactId>
<version>
0.1.9
</version>
<exclusions>
<exclusion>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
cameo-com-jeromq
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
cameo-com-jzmq
</artifactId>
<version>
0.0.3
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/fr/ill/ics/mail/MailSender.java
View file @
53798a0f
...
...
@@ -27,11 +27,15 @@ import fr.ill.ics.cameo.Server;
public
class
MailSender
{
private
String
nomadServerEndpoint
;
private
String
instrumentName
;
private
Server
server
;
private
String
mailSubject
;
private
String
mailContent
;
private
String
mailSender
;
private
String
mailRecipients
;
public
static
String
FILE_SEPARATOR
=
System
.
getProperty
(
"file.separator"
);
public
static
String
NOMADENDPOINT_DIRECTORY
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
FILE_SEPARATOR
+
"nomad"
;
public
static
String
NOMADENDPOINT_DIRECTORY
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
FILE_SEPARATOR
+
"nomad"
;
public
static
String
NOMADENDPOINT_FILE
=
"session.properties"
;
public
static
String
NOMADMAIL
=
"nomadmail"
;
...
...
@@ -48,41 +52,6 @@ public class MailSender {
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);
//
// String virtualHomeValue = System.getProperty(VIRTUAL_HOME);
// System.out.println(VIRTUAL_HOME + " = " + virtualHomeValue);
//
// ConfigManager.initInstance(virtualHomeValue);
//
// SessionManager.getInstance(CommandZoneWrapper.SERVER_ID).setSessionInformation("", "", instrumentName);
//
// String[] cameoArgs = {ConfigManager.getInstance().getServerEndpoint() + ":nomadmail"};
// Application.This.init(cameoArgs);
// ServerInstance.getInstance().init();
//
// return true;
// }
private
void
connectToServer
()
{
...
...
@@ -101,7 +70,7 @@ public class MailSender {
}
nomadServerEndpoint
=
sessionProperties
.
getProperty
(
"nomadServerEndpoint"
);
String
instrumentName
=
getInstrumentName
(
nomadServerEndpoint
);
instrumentName
=
getInstrumentName
(
nomadServerEndpoint
);
System
.
out
.
println
(
"nomadServerEndpoint = "
+
nomadServerEndpoint
);
System
.
out
.
println
(
"instrument = "
+
instrumentName
);
...
...
@@ -117,29 +86,34 @@ public class MailSender {
private
void
init
(
String
[]
args
)
{
if
(
args
!=
null
&&
args
.
length
<
1
)
{
System
.
err
.
println
(
"Wrong number of arguments, usage is: nomadmail <mail content>"
);
if
(
args
!=
null
&&
args
.
length
<
4
)
{
System
.
err
.
println
(
"Wrong number of arguments, usage is: nomadmail
<subject>
<mail content>
<sender> <recipients>
"
);
System
.
exit
(
1
);
}
connectToServer
();
mailContent
=
args
[
0
];
mailSubject
=
args
[
0
];
mailContent
=
args
[
1
];
mailSender
=
args
[
2
];
mailRecipients
=
args
[
3
];
}
private
void
run
()
{
String
[]
args
=
new
String
[
4
];
args
[
0
]
=
"
nomad crash"
;
args
[
0
]
=
"
["
+
instrumentName
+
"]"
+
mailSubject
;
args
[
1
]
=
mailContent
;
args
[
2
]
=
"sci_l@ill.fr"
;
args
[
3
]
=
"nomad_l@ill.fr"
;
args
[
2
]
=
mailSender
;
args
[
3
]
=
mailRecipients
;
Application
.
Instance
app
=
server
.
start
(
NOMADMAIL
,
args
);
if
(!
app
.
exists
())
{
System
.
err
.
println
(
"Cannot send mail, the application "
+
NOMADMAIL
+
" does not exist in the server "
+
nomadServerEndpoint
);
}
server
.
terminate
();
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment