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:be.fedict.trust.tsl.TSLParser.java
private TrustStatusListType parseTslInputStream() throws JAXBException { Unmarshaller unmarshaller = getUnmarshaller(); JAXBElement<TrustStatusListType> jaxbElement = (JAXBElement<TrustStatusListType>) unmarshaller .unmarshal(this.tslInputStream); TrustStatusListType trustServiceStatusList = jaxbElement.getValue(); return trustServiceStatusList; }
From source file:cz.lbenda.dataman.db.ExtConfFactory.java
private void loadExConfType(Reader reader) { if (reader == null) { loadExConfType((ExConfType) null); } else {/* w w w . j a va 2s . co m*/ try { JAXBContext jc = JAXBContext.newInstance(cz.lbenda.dataman.schema.exconf.ObjectFactory.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement o = (JAXBElement) u.unmarshal(reader); if (o.getValue() instanceof ExConfType) { loadExConfType((ExConfType) o.getValue()); } else { LOG.error("The file didn't contains expected configuration: " + o.getClass().getName()); } } catch (JAXBException e) { LOG.error("Problem with reading extended configuration: " + e.toString(), e); } } }
From source file:org.jasig.portlet.courses.dao.xml.Jaxb2CourseSummaryHttpMessageConverter.java
@Override protected Object readFromSource(Class<? extends Object> clazz, HttpHeaders headers, Source source) throws IOException { try {/*from www . j a v a 2 s . c o m*/ Unmarshaller unmarshaller = createWrapperUnmarshaller(clazz); if (clazz.isAnnotationPresent(XmlRootElement.class)) { return unmarshaller.unmarshal(source); } else { JAXBElement<? extends Object> jaxbElement = unmarshaller.unmarshal(source, clazz); return jaxbElement.getValue(); } } catch (UnmarshalException ex) { throw new HttpMessageNotReadableException("Could not unmarshal to [" + clazz + "]: " + ex.getMessage(), ex); } catch (JAXBException ex) { throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex); } }
From source file:org.wallerlab.yoink.molecular.service.translator.ParameterTranslator.java
/** * get parameters a Map(JobParameter -/*w ww. ja va 2 s. co m*/ * {@link org.wallerlab.yoink.api.model.bootstrap.JobParameter}, Object) * from JAXBElement ParameterList {@link org.xml_cml.schema.ParameterList} * in JAXBElement Cml {@link org.xml_cml.schema.Cml}. * * @param cml * {@link javax.xml.bind.JAXBElement} * @return parameters is a map, the key is a JobParameter - * {@link org.wallerlab.yoink.api.model.bootstrap.JobParameter} and * the value is an Object -{@link java.lang.Object } */ @Override public Map<JobParameter, Object> translate(JAXBElement<Cml> cml) { Map<JobParameter, Object> parameters = new HashMap<JobParameter, Object>(); Cml cmlMolecularSystem = cml.getValue(); parseParameterList(parameters, cmlMolecularSystem); return parameters; }
From source file:com.evolveum.midpoint.model.common.expression.evaluator.FunctionExpressionEvaluatorFactory.java
@Override public <V extends PrismValue, D extends ItemDefinition> ExpressionEvaluator<V, D> createEvaluator( Collection<JAXBElement<?>> evaluatorElements, D outputDefinition, ExpressionFactory factory, String contextDescription, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException { Validate.notNull(outputDefinition,//w ww .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 FunctionExpressionEvaluatorType)) { throw new SchemaException("Function expression evaluator cannot handle elements of type " + evaluatorTypeObject.getClass().getName() + " in " + contextDescription); } FunctionExpressionEvaluatorType functionEvaluatorType = (FunctionExpressionEvaluatorType) evaluatorTypeObject; return new FunctionExpressionEvaluator(functionEvaluatorType, outputDefinition, protector, getObjectResolver(), prismContext); }
From source file:edu.harvard.i2b2.eclipse.plugins.ontology.ws.OntologyResponseData.java
public StatusType processResult(String response) { StatusType status = null;/*w w w . j a v a2 s . co m*/ try { JAXBElement jaxbElement = OntologyJAXBUtil.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.wallerlab.yoink.service.PropertyWrapper.java
private void changeMoleculeId(Job<JAXBElement> job, JAXBElement<Cml> cmlElement) { for (Object elementList : cmlElement.getValue().getAnyCmlOrAnyOrAny()) { // check moleucleList JAXBElement element = (JAXBElement) elementList; if (element.getDeclaredType() == MoleculeList.class) { loopOverAllMolecules(job, elementList); }//w w w . j a v a2s . com } }
From source file:org.geosdi.geoplatform.connector.server.request.GPPostConnectorRequest.java
@Override public T getResponse() throws IllegalParameterFault, ServerInternalFault, IOException { T response = null;// w w w . j a v a 2 s. c o m try { HttpResponse httpResponse = super.securityConnector.secure(this, this.getPostMethod()); HttpEntity responseEntity = httpResponse.getEntity(); if (responseEntity != null) { InputStream is = responseEntity.getContent(); Unmarshaller unmarshaller = getUnmarshaller(); Object content = unmarshaller.unmarshal(is); if (!(content instanceof JAXBElement)) { // ExceptionReport logger.error("\n#############\n{}\n#############", content); throw new ServerInternalFault("Connector Server Error: incorrect responce"); } JAXBElement<T> elementType = (JAXBElement<T>) content; response = elementType.getValue(); EntityUtils.consume(responseEntity); } else { throw new ServerInternalFault("Connector Server Error: Connection " + "problem"); } } catch (JAXBException ex) { logger.error("\n@@@@@@@@@@@@@@@@@@ JAXBException *** {} ***", ex.getMessage()); throw new ServerInternalFault("*** JAXBException ***" + ex); } catch (ClientProtocolException ex) { logger.error("\n@@@@@@@@@@@@@@@@@@ ClientProtocolException *** {} ***", ex.getMessage()); throw new ServerInternalFault("*** ClientProtocolException ***"); } return response; }
From source file:edu.harvard.i2b2.im.ws.RequestDataMessage.java
public void setRequestMessageType(String requestWdo) throws I2B2Exception { try {//from ww w .java 2 s . c om JAXBElement jaxbElement = IMJAXBUtil.getJAXBUtil().unMashallFromString(requestWdo); this.reqMessageType = (RequestMessageType) jaxbElement.getValue(); } catch (JAXBUtilException e) { throw new I2B2Exception("Umarshaller error: " + e.getMessage() + requestWdo, e); } }
From source file:de.drv.dsrv.extra.marshaller.impl.ExtraUnmarschaller.java
@Override public <X> X unmarshal(final Source source, final Class<X> extraTransportClass, final boolean validation) throws XmlMappingException, IOException { Assert.notNull(source, "StreamSource is null"); Assert.notNull(extraTransportClass, "ExtraTransportClass is null"); final Unmarshaller unmarshaller = findUnmarschaller(validation); final Object responseObject = unmarshaller.unmarshal(source); logger.debug("ResponseObject Class: {}", responseObject.getClass()); Assert.notNull(responseObject, "Response is null"); X extraTransport = null;//from w ww. ja v a 2 s.c o m if (ResponseTransport.class.isAssignableFrom(responseObject.getClass())) { extraTransport = extraTransportClass.cast(responseObject); } else if (JAXBElement.class.isAssignableFrom(responseObject.getClass())) { // TODO Wie funktioniert es besser? @SuppressWarnings("rawtypes") final JAXBElement jaxbElementResponse = JAXBElement.class.cast(responseObject); final Object jaxBElementValue = jaxbElementResponse.getValue(); Assert.isAssignable(extraTransportClass, jaxBElementValue.getClass(), "JaxBElement.value can not be converted to the response.ResponseTransport"); extraTransport = extraTransportClass.cast(jaxBElementValue); } else { throw new IllegalArgumentException( "Response can not be converted to the response.ResponseTransport. ResponseObjectClass: " + responseObject.getClass()); } return extraTransport; }