/**
* Copyright 2012-2013 Nicolas LE GRAND
- * Copyright 2013-2015 Stephane Vast - Adullact Projet
+ * Copyright 2013-2016 Stephane Vast - Adullact Projet
*
* This file is part of PushDocParapheur.
*
*/
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.getLogger("LogTout");
try {
+ String logFilePath = "ClientParapheur.log";
FileHandler fh = new FileHandler(logFilePath);
logger.addHandler(fh);
logger.setUseParentHandlers(false);
}
// ##### Chargement de la configuration
- configLoader = new ConfigLoader(options.getConfFile().getAbsolutePath());
+ ConfigLoader configLoader = new ConfigLoader(options.getConfFile().getAbsolutePath());
- // ##### Initialisation du proxy java
- proxy = new ProxyParapheur(configLoader.getEndPoint(),
+ // ##### Initialisation du proxy java vers i-Parapheur.
+ ProxyParapheur proxy = new ProxyParapheur(configLoader.getEndPoint(),
configLoader.getUser(),
configLoader.getPass(),
configLoader.getTrustStorePath(),
// ##### SANITY CHECK
logger.log(Level.INFO, "Appel d'echo vers i-Parapheur...");
- if (!ProxyParapheur.appelEcho(ECHO_STRING).contains(ECHO_STRING)) {
+ String ECHO_STRING = "Hello i-Parapheur, I am the gentle bot.";
+ if (!proxy.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");
}
/**
* cas particulier de fichier XML: quelques paramètres en plus
*/
- retour = ProxyParapheur.appelCreerDossierXML(options.getType(), options.getsType(),
- options.getEmailEmetteur(), options.getIdDossier(), options.getNomDossier(),
- options.getDocumentPrincipal().getAbsolutePath(), options.getNomDocPrincipal(),
- options.getDocumentVisu().getAbsolutePath(), options.getxPath(),
- options.getVisibilite(), options.getMetaDataJson(),
- options.getDateLimite());
+ try {
+ retour = ProxyParapheur.appelCreerDossierXML(options.getType(), options.getsType(),
+ options.getEmailEmetteur(), options.getIdDossier(), options.getNomDossier(),
+ options.getDocumentPrincipal().getAbsolutePath(), options.getNomDocPrincipal(),
+ options.getDocumentVisu().getAbsolutePath(), options.getxPath(),
+ options.getVisibilite(), options.getMetaDataJson(),
+ options.getDateLimite());
+ } catch (Exception e) {
+ logger.log(Level.WARNING, e.getLocalizedMessage());
+ e.printStackTrace();
+ retour="--vide--";
+ }
} else {
- retour = ProxyParapheur.appelCreerDossier(options.getType(), options.getsType(),
- options.getEmailEmetteur(), options.getIdDossier(), options.getNomDossier(),
- options.getDocumentPrincipal().getAbsolutePath(),
- options.getNomDocPrincipal(), options.getVisibilite(),
- options.getMetaDataJson(), options.getDateLimite(), options.getAnnexesJson());
+ if (options.getUtilisateur()!=null && !options.getUtilisateur().isEmpty()) {
+ if (!ProxyParapheur.isUtilisateurExiste(options.getUtilisateur())) {
+ logger.log(Level.WARNING, " Echec, le parametre utilisateur est inexistant dans i-Parapheur.");
+ System.out.println("Echec, le parametre utilisateur est inexistant dans i-Parapheur.");
+ return;
+ }
+ }
+ try {
+ retour = ProxyParapheur.appelCreerDossier(options.getType(), options.getsType(),
+ options.getEmailEmetteur(), options.getIdDossier(), options.getNomDossier(),
+ options.getDocumentPrincipal().getAbsolutePath(),
+ options.getNomDocPrincipal(), options.getVisibilite(),options.getMetaDataJson(),
+ options.getDateLimite(), options.getAnnexesJson(), options.getUtilisateur());
+ } catch (Exception e) {
+ logger.log(Level.WARNING, e.getLocalizedMessage());
+ e.printStackTrace();
+ retour="--vide--";
+ }
}
logger.log(Level.INFO, " REPONSE de i-Parapheur: {0}", retour);
System.out.println(retour);