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:com.evolveum.midpoint.repo.common.expression.evaluator.AsIsExpressionEvaluatorFactory.java

@Override
public <V extends PrismValue, D extends ItemDefinition> AsIsExpressionEvaluator<V, D> createEvaluator(
        Collection<JAXBElement<?>> evaluatorElements, D outputDefinition, ExpressionFactory factory,
        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);
        }// w  w  w. j  a  va 2s.c  o 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<>((AsIsExpressionEvaluatorType) evaluatorTypeObject, outputDefinition,
            protector, prismContext);
}

From source file:fi.kela.kanta.cda.Purkaja.java

protected void puraText(POCDMT000040Section section, List<String> nayttomuoto) {
    StrucDocText text = section.getText();
    if (text != null && text.getContent() != null && !text.getContent().isEmpty()) {
        List<Serializable> content = text.getContent();
        for (int i = 0; i < content.size(); i++) {
            if (!(content.get(i) instanceof JAXBElement)) {
                continue;
            }/* ww  w  .  j  a v  a2  s.  com*/
            JAXBElement<?> elem = (JAXBElement<?>) content.get(i);
            if (elem.getValue() instanceof StrucDocParagraph) {
                StrucDocParagraph paragraph = (StrucDocParagraph) elem.getValue();
                puraDocParagraph(paragraph, nayttomuoto);
            }
        }
    }
}

From source file:edu.harvard.i2b2.fr.delegate.LoaderQueryRequestDelegate.java

@Override
public String handleRequest(String requestXml, RequestHandler requestHandler) throws I2B2Exception {
    String response = null;/*w  w w .j a  va 2s .c o  m*/
    JAXBUtil jaxbUtil = FRJAXBUtil.getJAXBUtil();

    try {
        log.debug("LoaderQueryRequestDelegate - RequestXML: " + requestXml);

        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");
        }

        log.debug("Calling PM Cell to vaidate user");
        //Call PM cell to validate user
        StatusType procStatus = null;
        ProjectType projectType = null;
        ConfigureType pmResponseUserInfo = null;
        try {
            SecurityType securityType = null;
            if (requestMessageType.getMessageHeader() != null) {
                if (requestMessageType.getMessageHeader().getSecurity() != null) {
                    securityType = requestMessageType.getMessageHeader().getSecurity();
                }
            }
            if (securityType == null) {
                procStatus = new StatusType();
                procStatus.setType("ERROR");
                procStatus.setValue("Request message missing user/password");
                response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
                return response;
            }

            pmResponseUserInfo = PMServiceDriver.checkValidUser(securityType);
            //projectType = pmResponseUserInfo.getUser().getProject().get(0);

            Iterator<?> it = pmResponseUserInfo.getUser().getProject().iterator();

            while (it.hasNext()) {
                projectType = (ProjectType) it.next();
                if (projectType.getId().equals(requestMessageType.getMessageHeader().getProjectId())) {
                    //      log.info(header.getProjectId());
                    //      log.info(projectType.getId());
                    break;
                }

            }

            if (projectType == null) {
                procStatus = new StatusType();
                procStatus.setType("ERROR");
                procStatus.setValue("Invalid user/password for the given domain");
                response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
                return response;
            }

            log.debug("project name from PM " + projectType.getName());
            log.debug("project id from PM " + projectType.getId());
            log.debug("Project role from PM " + projectType.getRole().get(0));

        } catch (AxisFault e) {
            log.error("AxisFault exception", e);
            procStatus = new StatusType();
            procStatus.setType("ERROR");
            procStatus.setValue("Could not connect to server");
            response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
            return response;
        } catch (I2B2Exception e) {
            log.error("I2B2Exception exception", e);
            procStatus = new StatusType();
            procStatus.setType("ERROR");
            procStatus.setValue("Message error connecting Project Management cell");
            response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
            return response;
        } catch (JAXBUtilException e) {
            log.error("JAXBUtil exception", e);
            procStatus = new StatusType();
            procStatus.setType("ERROR");
            procStatus.setValue("Message error from Project Management cell");
            response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
            return response;
        }

        JAXBUnWrapHelper unWrapHelper = new JAXBUnWrapHelper();

        BodyType responseBodyType = null;
        if (requestHandler instanceof SendfileRequestHandler) {
            String irodsStorageResource = null;

            // check if user have right permission to access this request
            log.debug("Number of roles:" + projectType.getRole().size());

            if (projectType != null && projectType.getRole().size() > 0) {
                //for (String a : projectType.getRole())
                //   log.debug("Roles:" + a);

                if (isRoleValid(projectType) == false) {
                    //!projectType.getRole().contains("MANAGER")  && !projectType.getRole().contains("EDITOR")) {
                    // Not authorized
                    procStatus = new StatusType();
                    procStatus.setType("ERROR");
                    procStatus.setValue("Authorization failure, need MANAGER or EDITOR role");
                    response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus,
                            bodyType);
                    return response;
                }
            } else {
                // Not authorized
                procStatus = new StatusType();
                procStatus.setType("ERROR");
                procStatus.setValue("Authorization failure, need MANAGER or EDITOR role");
                response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
                return response;
            }

            for (ParamType paramType : projectType.getParam()) {

                if (paramType.getName().equalsIgnoreCase("SRBDefaultStorageResource")) {
                    irodsStorageResource = paramType.getValue();
                    log.debug("param value for SRBDefaultStorageResource" + paramType.getValue());
                }
            }
            ((SendfileRequestHandler) requestHandler).setPmResponseUserInfo(pmResponseUserInfo);
        }

        if (requestHandler instanceof RecvfileRequestHandler) {
            String irodsStorageResource = null;
            for (ParamType paramType : projectType.getParam()) {

                if (paramType.getName().equalsIgnoreCase("SRBDefaultStorageResource")) {
                    irodsStorageResource = paramType.getValue();
                    log.debug("param value for SRBDefaultStorageResource" + paramType.getValue());
                }
            }
            ((RecvfileRequestHandler) requestHandler).setPmResponseUserInfo(pmResponseUserInfo);
        }

        responseBodyType = requestHandler.execute();

        procStatus = new StatusType();
        procStatus.setType("DONE");
        procStatus.setValue("DONE");

        response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, responseBodyType,
                true);

    } 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.qmetry.qaf.automation.integration.qmetry.qmetry6.scheduler.Qmetry6SchedulerFilter.java

