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.crc.ejb.QueryManagerBeanUtil.java

public long getTimeout(String xmlRequest) throws Exception {
    JAXBUtil jaxbUtil = CRCJAXBUtil.getJAXBUtil();
    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlRequest);
    RequestMessageType requestMessageType = (RequestMessageType) jaxbElement.getValue();

    RequestHeaderType requestHeader = requestMessageType.getRequestHeader();
    long timeOut = 1;
    if (requestHeader != null && requestHeader.getResultWaittimeMs() > -1) {
        timeOut = requestHeader.getResultWaittimeMs();
    }/*w w  w . ja  va2s .  c  o m*/
    return timeOut;
}

From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.PresentationWSDaoImpl.java

@Override
public List<BlackboardPresentationResponse> getSessionPresentations(long sessionId) {
    BlackboardListSessionContent request = new ObjectFactory().createBlackboardListSessionContent();
    request.setSessionId(sessionId);/*from  w ww. ja v a 2 s.co m*/

    JAXBElement<BlackboardListSessionContent> createListSessionPresentation = new ObjectFactory()
            .createListSessionPresentation(request);
    @SuppressWarnings("unchecked")
    final JAXBElement<BlackboardPresentationResponseCollection> objSessionResponse = (JAXBElement<BlackboardPresentationResponseCollection>) sasWebServiceOperations
            .marshalSendAndReceiveToSAS("http://sas.elluminate.com/ListSessionPresentation",
                    createListSessionPresentation);

    return objSessionResponse.getValue().getPresentationResponses();
}

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()),//w ww.j a v  a  2 s .  c  o m
            RevokeMedicalCertificateRequestType.class);
    return request.getValue();
}

From source file:edu.harvard.i2b2.crc.ejb.QueryManagerBeanUtil.java

public DataSourceLookup getDataSourceLookupInput(String xmlRequest) throws Exception {
    DataSourceLookup dsLookupInput = null;
    JAXBUtil jaxbUtil = CRCJAXBUtil.getJAXBUtil();
    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlRequest);
    RequestMessageType requestMessageType = (RequestMessageType) jaxbElement.getValue();
    String projectId = requestMessageType.getMessageHeader().getProjectId();
    String domainId = requestMessageType.getMessageHeader().getSecurity().getDomain();
    String ownerId = requestMessageType.getMessageHeader().getSecurity().getUsername();
    dsLookupInput = new DataSourceLookup();
    dsLookupInput.setProjectPath(projectId);
    dsLookupInput.setDomainId(domainId);
    dsLookupInput.setOwnerId(ownerId);//from ww  w. j a v a 2 s .com
    return dsLookupInput;

}

From source file:com.vmware.vchs.publicapi.samples.VDCListSample.java

/**
 * This method retrieves a vCloud API EndPoint to get access to its organization, then its 
 * catalog and finally display names of vApp templates available to the console
 * /*from  w ww.  j a  v a 2s  . co  m*/
 * @param vdc
 *            the reference to VDC for which the available vApp template to be displayed
 */
