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:fr.mael.microrss.xml.AtomFeedParser.java

@Override
public List<Article> readArticles(Feed feed) throws Exception {
    List<Article> articles = new ArrayList<Article>();
    JAXBContext jc = JAXBContext.newInstance("fr.mael.microrss.xml.atom");
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    HttpGet get = new HttpGet(feed.getUrl());
    HttpResponse response = client.execute(get);
    try {/*from  w w  w.j  a  va 2 s  .co  m*/
        Object o = unmarshaller.unmarshal(response.getEntity().getContent());
        if (o instanceof JAXBElement) {
            JAXBElement element = (JAXBElement) o;
            FeedType feedType = (FeedType) element.getValue();
            articles = readEntries(feedType.getAuthorOrCategoryOrContributor(), feed, feedType);
        }
        return articles;
    } catch (Exception e) {
        EntityUtils.consume(response.getEntity());
        throw new Exception(e);
    }
}

From source file:com.samples.platform.serviceprovider.library.internal.GetBookOperation.java

/**
 * @param message//from w w  w.ja v  a  2 s .  com
 *            the {@link JAXBElement} containing a
 *            {@link GetBookRequestType}.
 * @return the {@link JAXBElement} with a {@link GetBookResponseType}.
 */
@InsightEndPoint
@ServiceActivator
public final JAXBElement<GetBookResponseType> getBook(final JAXBElement<GetBookRequestType> message) {
    this.logger.debug("+getBook");
    GetBookRequestType request = message.getValue();
    GetBookResponseType response = this.of.createGetBookResponseType();
    long start = System.currentTimeMillis();
    try {
        if (request.getCriteria().isSetISBN()) {
            response.getBook().add(this.dao.getBookByISBN(request.getCriteria().getISBN()));
        } else if (request.getCriteria().getId().size() > 0) {
            for (String uuid : request.getCriteria().getId()) {
                response.getBook().add(this.dao.getBookById(uuid));
            }
        }
    } catch (Throwable e) {
        /* Add a not covered error to the response. */
        this.logger.error(e.getMessage(), e);
        // response.getFailure().add(
        // FailureHandler.handleException(e, "E_ALL_NOT_KNOWN_ERROR",
        // this.logger);
    } finally {
        this.logger.debug(" getBook duration {}", this.requestDuration(start));
        this.logger.debug("-getBook #{}, #f{}", response/* .get() */ != null ? 1 : 0,
                response.getFailure().size());
    }
    return this.of.createGetBookResponse(response);
}

From source file:org.wallerlab.yoink.molecular.service.translator.ParameterTranslator.java

private void parseParameters(Map<JobParameter, Object> parameters, JAXBElement element) {
    ParameterList cmlParameterList = (ParameterList) element.getValue();
    if (cmlParameterList.getTitle().equalsIgnoreCase("parameters")) {
        parseParameter(parameters, cmlParameterList);
    }/*from w w w.ja va2 s  . c o m*/
}

From source file:edu.harvard.i2b2.crc.loader.delegate.pm.PMResponseMessage.java

public StatusType processResult(String response) throws JAXBUtilException {
    StatusType status = null;/*from  ww w.j a  v a2s  .co  m*/
    try {

        JAXBElement jaxbElement = CRCLoaderJAXBUtil.getJAXBUtil().unMashallFromString(response);
        pmRespMessageType = (ResponseMessageType) jaxbElement.getValue();

        // Get response message status 
        ResponseHeaderType responseHeader = pmRespMessageType.getResponseHeader();
        status = responseHeader.getResultStatus().getStatus();
        String procStatus = status.getType();
        String procMessage = status.getValue();

        if (procStatus.equals("ERROR")) {
            log.info("Error reported by CRC web Service " + procMessage);
        } else if (procStatus.equals("WARNING")) {
            log.info("Warning reported by CRC web Service" + procMessage);
        }

    } catch (JAXBUtilException e) {
        log.error(e);
        throw e;
    }
    return status;
}

