List of usage examples for javax.xml.bind JAXBElement getValue
public T getValue()
Return the content model and attribute values for this element.
See #isNil() for a description of a property constraint when this value is null
From source file:org.socialhistoryservices.pid.ws.PidServiceEndPoint.java
@PayloadRoot(localPart = "DeletePidRequest", namespace = namespace) @ResponsePayload//from www. j ava 2 s . co m public JAXBElement<DeletePidResponseType> deletePid( @RequestPayload JAXBElement<DeletePidRequestType> requestElement) { final String pid = normalize(requestElement.getValue().getPid(), true); final boolean deleted = pidResourceService.deletePid(pid); final DeletePidResponseType response = objectFactory.createDeletePidResponseType(); response.setDeleted(deleted); return objectFactory.createDeletePidResponse(response); }
From source file:org.socialhistoryservices.pid.ws.PidServiceEndPoint.java
@PayloadRoot(localPart = "DeletePidsRequest", namespace = namespace) @ResponsePayload// w w w .j a v a 2 s .co m public JAXBElement<DeletePidsResponseType> deletePids( @RequestPayload JAXBElement<DeletePidsRequestType> requestElement) { final String na = normalize(requestElement.getValue().getNa(), true); final long count = pidResourceService.deletePids(na); final DeletePidsResponseType response = objectFactory.createDeletePidsResponseType(); response.setCount(count); return objectFactory.createDeletePidsResponse(response); }
From source file:edu.harvard.i2b2.crc.axis2.RequestDataMessage.java
public void setRequestMessageType(String requestWdo) throws I2B2Exception { try {/*from w ww . ja v a2s .c o m*/ JAXBElement jaxbElement = CRCJAXBUtil.getJAXBUtil().unMashallFromString(requestWdo); this.reqMessageType = (RequestMessageType) jaxbElement.getValue(); } catch (JAXBUtilException e) { throw new I2B2Exception("Umarshaller error: " + e.getMessage() + requestWdo, e); } }
From source file:com.kurtraschke.wsf.gtfsrealtime.services.WSFVesselLocationService.java
public List<VesselLocationResponse> getAllVessels() throws URISyntaxException, IOException, JAXBException { ImmutableList.Builder<VesselLocationResponse> allVessels = ImmutableList.builder(); URI endpoint = new URIBuilder("http://www.wsdot.wa.gov/ferries/api/vessels/rest/vessellocations") .addParameter("apiaccesscode", _apiAccessCode).build(); CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(_connectionManager).build(); HttpGet request = new HttpGet(endpoint); request.addHeader("Accept", "text/xml"); try (CloseableHttpResponse response = httpclient.execute(request)) { HttpEntity entity = response.getEntity(); if (entity != null) { try (InputStream instream = entity.getContent()) { JAXBElement<ArrayOfVesselLocationResponse> responseArray; responseArray = _um.unmarshal(new StreamSource(instream), ArrayOfVesselLocationResponse.class); allVessels.addAll(responseArray.getValue().getVesselLocationResponse()); }//from w w w . j a va 2s . c o m } } return allVessels.build(); }
From source file:edu.harvard.i2b2.eclipse.plugins.metadataLoader.ws.OntologyResponseData.java
public StatusType processResult(String response) { StatusType status = null;// w ww .j a va2 s. co m try { JAXBElement jaxbElement = MetadataLoaderJAXBUtil.getJAXBUtil().unMashallFromString(response); respMessageType = (ResponseMessageType) jaxbElement.getValue(); // Get response message status ResponseHeaderType responseHeader = respMessageType.getResponseHeader(); status = responseHeader.getResultStatus().getStatus(); String procStatus = status.getType(); String procMessage = status.getValue(); if (procStatus.equals("ERROR")) { log.error("Error reported by Ont web Service " + procMessage); } else if (procStatus.equals("WARNING")) { log.error("Warning reported by Ont web Service" + procMessage); } } catch (JAXBUtilException e) { log.error(e.getMessage()); } return status; }
From source file:org.apache.taverna.scufl2.translator.t2flow.defaultactivities.AbstractActivityParser.java
public <ConfigType> ConfigType unmarshallConfig(T2FlowParser t2FlowParser, ConfigBean configBean, String encoding, Class<ConfigType> configType) throws ReaderException { Object config = configBean.getAny(); if (config instanceof JAXBElement) { JAXBElement<?> jaxbElement = (JAXBElement<?>) config; if (!configType.isInstance((jaxbElement.getValue()))) throw new ReaderException("Unexpected config type: " + jaxbElement.getValue().getClass() + ", expected " + configType); return configType.cast(jaxbElement.getValue()); }//from w w w .ja v a 2 s .c o m if (!(config instanceof Element) || !configBean.getEncoding().equals(encoding)) throw new ReaderException("Unsupported config bean " + configBean); return unmarshallElement(t2FlowParser, (Element) config, configType); }
From source file:com.evolveum.midpoint.model.common.expression.evaluator.GenerateExpressionEvaluatorFactory.java
@Override public <V extends PrismValue, D extends ItemDefinition> ExpressionEvaluator<V, D> createEvaluator( Collection<JAXBElement<?>> evaluatorElements, D outputDefinition, String contextDescription, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException { Validate.notNull(outputDefinition,//from www . j a v a 2 s . c om "output definition must be specified for 'generate' expression evaluator"); if (evaluatorElements.size() > 1) { throw new SchemaException("More than one evaluator specified in " + contextDescription); } JAXBElement<?> evaluatorElement = evaluatorElements.iterator().next(); Object evaluatorTypeObject = null; if (evaluatorElement != null) { evaluatorTypeObject = evaluatorElement.getValue(); } if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof GenerateExpressionEvaluatorType)) { throw new SchemaException("Generate expression evaluator cannot handle elements of type " + evaluatorTypeObject.getClass().getName() + " in " + contextDescription); } GenerateExpressionEvaluatorType generateEvaluatorType = (GenerateExpressionEvaluatorType) evaluatorTypeObject; StringPolicyType elementStringPolicy = null; if (generateEvaluatorType.getValuePolicyRef() != null) { ValuePolicyType valuePolicyType = objectResolver.resolve(generateEvaluatorType.getValuePolicyRef(), ValuePolicyType.class, null, "resolving value policy reference in " + contextDescription, task, result); elementStringPolicy = valuePolicyType.getStringPolicy(); } return new GenerateExpressionEvaluator<V, D>(generateEvaluatorType, outputDefinition, protector, elementStringPolicy, prismContext); }
From source file:edu.harvard.i2b2.im.ws.ResponseDataMessage.java
public void setResponseMessageType(String responseWdo) throws I2B2Exception { try {/*from w ww. j a v a2 s. co m*/ JAXBElement jaxbElement = IMJAXBUtil.getJAXBUtil().unMashallFromString(responseWdo); this.reqMessageType = (ResponseMessageType) jaxbElement.getValue(); } catch (JAXBUtilException e) { throw new I2B2Exception("Umarshaller error: " + e.getMessage() + responseWdo, e); } }
From source file:com.dalendev.meteotndata.servlet.UpdateStationDataServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w . j ava 2s . c om * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { InputStream inputStream = request.getInputStream(); ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); int length; byte[] buffer = new byte[1024]; while ((length = inputStream.read(buffer)) >= 0) { byteArrayStream.write(buffer, 0, length); } if (byteArrayStream.size() > 0) { Station station = SerializationUtils.deserialize(byteArrayStream.toByteArray()); Logger.getLogger(UpdateStationDataServlet.class.getName()).log(Level.INFO, station.getCode()); JAXBContext jc; try { jc = JAXBContext.newInstance(MeasurementList.class); Unmarshaller u = jc.createUnmarshaller(); URL url = new URL( "http://dati.meteotrentino.it/service.asmx/ultimiDatiStazione?codice=" + station.getCode()); StreamSource src = new StreamSource(url.openStream()); JAXBElement je = u.unmarshal(src, MeasurementList.class); MeasurementList measurementList = (MeasurementList) je.getValue(); MeasurmentSamplerService mss = new MeasurmentSamplerService(); mss.mergeMeasurment(station, measurementList); List<Measurement> sampledList = mss.getSampledMeasurementList(); MeasurementDAO.storeStation(sampledList); if (sampledList.size() > 0) { Measurement lastMeasurement = sampledList.get(sampledList.size() - 1); station.setLastUpdate(lastMeasurement.getTimestamp()); StationDAO.storeStation(station); } Logger.getLogger(UpdateStationDataServlet.class.getName()).log(Level.INFO, "Station {0} has {1} new measurements", new Object[] { station.getCode(), sampledList.size() }); } catch (JAXBException ex) { Logger.getLogger(UpdateStationDataServlet.class.getName()).log(Level.SEVERE, null, ex); } response.setStatus(200); } else { Logger.getLogger(UpdateStationDataServlet.class.getName()).log(Level.INFO, "Cannot retrieve Station's serialization"); } }
From source file:edu.harvard.i2b2.crc.axis2.ResponseDataMessage.java
public void setResponseMessageType(String responseWdo) throws I2B2Exception { try {//from w ww. j a va 2s. c o m JAXBElement jaxbElement = CRCJAXBUtil.getJAXBUtil().unMashallFromString(responseWdo); this.reqMessageType = (ResponseMessageType) jaxbElement.getValue(); } catch (JAXBUtilException e) { throw new I2B2Exception("Umarshaller error: " + e.getMessage() + responseWdo, e); } }