private void listSystemTemplates(VdcReferenceType vdc) {
    String vcloudSessionHref = null;

    // Retrieve the List of Links associated with VDC Reference
    List<LinkType> vdcLinks = vdc.getLink();

    // Iterate through the list of links associated VDC Reference
    for (LinkType link : vdcLinks) {
        if (link.getType().equals("application/xml;class=vnd.vmware.vchs.vcloudsession")) {
            vcloudSessionHref = link.getHref();

            // Found it, break out of loop
            break;
        }
    }

    System.out.println();
    System.out.println("  Available templates");
    System.out.println("  -------------------");

    if (null != vcloudSessionHref) {
        // Retrieve the vCloud API EndPoint for the VDC.
        Vcd vcd = HttpUtils.getVCDEndPoint(vchs, options, vcloudSessionHref);

        // getQueryResults() will use the vCloud Query API service and get a list of all the system
        // templates.
        //
        // About filtering templates:
        //   filter=isPublished==true  : retrieve only vCHS system templates.
        //   filter=isPublished==false : retrieve user uploaded templates.
        //   (without isPublished filter query parameter) : retrieve all templates.
        // Example: type=vAppTemplate&filter=isPublished==true
        //
        QueryResultRecordsType queryResults = HttpUtils.getQueryResults(HttpUtils.getHostname(vcd.vdcHref),
                "type=vAppTemplate", options, vcd.vcdToken);

        if (null != queryResults && queryResults.getRecord().size() > 0) {
            List<JAXBElement<? extends QueryResultRecordType>> records = queryResults.getRecord();
            for (JAXBElement<? extends QueryResultRecordType> record : records) {
                // We should have only one record with the name matching templateName
                QueryResultVAppTemplateRecordType qrrt = (QueryResultVAppTemplateRecordType) record.getValue();
                // Print the name of the system template to the console
                System.out.println("  " + qrrt.getName());
            }
        } else {
            System.out.println("  None");
        }
    } else {
        System.out.println("  None");
    }
}

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()),/*from  w  ww  . j  av  a 2  s  . com*/
            SendMedicalCertificateQuestionType.class);
    return request.getValue();
}

From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.SessionWSDaoImpl.java

@Override
public List<BlackboardSessionResponse> getSessions(String userId, String groupingId, Long sessionId,
        String creatorId, Long startTime, Long endTime, String sessionName) {
    //build search request
    BlackboardListSession request = new ObjectFactory().createBlackboardListSession();

    if (userId == null && groupingId == null && sessionId == null && creatorId == null && startTime == null
            && endTime == null && sessionName == null) {
        throw new IllegalStateException("You must specify at least 1 piece of criteria");
    }//from w  ww.  j a  v  a  2s .  com

    if (userId != null) {
        request.setUserId(userId);
    }
    if (groupingId != null) {
        request.setGroupingId(groupingId);
    }

    if (sessionId != null) {
        request.setSessionId(sessionId);
    }

    if (creatorId != null) {
        request.setCreatorId(creatorId);
    }

    if (startTime != null) {
        request.setStartTime(startTime);
    }

    if (endTime != null) {
        request.setEndTime(endTime);
    }

    if (sessionName != null) {
        request.setSessionName(sessionName);
    }

    Object obj = sasWebServiceOperations.marshalSendAndReceiveToSAS("http://sas.elluminate.com/ListSession",
            request);
    @SuppressWarnings("unchecked")
    JAXBElement<BlackboardSessionResponseCollection> responseCollection = (JAXBElement<BlackboardSessionResponseCollection>) obj;
    return responseCollection.getValue().getSessionResponses();
}

From source file:edu.harvard.i2b2.crc.delegate.pdo.PdoQueryRequestDelegate.java

/**
 * @see edu.harvard.i2b2.crc.delegate.RequestHandlerDelegate#handleRequest(java.lang.String)
 *///from   www . ja va 2s.c om
