List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:org.onosproject.drivers.juniper.tools.XmlParserJuniper.java
public static String getReplyXml(HierarchicalConfiguration cfg) { StringWriter stringWriter = new StringWriter(); try {/*from www . j ava 2 s.c o m*/ XMLConfiguration xcfg = (XMLConfiguration) cfg; xcfg.save(stringWriter); } catch (ConfigurationException e) { System.out.println(e.getMessage()); } String s = stringWriter.toString(); return s; }
From source file:org.onosproject.drivers.utilities.YangXmlUtils.java
/** * Return the string representation of the XMLConfig without header * and configuration element./*from www . ja va 2 s . c o m*/ * * @param cfg the XML to convert * @return the cfg string. */ public String getString(XMLConfiguration cfg) { StringWriter stringWriter = new StringWriter(); try { cfg.save(stringWriter); } catch (ConfigurationException e) { log.error("Cannot convert configuration", e.getMessage()); } String xml = stringWriter.toString(); xml = xml.substring(xml.indexOf("\n")); xml = xml.substring(xml.indexOf(">") + 1); return xml; }
From source file:org.oryxeditor.server.ExportServlet.java
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); try {/*from w ww .j av a 2s. c om*/ if (config == null) { config = new PropertiesConfiguration("pnengine.properties"); } } catch (ConfigurationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String postVariable = config.getString("pnengine.post_variable"); String engineURL = config.getString("pnengine.url") + "/petrinets"; String engineURL_host = config.getString("pnengine.url"); String modelURL = config.getString("pnengine.default_model_url"); // String formURL = null; // String bindingsURL = null; String rdf = req.getParameter("data"); String diagramTitle = req.getParameter("title"); DocumentBuilder builder; BPMNDiagram diagram; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); builder = factory.newDocumentBuilder(); Document document = builder.parse(new ByteArrayInputStream(rdf.getBytes())); BPMNRDFImporter importer = new BPMNRDFImporter(document); diagram = (BPMNDiagram) importer.loadBPMN(); String basefilename = String.valueOf(System.currentTimeMillis()); String tmpPNMLFile = this.getServletContext().getRealPath("/") + "tmp" + File.separator + basefilename + ".pnml"; BufferedWriter out1 = new BufferedWriter(new FileWriter(tmpPNMLFile)); // URL only for testing purposes... ExecConverter converter = new ExecConverter(diagram, modelURL, this.getServletContext().getRealPath("/")); converter.setBaseFileName( this.getServletContext().getRealPath("/") + "tmp" + File.separator + basefilename); PetriNet net = converter.convert(); ExecPetriNet execnet = (ExecPetriNet) net; Document pnmlDoc = builder.newDocument(); ExecPNPNMLExporter exp = new ExecPNPNMLExporter(); execnet.setName(diagramTitle); exp.savePetriNet(pnmlDoc, execnet); OutputFormat format = new OutputFormat(pnmlDoc); XMLSerializer serial = new XMLSerializer(out1, format); serial.asDOMSerializer(); serial.serialize(pnmlDoc.getDocumentElement()); out1.close(); StringWriter stringOut = new StringWriter(); XMLSerializer serial2 = new XMLSerializer(stringOut, format); serial2.asDOMSerializer(); serial2.serialize(pnmlDoc.getDocumentElement()); URL url_engine = new URL(engineURL); HttpURLConnection connection_engine = (HttpURLConnection) url_engine.openConnection(); connection_engine.setRequestMethod("POST"); String encoding = new String(Base64.encodeBase64(("testuser:" + ":").getBytes())); ; connection_engine.setRequestProperty("Authorization", "Basic " + encoding); connection_engine.setUseCaches(false); connection_engine.setDoInput(true); connection_engine.setDoOutput(true); String escaped_content = postVariable + "=" + URLEncoder.encode(stringOut.toString(), "UTF-8"); connection_engine.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection_engine.setRequestProperty("Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"); // connection_engine.setRequestProperty("Content-Length", // ""+escaped_content.getBytes().length); String errorMessage = null; try { connection_engine.getOutputStream().write(escaped_content.getBytes()); connection_engine.connect(); } catch (ConnectException e) { errorMessage = e.getMessage(); } // output link address res.getWriter().print("tmp/" + basefilename + ".pnml" + "\">View PNML</a><br/><br/>"); if (errorMessage == null && connection_engine.getResponseCode() == 200) { res.getWriter().println("Deployment to Engine <a href=\"" + engineURL_host + "/worklist\" target=\"_blank\">" + engineURL_host + "</a><br/><b>successful</b>!"); } else { res.getWriter().println("Deployment to Engine <a href=\"" + engineURL + "\" target=\"_blank\">" + engineURL + "</a><br/><b>failed</b> with message: \n" + errorMessage + "!"); } } catch (ParserConfigurationException e1) { res.getWriter().println(e1.getMessage()); } catch (SAXException e1) { res.getWriter().println(e1.getMessage()); } }
From source file:org.overlord.sramp.governance.ConfigurationTest.java
/** * Add a bad query//from w w w . j a va2 s .co m * * @throws ConfigException */ @Test() public void testBad2QueryConfiguration() throws ConfigException { Governance governance = new Governance() { /** * @see org.overlord.sramp.governance.Governance#getConfiguration() */ @Override protected Configuration getConfiguration() { try { return new PropertiesConfiguration( ConfigurationTest.class.getClassLoader().getResource("bad2-governance.config.txt")); //$NON-NLS-1$ } catch (ConfigurationException e) { throw new RuntimeException(e); } } }; try { governance.validate(); Assert.fail("Expecting exception"); //$NON-NLS-1$ } catch (ConfigException e) { Assert.assertTrue(e.getMessage().startsWith(Governance.TARGET_ERROR)); } }
From source file:org.overlord.sramp.governance.ConfigurationTest.java
/** * Add a bad target//from w w w .ja v a2 s .c o m * * @throws ConfigException */ @Test() public void testBad3TargetConfiguration() throws ConfigException { Governance governance = new Governance() { /** * @see org.overlord.sramp.governance.Governance#getConfiguration() */ @Override protected Configuration getConfiguration() { try { return new PropertiesConfiguration( ConfigurationTest.class.getClassLoader().getResource("bad3-governance.config.txt")); //$NON-NLS-1$ } catch (ConfigurationException e) { throw new RuntimeException(e); } } }; try { governance.validate(); Assert.fail("Expecting exception"); //$NON-NLS-1$ } catch (ConfigException e) { Assert.assertTrue(e.getMessage().startsWith(Governance.TARGET_ERROR)); } }
From source file:org.ow2.aspirerfid.programmableengine.client.ProgrammableEngineClient.java
ProgrammableEngineClient() { String peEndPoint = null;//from ww w .j ava 2s .com // read parameters from configuration file config = new XMLConfiguration(); config.setListDelimiter(','); URL fileurl = this.getClass().getResource("/PeClientParameters.xml"); // sets the parameters according to the properties file try { config.load(fileurl); } catch (ConfigurationException e) { String message = "Couldn't get WarehouseParameters at: " + fileurl.getFile() + "\n" + e.getMessage(); LOG.debug(message); e.printStackTrace(); } peEndPoint = config.getString("PeEndPoint"); if (peEndPoint.equals(null) || peEndPoint.equals("") || peEndPoint == null) { this.peOLCBProcControlEndpoint = DEFAULT_peEndpoint + "/olcbproccontrol"; this.peCLCBProcControlEndpoint = DEFAULT_peEndpoint + "/clcbproccontrol"; this.peEBProcControlEndpoint = DEFAULT_peEndpoint + "/ebproccontrol"; } else if (!peEndPoint.endsWith("/")) { this.peOLCBProcControlEndpoint = peEndPoint + "olcbproccontrol"; this.peCLCBProcControlEndpoint = peEndPoint + "clcbproccontrol"; this.peEBProcControlEndpoint = peEndPoint + "ebproccontrol"; } else if (peEndPoint.endsWith("/")) { this.peOLCBProcControlEndpoint = peEndPoint + "/olcbproccontrol"; this.peCLCBProcControlEndpoint = peEndPoint + "/clcbproccontrol"; this.peEBProcControlEndpoint = peEndPoint + "/ebproccontrol"; } initializeWS(); }
From source file:org.parosproxy.paros.control.MenuToolsControl.java
public void options(String panel) { OptionsDialog dialog = view.getOptionsDialog(Constant.messages.getString("options.dialog.title")); dialog.initParam(model.getOptionsParam()); int result = dialog.showDialog(false, panel); if (result == JOptionPane.OK_OPTION) { try {//ww w . j a v a 2 s . c o m model.getOptionsParam().getConfig().save(); } catch (ConfigurationException e) { logger.error(e.getMessage(), e); view.showWarningDialog(Constant.messages.getString("menu.tools.options.errorSavingOptions")); return; } // ZAP: Notify all OptionsChangedListener. control.getExtensionLoader().optionsChangedAllPlugin(model.getOptionsParam()); control.getProxy().stopServer(); control.getProxy().startServer(); } }
From source file:org.parosproxy.paros.model.OptionsParam.java
/** * @param currentDirectory The currentFolder to set. *///from w w w .ja v a2 s . c om public void setUserDirectory(File currentDirectory) { this.userDirectory = currentDirectory; // ZAP: User directory now stored in the config file getConfig().setProperty(USER_DIR, currentDirectory.getAbsolutePath()); try { getConfig().save(); } catch (ConfigurationException e) { logger.error(e.getMessage(), e); } }
From source file:org.parosproxy.paros.view.MainFrame.java
private JToggleButton getShowTabIconNamesButton() { if (showTabIconNamesButton == null) { showTabIconNamesButton = new ZapToggleButton(); showTabIconNamesButton/*from www . j a va2 s .co m*/ .setIcon(new ImageIcon(WorkbenchPanel.class.getResource("/resource/icon/ui_tab_icon.png"))); showTabIconNamesButton.setToolTipText(Constant.messages.getString("view.toolbar.showNames")); showTabIconNamesButton.setSelectedIcon( new ImageIcon(WorkbenchPanel.class.getResource("/resource/icon/ui_tab_text.png"))); showTabIconNamesButton.setSelectedToolTipText(Constant.messages.getString("view.toolbar.showIcons")); showTabIconNamesButton .setSelected(Model.getSingleton().getOptionsParam().getViewParam().getShowTabNames()); DisplayUtils.scaleIcon(showTabIconNamesButton); showTabIconNamesButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent evt) { boolean showTabNames = getShowTabIconNamesButton().isSelected(); setShowTabNames(showTabNames); Model.getSingleton().getOptionsParam().getViewParam().setShowTabNames(showTabNames); try { Model.getSingleton().getOptionsParam().getViewParam().getConfig().save(); } catch (ConfigurationException e) { LOGGER.error(e.getMessage(), e); } } }); } return showTabIconNamesButton; }
From source file:org.parosproxy.paros.view.TabbedPanel.java
public void alternateParent() { if (alternativeParent == null) return;/*from w w w. jav a2 s .c om*/ if (Model.getSingleton().getOptionsParam().getViewParam().getWarnOnTabDoubleClick()) { if (View.getSingleton().showConfirmDialog( Constant.messages.getString("tab.doubleClick.warning")) != JOptionPane.OK_OPTION) { // They cancelled the dialog return; } // Only ever warn once Model.getSingleton().getOptionsParam().getViewParam().setWarnOnTabDoubleClick(false); try { Model.getSingleton().getOptionsParam().getViewParam().getConfig().save(); } catch (ConfigurationException e) { log.error(e.getMessage(), e); } } if (isAlternative) { originalParent = this.getParent(); originalParent.remove(this); backupChild = alternativeParent.getComponent(0); alternativeParent.remove(backupChild); alternativeParent.add(this); } else { alternativeParent.remove(this); alternativeParent.add(backupChild); originalParent.add(this); } originalParent.validate(); alternativeParent.validate(); this.validate(); isAlternative = !isAlternative; }