Commit ed418e25 authored by legoc's avatar legoc
Browse files

Mail sender by Nomad server implemented

parent a5ecc34b
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
/bin
/target/
/.settings/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>NomadMail</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
-Djava.library.path=/usr/lib:/usr/lib/x86_64-linux-gnu/jni -Djava.util.logging.config.file=conf/client/logging.properties -jar
#!/bin/sh
java -Djava.library.path=/usr/lib:/usr/lib/x86_64-linux-gnu/jni -Djava.util.logging.config.file=conf/client/logging.properties -jar ./target/nomadmail-1.0.0-full.jar $1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadmail</artifactId>
<version>1.0.0</version>
<name>NomadMail</name>
<description>Helper application to use Nomad server to send mails from VMs</description>
<distributionManagement>
<repository>
<id>ill-repo</id>
<name>The ILL Maven Repository</name>
<url>https://maven.ill.fr/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>ill-repo</id>
<name>The ILL Maven Repository</name>
<url>https://maven.ill.fr/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>ill-repo-thirdparty</id>
<url>https://maven.ill.fr/content/repositories/thirdparty</url>
</repository>
<repository>
<id>ill-repo-releases</id>
<url>https://maven.ill.fr/content/repositories/releases</url>
</repository>
<repository>
<id>ill-repo-snapshots</id>
<url>https://maven.ill.fr/content/repositories/snapshots</url>
</repository>
<repository>
<id>ill-repo-eclipse</id>
<url>https://maven.ill.fr/content/repositories/eclipse</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId>
<version>4.0.20-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Force the compilation with 1.8 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fr.ill.ics.mail.MailSender</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Build-Timestamp>${maven.build.timestamp}</Build-Timestamp>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>nomadmail-${project.version}-full</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.mail;
import fr.ill.ics.bridge.LoginManager;
import fr.ill.ics.bridge.LoginManager.ClientAlreadyLaunchedException;
import fr.ill.ics.bridge.LoginManager.ConnectionFailure;
import fr.ill.ics.bridge.LoginManager.LoginIncorrectException;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.nscclient.serverconnection.ServerConnection;
import fr.ill.ics.nscclient.serverconnection.ServerInstance;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager;
import fr.ill.ics.util.ConfigManager;
import fr.ill.ics.util.exception.ExitException;
public class MailSender {
private String mailContent;
public static void main(String[] args) {
int exitCode = 0;
try {
MailSender sender = new MailSender();
sender.init(args);
sender.run();
} catch (ExitException e) {
System.out.println("Exit exception");
exitCode = e.getExitCode();
} catch (Throwable e) {
System.out.println("Unexpected exception");
e.printStackTrace();
} finally {
ServerConnection.getInstance(CommandZoneWrapper.SERVER_ID).reset();
System.out.println("Resetting Cameo application");
CommandZoneWrapper.getInstance(CommandZoneWrapper.SERVER_ID).release();
LoginManager.getInstance().logout(CommandZoneWrapper.SERVER_ID);
System.out.println("Terminating Cameo application");
Application.This.terminate();
System.out.println("Terminated Cameo application");
}
System.out.println("Exiting with code " + exitCode);
// Get out with exit code.
System.exit(exitCode);
}
private void init(String[] args) {
if (args != null && args.length < 1) {
System.err.println("Wrong number of arguments, usage is: nomadmail <mail content>");
System.exit(1);
}
boolean serverOk = connectToNomadServer();
if (!serverOk) {
System.exit(1);
}
try {
LoginManager.getInstance().login("mail", true, CommandZoneWrapper.SERVER_ID);
} catch (Exception e) {
System.err.println("Error in login");
e.printStackTrace();
System.exit(1);
}
mailContent = args[0];
}
private void run() {
System.out.println("Sending " + mailContent);
SessionManager.getInstance(CommandZoneWrapper.SERVER_ID).sendCrashMail(mailContent);
}
private boolean connectToNomadServer() {
ConfigManager.initInstance(null);
String[] cameoArgs = {ConfigManager.getInstance().getServerEndpoint() + ":nomadmail"};
Application.This.init(cameoArgs);
ServerInstance.getInstance().init();
return true;
}
}
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