import org.xml.sax.SAXParseException
import org.lilie.services.eliot.textes.impression.template.htmldocbook.FeuillesDeStyle
+import javax.xml.parsers.DocumentBuilderFactory
+import javax.xml.parsers.DocumentBuilder
+import org.xml.sax.InputSource
+import org.w3c.dom.Document
+import java.util.regex.Pattern
+import java.util.regex.Matcher
+
/**
* Gestion des template permetant de générer du docbook.
* @author othe
* doit correspondre à ce qu'attend le modele
* @return un string contenant un fichier docbook
*/
- public String render(String template, Map model) {
+ public String render(String template, Map model) throws Exception{
ajouteTransformationHtml(model)
} catch (TemplateException e) {
throw new IllegalStateException(
"Erreur au traitement du template freemarker", e)
+ } catch (Throwable e){
+ Pattern TAG_REGEX = Pattern.compile("<title role=\"activite\">(.+?)</title>");
+ final List<String> tagValues = new ArrayList<String>();
+ final Matcher matcher = TAG_REGEX.matcher(out.toString());
+ while (matcher.find()) {
+ tagValues.add(matcher.group(1));
+ }
+ if (tagValues.size() > 0){
+ throw new IllegalStateException(
+ """L'impression n'a pas pu aboutir. Cela peut être dû au contenu du champ 'Description' de l'activité :""" + tagValues.get(tagValues.size() - 1), e)
+ } else {
+ throw new IllegalStateException(
+ """L'impression n'a pas pu aboutir""", e)
+ }
+
}
String resultat = corrigeDocbook(out.toString())