Example usage for javax.xml.bind JAXBElement getValue

List of usage examples for javax.xml.bind JAXBElement getValue

Introduction

In this page you can find the example usage for javax.xml.bind JAXBElement getValue.

Prototype

public T getValue() 

Source Link

Document

Return the content model and attribute values for this element.

See #isNil() for a description of a property constraint when this value is null

Usage

From source file:edu.harvard.i2b2.eclipse.plugins.ontology.ws.OntServiceDriver.java

public static int processSecurityResult(String response) {
    int timeout = -1;
    try {//from  w  w w. j a  va2s.c om
        JAXBElement jaxbElement = OntologyJAXBUtil.getJAXBUtil().unMashallFromString(response);
        ResponseMessageType respMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status
        MessageHeaderType messageHeader = respMessageType.getMessageHeader();
        if (messageHeader.getSecurity() != null && messageHeader.getSecurity().getPassword() != null
                && messageHeader.getSecurity().getPassword().getTokenMsTimeout() != null) {
            timeout = messageHeader.getSecurity().getPassword().getTokenMsTimeout().intValue();
        }

        /*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 timeout;
}

From source file:org.wallerlab.yoink.service.response.JmsJobItemWriter.java

/**
 * write adaptive QM/MM result into a String, and then send to a JMS queue.
 * //from  w  w  w . j  a va2 s  . co m
 * @param jobs
 *            - a List of Job
 *            {@link org.wallerlab.yoink.api.model.bootstrap.Job } List
 */
@Override
public void write(List<? extends Job> jobs) throws Exception {
    List<String> items = new ArrayList<>();
    for (Job job : jobs) {
        JAXBElement<Cml> input = (JAXBElement<Cml>) job.getInput();
        jaxbStringWriter.write("notused", input.getValue());
        items.add(jaxbStringWriter.getOutput());
    }
    jmsItemWriter.write(items);
}

From source file:edu.harvard.i2b2.workplace.ws.RequestDataMessage.java

public void setRequestMessageType(String requestWdo) throws I2B2Exception {
    try {//from  www  . j ava  2  s .c o m
        JAXBElement jaxbElement = WorkplaceJAXBUtil.getJAXBUtil().unMashallFromString(requestWdo);
        this.reqMessageType = (RequestMessageType) jaxbElement.getValue();

    } catch (JAXBUtilException e) {
        throw new I2B2Exception("Umarshaller error: " + e.getMessage() + requestWdo, e);
    }
}

From source file:fr.mael.microrss.xml.AtomFeedParser.java

private String readFeedAuthor(FeedType feedType) {
    for (Object o : feedType.getAuthorOrCategoryOrContributor()) {
        if (o instanceof JAXBElement) {
            JAXBElement element = (JAXBElement) o;
            if (element.getValue() instanceof PersonType) {
                PersonType person = (PersonType) element.getValue();
                return XMLUtil.readProperty("name", person.getNameOrUriOrEmail());
            }//from  w  w w  .j a  va  2s.  com
        }
    }
    return null;
}

From source file:fr.mael.microrss.xml.AtomFeedParser.java

private List<Article> readEntries(List<Object> objects, Feed feed, FeedType feedType) {
    List<Article> articles = new ArrayList<Article>();
    for (Object o : objects) {
        if (o instanceof JAXBElement) {
            JAXBElement element = (JAXBElement) o;
            if (element.getValue() instanceof EntryType) {
                EntryType entry = (EntryType) element.getValue();
                Article article = readEntry(entry, feedType);
                article.getFeeds().add(feed);
                articles.add(article);//from  www  . j a va2  s .c o  m
            }
        }
    }
    return articles;
}

From source file:jails.http.converter.xml.Jaxb2RootElementHttpMessageConverter.java

@Override
protected Object readFromSource(Class<?> clazz, HttpHeaders headers, Source source) throws IOException {
    try {/*ww  w. j  a  v a2 s .  c  o m*/
        Unmarshaller unmarshaller = createUnmarshaller(clazz);
        if (clazz.isAnnotationPresent(XmlRootElement.class)) {
            return unmarshaller.unmarshal(source);
        } else {
            JAXBElement 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.osmtools.api.SchemaService.java

public Osm fromStream(InputStream inputStream) {
    try {//  w  w  w  . j a v a 2s.  c  om
        JAXBElement<Osm> jaxbElement = createOsmUnmarshaller().unmarshal(new StreamSource(inputStream),
                Osm.class);
        return jaxbElement.getValue();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}

From source file:ddf.catalog.registry.transformer.Gml3ToWkt.java

@SuppressWarnings("unchecked")
public String convert(InputStream xml) {
    AbstractGeometryType geometry = null;
    try {//  w  w  w  .j av  a 2  s  .c  o m
        JAXBElement<AbstractGeometryType> jaxbElement = parser.unmarshal(configurator, JAXBElement.class, xml);
        geometry = jaxbElement.getValue();
        GML311ToJTSGeometryConverter geometryConverter = new GML311ToJTSGeometryConverter();
        Geometry jtsGeo = geometryConverter.createGeometry(new DefaultRootObjectLocator(jaxbElement), geometry);
        WKTWriter wktWriter = new WKTWriter();
        return wktWriter.write(jtsGeo);
    } catch (ParserException e) {
        LOGGER.error("Cannot parse gml: {}", e.getMessage());
    } catch (ConversionFailedException e) {
        LOGGER.error("Cannot convert gml311 geo object {} to jts", geometry);
    }

    return "";
}

From source file:io.mapzone.controller.catalog.csw.CswResponse.java

protected <T> T readObject(InputStream in, Class<T> type) throws JAXBException {
    Unmarshaller unmarshaller = jaxbContext.get().createUnmarshaller();
    JAXBElement<T> elm = unmarshaller.unmarshal(new StreamSource(in), type);
    return elm.getValue();
}

From source file:com.qpark.eip.core.model.analysis.operation.GetClusterOperation.java

/**
 * @param message/*from   ww w  .  jav a 2 s. com*/
 *            the {@link JAXBElement} containing a
 *            {@link GetClusterRequestType}.
 * @return the {@link JAXBElement} with a {@link GetComplexTypeResponseType}
 *         .
 */
@Override
public JAXBElement<GetClusterResponseType> invoke(final JAXBElement<GetClusterRequestType> message) {
    this.logger.debug("+getCluster");
    GetClusterRequestType request = message.getValue();
    GetClusterResponseType response = this.of.createGetClusterResponseType();
    long start = System.currentTimeMillis();
    try {
        String modelVersion = request.getRevision();
        if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) {
            modelVersion = this.dao.getLastModelVersion();
        }
        response.setCluster(this.dao.getClusterByTargetNamespace(modelVersion, request.getTargetNamespace()));
    } catch (Throwable e) {
        /* Add a not covered error to the response. */
        this.logger.error(e.getMessage(), e);
    } finally {
        this.logger.debug(" getCluster duration {}", DateUtil.getDuration(start, System.currentTimeMillis()));
        this.logger.debug("-getCluster #{}", response.getCluster() == null ? 0 : 1);
    }
    return this.of.createGetClusterResponse(response);
}