import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
+import java.io.IOException;
+import java.util.logging.FileHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
/**
* Client assez generique pour i-Parapheur.
* But: deposer simplement des dossiers en validation dans i-Parapheur.
*/
public class PusherDeDoc {
+ static String logFilePath = "ClientParapheur.log";
static String ECHO_STRING = "Hello i-Parapheur, I am the gentle bot.";
static ProxyParapheur proxy;
static ConfigLoader configLoader;
public static void main( String[] args ){
+ // ##### Creation du log
+ Logger logger;
+ logger = Logger.getLogger("LogTout");
+
+ try {
+ FileHandler fh = new FileHandler(logFilePath);
+ logger.addHandler(fh);
+ logger.setUseParentHandlers(false);
+ fh.setFormatter(new FormatterPerso());
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ logger.log(Level.INFO, "Version: 1.4 , build 2014-11-21");
+
MesOptions options = new MesOptions();
CmdLineParser parser = new CmdLineParser(options);
System.out.println("Probleme sur les parametres, cause: " + e.getLocalizedMessage());
parser.setUsageWidth(80);
parser.printUsage(System.out);
+ logger.log(Level.ALL, "Probleme sur les parametres, cause: {0}", e.getLocalizedMessage());
return;
}
configLoader.getKeyStorePass());
// ##### SANITY CHECK
- if (!ProxyParapheur.appelEcho(ECHO_STRING).contains(ECHO_STRING))
+ logger.log(Level.INFO, "Appel d'echo vers i-Parapheur...");
+ if (!ProxyParapheur.appelEcho(ECHO_STRING).contains(ECHO_STRING)) {
+ logger.log(Level.INFO, "Connexion impossible vers i-Parapheur, attention au contenu du fichier de configuration");
System.out.println("Connexion impossible vers i-Parapheur, attention au contenu du fichier de configuration");
-
- if (options.getNomDocPrincipal().trim().isEmpty()) {
- options.setNomDocPrincipal(options.getDocumentPrincipal().getName());
- }
- // ##### Envoi simple du document
- String retour;
- if (options.getNomDocPrincipal().trim().toLowerCase().endsWith(".xml")) {
- retour = ProxyParapheur.appelCreerDossierXML(options.getType(), options.getsType(),
- options.getEmailEmetteur(), options.getIdDossier(),
- options.getDocumentPrincipal().getAbsolutePath(), options.getNomDocPrincipal(),
- options.getDocumentVisu().getAbsolutePath(), options.getxPath(), options.getVisibilite());
}
else {
- retour = ProxyParapheur.appelCreerDossier(options.getType(), options.getsType(), options.getEmailEmetteur(),
- options.getIdDossier(), options.getDocumentPrincipal().getAbsolutePath(),
- options.getNomDocPrincipal(),
- options.getVisibilite());
+ if (options.getNomDocPrincipal().trim().isEmpty()) {
+ options.setNomDocPrincipal(options.getDocumentPrincipal().getName());
+ }
+ // ##### Envoi simple du document
+ String retour;
+ if (options.getNomDocPrincipal().trim().toLowerCase().endsWith(".xml")) {
+ retour = ProxyParapheur.appelCreerDossierXML(options.getType(), options.getsType(),
+ options.getEmailEmetteur(), options.getIdDossier(),
+ options.getDocumentPrincipal().getAbsolutePath(), options.getNomDocPrincipal(),
+ options.getDocumentVisu().getAbsolutePath(), options.getxPath(),
+ options.getVisibilite(), options.getMetaDataJson(),
+ options.getDateLimite());
+ } else {
+ retour = ProxyParapheur.appelCreerDossier(options.getType(), options.getsType(),
+ options.getEmailEmetteur(), options.getIdDossier(),
+ options.getDocumentPrincipal().getAbsolutePath(), options.getNomDocPrincipal(),
+ options.getVisibilite(), options.getMetaDataJson(),
+ options.getDateLimite(), options.getAnnexesJson());
+ }
+ logger.log(Level.ALL, " REPONSE de i-Parapheur: {0}", retour);
+ System.out.println(retour);
}
- System.out.println(retour);
}
}
\ No newline at end of file