public static com.ebmwebsourcing.easyschema10.api.element.Schema readSchema(URL location) throws SchemaException { XmlObjectReader reader = xmlContext.createReader(); try { return reader.readDocument(location, com.ebmwebsourcing.easyschema10.api.element.Schema.class); } catch (XmlObjectReadException e) { throw new UncheckedException(e); } }
reader.setReadMode(XmlObjectReader.ReadMode.LAZY); try { XmlObject readXmlObject = reader.readDocument(s, XmlObject.class); childToAdopt = resolveXPath(readXmlObject, xpath); } catch (XmlObjectReadException e) {
public static Definitions readDefinitions (URL wsdlUrl) throws XmlObjectReadException { // create factory: can be static XmlContextFactory xmlContextFactory = new XmlContextFactory(); // create context: can be static XmlContext xmlContext = xmlContextFactory.newContext(); // create generic reader: cannot be static!!! not thread safe!!! XmlObjectReader reader = xmlContext.createReader(); // read WSDL 1.1 definitions from url Definitions definitions = reader.readDocument(wsdlUrl, Definitions.class); return definitions; }
public static Description readDescription11(URL location) throws XmlObjectReadException { XmlObjectReader reader = xmlContext.createReader(); return (org.petalslink.abslayer.service.api.Description) Factory.getInstance().wrap(reader.readDocument(location, Definitions.class)); }
defs = reader.readDocument(url, Definitions.class);
private File getBPELZipFromBPMN(File projectInstanceFile, IProjectInstanceMetaData exportData, File directory) throws Exception{ FileHelper.cleanDirectory(directory); //first retrieve the bpmn defintions form the given project instance file if(ZipHelper.getInstance().isZipFile(projectInstanceFile)) { ZipHelper.getInstance().unzipFile(projectInstanceFile,directory); } else { FileHelper.copyFile(projectInstanceFile, directory); } File bpmnFile = BPMNFileHelper.getBPMNFileInFolder(directory); URL url = bpmnFile.toURI().toURL(); Definitions defs = new XmlContextFactory().newContext().createReader().readDocument(url, Definitions.class); //get or create a temp dir and generate bpel and wsdl files in it String bpelZipPath = directory.getAbsolutePath()+File.separator+"zip"; File bpelZipDir = new File(bpelZipPath); if(!bpelZipDir.exists()) { bpelZipDir.mkdir(); } FileHelper.cleanDirectory(bpelZipDir); new BPELGenerator().generate(defs, bpelZipPath); //make a zip out of this temporary directory return ZipHelper.getInstance().createZipFromFolder(bpelZipPath, directory.getAbsolutePath()+File.separator+"BPEL"+defs.getId()+".zip"); }
Definitions bpmnDefs = new XmlContextFactory().newContext().createReader().readDocument(bpmnFile.toURI().toURL(), Definitions.class);
Definitions defs; try { defs = reader.readDocument(bpmnFile.toURI().toURL(), Definitions.class); validator.failFastValidate(defs); } catch (MalformedURLException e) {
@Override public IProjectInstanceMetaData getMetaData(File file, IProjectInstanceFormat format) throws ServiceException { XmlContext context = new XmlContextFactory().newContext(); XmlObjectReader reader = context.createReader(); XmlObjectValidator validator = context.createValidator(); Schema xsd; try { xsd = reader.readDocument(new FileInputStream(file), Schema.class); validator.failFastValidate(xsd); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } catch (XmlObjectReadException e) { e.printStackTrace(); return null; } catch (XmlObjectValidationException e) { e.printStackTrace(); throw new ServiceException("Invalid XSD file : "+e.getMessage()); } String location = WebEditorService.ATTACHMENTS_DIR + File.separator + file.getName(); XSDImportBean impt = ImportAdapter.adaptSchemaImport(getPrefix(), location, xsd); SchemaProjectInstanceMetaData metaData = new SchemaProjectInstanceMetaData(impt); return metaData; }
@Override public IProjectInstanceMetaData getMetaData(File file, IProjectInstanceFormat format) throws ServiceException { XmlContext context = new XmlContextFactory().newContext(); XmlObjectReader reader = context.createReader(); XmlObjectValidator validator = context.createValidator(); Definitions defs; try { defs = reader.readDocument(new FileInputStream(file), Definitions.class); validator.failFastValidate(defs); checkWSDLCompatibility(defs); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } catch (XmlObjectReadException e) { e.printStackTrace(); return null; } catch (XmlObjectValidationException e) { e.printStackTrace(); throw new ServiceException("Invalid WSDL file : "+e.getMessage()); } catch (IncompatibleWSDLException e) { throw new ServiceException("Incompatible WSDL file : "+e.getMessage()); } String location = WebEditorService.ATTACHMENTS_DIR + File.separator + file.getName(); WSDLImportBean impt = (WSDLImportBean) ImportAdapter.adaptWSDLImport(getPrefix(), location, defs); WSDLProjectInstanceMetaData metaData = new WSDLProjectInstanceMetaData(impt); return metaData; }