Example usage for javax.xml.namespace QName QName

List of usage examples for javax.xml.namespace QName QName

Introduction

In this page you can find the example usage for javax.xml.namespace QName QName.

Prototype

public QName(final String namespaceURI, final String localPart) 

Source Link

Document

QName constructor specifying the Namespace URI and local part.

If the Namespace URI is null, it is set to javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI .

Usage

From source file:org.javelin.sws.ext.bind.internal.model.ClassHierarchyTest.java

@Test
public void handleXmlAccessTypePublicMember() throws Exception {
    // f1, f3, f4, p1, p3, p4 - public fields, public properties, annotated fields, annotated properties
    System.out.println("\nC4");
    JAXBContext.newInstance(C4.class).createMarshaller()
            .marshal(new JAXBElement<C4>(new QName("", "r"), C4.class, new C4()), System.out);
    JAXBContext ctx = SweJaxbContextFactory.createContext(new Class[] { C4.class }, null);
    Map<Class<?>, TypedPattern<?>> patterns = (Map<Class<?>, TypedPattern<?>>) ReflectionTestUtils.getField(ctx,
            "patterns");
    ComplexTypePattern<C4> pattern = (ComplexTypePattern<C4>) patterns.get(C4.class);
    Map<QName, PropertyMetadata<C4, ?>> elements = (Map<QName, PropertyMetadata<C4, ?>>) ReflectionTestUtils
            .getField(pattern, "elements");
    assertThat(elements.size(), equalTo(6));
    assertTrue(elements.containsKey(new QName("", "f1")));
    assertTrue(elements.containsKey(new QName("", "f3")));
    assertTrue(elements.containsKey(new QName("", "f4")));
    assertTrue(elements.containsKey(new QName("", "p1")));
    assertTrue(elements.containsKey(new QName("", "p3")));
    assertTrue(elements.containsKey(new QName("", "p4")));
}

From source file:org.javelin.sws.ext.bind.internal.model.AnalyzeSimpleTypesTest.java

/**
 * /*  w w  w  .  j  a va  2  s. c om*/
 */