public List<IMethodInstance> applyQmetrySecheduledTCsFilter(List<IMethodInstance> list, ITestContext context,
        String jsonFile) {/*from w  ww. j a  v  a  2  s.  c om*/

    JAXBContext jc;

    List<IMethodInstance> filteredList = new ArrayList<IMethodInstance>();

    tcLst = new ArrayList<Testcase>();
    try {

        jc = JAXBContext.newInstance(Schedule.class);

        Unmarshaller unmarshell = jc.createUnmarshaller();

        // Set the Unmarshaller media type to JSON or XML
        unmarshell.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");

        // Set it to true if you need to include the JSON root element in
        // the
        // JSON input
        unmarshell.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, true);

        JAXBElement<Schedule> scheduleUnmarshal = null;

        StreamSource json = new StreamSource(new File(jsonFile));
        scheduleUnmarshal = unmarshell.unmarshal(json, Schedule.class);

        Schedule schedules = scheduleUnmarshal.getValue();

        List<Testcase> testcase = schedules.getTestcases();

        @SuppressWarnings("unused")
        Qmetry6RestClient wsUtil = Qmetry6RestClient.getInstance();
        QMetryRestWebservice integration = Qmetry6RestClient.getIntegration();
        integration.setPlatform(String.valueOf(schedules.getPlatformId()));
        integration.setSuite(String.valueOf(schedules.getTestsuiteId()));

        tcMap = new HashMap<String, Testcase>();

        ConfigurationManager.getBundle().setProperty(ApplicationProperties.INTEGRATION_PARAM_QMETRY_PRJ.key,
                String.valueOf(schedules.getProjectId()));
        ConfigurationManager.getBundle().setProperty(ApplicationProperties.INTEGRATION_PARAM_QMETRY_REL.key,
                String.valueOf(schedules.getReleaseId()));
        ConfigurationManager.getBundle().setProperty(ApplicationProperties.INTEGRATION_PARAM_QMETRY_CYCLE.key,
                String.valueOf(schedules.getBuildId()));
        ConfigurationManager.getBundle().setProperty(ApplicationProperties.INTEGRATION_PARAM_QMETRY_SUIT.key,
                String.valueOf(schedules.getTestsuiteId()));
        ConfigurationManager.getBundle().setProperty(
                ApplicationProperties.INTEGRATION_PARAM_QMETRY_SUITERUNID.key,
                String.valueOf(schedules.getTestsuiteRunId()));
        ConfigurationManager.getBundle().setProperty(ApplicationProperties.INTEGRATION_PARAM_QMETRY_DROP.key,
                String.valueOf(schedules.getDropId()));
        ConfigurationManager.getBundle().setProperty(
                ApplicationProperties.INTEGRATION_PARAM_QMETRY_PLATFORM.key,
                String.valueOf(schedules.getPlatformId()));

        Iterator<Testcase> testcaseIterator = testcase.iterator();
        while (testcaseIterator.hasNext()) {
            Testcase tc = testcaseIterator.next();
            String xmltcid = String.valueOf(tc.getTestcaseId());
            String xmlscriptname = tc.getTestcaseName();
            logger.info("Qmetry6 scheduled TC: " + xmltcid + " " + xmlscriptname);
            tcLst.add(tc);
            Iterator<IMethodInstance> iter = list.iterator();

            while (iter.hasNext()) {
                IMethodInstance iMethodInstance = iter.next();
                TestNGScenario method = (TestNGScenario) iMethodInstance.getMethod();
                logger.debug("SchedulerFilter testNG method: " + method);
                if (isScriptNameMaching(method, tc) || isRunIdMaching(method, tc)
                        || isTCIDMaching(method, tc)) {

                    logger.info("SchedulerFilter including testNG method: " + method);
                    filteredList.add(iMethodInstance);
                    tcMap.put(method.getSignature(), tc);
                    break;
                }
            }
        }

        Map<String, String> params = context.getCurrentXmlTest().getAllParameters();
        int platform = Integer.parseInt(String.valueOf(schedules.getPlatformId()));
        String qmetryplatform = platform == 116 ? "*iehta" : platform == 118 ? "*googlechrome" : "*firefox";
        params.put("browser", qmetryplatform);
        context.getCurrentXmlTest().setParameters(params);
        return filteredList;
    } catch (Exception e) {
        logger.error(e);
    }
    for (IMethodInstance l : list) {
        logger.info(l.getMethod());
    }
    return list;
}

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