public String handleRequest(String requestXml) throws I2B2Exception {
    PdoQryHeaderType headerType = null;
    String response = null;
    JAXBUtil jaxbUtil = CRCJAXBUtil.getJAXBUtil();
    List<String> roles = null;
    try {
        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(requestXml);
        RequestMessageType requestMessageType = (RequestMessageType) jaxbElement.getValue();
        BodyType bodyType = requestMessageType.getMessageBody();

        if (bodyType == null) {
            log.error("null value in body type");
            throw new I2B2Exception("null value in body type");
        }

        // Call PM cell to validate user

        StatusType procStatus = null;
        try {
            SecurityType securityType = null;
            String projectId = null;
            if (requestMessageType.getMessageHeader() != null) {
                if (requestMessageType.getMessageHeader().getSecurity() != null) {
                    securityType = requestMessageType.getMessageHeader().getSecurity();
                }
                projectId = requestMessageType.getMessageHeader().getProjectId();
            }

            if (securityType == null) {
                procStatus = new StatusType();
                procStatus.setType("ERROR");
                procStatus.setValue("Request message missing user/password");
                response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
                return response;
            }
            if (projectId == null) {
                procStatus = new StatusType();
                procStatus.setType("ERROR");
                procStatus.setValue("Missing <project_id>");
                response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
                return response;
            }

            PMServiceDriver pmServiceDriver = new PMServiceDriver();
            ProjectType projectType = pmServiceDriver.checkValidUser(securityType, projectId);
            // projectType.getRole()
            if (projectType == null) {
                procStatus = new StatusType();
                procStatus.setType("ERROR");
                procStatus.setValue("Invalid user/password for the given project [" + projectId + "]");
                response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
                return response;
            }

            log.debug("project name from PM " + projectType.getName());
            log.debug("project id from PM " + projectType.getId());
            if (projectType.getRole() != null) {
                log.debug("project role from PM " + projectType.getRole().get(0));
                this.putRoles(projectId, securityType.getUsername(), securityType.getDomain(),
                        projectType.getRole());

                //TODO removed cache
                //Node rootNode = CacheUtil.getCache().getRoot();
                //List<String> roles = (List<String>) rootNode
                //      .get(securityType.getDomain() + "/" + projectId
                //            + "/" + securityType.getUsername());
                roles = (List<String>) CacheUtil
                        .get(securityType.getDomain() + "/" + projectId + "/" + securityType.getUsername());
                if (roles != null) {
                    log.debug("User Roles count " + roles.size());
                }
                if (!roles.contains("DATA_LDS"))
                    throw new I2B2Exception("Access Denied need at least DATA_LDS");
                ParamUtil paramUtil = new ParamUtil();
                paramUtil.clearParam(projectId, securityType.getUsername(), securityType.getDomain(),
                        ParamUtil.CRC_ENABLE_UNITCD_CONVERSION);
                if (projectType.getParam() != null) {
                    for (ParamType param : projectType.getParam()) {
                        if (param.getName() != null && param.getName().trim()
                                .equalsIgnoreCase(ParamUtil.CRC_ENABLE_UNITCD_CONVERSION)) {
                            paramUtil.putParam(projectId, securityType.getUsername(), securityType.getDomain(),
                                    ParamUtil.CRC_ENABLE_UNITCD_CONVERSION, param);
                            String unitCdCache = paramUtil.getParam(projectId, securityType.getUsername(),
                                    securityType.getDomain(), ParamUtil.CRC_ENABLE_UNITCD_CONVERSION);
                            log.debug("CRC param stored in the cache Project Id [" + projectId + "] user ["
                                    + securityType.getUsername() + "] domain [" + securityType.getDomain()
                                    + "] " + ParamUtil.CRC_ENABLE_UNITCD_CONVERSION + "[" + unitCdCache + "]");
                            break;
                        }
                    }
                }

            } else {

                log.error("Project role not set for the user ");

            }
        } catch (AxisFault e) {
            procStatus = new StatusType();
            procStatus.setType("ERROR");
            procStatus.setValue("Could not connect to server[" + e.getDetail() + "]");
            response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
            return response;
        } catch (I2B2Exception e) {
            procStatus = new StatusType();
            procStatus.setType("ERROR");
            procStatus.setValue("Project Management cell interface error: [" + e.getMessage() + "]");
            response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
            return response;
        } catch (JAXBUtilException e) {
            procStatus = new StatusType();
            procStatus.setType("ERROR");
            procStatus.setValue("Message error from Project Management cell[" + e.getMessage() + "]");
            response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
            return response;
        }

        JAXBUnWrapHelper unWrapHelper = new JAXBUnWrapHelper();
        headerType = (PdoQryHeaderType) unWrapHelper.getObjectByClass(bodyType.getAny(),
                edu.harvard.i2b2.crc.datavo.pdo.query.PdoQryHeaderType.class);

        BodyType responseBodyType = null;
        if (headerType.getRequestType().equals(PdoRequestTypeType.GET_PDO_FROM_INPUT_LIST)) {
            GetPDOFromInputListHandler handler = new GetPDOFromInputListHandler(requestXml);
            responseBodyType = handler.execute();
        } else if (headerType.getRequestType().equals(PdoRequestTypeType.GET_OBSERVATIONFACT_BY_PRIMARY_KEY)) {

            //List<String> roles = (List<String>) cache.getRoot().get(rolePath);

            GetObservationFactFromPrimaryKeyHandler handler = new GetObservationFactFromPrimaryKeyHandler(
                    requestXml, roles);
            responseBodyType = handler.execute();
        } else if (headerType.getRequestType().equals(PdoRequestTypeType.GET_PDO_TEMPLATE)) {
            GetPDOTemplateHandler handler = new GetPDOTemplateHandler(requestXml);
            responseBodyType = handler.execute();
        }
        procStatus = new StatusType();
        procStatus.setType("DONE");
        procStatus.setValue("DONE");

        long startTime = System.currentTimeMillis();
        response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, responseBodyType,
                true);
        long endTime = System.currentTimeMillis();
        long totalTime = endTime - startTime;
        log.debug("Total time to pdo  jaxb  " + totalTime);

    } catch (JAXBUtilException e) {
        log.error("JAXBUtil exception", e);
        StatusType procStatus = new StatusType();
        procStatus.setType("ERROR");
        procStatus.setValue(requestXml + "\n\n" + StackTraceUtil.getStackTrace(e));
        try {
            response = I2B2MessageResponseFactory.buildResponseMessage(null, procStatus, null);
        } catch (JAXBUtilException e1) {
            e1.printStackTrace();
        }
    } catch (I2B2Exception e) {
        log.error("I2B2Exception", e);
        StatusType procStatus = new StatusType();
        procStatus.setType("ERROR");
        procStatus.setValue(StackTraceUtil.getStackTrace(e));
        try {
            response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, null);
        } catch (JAXBUtilException e1) {
            e1.printStackTrace();
        }
    } catch (Throwable e) {
        log.error("Throwable", e);
        StatusType procStatus = new StatusType();
        procStatus.setType("ERROR");
        procStatus.setValue(StackTraceUtil.getStackTrace(e));
        try {
            response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, null);
        } catch (JAXBUtilException e1) {
            e1.printStackTrace();
        }
    }
    return response;
}