private void flush() {
    try {
        this.writer.add(this.eventFactory.createEndElement(new QName("", "v"), null));
        this.writer.close();
    } catch (XMLStreamException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:edu.internet2.middleware.shibboleth.common.config.attribute.resolver.dataConnector.LdapDataConnectorBeanDefinitionParser.java

/**
 * Process the basic LDAP connection configuration for the LDAP data connector.
 * /*from   w  w w.  j ava  2 s.  c om*/
 * @param pluginId ID of the LDAP plugin
 * @param pluginConfig LDAP plugin configuration element
 * @param pluginConfigChildren child elements of the plugin
 * @param pluginBuilder plugin builder
 * @param parserContext current parsing context
 */
protected void processBasicConnectionConfig(String pluginId, Element pluginConfig,
        Map<QName, List<Element>> pluginConfigChildren, BeanDefinitionBuilder pluginBuilder,
        ParserContext parserContext) {

    String ldapURL = pluginConfig.getAttributeNS(null, "ldapURL");
    log.debug("Data connector {} LDAP URL: {}", pluginId, ldapURL);
    pluginBuilder.addPropertyValue("ldapUrl", ldapURL);

    ConnectionStrategy connStrategy = ConnectionStrategy.ACTIVE_PASSIVE;
    if (pluginConfig.hasAttributeNS(null, "connectionStrategy")) {
        connStrategy = ConnectionStrategy.valueOf(pluginConfig.getAttributeNS(null, "connectionStrategy"));
    }
    log.debug("Data connector {} connection strategy: {}", pluginId, connStrategy);
    pluginBuilder.addPropertyValue("connectionStrategy", connStrategy);

    if (pluginConfig.hasAttributeNS(null, "baseDN")) {
        String baseDN = pluginConfig.getAttributeNS(null, "baseDN");
        log.debug("Data connector {} base DN: {}", pluginId, baseDN);
        pluginBuilder.addPropertyValue("baseDN", baseDN);
    }

    AUTHENTICATION_TYPE authnType = AUTHENTICATION_TYPE.SIMPLE;
    if (pluginConfig.hasAttributeNS(null, "authenticationType")) {
        authnType = AUTHENTICATION_TYPE.valueOf(pluginConfig.getAttributeNS(null, "authenticationType"));
    }
    log.debug("Data connector {} authentication type: {}", pluginId, authnType);
    pluginBuilder.addPropertyValue("authenticationType", authnType);

    String principal = pluginConfig.getAttributeNS(null, "principal");
    log.debug("Data connector {} principal: {}", pluginId, principal);
    pluginBuilder.addPropertyValue("principal", principal);

    String credential = pluginConfig.getAttributeNS(null, "principalCredential");
    pluginBuilder.addPropertyValue("principalCredential", credential);

    String templateEngineRef = pluginConfig.getAttributeNS(null, "templateEngine");
    pluginBuilder.addPropertyReference("templateEngine", templateEngineRef);

    String filterTemplate = pluginConfigChildren
            .get(new QName(DataConnectorNamespaceHandler.NAMESPACE, "FilterTemplate")).get(0).getTextContent();
    filterTemplate = DatatypeHelper.safeTrimOrNullString(filterTemplate);
    log.debug("Data connector {} LDAP filter template: {}", pluginId, filterTemplate);
    pluginBuilder.addPropertyValue("filterTemplate", filterTemplate);

    SearchScope searchScope = SearchScope.SUBTREE;
    if (pluginConfig.hasAttributeNS(null, "searchScope")) {
        searchScope = SearchScope.valueOf(pluginConfig.getAttributeNS(null, "searchScope"));
    }
    log.debug("Data connector {} search scope: {}", pluginId, searchScope);
    pluginBuilder.addPropertyValue("searchScope", searchScope);

    QName returnAttributesName = new QName(DataConnectorNamespaceHandler.NAMESPACE, "ReturnAttributes");
    if (pluginConfigChildren.containsKey(returnAttributesName)) {
        List<String> returnAttributes = XMLHelper
                .getElementContentAsList(pluginConfigChildren.get(returnAttributesName).get(0));
        log.debug("Data connector {} return attributes: {}", pluginId, returnAttributes);
        pluginBuilder.addPropertyValue("returnAttributes", returnAttributes);
    }
}

From source file:com._4dconcept.springframework.data.marklogic.repository.query.PartTreeMarklogicQueryTest.java

@Test
public void collectionFieldsWithContainingKeyWordShouldBeConsideredAsOrCriteria() {
    List<String> skills = new ArrayList<>();
    skills.add("foo");
    skills.add("bar");

    Query query = deriveQueryFromMethod("findBySkillsContaining", skills);

    assertThat(query.getCriteria().getOperator(), is(Criteria.Operator.or));
    assertThat(query.getCriteria().getCriteriaObject(), instanceOf(List.class));

    List<Criteria> criteriaList = extractListCriteria(query.getCriteria());

    assertCriteria(criteriaList.get(0), is(new QName("http://spring.data.marklogic/test/contact", "skill")),
            is("foo"));

    assertCriteria(criteriaList.get(1), is(new QName("http://spring.data.marklogic/test/contact", "skill")),
            is("bar"));
}

From source file:de.extra.extraClientLight.helper.BuildExtraTransport.java

/**
 * Baut die Query zusammen/*from  ww  w  .j a  v  a2  s .co  m*/
 * 
 * @param requestBean
 * @return DataRequestType
 */

private static DataRequestType buildQuery(RequestExtraBean requestBean) {

    DataRequestType dataRequest = new DataRequestType();
    DataRequestQueryType dataQuery = new DataRequestQueryType();
    DataRequestArgumentType requestIdArgument = new DataRequestArgumentType();
    DataRequestArgumentType procedureArgument = new DataRequestArgumentType();
    DataRequestArgumentType dataTypeArgument = new DataRequestArgumentType();

    requestIdArgument.setProperty(ClientConstants.QUERY_REQUESTID);

    OperandType operand = new OperandType();
    operand.setValue("1234");

    final JAXBElement<OperandType> jaxbOperand = new JAXBElement<OperandType>(
            new QName("http://www.extra-standard.de/namespace/message/1", "GT"), OperandType.class, operand);
    jaxbOperand.setValue(operand);

    requestIdArgument.getContent().add(jaxbOperand);
    dataQuery.getArgument().add(requestIdArgument);

    procedureArgument.setProperty(ClientConstants.QUERY_PROCEDURE);

    dataQuery.getArgument().add(procedureArgument);

    dataTypeArgument.setProperty(ClientConstants.QUERY_DATATYPE);
    dataQuery.getArgument().add(dataTypeArgument);

    dataRequest.setQuery(dataQuery);

    return dataRequest;
}

From source file:edu.duke.cabig.c3pr.webservice.studyimportexport.impl.StudyImportExportImpl.java

/**
 * Creates the import study response.//from   w ww  .  j a  va2s .  co  m
 *
 * @return the sOAP message
 * @throws SOAPException the sOAP exception
 */
private SOAPMessage createImportStudyResponse() throws SOAPException {
    MessageFactory mf = MessageFactory.newInstance();
    SOAPMessage response = mf.createMessage();
    SOAPBody body = response.getSOAPBody();
    body.addChildElement(new QName(SERVICE_NS, "ImportStudyResponse"));
    response.saveChanges();
    return response;
}

From source file:org.n52.youngs.harvest.PoxCswSource.java

private HttpEntity createRequest(long startPosition, long maxRecords) {
    Marshaller m;//from   w  w  w . j  a  v  a2  s. c  o m
    try {
        m = getMarshaller();
    } catch (JAXBException e) {
        log.error("Could not create marshaller", e);
        return null;
    }

    GetRecordsType getRecords = new GetRecordsType();
    ObjectFactory objectFactory = new ObjectFactory();
    JAXBElement<GetRecordsType> jaxb_getRecords = objectFactory.createGetRecords(getRecords);

    getRecords.setResultType(ResultType.RESULTS);
    getRecords.setOutputSchema(getOutputSchemaParameter());
    getRecords.setStartPosition(BigInteger.valueOf(startPosition));
    getRecords.setMaxRecords(BigInteger.valueOf(maxRecords));
    QueryType query = new QueryType();
    ElementSetNameType esn = new ElementSetNameType();
    esn.setValue(ElementSetType.FULL);
    query.setElementSetName(esn);
    query.setTypeNames(Lists.newArrayList(new QName(getOutputSchemaParameter(),
            getTypeNamesParameter().substring(getTypeNamesParameter().indexOf(":") + 1))));
    getRecords.setAbstractQuery(objectFactory.createQuery(query));

    Writer w = new StringWriter();
    try {
        m.marshal(jaxb_getRecords, w);
    } catch (JAXBException e) {
        log.error("Error marshalling request", e);
    }

    log.trace("Created GetRecords request starting at {} for {} records:\n{}", startPosition, maxRecords,
            w.toString());

    StringEntity entity = new StringEntity(w.toString(), Charsets.UTF_8);
    return entity;
}

From source file:com.evolveum.midpoint.web.page.admin.configuration.PageDebugView.java

private ObjectViewDto loadObject() {
    StringValue objectOid = getPageParameters().get(PARAM_OBJECT_ID);
    if (objectOid == null || StringUtils.isEmpty(objectOid.toString())) {
        getSession().error(getString("pageDebugView.message.oidNotDefined"));
        throw new RestartResponseException(PageDebugList.class);
    }/*from   w  ww.  j  a va 2s .c  o m*/

    Task task = createSimpleTask(OPERATION_LOAD_OBJECT);
    OperationResult result = task.getResult(); //todo is this result != null ?
    ObjectViewDto dto = null;
    try {
        MidPointApplication application = PageDebugView.this.getMidpointApplication();

        GetOperationOptions rootOptions = GetOperationOptions.createRaw();

        rootOptions.setResolveNames(true);
        Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions
                .createCollection(rootOptions);
        // FIXME: ObjectType.class will not work well here. We need more specific type.
        //todo on page debug list create page params, put there oid and class for object type and send that to this page....read it here
        Class type = ObjectType.class;
        StringValue objectType = getPageParameters().get(PARAM_OBJECT_TYPE);
        if (objectType != null && StringUtils.isNotBlank(objectType.toString())) {
            type = getPrismContext().getSchemaRegistry().determineCompileTimeClass(
                    new QName(SchemaConstantsGenerated.NS_COMMON, objectType.toString()));
        }

        // TODO make this configurable (or at least do not show campaign cases in production)
        if (UserType.class.isAssignableFrom(type)) {
            options.add(SelectorOptions.create(UserType.F_JPEG_PHOTO,
                    GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
        }
        if (LookupTableType.class.isAssignableFrom(type)) {
            options.add(SelectorOptions.create(LookupTableType.F_ROW,
                    GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
        }
        if (AccessCertificationCampaignType.class.isAssignableFrom(type)) {
            options.add(SelectorOptions.create(AccessCertificationCampaignType.F_CASE,
                    GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
        }

        PrismObject<ObjectType> object = getModelService().getObject(type, objectOid.toString(), options, task,
                result);

        PrismContext context = application.getPrismContext();
        String xml = context.serializeObjectToString(object, PrismContext.LANG_XML);
        dto = new ObjectViewDto(object.getOid(), WebMiscUtil.getName(object), object, xml);

        result.recomputeStatus();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't load object.", ex);
    }

    if (dto == null) {
        showResultInSession(result);
        throw new RestartResponseException(PageDebugList.class);
    }

    if (!result.isSuccess()) {
        showResult(result);
    }

    if (!WebMiscUtil.isSuccessOrHandledErrorOrWarning(result)) {
        showResultInSession(result);
        throw new RestartResponseException(PageDebugList.class);
    }

    return dto;
}

From source file:com.nortal.jroad.wsdl.XTeeWsdlDefinition.java

private void addXRoadExtensions(Definition definition) throws WSDLException {
    definition.addNamespace(XROAD_PREFIX, XROAD_NAMESPACE);

    Message message = definition.createMessage();
    message.setQName(new QName(definition.getTargetNamespace(), XROAD_HEADER));

    addXroadHeaderPart(definition, message, XTeeHeader.CLIENT);
    addXroadHeaderPart(definition, message, XTeeHeader.SERVICE);
    addXroadHeaderPart(definition, message, XTeeHeader.ID);
    addXroadHeaderPart(definition, message, XTeeHeader.USER_ID);
    addXroadHeaderPart(definition, message, XTeeHeader.PROTOCOL_VERSION);

    message.setUndefined(false);// ww  w  . j  a v a  2  s.c  o  m
    definition.addMessage(message);

    // Add XRoad schema import to the first schema
    for (Object ex : definition.getTypes().getExtensibilityElements()) {
        if (ex instanceof Schema) {
            Schema schema = (Schema) ex;
            Element xRoadImport = schema.getElement().getOwnerDocument()
                    .createElement(schema.getElement().getPrefix() == null ? "import"
                            : schema.getElement().getPrefix() + ":import");
            xRoadImport.setAttribute("namespace", XROAD_NAMESPACE);
            xRoadImport.setAttribute("schemaLocation", XROAD_NAMESPACE);
            schema.getElement().insertBefore(xRoadImport, schema.getElement().getFirstChild());
            break;
        }
    }
}

From source file:com.evolveum.midpoint.wf.impl.processes.itemApproval.InitializeLoopThroughApproversInLevel.java

private Collection<LightweightObjectRef> evaluateExpression(ExpressionType approverExpression,
        ExpressionVariables expressionVariables, DelegateExecution execution, Task task, OperationResult result)
        throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException {

    if (expressionFactory == null) {
        expressionFactory = getExpressionFactory();
    }/*from   w  ww  .  jav  a  2 s  .c  om*/

    PrismContext prismContext = expressionFactory.getPrismContext();
    QName approverOidName = new QName(SchemaConstants.NS_C, "approverOid");
    PrismPropertyDefinition<String> approverOidDef = new PrismPropertyDefinition(approverOidName,
            DOMUtil.XSD_STRING, prismContext);
    Expression<PrismPropertyValue<String>, PrismPropertyDefinition<String>> expression = expressionFactory
            .makeExpression(approverExpression, approverOidDef, "approverExpression", task, result);
    ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables,
            "approverExpression", task, result);
    PrismValueDeltaSetTriple<PrismPropertyValue<String>> exprResult = expression.evaluate(params);

    List<LightweightObjectRef> retval = new ArrayList<LightweightObjectRef>();
    for (PrismPropertyValue<String> item : exprResult.getZeroSet()) {
        LightweightObjectRef ort = new LightweightObjectRefImpl(item.getValue());
        retval.add(ort);
    }
    return retval;

}