List of usage examples for javax.xml.bind Unmarshaller unmarshal
public <T> JAXBElement<T> unmarshal(javax.xml.stream.XMLEventReader reader, Class<T> declaredType) throws JAXBException;
From source file:com.trifork.batchcopy.client.BatchCopyClient.java
/** * Perform a batch copy request/*from www. j a va2 s . c om*/ * @param register Register name * @param dataType Datatype * @param offsetToken offset token * @return offset token of last entry * @throws JAXBException * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public String performRequest(String register, String dataType, String offsetToken) throws JAXBException, IOException, SAXException, ParserConfigurationException { ReplicationRequestType request = new ReplicationRequestType(); if (offsetToken != null) { request.setOffset(offsetToken); } else { request.setOffset("00000000000000000000"); } request.setVersion(1L); request.setDatatype(dataType); request.setRegister(register); request.setMaxRecords(1L); String requestString = createRequestString(request); Reply reply = sosiUtil.sendServiceRequest(endpointUrl, requestString); Element body = reply.getBody(); Unmarshaller unmarshaller = jaxContext.createUnmarshaller(); JAXBElement<ReplicationResponseType> jaxbResponse = unmarshaller.unmarshal(body, ReplicationResponseType.class); ReplicationResponseType response = jaxbResponse.getValue(); Node atomFeedNode = (Node) response.getAny(); printResponse(atomFeedNode); return extractLastToken(atomFeedNode); }
From source file:com.eventestimator.mvc.ContactCollectionController.java
@RequestMapping(value = "/json.j", method = RequestMethod.GET) protected ResponseEntity<Object> getContacts(Model model, HttpServletRequest request) throws Exception { HttpSession session = request.getSession(); String userName = (String) session.getAttribute("userName"); String accessToken = (String) session.getAttribute("accessToken"); String contactUrl = WS_URL_PREFIX + userName + "/contacts?access_token=" + accessToken; Feed contactSource = restTemplate.getForObject(contactUrl, Feed.class); List<Entry> contacts = contactSource.getEntries(); List<Contact> contactObjects = new ArrayList<Contact>(contacts.size()); for (Entry contact : contacts) { Link link = (Link) contact.getOtherLinks().get(0); String linkHref = link.getHref(); String contentXML = restTemplate.getForObject(WS_DOMAIN + linkHref + "?access_token=" + accessToken, String.class); // List<Content> contactContents = contactEntry.getBody().getContents(); // List<Content> contactContents = contactEntry.getContents(); ////from w w w. j a v a2s .c om // Content contactContent = contactContents.get(0); // String contentXML = contactContent.getValue(); final SAXParserFactory sax = SAXParserFactory.newInstance(); sax.setNamespaceAware(false); final XMLReader reader; try { reader = sax.newSAXParser().getXMLReader(); } catch (SAXException e) { throw new RuntimeException(e); } InputSource is = new InputSource(new StringReader(contentXML)); SAXSource source = new SAXSource(reader, is); JAXBContext context = JAXBContext.newInstance(ContactEntry.class); javax.xml.bind.Unmarshaller unmarshaller = context.createUnmarshaller(); JAXBElement<ContactEntry> contactEntry = (JAXBElement<ContactEntry>) unmarshaller.unmarshal(source, ContactEntry.class); Contact contactObject = contactEntry.getValue().getContent().getContact(); contactObjects.add(contactObject); } ResponseEntity<Object> response = new ResponseEntity<Object>(contactObjects, HttpStatus.OK); return response; }
From source file:esg.node.components.registry.LasSistersGleaner.java
public synchronized LasSistersGleaner loadMyLasServers() { log.info("Loading my LAS LasServers info from " + sistersPath + sistersFile); try {/* w ww .j a v a 2s. co m*/ JAXBContext jc = JAXBContext.newInstance(LasServers.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<LasServers> root = u.unmarshal(new StreamSource(new File(sistersPath + sistersFile)), LasServers.class); servers = root.getValue(); } catch (Exception e) { log.error(e); } return this; }
From source file:esg.node.components.registry.AzsWhitelistGleaner.java
public synchronized AzsWhitelistGleaner loadMyAzsWhitelist() { log.info("Loading my AZS Whitelist info from " + azsWhitelistPath + azsWhitelistFile); try {// w ww .j ava 2s. com JAXBContext jc = JAXBContext.newInstance(AzsWhitelist.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<AzsWhitelist> root = u .unmarshal(new StreamSource(new File(azsWhitelistPath + azsWhitelistFile)), AzsWhitelist.class); azss = root.getValue(); } catch (Exception e) { log.error(e); } return this; }
From source file:esg.node.components.registry.IdpWhitelistGleaner.java
public synchronized IdpWhitelistGleaner loadMyIdpWhitelist() { log.info("Loading my IDP Whitelist info from " + idpWhitelistPath + idpWhitelistFile); try {/* w ww . ja v a 2s . co m*/ JAXBContext jc = JAXBContext.newInstance(IdpWhitelist.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<IdpWhitelist> root = u .unmarshal(new StreamSource(new File(idpWhitelistPath + idpWhitelistFile)), IdpWhitelist.class); idps = root.getValue(); } catch (Exception e) { log.error(e); } return this; }
From source file:esg.node.components.registry.LasSistersGleaner.java
public LasServers createLasServersFromString(String lasServersContentString) { log.info("Loading my LAS LasServers info from \n" + lasServersContentString + "\n"); LasServers fromContentLasServers = null; try {//from w w w . j a v a2s.co m JAXBContext jc = JAXBContext.newInstance(LasServers.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<LasServers> root = u.unmarshal(new StreamSource(new StringReader(lasServersContentString)), LasServers.class); fromContentLasServers = root.getValue(); } catch (Exception e) { log.error(e); } return fromContentLasServers; }
From source file:esg.node.components.registry.AzsWhitelistGleaner.java
public AzsWhitelist createAzsWhitelistFromString(String azsWhitelistContentString) { log.info("Loading my AZS Whitelist info from \n" + azsWhitelistContentString + "\n"); AzsWhitelist fromContentAzsWhitelist = null; try {/*ww w .j a va 2s .com*/ JAXBContext jc = JAXBContext.newInstance(AzsWhitelist.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<AzsWhitelist> root = u .unmarshal(new StreamSource(new StringReader(azsWhitelistContentString)), AzsWhitelist.class); fromContentAzsWhitelist = root.getValue(); } catch (Exception e) { log.error(e); } return fromContentAzsWhitelist; }
From source file:esg.node.components.registry.IdpWhitelistGleaner.java
public IdpWhitelist createIdpWhitelistFromString(String idpWhitelistContentString) { log.info("Loading my IDP Whitelist info from \n" + idpWhitelistContentString + "\n"); IdpWhitelist fromContentIdpWhitelist = null; try {//from www . jav a 2 s .com JAXBContext jc = JAXBContext.newInstance(IdpWhitelist.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<IdpWhitelist> root = u .unmarshal(new StreamSource(new StringReader(idpWhitelistContentString)), IdpWhitelist.class); fromContentIdpWhitelist = root.getValue(); } catch (Exception e) { log.error(e); } return fromContentIdpWhitelist; }
From source file:se.inera.intyg.intygstjanst.web.integration.RevokeMedicalCertificateResponderImplTest.java
private SendMedicalCertificateQuestionType expectedSendRequest() throws Exception { // read request from file JAXBContext jaxbContext = JAXBContext.newInstance(SendMedicalCertificateQuestionType.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<SendMedicalCertificateQuestionType> request = unmarshaller.unmarshal(new StreamSource( new ClassPathResource("revoke-medical-certificate/send-medical-certificate-question-request.xml") .getInputStream()),/*ww w . j av a 2s. com*/ SendMedicalCertificateQuestionType.class); return request.getValue(); }
From source file:se.inera.intyg.intygstjanst.web.integration.RevokeMedicalCertificateResponderImplTest.java
protected RevokeMedicalCertificateRequestType revokeRequest() throws Exception { // read request from file JAXBContext jaxbContext = JAXBContext.newInstance(RevokeMedicalCertificateRequestType.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<RevokeMedicalCertificateRequestType> request = unmarshaller.unmarshal(new StreamSource( new ClassPathResource("revoke-medical-certificate/revoke-medical-certificate-request.xml") .getInputStream()),/*from w w w . j a v a2 s. c om*/ RevokeMedicalCertificateRequestType.class); return request.getValue(); }