From source file:com.evolveum.midpoint.model.common.expression.evaluator.AsIsExpressionEvaluatorFactory.java

@Override
public <V extends PrismValue, D extends ItemDefinition> AsIsExpressionEvaluator<V, D> createEvaluator(
        Collection<JAXBElement<?>> evaluatorElements, D outputDefinition, String contextDescription, Task task,
        OperationResult result) throws SchemaException {

    Validate.notNull(outputDefinition, "output definition must be specified for asIs expression evaluator");

    JAXBElement<?> evaluatorElement = null;
    if (evaluatorElements != null) {
        if (evaluatorElements.size() > 1) {
            throw new SchemaException("More than one evaluator specified in " + contextDescription);
        }/*from  w w  w .  j  a  va  2 s .co m*/
        evaluatorElement = evaluatorElements.iterator().next();
    }

    Object evaluatorTypeObject = null;
    if (evaluatorElement != null) {
        evaluatorTypeObject = evaluatorElement.getValue();
    }
    if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof AsIsExpressionEvaluatorType)) {
        throw new SchemaException("AsIs value constructor cannot handle elements of type "
                + evaluatorTypeObject.getClass().getName() + " in " + contextDescription);
    }
    return new AsIsExpressionEvaluator<V, D>((AsIsExpressionEvaluatorType) evaluatorTypeObject,
            outputDefinition, protector, prismContext);
}