From source file:edu.harvard.i2b2.eclipse.plugins.fr.ws.CrcResponseData.java

public StatusType processResult(String response) {
    StatusType status = null;//  w w w . j a  va2s.  c  om
    try {
        JAXBElement jaxbElement = FRJAXBUtil.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:edu.harvard.i2b2.eclipse.plugins.fr.ws.FrResponseData.java

public StatusType processResult(String response) {
    StatusType status = null;/*from ww  w.  jav a 2 s  .  c  om*/
    try {
        JAXBElement jaxbElement = FRJAXBUtil.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 FR web Service " + procMessage);
        } else if (procStatus.equals("WARNING")) {
            log.error("Warning reported by FR web Service" + procMessage);
        }

    } catch (JAXBUtilException e) {
        log.error(e.getMessage());
    }
    return status;
}

From source file:edu.wisc.cypress.dm.CypressJaxbTest.java

private <T> T unmarshall(String resource, Class<T> clazz) throws Exception {
    final JAXBContext context = JAXBContext.newInstance(clazz.getPackage().getName());

    final Unmarshaller unmarshaller = context.createUnmarshaller();

    final InputStream xmlStream = this.getClass().getResourceAsStream(resource);
    try {/*from w w w  .ja  v  a  2  s  .c  o m*/
        assertNotNull(xmlStream);
        final JAXBElement<T> statements = unmarshaller.unmarshal(new StreamSource(xmlStream), clazz);

        return statements.getValue();
    } finally {
        IOUtils.closeQuietly(xmlStream);
    }
}

From source file:edu.harvard.i2b2.eclipse.plugins.query.workplaceMessaging.WorkplaceResponseData.java

public StatusType processResult(String response) {
    StatusType status = null;/*from  w  w w  . j  ava 2  s . c o m*/
    try {
        JAXBElement jaxbElement = QueryJAXBUtil.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 Workplace web Service " + procMessage);
        } else if (procStatus.equals("WARNING")) {
            log.error("Warning reported by Workplace web Service" + procMessage);
        }

    } catch (JAXBUtilException e) {
        log.error(e.getMessage());
    }
    return status;
}

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

/**
 * @param message//from   w w  w .ja  v  a  2s .co  m
 *            the {@link JAXBElement} containing a
 *            {@link GetTargetNamespaceRequestType}.
 * @return the {@link JAXBElement} with a
 *         {@link GetTargetNamespaceResponseType}.
 */
@Override
public final JAXBElement<GetTargetNamespaceResponseType> invoke(
        final JAXBElement<GetTargetNamespaceRequestType> message) {
    this.logger.debug("+getTargetNamespace");
    GetTargetNamespaceRequestType request = message.getValue();
    GetTargetNamespaceResponseType response = this.of.createGetTargetNamespaceResponseType();
    long start = System.currentTimeMillis();
    try {
        String modelVersion = request.getRevision();
        if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) {
            modelVersion = this.dao.getLastModelVersion();
        }
        response.getTargetNamespace().addAll(this.dao.getTargetNamespaces(modelVersion));
    } catch (Throwable e) {
        /* Add a not covered error to the response. */
        this.logger.error(e.getMessage(), e);
    } finally {
        this.logger.debug(" getTargetNamespace duration {}",
                DateUtil.getDuration(start, System.currentTimeMillis()));
        this.logger.debug("-getTargetNamespace #{}", response.getTargetNamespace().size());
    }
    return this.of.createGetTargetNamespaceResponse(response);
}

From source file:edu.harvard.i2b2.eclipse.plugins.analysis.ontologyMessaging.OntologyResponseData.java

public StatusType processResult(String response) {
    StatusType status = null;/* ww  w .  ja v a2 s.  co  m*/
    try {
        JAXBElement jaxbElement = AnalysisJAXBUtil.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;
}