Commit 7d6f7c59 authored by legoc's avatar legoc
Browse files

Version 1.0.4: use session.properties

parent eb525c24
...@@ -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.3</version> <version>1.0.4</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>
......
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
*/ */
package fr.ill.ics.mail; 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.LoginManager;
import fr.ill.ics.bridge.command.CommandZoneWrapper; import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.cameo.Application; import fr.ill.ics.cameo.Application;
...@@ -88,9 +94,39 @@ public class MailSender { ...@@ -88,9 +94,39 @@ public class MailSender {
SessionManager.getInstance(CommandZoneWrapper.SERVER_ID).sendCrashMail(mailContent); 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() { 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); ConfigManager.initInstance(null);
SessionManager.getInstance(CommandZoneWrapper.SERVER_ID).setSessionInformation("", "", instrumentName);
String[] cameoArgs = {ConfigManager.getInstance().getServerEndpoint() + ":nomadmail"}; String[] cameoArgs = {ConfigManager.getInstance().getServerEndpoint() + ":nomadmail"};
Application.This.init(cameoArgs); Application.This.init(cameoArgs);
ServerInstance.getInstance().init(); ServerInstance.getInstance().init();
......
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