Package org.jconfig

Examples of org.jconfig.ConfigurationManagerException


      InputStream is = locator.findResource(fileName);
      return load(configurationName,is);
    }
    catch (IOException e) {
      ErrorReporter.getErrorHandler().reportError("Error while trying to read file",e);
            throw new ConfigurationManagerException("Error while trying to read file");
    }
    }
View Full Code Here


      InputStream is = new FileInputStream(fileName);
      return load(configurationName,is);
    }
    catch (Exception e) {
      ErrorReporter.getErrorHandler().reportError("Error while trying to read file",e);
            throw new ConfigurationManagerException("Error while trying to read file");
    }
  }
View Full Code Here

            }
            return cfg;
        }
        catch (IOException e) {
          ErrorReporter.getErrorHandler().reportError("Error while trying to read file",e);
            throw new ConfigurationManagerException("Error while trying to read file");
        }       
    }
View Full Code Here

      FileWriter writer = new FileWriter(getFile());
      writer.write(buffer.toString());
      writer.close();
    }
    catch (Exception e) {
      throw new ConfigurationManagerException("Error while saving script:"+e.getMessage());
    }
    }
View Full Code Here

      return null;
    }
  }
 
  public Configuration load(String configurationName, ConfigurationParser parser) throws ConfigurationManagerException {
    throw new ConfigurationManagerException("Using a specific parser with this handler is not supported");
  }
View Full Code Here

   
    private Configuration loadPropertiesFile(File file,String configName) throws ConfigurationManagerException {
        Configuration config = new DefaultConfiguration(configName);
        if ( file == null ) {
          ErrorReporter.getErrorHandler().reportError("The file is NULL");
            throw new ConfigurationManagerException("The file is NULL");
        }
        try {
            InputStream inputStream = null;
            if(file.exists()) {
                inputStream = new FileInputStream(file);
            } else {
                ResourceLocator locator = new ResourceLocator(file.getName());
                inputStream = locator.getInputStream();
            }
            if ( inputStream == null ) {
              ErrorReporter.getErrorHandler().reportError("Cannot find the properties file");
                throw new ConfigurationManagerException("Cannot find the properties file");
            }
            Properties myProperties = new Properties();
            myProperties.load(inputStream);
            Enumeration propertyNames = myProperties.propertyNames();
            while (propertyNames.hasMoreElements()) {
                String name = (String) propertyNames.nextElement();
                String value = myProperties.getProperty(name);
                config.setProperty(name, value);
            }
        } catch (Exception e) {
          ErrorReporter.getErrorHandler().reportError("The file cannot be loaded",e);
            throw new ConfigurationManagerException("The file cannot be loaded:"+e.getMessage());
        }
        config.resetCreated();
        return config;
    }
View Full Code Here

            }
            // close the file because we are done
            fw.close();
        } catch (Exception e) {
          ErrorReporter.getErrorHandler().reportError("The file cannot be saved",e);
            throw new ConfigurationManagerException("The file cannot be saved");
        }
    }
View Full Code Here

    public File getFile() {
        return file;
    }
 
  public Configuration load(String configurationName, ConfigurationParser parser) throws ConfigurationManagerException {
    throw new ConfigurationManagerException("Using a specific parser with this handler is not supported");
  }
View Full Code Here

     * @param file
     * @throws ConfigurationManagerException  */
    public synchronized Configuration load(File file,String configName,ConfigurationParser parser) throws ConfigurationManagerException {
        if (file == null) {
          ErrorReporter.getErrorHandler().reportError("The file is NULL");
            throw new ConfigurationManagerException("The file is NULL");
        }
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        // set the validation flag (true if it should be validated)
        dbf.setValidating(validate);
        DocumentBuilder db = null;
        try {
            db = dbf.newDocumentBuilder();
        } catch (ParserConfigurationException pce) {
          ErrorReporter.getErrorHandler().reportError("The parser cannot create a new document builder",pce);
            throw new ConfigurationManagerException("The parser cannot create a new document builder: "
            + pce.getMessage());
        }
        // if we have to validate then we need to define an error handler here
        if (validate) {
            try {
                // Set an ErrorHandler before parsing
                OutputStreamWriter errorWriter =
                new OutputStreamWriter(System.err, "UTF-8");
                db.setErrorHandler(
                new ConfigErrorHandler(new PrintWriter(errorWriter, true)));
            } catch (Exception e) {
              ErrorReporter.getErrorHandler().reportError("The parser cannot set up the error handler");
                throw new ConfigurationManagerException("The parser cannot set up the error handler");
            }
        }
        Document doc = null;
        try {                       
            FileInputStream fis = new FileInputStream(file);                      
           
            InputSource ins = new InputSource(fis);
            BufferedInputStream buffy = new BufferedInputStream(fis);
            ins = new InputSource(buffy);           
            doc = db.parse(file);           
        } catch (SAXException se) {
          ErrorReporter.getErrorHandler().reportError("The parser cannot parse the file",se);
            throw new ConfigurationManagerException(
            "The parser cannot parse the file: " + se.getMessage());
        } catch (IOException ioe) {
          ErrorReporter.getErrorHandler().reportError("The parser cannot parse the file",ioe);
            throw new ConfigurationManagerException(
            "The parser cannot open the file: " + ioe.getMessage());
        }       
        Configuration config = parser.parse(doc, configName);
        try {
            java.io.BufferedReader in = new java.io.BufferedReader(new java.io.FileReader(file));
View Full Code Here

         * @see org.jconfig.handler.ConfigurationHandler#load(java.lang.String)
         */
    public Configuration load(String configurationName) throws ConfigurationManagerException {
        if(configurationName == null) {
            ErrorReporter.getErrorHandler().reportError("Configuration name cannot be <null>");
            throw new ConfigurationManagerException("Configuration name cannot be <null>");
        }
        if(configurationName.length() == 0) {
            ErrorReporter.getErrorHandler().reportError("Configuration name not valid. Empty String not allowed");
            throw new ConfigurationManagerException("Configuration name not valid. Empty String not allowed");
        }
        setupJDBC();
       
        return loadConfiguration(configurationName);
    }
View Full Code Here

TOP

Related Classes of org.jconfig.ConfigurationManagerException

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.