org.jdom.JDOMException Java Examples
The following examples show how to use
org.jdom.JDOMException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JDOMUtils.java From geowave with Apache License 2.0 | 6 votes |
public static Element readElementFromString(final String xmlData) { try { final StringReader sr = new StringReader(xmlData); final SAXBuilder builder = new SAXBuilder(); builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); final Document doc = builder.build(sr); if (doc == null) { return null; } final Element root = doc.getRootElement(); return root; } catch (final IOException ioe) { LOGGER.info("read error", ioe); return null; } catch (final JDOMException jdome) { LOGGER.info("read error", jdome); return null; } }
Example #2
Source File: FileEditorManagerTest.java From consulo with Apache License 2.0 | 6 votes |
private void openFiles(String s) throws IOException, JDOMException, InterruptedException, ExecutionException { Document document = JDOMUtil.loadDocument(s); Element rootElement = document.getRootElement(); ExpandMacroToPathMap map = new ExpandMacroToPathMap(); map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath()); map.substitute(rootElement, true, true); myManager.loadState(rootElement); UIAccess uiAccess = UIAccess.get(); Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { myManager.getMainSplitters().openFiles(uiAccess); } }); future.get(); }
Example #3
Source File: TranslationCompilerProjectMonitor.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public Map<String, Couple<String>> getLastOutputRootsLayout() { File file = getOutputUrlsFile(); Map<String, Couple<String>> map = new HashMap<>(); if (file.exists()) { try { Element root = JDOMUtil.load(file); for (Element module : root.getChildren()) { String name = module.getAttributeValue("name"); String outputUrl = module.getAttributeValue("output-url"); String testOutputUrl = module.getAttributeValue("test-output-url"); map.put(name, Couple.of(outputUrl, testOutputUrl)); } } catch (IOException | JDOMException e) { LOG.error(e); } } return map; }
Example #4
Source File: TemplateSettings.java From consulo with Apache License 2.0 | 6 votes |
@Deprecated @SuppressWarnings("deprecation") private void readDefTemplate(DefaultLiveTemplatesProvider provider, String defTemplate, boolean registerTemplate) throws JDOMException, InvalidDataException, IOException { InputStream inputStream = DecodeDefaultsUtil.getDefaultsInputStream(provider, defTemplate); if (inputStream != null) { TemplateGroup group = readTemplateFile(JDOMUtil.loadDocument(inputStream), defTemplate, true, registerTemplate, provider.getClass().getClassLoader()); if (group != null && group.getReplace() != null) { Collection<TemplateImpl> templates = myTemplates.get(group.getReplace()); for (TemplateImpl template : templates) { removeTemplate(template); } } } }
Example #5
Source File: AnnotationSchema.java From gate-core with GNU Lesser General Public License v3.0 | 6 votes |
/** * Creates an AnnotationSchema object from an XSchema file * * @param anXSchemaURL the ResourceReference where to find the XSchema file */ public void fromXSchema(ResourceReference anXSchemaURL) throws ResourceInstantiationException { org.jdom.Document jDom = null; SAXBuilder saxBuilder = new SAXBuilder(false); try { try{ jDom = saxBuilder.build(anXSchemaURL.toURL()); }catch(JDOMException je){ throw new ResourceInstantiationException(je); } } catch (java.io.IOException ex) { throw new ResourceInstantiationException(ex); } workWithJDom(jDom); }
Example #6
Source File: CreoleRegisterImpl.java From gate-core with GNU Lesser General Public License v3.0 | 6 votes |
private void processFullCreoleXmlTree(Plugin plugin, Document jdomDoc, CreoleAnnotationHandler annotationHandler) throws GateException, IOException, JDOMException { // now we can process any annotations on the new classes // and augment the XML definition annotationHandler.processAnnotations(jdomDoc); // debugging if(DEBUG) { XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); xmlOut.output(jdomDoc, System.out); } // finally, parse the augmented definition with the normal parser DefaultHandler handler = new CreoleXmlHandler(this, plugin); SAXOutputter outputter = new SAXOutputter(handler, handler, handler, handler); outputter.output(jdomDoc); if(DEBUG) { Out.prln("done parsing " + plugin); } }
Example #7
Source File: TelegramSettingsManager.java From teamcity-telegram-plugin with Apache License 2.0 | 6 votes |
private synchronized void reloadConfiguration() throws JDOMException, IOException { LOG.info("Loading configuration file: " + configFile); Document document = JDOMUtil.loadDocument(configFile.toFile()); Element root = document.getRootElement(); TelegramSettings newSettings = new TelegramSettings(); newSettings.setBotToken(unscramble(root.getAttributeValue(BOT_TOKEN_ATTR))); newSettings.setPaused(Boolean.parseBoolean(root.getAttributeValue(PAUSE_ATTR))); newSettings.setUseProxy(Boolean.parseBoolean(root.getAttributeValue(USE_PROXY_ATTR))); newSettings.setProxyServer(root.getAttributeValue(PROXY_SERVER_ATTR)); newSettings.setProxyPort(restoreInteger(root.getAttributeValue(PROXY_PORT_ATTR))); newSettings.setProxyUsername(root.getAttributeValue(PROXY_PASSWORD_ATTR)); newSettings.setProxyPassword(unscramble(root.getAttributeValue(PROXY_PASSWORD_ATTR))); settings = newSettings; botManager.reloadIfNeeded(settings); }
Example #8
Source File: AnnotationSchema.java From gate-core with GNU Lesser General Public License v3.0 | 6 votes |
/** Creates an AnnotationSchema object from an XSchema file * @param anXSchemaInputStream the Input Stream containing the XSchema file */ public void fromXSchema(InputStream anXSchemaInputStream) throws ResourceInstantiationException { org.jdom.Document jDom = null; SAXBuilder saxBuilder = new SAXBuilder(false); try { try{ jDom = saxBuilder.build(anXSchemaInputStream); }catch(JDOMException je){ throw new ResourceInstantiationException(je); } } catch (java.io.IOException ex) { throw new ResourceInstantiationException(ex); } workWithJDom(jDom); }
Example #9
Source File: SAXBuilder_JDOMTest.java From learnjavabug with MIT License | 6 votes |
public static void main(String[] args) throws JDOMException, IOException { //todo 存在xxe漏洞 SAXBuilder saxBuilder = new SAXBuilder(); //todo 修复方式1 // SAXBuilder saxBuilder = new SAXBuilder(true); //todo 修复方式2 // SAXBuilder saxBuilder = new SAXBuilder(); // saxBuilder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); // saxBuilder.setFeature("http://xml.org/sax/features/external-general-entities", false); // saxBuilder.setFeature("http://xml.org/sax/features/external-parameter-entities", false); // saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(Payloads.FEEDBACK.getBytes()); Document document = saxBuilder.build(byteArrayInputStream); Element element = document.getRootElement(); List<Content> contents = element.getContent(); for (Content content : contents) { System.out.println(content.getValue()); } }
Example #10
Source File: InitializrModuleBuilder.java From intellij-spring-assistant with MIT License | 6 votes |
@NotNull @Override public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException { Module module = super.createModule(moduleModel); getApplication().invokeLater(() -> { ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { try { InitializerDownloader downloader = new InitializerDownloader(this); downloader.execute(ProgressManager.getInstance().getProgressIndicator()); } catch (IOException var2) { getApplication() .invokeLater(() -> showErrorDialog("Error: " + var2.getMessage(), "Creation Failed")); } }, "Downloading Required Files...", true, null); ModuleBuilderPostProcessor[] postProcessors = ModuleBuilderPostProcessor.EXTENSION_POINT_NAME.getExtensions(); for (ModuleBuilderPostProcessor postProcessor : postProcessors) { if (!postProcessor.postProcess(module)) { return; } } }, current()); return module; }
Example #11
Source File: ApplicationDefaultStoreCache.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public Element findDefaultStoreElement(@Nonnull Class<?> clazz, @Nonnull String path) { Object result = myUrlCache.computeIfAbsent(Pair.create(clazz.getClassLoader(), path), pair -> { URL resource = pair.getFirst().getResource(pair.getSecond()); if(resource != null) { try { Document document = JDOMUtil.loadDocument(resource); Element rootElement = document.getRootElement(); rootElement.detach(); return rootElement; } catch (JDOMException | IOException e) { throw new RuntimeException(e); } } return ObjectUtil.NULL; }); return result == ObjectUtil.NULL ? null : (Element)result; }
Example #12
Source File: JDOMUtils.java From geowave with Apache License 2.0 | 6 votes |
public static Element parseDocument(final InputStream is) { try { final SAXBuilder builder = new SAXBuilder(); builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); final Document doc = builder.build(is); if (doc == null) { return null; } final Element root = doc.getRootElement(); return root; } catch (final IOException ioe) { LOGGER.warn("parse error", ioe); return null; } catch (final JDOMException jdome) { LOGGER.warn("parse error", jdome); return null; } }
Example #13
Source File: IndexCreator.java From icure-backend with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") public void createIndex() throws JDOMException, IOException, MappingException, ClassNotFoundException { buildAnalyzerMap(); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(config); Element root = doc.getRootElement(); SessionFactory sf = createSessionFactory(root.getAttributeValue("url"), root.getAttributeValue("login"), root.getAttributeValue("passwd"), root.getAttributeValue("dialect"), root.getAttributeValue("driverClass"), root.getAttributeValue("mappedClasses")); Directory indexDir = FSDirectory.open(new File(output)); Version lucene47 = Version.LUCENE_47; IndexWriter writer = new IndexWriter(indexDir,new IndexWriterConfig(lucene47,new StandardAnalyzer(lucene47))); for (Element classToIndex:(Collection<Element>)root.getChildren("index-class")) { processClass(classToIndex,writer,sf); } log.info("Closing index"); writer.close(); log.info("All done!"); }
Example #14
Source File: BeastImporter.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
public BeastImporter(Reader reader) throws IOException, JDOMException, Importer.ImportException { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(reader); root = doc.getRootElement(); if (!root.getName().equalsIgnoreCase("beast")) { throw new Importer.ImportException("Unrecognized root element in XML file"); } dateFormat = DateFormat.getDateInstance(java.text.DateFormat.SHORT, Locale.UK); dateFormat.setLenient(true); Calendar cal = Calendar.getInstance(Locale.getDefault()); // set uses a zero based month (Jan = 0): cal.set(0000, 00, 01); // origin = cal.getTime(); cal.setTimeInMillis(0); origin = cal.getTime(); }
Example #15
Source File: MachoPrelinkUtils.java From ghidra with Apache License 2.0 | 6 votes |
/** * Parses the provider looking for PRELINK XML. * * @param provider The provider to parse. * @param monitor A monitor. * @return A list of discovered {@link PrelinkMap}s. An empty list indicates that the provider * did not represent valid Mach-O PRELINK binary. * @throws IOException if there was an IO-related issue. * @throws JDOMException if there was a issue parsing the PRELINK XML. */ public static List<PrelinkMap> parsePrelinkXml(ByteProvider provider, TaskMonitor monitor) throws IOException, JDOMException { try { MachHeader mainHeader = MachHeader.createMachHeader(RethrowContinuesFactory.INSTANCE, provider); mainHeader.parse(); // make sure first Mach-O header is valid.... monitor.setMessage("Parsing PRELINK XML..."); return new PrelinkParser(mainHeader, provider).parse(monitor); } catch (NoPreLinkSectionException | MachException e) { return Collections.emptyList(); } }
Example #16
Source File: IndexCreator.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") public void createIndex() throws JDOMException, IOException, MappingException, ClassNotFoundException { buildAnalyzerMap(); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(config); Element root = doc.getRootElement(); SessionFactory sf = createSessionFactory(root.getAttributeValue("url"), root.getAttributeValue("login"), root.getAttributeValue("passwd"), root.getAttributeValue("dialect"), root.getAttributeValue("driverClass"), root.getAttributeValue("mappedClasses")); Directory indexDir = FSDirectory.open(new File(output)); Version lucene47 = Version.LUCENE_47; IndexWriter writer = new IndexWriter(indexDir,new IndexWriterConfig(lucene47,new StandardAnalyzer(lucene47))); for (Element classToIndex:(Collection<Element>)root.getChildren("index-class")) { processClass(classToIndex,writer,sf); } log.info("Closing index"); writer.close(); log.info("All done!"); }
Example #17
Source File: BlazeProjectOpenProcessor.java From intellij with Apache License 2.0 | 6 votes |
@Nullable @Override public Project doOpenProject( VirtualFile file, @Nullable Project projectToClose, boolean forceOpenInNewFrame) { ProjectManager pm = ProjectManager.getInstance(); if (projectToClose != null) { pm.closeProject(projectToClose); } try { VirtualFile ideaSubdirectory = getIdeaSubdirectory(file); if (ideaSubdirectory == null) { return null; } VirtualFile projectSubdirectory = ideaSubdirectory.getParent(); return pm.loadAndOpenProject(projectSubdirectory.getPath()); } catch (IOException | JDOMException e) { return null; } }
Example #18
Source File: KeyManagement.java From axelor-open-suite with GNU Affero General Public License v3.0 | 6 votes |
/** * Sends the SPR order to the bank. After that you have to start over with sending INI and HIA. * * @throws IOException Communication exception * @throws AxelorException * @throws JDOMException * @throws EbicsException Error message generated by the bank. */ public void lockAccess() throws IOException, AxelorException, JDOMException { HttpRequestSender sender; SPRRequestElement request; SPRResponseElement response; int httpCode; sender = new HttpRequestSender(session); request = new SPRRequestElement(session); request.build(); request.validate(); httpCode = sender.send(new ByteArrayContentFactory(request.prettyPrint())); EbicsUtils.checkHttpCode(httpCode); response = new SPRResponseElement(sender.getResponseBody(), session.getUser()); response.build(); response.report(new EbicsRootElement[] {request, response}); }
Example #19
Source File: FeatureSpecification.java From gateplugin-LearningFramework with GNU Lesser General Public License v2.1 | 6 votes |
/** * Constructor from URL * @param configFileURL URL of feature config XML file */ public FeatureSpecification(URL configFileURL) { url = configFileURL; SAXBuilder saxBuilder = new SAXBuilder(false); try { try { jdomDocConf = saxBuilder.build(configFileURL); parseConfigXml(); } catch (JDOMException jde) { throw new GateRuntimeException(jde); } } catch (java.io.IOException ex) { throw new GateRuntimeException("Error parsing config file URL " + url, ex); } }
Example #20
Source File: HaplogroupTest.java From haplogrep-cmd with MIT License | 5 votes |
@Test public void testL5a1a() throws NumberFormatException, JDOMException, IOException, InvalidPolymorphismException, HsdFileException, InvalidColumnCountException { List<RankedResult> result = phylotree.search(TestSample.parse("1 1-16569 73G 152C 182T 189G 195C 247A 263G 315.1C 455.1T 455.2T 455.3C 522del 523del 709A 750G 769A 825A 851G 930A 1018A 1438G 1822C 2706G 3423C 3594T 4104G 4496T 4769G 5004C 5111T 5147A 5656G 6182A 6297C 7028T 256T 7424G 7521A 7873T 7972G 8155A 8188G 8582T 8655T 8701G 8754T 8860G 9305A 9329A 9540C 9899C 10398G 10688A 10810C 10873C 11015G 11025C 11719A 11881T 12236A 12432T 12705T 12950G 13105G 13506T 13650T 13722G 14212C 14239T 14581C 14766T 14905A 14971C 15217A 15326G 15884A 16129A 16148T 16166G 16187T 16189C 16223T 16278T 16311C 16355T 16362C"),new HammingRanking()); Assert.assertEquals("L5a1a", result.get(0).getHaplogroup().toString()); }
Example #21
Source File: HaplogroupTest.java From haplogrep-cmd with MIT License | 5 votes |
@Test public void testL3e1c() throws NumberFormatException, JDOMException, IOException, InvalidPolymorphismException, HsdFileException, InvalidColumnCountException { List<RankedResult> result = phylotree.search(TestSample.parse("549 1-16569 L3e1c 73G 150T 189G 200G 263G 309.1C 315.1C 750G 1438G 2352C 2706G 3106N 3675G 4769G 5460A 6221C 6587T 7028T 8289.1C 8289.2C 8289.3C 8289.4C 8289.5C 8289.6T 8289.7C 8289.8T 8289.9A 8289.10C 8289.11C 8289.12C 8289.13C 8289.14C 8289.15T 8289.16C 8289.17T 8289.18A 8860G 9540C 10398G 10819G 10873C 11719A 12705T 14152G 14212C 14323A 14766T 15301A 15326G 15670C 15942C 16327T "),new HammingRanking()); Assert.assertEquals("L3e1c", result.get(0).getHaplogroup().toString()); }
Example #22
Source File: HaplogroupTest.java From haplogrep-cmd with MIT License | 5 votes |
@Test public void testHV() throws NumberFormatException, JDOMException, IOException, InvalidPolymorphismException, HsdFileException, InvalidColumnCountException { List<RankedResult> result = phylotree.search(TestSample.parse("1 1-16569 263G 8860G 15326G 750G 4769G 1438G 2706G 7028T"),new HammingRanking()); Assert.assertEquals("HV", result.get(0).getHaplogroup().toString()); }
Example #23
Source File: ProjectManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nullable public Project loadProject(@Nonnull String filePath) throws IOException, JDOMException, InvalidDataException { try { ProjectImpl project = createProject(null, filePath, false, false); initProject(project, null); return project; } catch (Throwable t) { LOG.info(t); throw new IOException(t); } }
Example #24
Source File: HaplogroupTest.java From haplogrep-cmd with MIT License | 5 votes |
@Test public void testH() throws NumberFormatException, JDOMException, IOException, InvalidPolymorphismException, HsdFileException, InvalidColumnCountException { List<RankedResult> result = phylotree.search(TestSample.parse("1 1-16569 263G 8860G 15326G 750G 4769G 1438G"),new HammingRanking()); Assert.assertEquals("H", result.get(0).getHaplogroup().toString()); }
Example #25
Source File: XmlStringBuffer.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Constructs an XmlStringBuffer whose initial value is Document * * @param jdomDoc * * @deprecated using XmlStringBuffer(org.w3c.dom.Document document) instead. */ public XmlStringBuffer(org.jdom.Document jdomDoc) { try { this.document = new DOMOutputter().output(jdomDoc); } catch(JDOMException e) { log.error(e.getMessage(), e); } }
Example #26
Source File: HaplogroupTest.java From haplogrep-cmd with MIT License | 5 votes |
@Test public void testR0() throws NumberFormatException, JDOMException, IOException, InvalidPolymorphismException, HsdFileException, InvalidColumnCountException { List<RankedResult> result = phylotree.search(TestSample.parse("1 1-16569 263G 8860G 15326G 750G 4769G 1438G 2706G 7028T 14766T"),new HammingRanking()); Assert.assertEquals("R0", result.get(0).getHaplogroup().toString()); }
Example #27
Source File: KeyManagement.java From axelor-open-suite with GNU Affero General Public License v3.0 | 5 votes |
/** * Sends encryption and authentication keys to the bank. This order is only allowed for a new user * at the bank side that has been created by copying the A005 key. The keys will be activated * immediately after successful completion of the transfer. * * @param orderId the order ID. Let it null to generate a random one. * @throws IOException communication error * @throws GeneralSecurityException data decryption error * @throws AxelorException * @throws JDOMException * @throws EbicsException server generated error message */ public X509Certificate[] sendHPB() throws IOException, GeneralSecurityException, AxelorException, JDOMException { HPBRequestElement request; KeyManagementResponseElement response; HttpRequestSender sender; HPBResponseOrderDataElement orderData; ContentFactory factory; int httpCode; sender = new HttpRequestSender(session); request = new HPBRequestElement(session); request.build(); request.validate(); httpCode = sender.send(new ByteArrayContentFactory(request.prettyPrint())); EbicsUtils.checkHttpCode(httpCode); response = new KeyManagementResponseElement( sender.getResponseBody(), "HBPResponse", session.getUser()); response.build(); response.report(new EbicsRootElement[] {request, response}); EbicsUserService userService = Beans.get(EbicsUserService.class); factory = new ByteArrayContentFactory( EbicsUtils.unzip( userService.decrypt( session.getUser(), response.getOrderData(), response.getTransactionKey()))); orderData = new HPBResponseOrderDataElement(factory, session.getUser()); orderData.build(); return createCertificates(orderData); }
Example #28
Source File: HaplogroupTest.java From haplogrep-cmd with MIT License | 5 votes |
@Test public void testH2a2b() throws NumberFormatException, JDOMException, IOException, InvalidPolymorphismException, HsdFileException, InvalidColumnCountException { List<RankedResult> result = phylotree.search(TestSample.parse("549 1-16569 H2a2b 263G 309.1C 309.2T 4080C 8860G 15326G 16291T"),new HammingRanking()); Assert.assertEquals("H2a2b3", result.get(0).getHaplogroup().toString()); }
Example #29
Source File: HaplogroupTest.java From haplogrep-cmd with MIT License | 5 votes |
@Test //GH #11 public void testW1_119() throws NumberFormatException, JDOMException, IOException, InvalidPolymorphismException, HsdFileException, InvalidColumnCountException { List<RankedResult> result = phylotree.search(TestSample.parse("ID 1-16569 W1+119 73G 94A 103A 118C 119C 189G 195C 198T 204C 207A 263G 709A 750G 1243C 1438G 2706G 3505G 4769G 5046A 5460A 7028T 7864T 8251A 8860G 8994A 11674T 11719A 11947G 12414C 12705T 14766T 15326G 15884C 16223T 16278T 16292T 16295T 16519C"),new HammingRanking()); Assert.assertEquals("W1+119", result.get(0).getHaplogroup().toString()); }
Example #30
Source File: InspectionProfileLoadUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Profile load(@Nonnull File file, @Nonnull InspectionToolRegistrar registrar, @Nonnull ProfileManager profileManager) throws JDOMException, IOException, InvalidDataException { Element element = JDOMUtil.loadDocument(file).getRootElement(); InspectionProfileImpl profile = new InspectionProfileImpl(getProfileName(file, element), registrar, profileManager); final Element profileElement = element.getChild(PROFILE_TAG); if (profileElement != null) { element = profileElement; } profile.readExternal(element); return profile; }