@Override
public BlackboardSessionResponse updateSession(long bbSessionId, SessionForm sessionForm) {
    final BlackboardUpdateSession updateSession = new ObjectFactory().createBlackboardUpdateSession();

    updateSession.setSessionId(bbSessionId);
    updateSession.setSessionName(sessionForm.getSessionName());
    updateSession.setStartTime(sessionForm.getStartTime().getMillis());
    updateSession.setEndTime(sessionForm.getEndTime().getMillis());
    updateSession.setBoundaryTime(sessionForm.getBoundaryTime());

    if (securityExpressionEvaluator.authorize("hasRole('ROLE_FULL_ACCESS')")) {
        updateSession.setMaxTalkers(sessionForm.getMaxTalkers());
        updateSession.setMaxCameras(sessionForm.getMaxCameras());
        updateSession.setMustBeSupervised(sessionForm.isMustBeSupervised());
        updateSession.setPermissionsOn(sessionForm.isPermissionsOn());
        updateSession.setRaiseHandOnEnter(sessionForm.isRaiseHandOnEnter());
        final RecordingMode recordingMode = sessionForm.getRecordingMode();
        if (recordingMode != null) {
            updateSession.setRecordingModeType(recordingMode.getBlackboardRecordingMode());
        }//w  w w  .  j a  va 2  s .c o m
        updateSession.setHideParticipantNames(sessionForm.isHideParticipantNames());
        updateSession.setAllowInSessionInvites(sessionForm.isAllowInSessionInvites());
    }

    final Object objSessionResponse = sasWebServiceOperations
            .marshalSendAndReceiveToSAS("http://sas.elluminate.com/UpdateSession", updateSession);
    @SuppressWarnings("unchecked")
    JAXBElement<BlackboardSessionResponseCollection> response = (JAXBElement<BlackboardSessionResponseCollection>) objSessionResponse;
    return DataAccessUtils.singleResult(response.getValue().getSessionResponses());
}

