Commit 04bfcc8f authored by legoc's avatar legoc
Browse files

version 1.0.7

parent 7d6f7c59
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId> <groupId>fr.ill.ics</groupId>
<artifactId>nomadmail</artifactId> <artifactId>nomadmail</artifactId>
<version>1.0.4</version> <version>1.0.6</version>
<name>NomadMail</name> <name>NomadMail</name>
<description>Helper application to use Nomad server to send mails from VMs</description> <description>Helper application to use Nomad server to send mails from VMs</description>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<dependency> <dependency>
<groupId>fr.ill.ics</groupId> <groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId> <artifactId>nomadcommandsystem</artifactId>
<version>4.0.26</version> <version>4.0.27</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -17,11 +17,12 @@ ...@@ -17,11 +17,12 @@
*/ */
package fr.ill.ics.mail; package fr.ill.ics.mail;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import fr.ill.ics.bridge.LoginManager; import fr.ill.ics.bridge.LoginManager;
import fr.ill.ics.bridge.command.CommandZoneWrapper; import fr.ill.ics.bridge.command.CommandZoneWrapper;
...@@ -34,7 +35,8 @@ import fr.ill.ics.util.exception.ExitException; ...@@ -34,7 +35,8 @@ import fr.ill.ics.util.exception.ExitException;
public class MailSender { public class MailSender {
private String mailContent; private String mailContentFile;
private static final String VIRTUAL_HOME = "virtualHome";
public static void main(String[] args) { public static void main(String[] args) {
int exitCode = 0; int exitCode = 0;
...@@ -84,16 +86,42 @@ public class MailSender { ...@@ -84,16 +86,42 @@ public class MailSender {
System.exit(1); System.exit(1);
} }
mailContent = args[0]; mailContentFile = 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() { 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) { private String getInstrumentName(String endpoint) {
int pos1 = endpoint.lastIndexOf('/'); int pos1 = endpoint.lastIndexOf('/');
...@@ -123,7 +151,10 @@ public class MailSender { ...@@ -123,7 +151,10 @@ public class MailSender {
System.out.println("nomadServerEndpoint = " + nomadServerEndpoint); System.out.println("nomadServerEndpoint = " + nomadServerEndpoint);
System.out.println("instrument = " + instrumentName); 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); SessionManager.getInstance(CommandZoneWrapper.SERVER_ID).setSessionInformation("", "", instrumentName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment