Package it.unina.seclab.jafimon.exceptions

Examples of it.unina.seclab.jafimon.exceptions.InvalidConfigurationFileException


     
      // Controllo che sia giusto
      if (! root.getTagName().equalsIgnoreCase(XML_ROOT_ELEMENT_NAME)) {
        logger.error("Root element is \"" + root.getTagName() + "\" should be \"" + XML_ROOT_ELEMENT_NAME + "\"");
        res = null;
        throw new InvalidConfigurationFileException("Root element is \"" + root.getTagName() + "\" should be \"" + XML_ROOT_ELEMENT_NAME + "\"");
      }
     
      // Controllo la versione
      try {
        cfgVer = Double.parseDouble(root.getAttribute(XML_ROOT_ATTRIBUTE_VERSION_NAME));
        if (cfgVer > MAX_SUPPORTED_VERSION) {
          res = null;
          logger.error("Configuration version is not supported. Max supported version is " + MAX_SUPPORTED_VERSION + ". Found " + cfgVer);
          throw new InvalidConfigurationFileException("Configuration version is not supported. Max supported version is " + MAX_SUPPORTED_VERSION + ". Found " + cfgVer);
        }
      } catch (NumberFormatException nfe) {
        logger.error("Attribute \"" + XML_ROOT_ATTRIBUTE_VERSION_NAME + "\" for root element has invalid value. Max supported version is " + MAX_SUPPORTED_VERSION);
        res = null;
        throw new InvalidConfigurationFileException("Attribute \"" + XML_ROOT_ATTRIBUTE_VERSION_NAME + "\" for root element has invalid value. Max supported version is " + MAX_SUPPORTED_VERSION);
      }
     
      // Verifico i nodi
      if (root.getElementsByTagName(MONITOR_ELEMENT_NAME).getLength() <= 0) {
        res = null;
        logger.error("Configuration file is invalid. \"" + MONITOR_ELEMENT_NAME + "\" element not found");
        throw new InvalidConfigurationFileException("Configuration file is invalid. \"" + MONITOR_ELEMENT_NAME + "\" element not found");
      } else
        logger.debug("Found \"" + MONITOR_ELEMENT_NAME + "\" element");
     
      if (root.getElementsByTagName(INJECTOR_ELEMENT_NAME).getLength() <= 0) {
        res = null;
        logger.error("Configuration file is invalid. \"" + INJECTOR_ELEMENT_NAME + "\" element not found");
        throw new InvalidConfigurationFileException("Configuration file is invalid. \"" + INJECTOR_ELEMENT_NAME + "\" element not found");
      } else
        logger.debug("Found \"" + INJECTOR_ELEMENT_NAME + "\" element");
     
    } catch (ParserConfigurationException pce) {
      logger.error("Could not locate a JAXP parser");
          throw new GenericConfigurationParsingException("Could not locate a JAXP parser");

    } catch (IOException e) {
      logger.error("IOException occourred during parsing for \"" + is.toString() + "\" file. Message is: \"" + e.getLocalizedMessage() + "\"");
          throw new GenericConfigurationParsingException("IOException occourred during parsing for \"" + is.toString() + "\" file. Message is: \"" + e.getLocalizedMessage() + "\"");
   
    } catch (SAXException e) {
      logger.error("XML document \"" + is.toString() + "\" is not well-formed");
      throw new InvalidConfigurationFileException("XML document \"" + is.toString() + "\" is not well-formed");
    }

    return res;
   
  }
View Full Code Here

TOP

Related Classes of it.unina.seclab.jafimon.exceptions.InvalidConfigurationFileException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.