From source file:com.evolveum.midpoint.model.common.expression.evaluator.AssociationFromLinkExpressionEvaluatorFactory.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 {

    Validate.notNull(outputDefinition,// w  ww . j  a  v a 2  s  .  c  o m
            "output definition must be specified for associationFromLink expression evaluator");

    JAXBElement<?> evaluatorElement = null;
    if (evaluatorElements != null) {
        if (evaluatorElements.size() > 1) {
            throw new SchemaException("More than one evaluator specified in " + contextDescription);
        }
        evaluatorElement = evaluatorElements.iterator().next();
    }

    Object evaluatorTypeObject = null;
    if (evaluatorElement != null) {
        evaluatorTypeObject = evaluatorElement.getValue();
    }
    if (evaluatorTypeObject != null
            && !(evaluatorTypeObject instanceof ShadowDiscriminatorExpressionEvaluatorType)) {
        throw new SchemaException("Association expression evaluator cannot handle elements of type "
                + evaluatorTypeObject.getClass().getName() + " in " + contextDescription);
    }
    AssociationFromLinkExpressionEvaluator evaluator = new AssociationFromLinkExpressionEvaluator(
            (ShadowDiscriminatorExpressionEvaluatorType) evaluatorTypeObject,
            (PrismContainerDefinition<ShadowAssociationType>) outputDefinition, objectResolver, prismContext);
    return (ExpressionEvaluator<V, D>) evaluator;
}

From source file:com.evolveum.midpoint.model.common.expression.evaluator.AssociationTargetSearchExpressionEvaluatorFactory.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 {

    Validate.notNull(outputDefinition,// w w  w . jav a2  s  . c  om
            "output definition must be specified for associationTargetSearch expression evaluator");

    JAXBElement<?> evaluatorElement = null;
    if (evaluatorElements != null) {
        if (evaluatorElements.size() > 1) {
            throw new SchemaException("More than one evaluator specified in " + contextDescription);
        }
        evaluatorElement = evaluatorElements.iterator().next();
    }

    Object evaluatorTypeObject = null;
    if (evaluatorElement != null) {
        evaluatorTypeObject = evaluatorElement.getValue();
    }
    if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof SearchObjectExpressionEvaluatorType)) {
        throw new SchemaException("Association expression evaluator cannot handle elements of type "
                + evaluatorTypeObject.getClass().getName() + " in " + contextDescription);
    }
    AssociationTargetSearchExpressionEvaluator evaluator = new AssociationTargetSearchExpressionEvaluator(
            (SearchObjectExpressionEvaluatorType) evaluatorTypeObject,
            (PrismContainerDefinition<ShadowAssociationType>) outputDefinition, protector, objectResolver,
            modelService, prismContext, securityEnforcer);
    return (ExpressionEvaluator<V, D>) evaluator;
}

