List of usage examples for org.apache.commons.configuration XMLConfiguration getFile
public File getFile()
From source file:logica.Estacion.java
/** * @brief Ubicacion de los resumenes, en un Vector<String> * // www . ja v a 2 s .c o m * Retorna la ubicacion de los resumenes de esta estacion y de sus * sub-estaciones, en un Vector<String>. * Se guardan en esa forma, primero la direccion propia y luego la de las * sub-estaciones. * * @return Direccion donde se encuentra el resumen. */ public Vector<String> getResumen() { Vector<String> direcciones = new Vector(); // Instancio el manejador de XML XMLConfiguration registro = new XMLConfiguration(); registro.setFileName(String.format("resumenes/%d.xml", ID)); // No es necesario crear el resumen si no existe // if ( !registro.getFile().exists() ) { // // Si no existe, simplemente seteo el nombre del elemento base // registro.setRootElementName("resumen"); // // Y creo el archivo // try { // registro.save(); // } catch (ConfigurationException ex1) { // LOGGER.log(Level.SEVERE, null, ex1); // } // } // getFileName() me devuelve la direccion dentro del proyecto. // getURL() me devuelve la direccion desde el root de la maquina. if (registro.getFile().exists()) direcciones.add(registro.getFileName()); for (Estacion subestacion : redEstaciones) { if (subestacion != null) direcciones.addAll(subestacion.getResumen()); } return direcciones; }
From source file:org.glite.slcs.acl.impl.XMLFileAccessControlList.java
/** * Loads the ACL XML FileConfiguration./*from w ww . ja va 2 s . c o m*/ * * @param filename * The ACL XML filename to load. * @return The FileConfiguration object. * @throws SLCSConfigurationException * If an configration error occurs while loading the file. */ static private XMLConfiguration createACLXMLConfiguration(String filename) throws SLCSConfigurationException { XMLConfiguration config = null; try { LOG.info("XMLConfiguration file=" + filename); config = new XMLConfiguration(filename); if (LOG.isDebugEnabled()) { File configFile = config.getFile(); LOG.debug("XMLConfiguration file=" + configFile.getAbsolutePath()); } } catch (ConfigurationException e) { LOG.error("Failed to create XMLConfiguration: " + filename, e); throw new SLCSConfigurationException("Failed to create XMLConfiguration: " + filename, e); } return config; }
From source file:org.glite.slcs.acl.impl.XMLOperation.java
/** * Saves the given XML file./*from w w w. j a v a 2 s . co m*/ * * @param config * The {@link XMLConfiguration} to save */ protected void save(XMLConfiguration config) { // save try { File file = config.getFile(); LOG.info("saving file=" + file.getAbsolutePath()); config.save(file); } catch (ConfigurationException e) { LOG.error(e); } }
From source file:org.glite.slcs.config.SLCSConfiguration.java
/** * Creates a XMLConfiguration loaded with the given file. * // w w w . ja v a 2s. co m * @param filename * The file name to load the XML configuration from. * @return The new FileConfiguration object * @throws SLCSConfigurationException * If a configuration error occurs while loading the XML file. */ static protected FileConfiguration loadConfiguration(String filename) throws SLCSConfigurationException { XMLConfiguration config = null; try { LOG.info("XMLConfiguration file=" + filename); config = new XMLConfiguration(filename); LOG.debug("XMLConfiguration resolved file=" + config.getFile().getAbsolutePath()); } catch (ConfigurationException e) { LOG.error("Failed to create XMLConfiguration: " + filename, e); throw new SLCSConfigurationException("Failed to create XMLConfiguration: " + filename, e); } return config; }
From source file:org.glite.slcs.group.impl.XMLFileGroupManager.java
/** * Loads the groups XMLConfiguration file. * //from w w w . j a v a 2s . co m * @param filename * The groups XML filename to load. * @return The loaded {@link XMLConfiguration} object. * @throws SLCSConfigurationException * If an configration error occurs while loading the file. */ static private XMLConfiguration createGroupsConfiguration(String filename) throws SLCSConfigurationException { XMLConfiguration config = null; try { config = new XMLConfiguration(filename); if (LOG.isDebugEnabled()) { File configFile = config.getFile(); LOG.debug("XMLConfiguration file=" + configFile.getAbsolutePath()); } } catch (ConfigurationException e) { LOG.error("Failed to create XMLConfiguration: " + filename, e); throw new SLCSConfigurationException("Failed to create XMLConfiguration: " + filename, e); } return config; }
From source file:org.jkcsoft.java.util.ConfigHelper.java
/** * @param config//from www. j a v a 2s. c om */ public String getConfFilePath(XMLConfiguration config) { String path = "null config"; if (config != null) { if (config.getFile() != null) { try { path = config.getFile().getCanonicalPath(); } catch (IOException e) { path = e.getMessage(); } } else if (config.getURL() != null) { path = config.getURL().toString(); } } return path; }