List of usage examples for org.apache.commons.configuration ConfigurationException printStackTrace
public void printStackTrace()
From source file:pl.otros.logview.gui.message.editor.MessageColorizerBrowser.java
protected void saveMessageColorizer(File selectedFile) { FileOutputStream fout = null; try {//from w w w .jav a 2 s . c o m PropertyPatternMessageColorizer mc = editor.createMessageColorizer(); mc.setTestMessage(editor.getTextToColorize()); fout = new FileOutputStream(selectedFile); mc.store(fout); } catch (ConfigurationException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(fout); } }
From source file:pl.otros.vfs.browser.demo.TestBrowser.java
public static void main(final String[] args) throws InterruptedException, InvocationTargetException, SecurityException, IOException { if (args.length > 1) throw new IllegalArgumentException( "SYNTAX: java... " + TestBrowser.class.getName() + " [initialPath]"); SwingUtilities.invokeAndWait(new Runnable() { @Override// www. j av a 2s . co m public void run() { tryLoadSubstanceLookAndFeel(); final JFrame f = new JFrame("OtrosVfsBrowser demo"); Container contentPane = f.getContentPane(); contentPane.setLayout(new BorderLayout()); DataConfiguration dc = null; final PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); File favoritesFile = new File("favorites.properties"); propertiesConfiguration.setFile(favoritesFile); if (favoritesFile.exists()) { try { propertiesConfiguration.load(); } catch (ConfigurationException e) { e.printStackTrace(); } } dc = new DataConfiguration(propertiesConfiguration); propertiesConfiguration.setAutoSave(true); final VfsBrowser comp = new VfsBrowser(dc, (args.length > 0) ? args[0] : null); comp.setSelectionMode(SelectionMode.FILES_ONLY); comp.setMultiSelectionEnabled(true); comp.setApproveAction(new AbstractAction(Messages.getMessage("demo.showContentButton")) { @Override public void actionPerformed(ActionEvent e) { FileObject[] selectedFiles = comp.getSelectedFiles(); System.out.println("Selected files count=" + selectedFiles.length); for (FileObject selectedFile : selectedFiles) { try { FileSize fileSize = new FileSize(selectedFile.getContent().getSize()); System.out.println(selectedFile.getName().getURI() + ": " + fileSize.toString()); byte[] bytes = readBytes(selectedFile.getContent().getInputStream(), 150 * 1024l); JScrollPane sp = new JScrollPane(new JTextArea(new String(bytes))); JDialog d = new JDialog(f); d.setTitle("Content of file: " + selectedFile.getName().getFriendlyURI()); d.getContentPane().add(sp); d.setSize(600, 400); d.setVisible(true); } catch (Exception e1) { LOGGER.error("Failed to read file", e1); JOptionPane.showMessageDialog(f, (e1.getMessage() == null) ? e1.toString() : e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }); comp.setCancelAction(new AbstractAction(Messages.getMessage("general.cancelButtonText")) { @Override public void actionPerformed(ActionEvent e) { f.dispose(); try { propertiesConfiguration.save(); } catch (ConfigurationException e1) { e1.printStackTrace(); } System.exit(0); } }); contentPane.add(comp); f.pack(); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }); }
From source file:pt.ua.dicoogle.plugins.PluginController.java
public PluginController(File pathToPluginDirectory) { logger.info("Creating PluginController Instance"); pluginFolder = pathToPluginDirectory; pluginSets = new ArrayList<>(); tasks = new TaskQueue(); //the plugin directory does not exist. lets create it if (!pathToPluginDirectory.exists()) { logger.info("Creating new Plugin Folder"); pathToPluginDirectory.mkdirs();// ww w . j av a2s . c o m } //loads the plugins pluginSets = PluginFactory.getPlugins(pathToPluginDirectory); logger.info("Loaded Local Plugins"); //loads plugins' settings and passes them to the plugin File settingsFolder = new File(pluginFolder.getPath() + "/settings/"); if (!settingsFolder.exists()) { logger.info("Creating Local Settings Folder"); settingsFolder.mkdir(); } for (PluginSet plugin : pluginSets) { System.err.println("LOADING:" + plugin.getName()); File pluginSettingsFile = new File(settingsFolder + "/" + plugin.getName() + ".xml"); try { ConfigurationHolder holder = new ConfigurationHolder(pluginSettingsFile); if (plugin.getName().equals("RemotePluginSet")) { this.remoteQueryPlugins = plugin; holder.getConfiguration().setProperty("NodeName", ServerSettings.getInstance().getNodeName()); holder.getConfiguration().setProperty("TemporaryPath", ServerSettings.getInstance().getPath()); logger.info("Started Remote Communications Manager"); } plugin.setSettings(holder); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperationException e) { // TODO log this properly, remove plugin from plugin list e.printStackTrace(); } } logger.info("Settings pushed to plugins"); pluginSets.add(new DefaultFileStoragePlugin()); logger.info("Added default storage plugin"); initializePlugins(pluginSets); initRestInterface(pluginSets); initJettyInterface(pluginSets); logger.info("Initialized plugins"); }
From source file:ro.nextreports.server.web.ApplicationLoaderListener.java
private void config() { LOG.info("NextReports Server " + ReleaseInfo.getVersion() + " starting ... "); CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); try {/* ww w.j a va2s . c o m*/ config.addConfiguration(new PropertiesConfiguration(getClass().getResource("/nextserver.properties"))); } catch (ConfigurationException e) { // TODO e.printStackTrace(); } File defaultNextServerHomeFolder = new File(System.getProperty("user.home"), ".nextserver"); String defaultNextServerHome = defaultNextServerHomeFolder.getPath(); String nextServerHome = config.getString("nextserver.home", defaultNextServerHome); LOG.info("nextserver.home = " + nextServerHome); String demo = System.getProperty("DEMO"); LOG.info("DEMO=" + demo); boolean installWithDemo = Boolean.valueOf(demo); File nextServerHomeFolder = new File(nextServerHome); if (!nextServerHomeFolder.exists()) { try { if (installWithDemo) { deployDemoData(nextServerHome); } else { if (LOG.isDebugEnabled()) { LOG.debug("Create nextserver home folder: '" + nextServerHomeFolder + "'"); } FileUtils.forceMkdir(nextServerHomeFolder); } } catch (IOException e) { // TODO e.printStackTrace(); } } System.setProperty("nextserver.home", nextServerHome); // File defaultJaspersHomeFolder = new File(nextServerHome, "jaspers"); // String defaultJaspersHome = defaultJaspersHomeFolder.getPath(); // String jaspersHome = config.getString("jaspers.home", defaultJaspersHome); // System.setProperty("jaspers.home", jaspersHome); // if (LOG.isDebugEnabled()) { // LOG.debug("jaspers.home = " + jaspersHome); // } // indexing.file ClassPathResource classPathResource = new ClassPathResource("indexing.xml"); String indexingFile = null; try { indexingFile = classPathResource.getFile().getAbsolutePath(); } catch (IOException e) { // TODO e.printStackTrace(); } System.setProperty("indexing.file", indexingFile); if (LOG.isDebugEnabled()) { LOG.debug("indexing.file = " + indexingFile); } // String baseUrl = config.getString("nextserver.baseUrl"); // String reportsUrl = config.getString("reports.url"); // if (LOG.isDebugEnabled()) { // LOG.debug("nextserver.baseUrl = " + baseUrl); // LOG.debug("reports.url = " + reportsUrl); // } }
From source file:tagtime.settings.Settings.java
/** * Creates a new settings manager for the given user. *//*from w w w . j ava2 s . c o m*/ private Settings(String userName) { //setup this.username = userName; //settingValues = new EnumMap<SettingType, Object>(SettingType.class); String fileLocation = Main.getDataDirectory().getPath() + "/" + userName + ".properties"; //load the file PropertiesConfiguration tempProperties; try { tempProperties = new PropertiesConfiguration(fileLocation); } catch (ConfigurationException e) { //file not found tempProperties = new PropertiesConfiguration(); tempProperties.setPath(fileLocation); try { tempProperties.save(); } catch (ConfigurationException e1) { e1.printStackTrace(); } } properties = tempProperties; /*if(settingsFile.exists()) { //read the save file and load the settings BufferedReader in = new BufferedReader(new FileReader(settingsFile)); readInSettings(in); //TagTime doesn't bother reading the file from here on; if the //user changes it, those changes will be overwritten in.close(); } else { applyDefaultSettings(); flush(); }*/ }
From source file:tagtime.settings.Settings.java
/** * Writes the user's settings to the save file. *//*from w w w . j av a 2 s. c o m*/ public void flush() { if (tagCounts != null) { List<String> tagCountsAsStrings = new ArrayList<String>(tagCounts.size()); for (TagCount tagCount : tagCounts) { tagCountsAsStrings.add(tagCount.toString()); } properties.setProperty(SettingType.CACHED_TAGS.toString(), tagCountsAsStrings); } try { properties.save(); } catch (ConfigurationException e) { e.printStackTrace(); } }
From source file:Tim.AppConfig.java
/** * Initialize the class./*from w ww. ja v a 2s. com*/ * * @param fileName Configuration file name. */ private void init(String fileName) { setFileName(fileName); try { load(); } catch (ConfigurationException configEx) { configEx.printStackTrace(); } }
From source file:tw.com.mt.DocAPIDemo.java
/** * Default constructor.//www .j a va 2 s . c o m */ public DocAPIDemo() { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); try { config.addConfiguration(new PropertiesConfiguration(propertyFile)); this.projObjKey = config.getInt("projObjKey"); this.parentObjKey = config.getInt("parentObjKey"); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:tw.com.mt.ObsAPIDemo.java
/** * Default constructor./* www . j a va2s. c o m*/ */ public ObsAPIDemo() { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); try { config.addConfiguration(new PropertiesConfiguration(propertyFile)); this.parentObjKey = config.getInt("parentObjKey"); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:tw.com.mt.TaskAPIDemo.java
/** * Default constructor./*from w ww .ja v a2s .c om*/ */ public TaskAPIDemo() { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); try { config.addConfiguration(new PropertiesConfiguration(propertyFile)); this.projObjKey = config.getInt("projObjKey"); this.parentObjKey = config.getInt("parentObjKey"); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }