InformationMissingUtils.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.protocol.information_missing.utils;

  21. import org.openspcoop2.protocol.information_missing.constants.Costanti;
  22. import org.w3c.dom.Document;
  23. import org.w3c.dom.Element;
  24. import org.w3c.dom.Node;

  25. /**
  26.  *  ConfigurazionePdDUtils
  27.  *
  28.  * @author Poli Andrea (apoli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */
  32. public class InformationMissingUtils {

  33.     public static boolean isInformationMissing(byte [] doc){
  34.         return InformationMissingUtils.isInformationMissing(doc,Costanti.ROOT_LOCAL_NAME_INFORMATION_MISSING);
  35.     }
  36.     public static boolean isInformationMissing(byte [] doc,String localName){
  37.         try{
  38.             org.openspcoop2.message.xml.MessageXMLUtils xmlUtils = org.openspcoop2.message.xml.MessageXMLUtils.DEFAULT;
  39.             Document docXML = xmlUtils.newDocument(doc);
  40.             Element elemXML = docXML.getDocumentElement();
  41.             return InformationMissingUtils.isInformationMissing_engine(elemXML,localName);
  42.         }catch(Exception e){
  43.             //System.out.println("NON e' un DOCUMENTO VALIDO: "+e.getMessage());
  44.             return false;
  45.         }
  46.     }
  47.     public static boolean isInformationMissing(Document docXML){
  48.         return InformationMissingUtils.isInformationMissing(docXML,Costanti.ROOT_LOCAL_NAME_INFORMATION_MISSING);
  49.     }
  50.     public static boolean isInformationMissing(Document docXML,String localName){
  51.         try{
  52.             Element elemXML = docXML.getDocumentElement();
  53.             return InformationMissingUtils.isInformationMissing_engine(elemXML,localName);
  54.         }catch(Exception e){
  55.             //System.out.println("NON e' un DOCUMENTO VALIDO: "+e.getMessage());
  56.             return false;
  57.         }
  58.     }
  59.     public static boolean isInformationMissing(Element elemXML,String localName){
  60.         return isInformationMissing_engine(elemXML,localName);
  61.     }
  62.     public static boolean isInformationMissing(Node nodeXml,String localName){
  63.         return isInformationMissing_engine(nodeXml,localName);
  64.     }
  65.     private static boolean isInformationMissing_engine(Node nodeXml,String localName){
  66.         try{
  67.             //System.out.println("LOCAL["+Costanti.ROOT_LOCAL_NAME_INFORMATION_MISSING+"]vs["+elemXML.getLocalName()+"]  NAMESPACE["+Costanti.TARGET_NAMESPACE+"]vs["+elemXML.getNamespaceURI()+"]");
  68.             if(localName.equals(nodeXml.getLocalName()) &&
  69.                     Costanti.TARGET_NAMESPACE.equals(nodeXml.getNamespaceURI() )
  70.                 ){
  71.                 return true;
  72.             }
  73.             else{
  74.                 return false;
  75.             }
  76.         }catch(Exception e){
  77.             //System.out.println("NON e' un DOCUMENTO VALIDO: "+e.getMessage());
  78.             return false;
  79.         }
  80.     }
  81.    
  82. }