List of usage examples for javax.xml.bind JAXBContext createUnmarshaller
public abstract Unmarshaller createUnmarshaller() throws JAXBException;
From source file:com.qmetry.qaf.automation.integration.qmetry.testnglistener.QmetryMethodSelector.java
public ArrayList<String> getQmetrySecheduledTCs() { String xmlFile = System.getProperty("qmetry.schedule.file"); String pkg =/*from w w w. j a va 2 s . c om*/ ConfigurationManager.getBundle().getString("qmetry.jax.pkg", "com.qmetry.schedule.jax"); ArrayList<String> tcLst = null; if (StringUtils.isNotBlank(xmlFile)) { // create a JAXBContext capable of handling classes generated into // the testrunner.jax package JAXBContext jc; tcLst = new ArrayList<String>(); try { jc = JAXBContext.newInstance(pkg); // create an Unmarshaller Unmarshaller u = jc.createUnmarshaller(); // unmarshal a xml file into a tree of Java content // objects composed of classes from the testrunner.jax package. Schedules schedules = null; schedules = (Schedules) u.unmarshal(new File(xmlFile)); Schedule schedule = schedules.getSchedule(); Testsuite suit = schedule.getTestsuite(); Testcases tcs = suit.getTestcases(); QmetryWSUtil wsUtil = QmetryWSUtil.getInstance(); String prj = suit.getProjectname(); String rel = suit.getReleasename(); String build = suit.getBuildname(); System.out.println("Qmetry scheduled prj: " + prj + " rel : " + rel + " build: " + build); wsUtil.setScope(prj, rel, build); for (Testcase tc : tcs.getTestcase()) { String tcid = String.valueOf(tc.getTestcaseid().intValue()); System.out.println("Qmetry scheduled TC: " + tcid); tcLst.add(tcid); } } catch (Exception e) { e.printStackTrace(); } } return tcLst; }
From source file:eu.learnpad.core.impl.mv.XwikiBridgeInterfaceRestResource.java
@Override public VerificationId startVerification(String modelSetId, String verificationType) throws LpRestException { HttpClient httpClient = this.getHttpClient(); String uri = String.format("%s/learnpad/mv/bridge/startverification", this.restPrefix); GetMethod getMethod = new GetMethod(uri); getMethod.addRequestHeader("Accept", "application/xml"); NameValuePair[] queryString = new NameValuePair[2]; queryString[0] = new NameValuePair("modelsetid", modelSetId); queryString[1] = new NameValuePair("verificationtype", verificationType); getMethod.setQueryString(queryString); try {//from ww w .j ava2s .c o m httpClient.executeMethod(getMethod); } catch (IOException e) { throw new LpRestExceptionXWikiImpl(e.getMessage(), e); } VerificationId verificationId = null; try { JAXBContext jaxbContext = JAXBContext.newInstance(VerificationId.class); InputStream retIs = getMethod.getResponseBodyAsStream(); verificationId = (VerificationId) jaxbContext.createUnmarshaller().unmarshal(retIs); } catch (Exception e) { throw new LpRestExceptionXWikiImpl(e.getMessage(), e); } return verificationId; }
From source file:jp.co.tis.gsp.tools.db.ObjectBrowserErParser.java
public void parse(File erdFile) throws JAXBException, IOException, TemplateException { JAXBContext context = JAXBContext.newInstance(Erd.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Erd erd = (Erd) unmarshaller.unmarshal(erdFile); erd.init();/*from w w w . j av a 2 s .c o m*/ setupTemplateLoader(); Template template = getTemplate("createTable.ftl"); Template indexTemplate = getTemplate("createIndex.ftl"); Template fkTemplate = getTemplate("addForeignKey.ftl"); Template viewTemplate = getTemplate("createView.ftl"); Map<String, Object> dto = new HashMap<String, Object>(); erd.setSchema(schema); dto.put("erd", erd); List<Entity> entityList; List<View> viewList; ModelView modelView = erd.getModelView(schema); if (modelView == null) { entityList = erd.entityList; viewList = erd.getViewList(); } else { entityList = modelView.getEntityList(); viewList = modelView.getViewList(); } for (Entity entity : entityList) { // != ?????? if (!user.equals(schema)) { //ftl?.()?????????????? entity.setSchema(schema + "."); } // SHOWTYPE?0???? if (entity.getShowType() != 0) { continue; } // ????????? for (Column column : entity.getColumnList()) { if (typeMapper != null) { typeMapper.convert(column); } } dto.put("entity", entity); dto.put("LengthSemantics", BeansWrapper.getDefaultInstance().getEnumModels().get(LengthSemantics.class.getName())); dto.put("lengthSemantics", lengthSemantics); dto.put("allocationSize", allocationSize); if (printTable) { template.process(dto, getWriter("10_CREATE_" + entity.getName())); } // index int i = 0; for (Index index : entity.getIndexList()) { // ??????NULL????? if (!printIndex || index.getColumnList() == null) { continue; } if (StringUtils.isBlank(index.getName())) { index.setName("IDX_" + entity.getName() + String.format("%02d", ++i)); } Map<String, Object> indexDto = new HashMap<String, Object>(dto); indexDto.put("index", index); indexTemplate.process(indexDto, getWriter("20_CREATE_" + index.getName())); } // Foreign Key i = 0; for (ForeignKey foreignKey : entity.getForeignKeyList()) { // ?????????EntityList????????? // FK???? if (!printForeignKey || foreignKey.getReferenceEntity().getShowType() != 0 || !contains(entityList, foreignKey.getReferenceEntity())) { continue; } if (StringUtils.isBlank(foreignKey.getName())) { foreignKey.setName("FK_" + entity.getName() + String.format("%02d", ++i)); } Map<String, Object> fkDto = new HashMap<String, Object>(dto); fkDto.put("foreignKey", foreignKey); fkTemplate.process(fkDto, getWriter("30_CREATE_" + foreignKey.getName())); } } // View if (viewList != null) { for (View view : viewList) { // != ?????? if (!user.equals(schema)) { //ftl?.()?????????????? view.setSchema(schema + "."); } if (!printView || view.getShowType() != 0) { continue; } dto.put("view", view); viewTemplate.process(dto, getWriter("40_CREATE_" + view.getName())); } } }
From source file:com.rapid.server.ActionCache.java
public ActionCache(ServletContext servletContext) throws JAXBException { // retain servletContext _servletContext = servletContext;//w w w . j a va2 s. co m // create the JAXB context and marshalers for this JAXBContext jaxb = JAXBContext.newInstance(Cache.class); _marshaller = jaxb.createMarshaller(); _marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); _unmarshaller = jaxb.createUnmarshaller(); // initialise the map of all application caches _applicationCaches = new HashMap<String, Cache>(); }
From source file:de.jcup.egradle.codecompletion.UserHomeBasedXMLProposalDataModelProvider.java
public void reload() { synchronized (monitor) { loaded = true;/* w w w . j a va 2 s. co m*/ cachedDataModels.clear(); Set<File> files = findCodeCompletionFilesInUserHome(); if (files == null || files.size() == 0) { return; } JAXBContext jc; try { jc = JAXBContext.newInstance(XMLProposalDataModel.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); for (File file : files) { try { XMLProposalDataModel loadedModel = (XMLProposalDataModel) unmarshaller .unmarshal(new FileInputStream(file)); cachedDataModels.add(loadedModel); } catch (IOException e) { if (errorHandler != null) { errorHandler.handleError( "Was not able to create xml code completion model for file:" + file, e); } } } } catch (JAXBException e) { if (errorHandler != null) { errorHandler.handleError( "Was not able to create JAXB context - so no xml code completion from user home base by xmls possible!", e); } return; } } }
From source file:org.exist.xquery.RestBinariesTest.java
@Override protected QueryResultAccessor<Result, Exception> executeXQuery(final String xquery) throws Exception { final HttpResponse response = postXquery(xquery); final HttpEntity entity = response.getEntity(); try (final InputStream is = entity.getContent()) { final JAXBContext jaxbContext = JAXBContext.newInstance("org.exist.http.jaxb"); final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); final Result result = (Result) unmarshaller.unmarshal(is); return consumer -> consumer.accept(result); }//from w w w . j av a 2 s. co m }
From source file:io.treefarm.plugins.haxe.components.HaxeCompiler.java
private void addHars(List<String> argumentsList, MavenProject project, Set<CompileTarget> targets) { File dependenciesDirectory = new File(outputDirectory, "dependencies"); if (!dependenciesDirectory.exists()) dependenciesDirectory.mkdir();/*from ww w . j a va 2 s. c o m*/ for (Artifact artifact : project.getArtifacts()) { if (artifact.getType().equals(HaxeFileExtensions.HAR)) { File harUnpackDirectory = new File(dependenciesDirectory, artifact.getArtifactId()); if (!harUnpackDirectory.exists()) { harUnpackDirectory.mkdir(); ZipUnArchiver unArchiver = new ZipUnArchiver(); unArchiver.enableLogging(logger); unArchiver.setSourceFile(artifact.getFile()); unArchiver.setDestDirectory(harUnpackDirectory); unArchiver.extract(); } try { File metadataFile = new File(harUnpackDirectory, HarMetadata.METADATA_FILE_NAME); JAXBContext jaxbContext = JAXBContext.newInstance(HarMetadata.class, CompileTarget.class); HarMetadata metadata = (HarMetadata) jaxbContext.createUnmarshaller().unmarshal(metadataFile); if (!metadata.target.containsAll(targets)) logger.warn("Dependency " + artifact + " is not compatible with your compile targets."); } catch (JAXBException e) { logger.warn("Can't read " + artifact + "metadata", e); } addSourcePath(argumentsList, harUnpackDirectory.getAbsolutePath()); } } }
From source file:eu.learnpad.core.impl.mv.XwikiBridgeInterfaceRestResource.java
@Override public VerificationStatus getVerificationStatus(String verificationProcessId) throws LpRestException { HttpClient httpClient = this.getHttpClient(); String uri = String.format("%s/learnpad/mv/bridge/getverificationstatus", this.restPrefix); GetMethod getMethod = new GetMethod(uri); getMethod.addRequestHeader("Accept", "application/xml"); NameValuePair[] queryString = new NameValuePair[1]; queryString[0] = new NameValuePair("verificationprocessid", verificationProcessId); getMethod.setQueryString(queryString); try {/*from ww w . j av a 2s. c o m*/ httpClient.executeMethod(getMethod); } catch (IOException e) { throw new LpRestExceptionXWikiImpl(e.getMessage(), e); } VerificationStatus verificationStatus = null; try { JAXBContext jaxbContext = JAXBContext.newInstance(VerificationStatus.class); InputStream retIs = getMethod.getResponseBodyAsStream(); verificationStatus = (VerificationStatus) jaxbContext.createUnmarshaller().unmarshal(retIs); } catch (Exception e) { throw new LpRestExceptionXWikiImpl(e.getMessage(), e); } return verificationStatus; }
From source file:hu.bme.iit.quiz.service.QuizServiceImpl.java
public QuizData getQuizDataFromXML(Quiz quiz) { try {/*from ww w.ja va 2 s. co m*/ ObjectFactory objectFactory = new ObjectFactory(); JAXBContext jc = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName(), ObjectFactory.class.getClassLoader()); Unmarshaller unmarshaller = jc.createUnmarshaller(); InputStream inputStream = new ByteArrayInputStream(quiz.getBlobdata()); QuizData quizData = (QuizData) unmarshaller.unmarshal(inputStream); return quizData; } catch (JAXBException ex) { logger.error(ex); } return null; }
From source file:eu.learnpad.core.rest.XWikiRestUtils.java
public String getEmailAddress(String wikiName, String username) throws LpRestExceptionXWikiImpl { String emailAddress = null;/*from w ww .j a v a 2 s .c om*/ HttpClient httpClient = restResource.getClient(); // http://<server>/rest/wikis/xwiki/spaces/XWiki/pages/<username>/objects/XWiki.XWikiUsers/0/properties/email String uri = String.format("%s/wikis/%s/spaces/XWiki/pages/%s/objects/XWiki.XWikiUsers/0/properties/email", DefaultRestResource.REST_URI, wikiName, username); GetMethod getMethod = new GetMethod(uri); try { httpClient.executeMethod(getMethod); InputStream response = getMethod.getResponseBodyAsStream(); JAXBContext jaxbContext = JAXBContext.newInstance(Property.class); Property emailProperty = (Property) jaxbContext.createUnmarshaller().unmarshal(response); emailAddress = emailProperty.getValue(); } catch (IOException e) { String message = String.format("Unable to GET the email propery of '%s' on %s@%s'.", username, wikiName, DefaultRestResource.REST_URI); logger.error(message, e); throw new LpRestExceptionXWikiImpl(message, e.getCause()); } catch (JAXBException e) { String message = String.format("Unable to unmarshall the email propery of '%s' on %s@%s'.", username, wikiName, DefaultRestResource.REST_URI); logger.error(message, e); throw new LpRestExceptionXWikiImpl(message, e.getCause()); } return emailAddress; }