XMLUtils.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */



  20. package org.openspcoop2.core.eccezione.details.utils;

  21. import java.io.ByteArrayInputStream;
  22. import java.io.ByteArrayOutputStream;
  23. import java.io.File;
  24. import java.io.FileInputStream;
  25. import java.io.InputStream;
  26. import java.io.OutputStream;
  27. import java.text.SimpleDateFormat;
  28. import java.util.Iterator;

  29. import javax.xml.namespace.QName;
  30. import javax.xml.soap.SOAPBody;
  31. import javax.xml.soap.SOAPElement;
  32. import javax.xml.soap.SOAPFault;

  33. import org.openspcoop2.core.eccezione.details.Dettaglio;
  34. import org.openspcoop2.core.eccezione.details.DettaglioEccezione;
  35. import org.openspcoop2.core.eccezione.details.Dominio;
  36. import org.openspcoop2.core.eccezione.details.Eccezione;
  37. import org.openspcoop2.core.eccezione.details.constants.Costanti;
  38. import org.openspcoop2.core.eccezione.details.utils.serializer.JsonJacksonDeserializer;
  39. import org.openspcoop2.message.OpenSPCoop2Message;
  40. import org.openspcoop2.message.OpenSPCoop2MessageFactory;
  41. import org.openspcoop2.message.OpenSPCoop2RestJsonMessage;
  42. import org.openspcoop2.message.OpenSPCoop2RestXmlMessage;
  43. import org.openspcoop2.message.OpenSPCoop2SoapMessage;
  44. import org.openspcoop2.message.xml.ValidatoreXSD;
  45. import org.openspcoop2.utils.beans.WriteToSerializerType;
  46. import org.openspcoop2.utils.date.DateUtils;
  47. import org.slf4j.Logger;
  48. import org.w3c.dom.Document;
  49. import org.w3c.dom.Element;
  50. import org.w3c.dom.Node;


  51. /**
  52.  * Classe utilizzata per la generazione degli element Details inseriti in un SOAPFault generato dalla PdD in caso di errore di processamento
  53.  *
  54.  *
  55.  * @author Poli Andrea (apoli@link.it)
  56.  * @author $Author$
  57.  * @version $Rev$, $Date$
  58.  */

  59. public class XMLUtils  {

  60.     /** Validatore XSD */
  61.     static ValidatoreXSD validatoreXSD = null;
  62.     private static synchronized void initValidatoreXSD(Logger log) throws Exception{
  63.         if(XMLUtils.validatoreXSD==null){
  64.             XMLUtils.validatoreXSD = new ValidatoreXSD(OpenSPCoop2MessageFactory.getDefaultMessageFactory(), log,XMLUtils.class.getResourceAsStream("/openspcoopDetail.xsd"));
  65.         }
  66.     }
  67.     public static ValidatoreXSD getValidatoreXSD(Logger log) throws Exception{
  68.         if(XMLUtils.validatoreXSD==null){
  69.             initValidatoreXSD(log);
  70.         }
  71.         return XMLUtils.validatoreXSD;
  72.     }
  73.     public static boolean validate(DettaglioEccezione eccezione,StringBuilder motivoErroreValidazione){
  74.        
  75.         int size = motivoErroreValidazione.length();
  76.        
  77.         if(eccezione.getDomain()==null){
  78.             motivoErroreValidazione.append("Dominio non definito\n");
  79.         }
  80.         else{
  81.             validate(eccezione.getDomain(), motivoErroreValidazione);
  82.         }
  83.        
  84.         if(eccezione.getTimestamp()==null){
  85.             motivoErroreValidazione.append("OraRegistrazione non definita\n");
  86.         }

  87.         if(eccezione.getExceptions()==null){
  88.             motivoErroreValidazione.append("Nessuna eccezione definita\n");
  89.         }else{
  90.             if(eccezione.getExceptions().sizeExceptionList()<=0){
  91.                 motivoErroreValidazione.append("Nessuna eccezione definita\n");
  92.             }
  93.             else{
  94.                 for (int i = 0; i < eccezione.getExceptions().sizeExceptionList(); i++) {
  95.                     Eccezione ecc = eccezione.getExceptions().getException(i);
  96.                     if(ecc.getCode()==null){
  97.                         motivoErroreValidazione.append("Eccezione.codice non definito\n");
  98.                     }
  99.                     if(ecc.getDescription()==null){
  100.                         motivoErroreValidazione.append("Eccezione.codice non definito\n");
  101.                     }
  102.                     if(ecc.getType()==null){
  103.                         motivoErroreValidazione.append("Eccezione.tipo non definito\n");
  104.                     }
  105.                 }
  106.             }
  107.         }
  108.         if(eccezione.getDetails()!=null){
  109.             if(eccezione.getDetails().sizeDetailList()>0){
  110.                 for (int i = 0; i < eccezione.getDetails().sizeDetailList(); i++) {
  111.                     Dettaglio detail = eccezione.getDetails().getDetail(i);
  112.                     if(detail==null){
  113.                         motivoErroreValidazione.append("Detail presente e non definito??\n");
  114.                     }
  115.                     else{
  116.                         if(detail.getType()==null){
  117.                             motivoErroreValidazione.append("Detail["+i+"].tipo non definito\n");
  118.                         }
  119.                         if(detail.getBase()==null){
  120.                             motivoErroreValidazione.append("Detail["+i+"].tipo non definito\n");
  121.                         }
  122.                     }
  123.                 }
  124.             }
  125.         }
  126.        
  127.         if(motivoErroreValidazione.length()!=size)
  128.             return false;
  129.         else
  130.             return true;

  131.     }
  132.     private static void validate(Dominio dominio,StringBuilder motivoErroreValidazione){
  133.         if(dominio.getId()==null){
  134.             motivoErroreValidazione.append("Dominio.identificativoPorta non definito\n");
  135.         }
  136.         if(dominio.getRole()==null){
  137.             motivoErroreValidazione.append("Dominio.funzione non definito\n");
  138.         }
  139.         if(dominio.getModule()==null){
  140.             motivoErroreValidazione.append("Dominio.modulo non definito\n");
  141.         }
  142.         if(dominio.getOrganization()==null){
  143.             motivoErroreValidazione.append("Dominio.soggetto non definita\n");
  144.         }
  145.         else{
  146.             if(dominio.getOrganization().getType()==null){
  147.                 motivoErroreValidazione.append("Dominio.soggetto.tipo non definita\n");
  148.             }
  149.             if(dominio.getOrganization().getBase()==null){
  150.                 motivoErroreValidazione.append("Dominio.soggetto.nome non definita\n");
  151.             }
  152.         }
  153.     }
  154.    
  155.    
  156.    
  157.     /* ----- Unmarshall ----- */
  158.    
  159.     /**
  160.      * Ritorna la rappresentazione java
  161.      *
  162.      * @param m byte[]
  163.      * @return DettaglioEccezione
  164.      * @throws XMLUtilsException
  165.      */
  166.     public static DettaglioEccezione getDettaglioEccezione(Logger log,byte[] m) throws XMLUtilsException{
  167.         ByteArrayInputStream bin = null;
  168.         try{
  169.             bin = new ByteArrayInputStream(m);
  170.             return XMLUtils.getDettaglioEccezione(log,bin);
  171.         }catch(Exception e){
  172.             throw new XMLUtilsException(e.getMessage(),e);
  173.         }finally{
  174.             try{
  175.                 if(bin!=null)
  176.                     bin.close();
  177.             }catch(Exception eClose){
  178.                 // close
  179.             }
  180.         }
  181.     }
  182.    
  183.     /**
  184.      * Ritorna la rappresentazione java
  185.      *
  186.      * @param m File
  187.      * @return DettaglioEccezione
  188.      * @throws XMLUtilsException
  189.      */
  190.     public static DettaglioEccezione getDettaglioEccezione(Logger log,File m) throws XMLUtilsException{
  191.         FileInputStream fin = null;
  192.         try{
  193.             fin = new FileInputStream(m);
  194.             return XMLUtils.getDettaglioEccezione(log,fin);
  195.         }catch(Exception e){
  196.             throw new XMLUtilsException(e.getMessage(),e);
  197.         }finally{
  198.             try{
  199.                 if(fin!=null)
  200.                     fin.close();
  201.             }catch(Exception eClose){
  202.                 // close
  203.             }
  204.         }
  205.     }
  206.    
  207.     /**
  208.      * Ritorna la rappresentazione java
  209.      *
  210.      * @param m String
  211.      * @return DettaglioEccezione
  212.      * @throws XMLUtilsException
  213.      */
  214.     public static DettaglioEccezione getDettaglioEccezione(Logger log,String m) throws XMLUtilsException{
  215.         return XMLUtils.getDettaglioEccezione(log,m.getBytes());
  216.     }
  217.    
  218.     /**
  219.      * Ritorna la rappresentazione java
  220.      *
  221.      * @param m InputStream
  222.      * @return DettaglioEccezione
  223.      * @throws XMLUtilsException
  224.      */
  225.     public static DettaglioEccezione getDettaglioEccezione(Logger log,InputStream m) throws XMLUtilsException{
  226.         try{
  227.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  228.             byte[]reads = new byte[1024];
  229.             int letti = 0;
  230.             while( (letti=m.read(reads)) != -1){
  231.                 bout.write(reads, 0, letti);
  232.             }
  233.             bout.flush();
  234.             bout.close();
  235.             byte [] xml = bout.toByteArray();
  236.            
  237.             // Validazione XSD
  238.             ByteArrayInputStream binValidazione = new ByteArrayInputStream(xml);
  239.             ValidatoreXSD validatoreXSD = XMLUtils.getValidatoreXSD(log);
  240.             validatoreXSD.valida(binValidazione);
  241.            
  242.             // trasformazione in oggetto DettaglioEccezione
  243.             ByteArrayInputStream binTrasformazione = new ByteArrayInputStream(xml);
  244.             return (DettaglioEccezione) org.openspcoop2.utils.xml.JaxbUtils.xmlToObj(binTrasformazione, DettaglioEccezione.class);
  245.            
  246.         }catch(Exception e){
  247.             throw new XMLUtilsException(e.getMessage(),e);
  248.         }
  249.     }

  250.     public static DettaglioEccezione getDettaglioEccezioneFromJson(Logger log,InputStream is) throws XMLUtilsException{
  251.         try{            
  252.             JsonJacksonDeserializer deserializer = new JsonJacksonDeserializer();
  253.             return deserializer.readDettaglioEccezione(is);
  254.         }catch(Exception e){
  255.             throw new XMLUtilsException(e.getMessage(),e);
  256.         }
  257.     }
  258.    
  259.    
  260.    
  261.    
  262.     /* ----- Marshall ----- */
  263.     public static void generateDettaglioEccezione(DettaglioEccezione eccezione,File out) throws XMLUtilsException{
  264.         try{
  265.             StringBuilder risultatoValidazione = new StringBuilder();
  266.             if(XMLUtils.validate(eccezione, risultatoValidazione)==false){
  267.                 throw new Exception(risultatoValidazione.toString());
  268.             }
  269.             org.openspcoop2.utils.xml.JaxbUtils.objToXml(out.getName(),XMLUtils.generateDettaglioEccezione_engine(eccezione));
  270.         }catch(Exception e){
  271.             throw new XMLUtilsException(e.getMessage(),e);
  272.         }
  273.     }
  274.    
  275.     public static void generateDettaglioEccezione(DettaglioEccezione eccezione,String fileName) throws XMLUtilsException{
  276.         try{
  277.             StringBuilder risultatoValidazione = new StringBuilder();
  278.             if(XMLUtils.validate(eccezione, risultatoValidazione)==false){
  279.                 throw new Exception(risultatoValidazione.toString());
  280.             }
  281.             org.openspcoop2.utils.xml.JaxbUtils.objToXml(fileName,XMLUtils.generateDettaglioEccezione_engine(eccezione));
  282.         }catch(Exception e){
  283.             throw new XMLUtilsException(e.getMessage(),e);
  284.         }
  285.     }
  286.    
  287.     public static byte[] generateDettaglioEccezione(DettaglioEccezione eccezione) throws XMLUtilsException{
  288.         try{
  289.             StringBuilder risultatoValidazione = new StringBuilder();
  290.             if(XMLUtils.validate(eccezione, risultatoValidazione)==false){
  291.                 throw new Exception(risultatoValidazione.toString());
  292.             }
  293.             return XMLUtils.generateDettaglioEccezione_engine(eccezione);
  294.         }catch(Exception e){
  295.             throw new XMLUtilsException(e.getMessage(),e);
  296.         }
  297.     }

  298.     public static void generateDettaglioEccezione(DettaglioEccezione eccezione,OutputStream out) throws XMLUtilsException{
  299.         try{
  300.             StringBuilder risultatoValidazione = new StringBuilder();
  301.             if(XMLUtils.validate(eccezione, risultatoValidazione)==false){
  302.                 throw new Exception(risultatoValidazione.toString());
  303.             }
  304.             out.write(XMLUtils.generateDettaglioEccezione_engine(eccezione));
  305.             out.flush();
  306.             out.close();
  307.         }catch(Exception e){
  308.             throw new XMLUtilsException(e.getMessage(),e);
  309.         }
  310.     }
  311.    
  312.     public static String generateDettaglioEccezioneAsJson(DettaglioEccezione eccezione) throws XMLUtilsException{
  313.         try{
  314.             StringBuilder risultatoValidazione = new StringBuilder();
  315.             if(XMLUtils.validate(eccezione, risultatoValidazione)==false){
  316.                 throw new Exception(risultatoValidazione.toString());
  317.             }
  318.             return XMLUtils.generateDettaglioEccezioneAsJson_engine(eccezione);
  319.         }catch(Exception e){
  320.             throw new XMLUtilsException(e.getMessage(),e);
  321.         }
  322.     }
  323.    
  324.     private static byte[] generateDettaglioEccezione_engine(DettaglioEccezione eccezione) throws XMLUtilsException{
  325.         try{
  326.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  327.             org.openspcoop2.utils.xml.JaxbUtils.objToXml(bout, DettaglioEccezione.class, eccezione);
  328.             byte[] dichiarazione = bout.toByteArray();
  329.             return dichiarazione;
  330.         }catch(Exception e){
  331.             throw new XMLUtilsException(e.getMessage(),e);
  332.         }
  333.     }
  334.    
  335.     private static String generateDettaglioEccezioneAsJson_engine(DettaglioEccezione eccezione) throws XMLUtilsException{
  336.         try{
  337.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  338.             eccezione.writeTo(bout, WriteToSerializerType.JSON_JACKSON);
  339.             bout.flush();
  340.             bout.close();
  341.             return bout.toString();
  342.         }catch(Exception e){
  343.             throw new XMLUtilsException(e.getMessage(),e);
  344.         }
  345.     }
  346.    
  347.    
  348.     public static DettaglioEccezione getDettaglioEccezione(Logger log,OpenSPCoop2Message msg)throws XMLUtilsException{
  349.         switch (msg.getMessageType()) {
  350.         case SOAP_11:
  351.         case SOAP_12:
  352.             try{
  353.                 return getDettaglioEccezione(log, msg.castAsSoap());
  354.             }catch(XMLUtilsException e){
  355.                 throw e;
  356.             }catch(Exception e){
  357.                 throw new XMLUtilsException(e.getMessage(),e);
  358.             }
  359.         case XML:
  360.             try{
  361.                 OpenSPCoop2RestXmlMessage rest = msg.castAsRestXml();
  362.                 if(rest.hasContent()){
  363.                     Element element = rest.getContent();
  364.                     if(XMLUtils.isDettaglioEccezione(element)){
  365.                         org.openspcoop2.message.xml.MessageXMLUtils xmlUtils = org.openspcoop2.message.xml.MessageXMLUtils.DEFAULT;
  366.                         byte [] xml = xmlUtils.toByteArray(element);
  367.                         //System.out.println("XML S: "+new String(xml));
  368.                         DettaglioEccezione de = XMLUtils.getDettaglioEccezione(log,xml);
  369.                         return de;
  370.                     }
  371.                 }
  372.                 return null;
  373.             }catch(XMLUtilsException e){
  374.                 throw e;
  375.             }catch(Exception e){
  376.                 throw new XMLUtilsException(e.getMessage(),e);
  377.             }
  378.         case JSON:
  379.             try{
  380.                 OpenSPCoop2RestJsonMessage rest = msg.castAsRestJson();
  381.                 if(rest.hasContent()){
  382.                     String json = rest.getContent();
  383.                     try{
  384.                         DettaglioEccezione de = XMLUtils.getDettaglioEccezioneFromJson(log, new ByteArrayInputStream(json.getBytes()));
  385.                         return de;
  386.                     }catch(Exception e){}
  387.                 }
  388.                 return null;
  389.             }catch(Exception e){
  390.                 throw new XMLUtilsException(e.getMessage(),e);
  391.             }
  392.         default:
  393.             return null;
  394.         }
  395.     }
  396.     public static DettaglioEccezione getDettaglioEccezione(Logger log,OpenSPCoop2SoapMessage msg)throws XMLUtilsException{
  397.         try{
  398.             if(msg==null)
  399.                 throw new XMLUtilsException("Messaggio non presente");
  400.             SOAPBody soapBody = msg.getSOAPBody();
  401.             if(soapBody==null)
  402.                 throw new XMLUtilsException("SOAPBody non presente");
  403.             SOAPFault faultOriginale = null;
  404.             if(soapBody.hasFault()==false)
  405.                 return null; // casi di buste mal formate, verranno segnalate dal validatore
  406.             else
  407.                 faultOriginale = soapBody.getFault();
  408.             if(faultOriginale==null)
  409.                 throw new XMLUtilsException("SOAPFault is null");
  410.            
  411.             QName nameDetail = new QName("detail");
  412.             Iterator<?> itSF = faultOriginale.getChildElements(nameDetail);
  413.             SOAPElement detailsFaultOriginale = null;
  414.             if(itSF.hasNext()){
  415.                 detailsFaultOriginale = (SOAPElement) itSF.next();
  416.             }
  417.                
  418.             msg.saveChanges();
  419.                
  420.             if(detailsFaultOriginale!=null){
  421.                 Iterator<?> it = detailsFaultOriginale.getChildElements();
  422.                 while (it.hasNext()) {
  423.                     Object o = it.next();
  424.                     if(o instanceof SOAPElement){
  425.                         SOAPElement elem = (SOAPElement) o;
  426.                         try{
  427.                             if(XMLUtils.isDettaglioEccezione(elem)){
  428.                                 //System.out.println("ITEM ["+elem.getLocalName()+"] TROVATO");
  429.                                 org.openspcoop2.message.xml.MessageXMLUtils xmlUtils = org.openspcoop2.message.xml.MessageXMLUtils.DEFAULT;
  430.                                 byte [] xml = xmlUtils.toByteArray(elem);
  431.                                 //System.out.println("XML S: "+new String(xml));
  432.                                 DettaglioEccezione de = XMLUtils.getDettaglioEccezione(log,xml);
  433.                                 return de;
  434.                             }
  435.                         }catch(Exception e){
  436.                             e.printStackTrace(System.out);
  437.                         }
  438.                     }
  439.                 }
  440.             }
  441.                
  442.             return null;
  443.         }catch(Exception e){
  444.             throw new XMLUtilsException(e.getMessage(),e);
  445.         }
  446.     }
  447.    
  448.     public static boolean isDettaglioEccezione(byte [] doc){
  449.         try{
  450.             org.openspcoop2.message.xml.MessageXMLUtils xmlUtils = org.openspcoop2.message.xml.MessageXMLUtils.DEFAULT;
  451.             Document docXML = xmlUtils.newDocument(doc);
  452.             Element elemXML = docXML.getDocumentElement();
  453.             return XMLUtils.isDettaglioEccezione_engine(elemXML);
  454.         }catch(Exception e){
  455.             //System.out.println("NON e' un DOCUMENTO VALIDO: "+e.getMessage());
  456.             return false;
  457.         }
  458.     }
  459.     public static boolean isDettaglioEccezione(Document docXML){
  460.         try{
  461.             Element elemXML = docXML.getDocumentElement();
  462.             return XMLUtils.isDettaglioEccezione_engine(elemXML);
  463.         }catch(Exception e){
  464.             //System.out.println("NON e' un DOCUMENTO VALIDO: "+e.getMessage());
  465.             return false;
  466.         }
  467.     }
  468.     public static boolean isDettaglioEccezione(Element elemXML){
  469.         return isDettaglioEccezione_engine(elemXML);
  470.     }
  471.     public static boolean isDettaglioEccezione(Node nodeXml){
  472.         return isDettaglioEccezione_engine(nodeXml);
  473.     }
  474.     private static boolean isDettaglioEccezione_engine(Node nodeXml){
  475.         try{
  476.             //System.out.println("LOCAL["+Costanti.ROOT_LOCAL_NAME_DETTAGLIO_ECCEZIONE+"]vs["+elemXML.getLocalName()+"]  NAMESPACE["+Costanti.TARGET_NAMESPACE+"]vs["+elemXML.getNamespaceURI()+"]");
  477.             if(Costanti.ROOT_LOCAL_NAME_DETTAGLIO_ECCEZIONE.equals(nodeXml.getLocalName()) &&
  478.                     Costanti.TARGET_NAMESPACE.equals(nodeXml.getNamespaceURI() )
  479.                 ){
  480.                 return true;
  481.             }
  482.             else{
  483.                 return false;
  484.             }
  485.         }catch(Exception e){
  486.             //System.out.println("NON e' un DOCUMENTO VALIDO: "+e.getMessage());
  487.             return false;
  488.         }
  489.     }
  490.    
  491.    

  492.    
  493.    
  494.    
  495.    
  496.     public static String toString(DettaglioEccezione de){
  497.         StringBuilder bf = new StringBuilder();
  498.         if(de!=null){
  499.            
  500.             if(de.getTimestamp()!=null){
  501.                 SimpleDateFormat dateformat = DateUtils.getSimpleDateFormatMs();
  502.                 bf.append("("+dateformat.format(de.getTimestamp())+")");
  503.             }
  504.            
  505.             if(de.getDomain()!=null){
  506.                
  507.                 bf.append(" ");
  508.                
  509.                 boolean writeSoggetto = false;
  510.                 if(de.getDomain().getId()!=null){
  511.                     bf.append(de.getDomain().getId());
  512.                     writeSoggetto = true;
  513.                     if(de.getDomain().getOrganization()!=null){
  514.                         bf.append(".");
  515.                     }
  516.                 }
  517.                
  518.                 if(de.getDomain().getOrganization()!=null){
  519.                     bf.append(de.getDomain().getOrganization().getType()+"/"+de.getDomain().getOrganization().getBase());
  520.                     writeSoggetto = true;
  521.                 }
  522.                
  523.                 if(de.getDomain().getRole()!=null || de.getDomain().getModule()!=null){
  524.                     if(writeSoggetto){
  525.                         bf.append(" ");
  526.                     }
  527.                 }
  528.                
  529.                 if(de.getDomain().getRole()!=null){
  530.                     bf.append(de.getDomain().getRole());
  531.                     if(de.getDomain().getModule()!=null){
  532.                         bf.append(".");
  533.                     }
  534.                 }
  535.                 if(de.getDomain().getModule()!=null){
  536.                     bf.append(de.getDomain().getModule());
  537.                 }
  538.             }
  539.            
  540.            
  541.             if(bf.length()>0){
  542.                 bf.append(" ");
  543.             }
  544.            
  545.             int sizeEccezioni = 0;
  546.             if(de.getExceptions()!=null){
  547.                 sizeEccezioni = de.getExceptions().sizeExceptionList();
  548.             }
  549.            
  550.             int sizeDettagli = 0;
  551.             if(de.getDetails()!=null){
  552.                 sizeDettagli = de.getDetails().sizeDetailList();
  553.             }
  554.            
  555.             bf.append("ha rilevato "+sizeEccezioni+" eccezione/i (dettagli:"+sizeDettagli+")");
  556.             for(int k=0; k<sizeEccezioni;k++){
  557.                 bf.append("\n- Eccezione ("+de.getExceptions().getException(k).getType()+") ["+de.getExceptions().getException(k).getCode()+"] "+de.getExceptions().getException(k).getDescription());
  558.             }
  559.             if(sizeDettagli>0){
  560.                 for(int k=0; k<sizeDettagli;k++){
  561.                     bf.append("\n- Dettaglio ["+de.getDetails().getDetail(k).getType()+"] "+de.getDetails().getDetail(k).getBase());
  562.                 }
  563.             }
  564.         }
  565.         return bf.toString();
  566.     }
  567. }