From source file:com.evolveum.midpoint.model.common.expression.evaluator.ReferenceSearchExpressionEvaluatorFactory.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 {

    Validate.notNull(outputDefinition,/*from ww  w. ja  v  a2 s  . c  o  m*/
            "output definition must be specified for referenceSearch expression evaluator");

    JAXBElement<?> evaluatorElement = null;
    if (evaluatorElements != null) {
        if (evaluatorElements.size() > 1) {
            throw new SchemaException("More than one evaluator specified in " + contextDescription);
        }
        evaluatorElement = evaluatorElements.iterator().next();
    }

    Object evaluatorTypeObject = null;
    if (evaluatorElement != null) {
        evaluatorTypeObject = evaluatorElement.getValue();
    }
    if (evaluatorTypeObject != null
            && !(evaluatorTypeObject instanceof SearchObjectRefExpressionEvaluatorType)) {
        throw new SchemaException("reference search expression evaluator cannot handle elements of type "
                + evaluatorTypeObject.getClass().getName() + " in " + contextDescription);
    }
    ReferenceSearchExpressionEvaluator expressionEvaluator = new ReferenceSearchExpressionEvaluator(
            (SearchObjectRefExpressionEvaluatorType) evaluatorTypeObject,
            (PrismReferenceDefinition) outputDefinition, protector, objectResolver, modelService, prismContext,
            securityEnforcer);
    return (ExpressionEvaluator<V, D>) expressionEvaluator;
}

From source file:com.evolveum.midpoint.model.common.expression.evaluator.AssignmentTargetSearchExpressionEvaluatorFactory.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 {

    Validate.notNull(outputDefinition,/*from  w ww.ja v  a 2  s  .c  o m*/
            "output definition must be specified for assignmentTargetSearch expression evaluator");

    JAXBElement<?> evaluatorElement = null;
    if (evaluatorElements != null) {
        if (evaluatorElements.size() > 1) {
            throw new SchemaException("More than one evaluator specified in " + contextDescription);
        }
        evaluatorElement = evaluatorElements.iterator().next();
    }

    Object evaluatorTypeObject = null;
    if (evaluatorElement != null) {
        evaluatorTypeObject = evaluatorElement.getValue();
    }
    if (evaluatorTypeObject != null
            && !(evaluatorTypeObject instanceof SearchObjectRefExpressionEvaluatorType)) {
        throw new SchemaException("assignment expression evaluator cannot handle elements of type "
                + evaluatorTypeObject.getClass().getName() + " in " + contextDescription);
    }
    AssignmentTargetSearchExpressionEvaluator expressionEvaluator = new AssignmentTargetSearchExpressionEvaluator(
            (SearchObjectRefExpressionEvaluatorType) evaluatorTypeObject,
            (PrismContainerDefinition<AssignmentType>) outputDefinition, protector, objectResolver,
            modelService, prismContext, securityEnforcer);
    return (ExpressionEvaluator<V, D>) expressionEvaluator;
}

From source file:com.evolveum.midpoint.model.impl.lens.projector.policy.evaluators.ObjectModificationConstraintEvaluator.java

private <F extends FocusType> boolean modificationConstraintMatches(
        JAXBElement<ModificationPolicyConstraintType> constraintElement,
        ObjectPolicyRuleEvaluationContext<F> ctx, OperationResult result)
        throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException,
        SecurityViolationException, ExpressionEvaluationException {
    ModificationPolicyConstraintType constraint = constraintElement.getValue();
    if (!operationMatches(ctx.focusContext, constraint.getOperation())) {
        LOGGER.trace("Rule {} operation not applicable", ctx.policyRule.getName());
        return false;
    }//w  w w.  j  a va  2  s  .c om
    if (constraint.getItem().isEmpty()) {
        return ctx.focusContext.hasAnyDelta();
    }
    ObjectDelta<?> summaryDelta = ObjectDelta.union(ctx.focusContext.getPrimaryDelta(),
            ctx.focusContext.getSecondaryDelta());
    if (summaryDelta == null) {
        return false;
    }
    boolean exactPathMatch = isTrue(constraint.isExactPathMatch());
    for (ItemPathType path : constraint.getItem()) {
        if (!pathMatches(summaryDelta, ctx.focusContext.getObjectOld(), path.getItemPath(), exactPathMatch)) {
            return false;
        }
    }
    if (!expressionPasses(constraintElement, ctx, result)) {
        return false;
    }
    return true;
}