Example usage for javax.xml.namespace QName getLocalPart

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

Introduction

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

Prototype

public String getLocalPart() 

Source Link

Document

Get the local part of this QName.

Usage

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

private void initSearchForm(Form searchForm) {
    BasicSearchPanel<AccountDetailsSearchDto> basicSearch = new BasicSearchPanel<AccountDetailsSearchDto>(
            ID_SEARCH_BASIC) {//from  w  w  w .j a v a  2s.  c  om

        @Override
        protected IModel<String> createSearchTextModel() {
            return new PropertyModel<>(searchModel, AccountDetailsSearchDto.F_SEARCH_TEXT);
        }

        @Override
        protected void searchPerformed(AjaxRequestTarget target) {
            PageAccounts.this.searchPerformed(target);
        }

        @Override
        protected void clearSearchPerformed(AjaxRequestTarget target) {
            PageAccounts.this.clearSearchPerformed(target);
        }
    };
    basicSearch.setOutputMarkupId(true);
    searchForm.add(basicSearch);

    DropDownChoice failedOperationType = new DropDownChoice<>(ID_SEARCH_FAILED_OPERATION_TYPE,
            new PropertyModel<FailedOperationTypeType>(searchModel,
                    AccountDetailsSearchDto.F_FAILED_OPERATION_TYPE),
            WebMiscUtil.createReadonlyModelFromEnum(FailedOperationTypeType.class),
            new EnumChoiceRenderer<FailedOperationTypeType>(this));
    failedOperationType.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    });
    failedOperationType.setOutputMarkupId(true);
    failedOperationType.setNullValid(true);
    searchForm.add(failedOperationType);

    DropDownChoice kind = new DropDownChoice<>(ID_SEARCH_KIND,
            new PropertyModel<ShadowKindType>(searchModel, AccountDetailsSearchDto.F_KIND),
            WebMiscUtil.createReadonlyModelFromEnum(ShadowKindType.class),
            new EnumChoiceRenderer<ShadowKindType>(this));
    kind.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    });
    kind.setOutputMarkupId(true);
    kind.setNullValid(true);
    searchForm.add(kind);

    DropDownChoice intent = new DropDownChoice<>(ID_SEARCH_INTENT,
            new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_INTENT), createIntentChoices(),
            new IChoiceRenderer<String>() {

                @Override
                public String getDisplayValue(String object) {
                    return object;
                }

                @Override
                public String getIdValue(String object, int index) {
                    return Integer.toString(index);
                }
            });
    intent.setNullValid(true);
    intent.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    });
    intent.setOutputMarkupId(true);
    searchForm.add(intent);

    AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_SEARCH_OBJECT_CLASS,
            new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_OBJECT_CLASS)) {

        @Override
        protected Iterator<String> getChoices(String input) {
            if (Strings.isEmpty(input)) {
                List<String> emptyList = Collections.emptyList();
                return emptyList.iterator();
            }

            AccountDetailsSearchDto dto = searchModel.getObject();
            List<QName> accountObjectClassList = dto.getObjectClassList();
            List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);

            for (QName s : accountObjectClassList) {
                if (s.getLocalPart().toLowerCase().startsWith(input.toLowerCase())) {
                    choices.add(s.getLocalPart());

                    if (choices.size() == AUTO_COMPLETE_LIST_SIZE) {
                        break;
                    }
                }
            }

            return choices.iterator();
        }
    };
    objectClass.add(AttributeModifier.replace("placeholder",
            createStringResource("PageAccounts.accounts.objectClass")));
    objectClass.setOutputMarkupId(true);
    objectClass.add(createObjectClassValidator());
    objectClass.add(new SearchFormEnterBehavior(basicSearch.getSearchButton()));
    searchForm.add(objectClass);
}

From source file:com.evolveum.midpoint.certification.impl.AccCertReviewersHelper.java

private List<ObjectReferenceType> getAssignees(AbstractRoleType role, QName relation, Task task,
        OperationResult result) throws SchemaException {
    List<ObjectReferenceType> rv = new ArrayList<>();
    if (SchemaConstants.ORG_OWNER.equals(relation)) {
        CollectionUtils.addIgnoreNull(rv, role.getOwnerRef());
    } else if (SchemaConstants.ORG_APPROVER.equals(relation)) {
        rv.addAll(role.getApproverRef());
    } else {//  w  w  w . j a va 2 s.c  o m
        throw new AssertionError(relation);
    }
    // TODO in theory, we could look for approvers/owners of UserType, right?
    PrismReferenceValue ref = new PrismReferenceValue(role.getOid());
    ref.setRelation(relation);
    ObjectQuery query = QueryBuilder.queryFor(FocusType.class, prismContext)
            .item(FocusType.F_ROLE_MEMBERSHIP_REF).ref(ref).build();
    List<PrismObject<FocusType>> assignees = repositoryService.searchObjects(FocusType.class, query, null,
            result);
    LOGGER.trace("Looking for '{}' of {} using {}: found: {}", relation.getLocalPart(), role, query, assignees);
    assignees.forEach(o -> rv.add(ObjectTypeUtil.createObjectRef(o)));
    return rv;
}

From source file:com.example.soaplegacy.WsdlValidator.java

private void validateDocLiteral(BindingOperation bindingOperation, Part[] parts, XmlObject msgXml,
        List<XmlError> errors, boolean isResponse, boolean strict) throws Exception {

    Part part = null;/*from w w  w .j  ava2  s  . c  o  m*/
    // start by finding body part
    for (int c = 0; c < parts.length; c++) {
        // content part?
        if ((isResponse && !WsdlUtils.isAttachmentOutputPart(parts[c], bindingOperation))
                || (!isResponse && !WsdlUtils.isAttachmentInputPart(parts[c], bindingOperation))) {
            // already found?
            if (part != null) {
                if (strict) {
                    errors.add(XmlError.forMessage("DocLiteral message must contain 1 body part definition"));
                }
                return;
            }
            part = parts[c];
        }
    }

    QName elementName = part.getElementName();
    if (elementName != null) {
        // just check for correct message element, other elements are avoided
        // (should create an error)
        XmlObject[] paths = msgXml
                .selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace()
                        + "';" + "declare namespace ns='" + elementName.getNamespaceURI() + "';"
                        + "$this/env:Envelope/env:Body/ns:" + elementName.getLocalPart());

        if (paths.length == 1) {
            SchemaGlobalElement elm = wsdlContext.getSchemaTypeLoader().findElement(elementName);
            if (elm != null) {
                validateMessageBody(errors, elm.getType(), paths[0]);

                // ensure no other elements in body
                NodeList children = XmlUtils.getChildElements((Element) paths[0].getDomNode().getParentNode());
                for (int d = 0; d < children.getLength(); d++) {
                    QName childName = XmlUtils.getQName(children.item(d));
                    if (!elementName.equals(childName)) {
                        XmlCursor cur = paths[0].newCursor();
                        cur.toParent();
                        cur.toChild(childName);
                        errors.add(XmlError.forCursor("Invalid element [" + childName + "] in SOAP Body", cur));
                        cur.dispose();
                    }
                }
            } else {
                errors.add(XmlError.forMessage("Missing part type [" + elementName + "] in associated schema"));
            }
        } else {
            errors.add(XmlError.forMessage("Missing message part with name [" + elementName + "]"));
        }
    } else if (part.getTypeName() != null) {
        QName typeName = part.getTypeName();

        XmlObject[] paths = msgXml.selectPath("declare namespace env='"
                + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "';" + "declare namespace ns='"
                + typeName.getNamespaceURI() + "';" + "$this/env:Envelope/env:Body/ns:" + part.getName());

        if (paths.length == 1) {
            SchemaType type = wsdlContext.getSchemaTypeLoader().findType(typeName);
            if (type != null) {
                validateMessageBody(errors, type, paths[0]);
                // XmlObject obj = paths[0].copy().changeType( type );
                // obj.validate( new XmlOptions().setErrorListener( errors ));
            } else
                errors.add(XmlError.forMessage("Missing part type in associated schema"));
        } else
            errors.add(XmlError.forMessage(
                    "Missing message part with name:type [" + part.getName() + ":" + typeName + "]"));
    }
}

From source file:com.example.soaplegacy.WsdlValidator.java

@SuppressWarnings("unchecked")
private void validateSoapFault(BindingOperation bindingOperation, XmlObject msgXml, List<XmlError> errors)
        throws Exception {
    Map faults = bindingOperation.getBindingFaults();
    Iterator<BindingFault> i = faults.values().iterator();

    // create internal error list
    List<?> list = new ArrayList<Object>();

    XmlOptions xmlOptions = new XmlOptions();
    xmlOptions.setErrorListener(list);//w  ww . j  a v  a 2s  .co m
    xmlOptions.setValidateTreatLaxAsSkip();
    msgXml.validate(xmlOptions);

    for (Object o : list) {
        if (o instanceof XmlError)
            errors.add((XmlError) o);
        else
            errors.add(XmlError.forMessage(o.toString()));
    }

    while (i.hasNext()) {
        BindingFault bindingFault = i.next();
        String faultName = bindingFault.getName();

        Part[] faultParts = WsdlUtils.getFaultParts(bindingOperation, faultName);
        if (faultParts.length == 0) {
            log.warn("Missing fault parts in wsdl for fault [" + faultName + "] in bindingOperation ["
                    + bindingOperation.getName() + "]");
            continue;
        }

        if (faultParts.length != 1) {
            log.info("Too many fault parts in wsdl for fault [" + faultName + "] in bindingOperation ["
                    + bindingOperation.getName() + "]");
            continue;
        }

        Part part = faultParts[0];
        QName elementName = part.getElementName();

        if (elementName != null) {
            XmlObject[] paths = msgXml.selectPath("declare namespace env='"
                    + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "'; declare namespace flt='"
                    + wsdlContext.getSoapVersion().getFaultDetailNamespace() + "';" + "declare namespace ns='"
                    + elementName.getNamespaceURI() + "';" + "//env:Fault/flt:detail/ns:"
                    + elementName.getLocalPart());

            if (paths.length == 1) {
                SchemaGlobalElement elm = wsdlContext.getSchemaTypeLoader().findElement(elementName);
                if (elm != null) {
                    validateMessageBody(errors, elm.getType(), paths[0]);
                } else
                    errors.add(XmlError.forMessage("Missing fault part element [" + elementName
                            + "] for fault [" + part.getName() + "] in associated schema"));

                return;
            }
        }
        // this is not allowed by Basic Profile.. remove?
        else if (part.getTypeName() != null) {
            QName typeName = part.getTypeName();

            XmlObject[] paths = msgXml.selectPath("declare namespace env='"
                    + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "'; declare namespace flt='"
                    + wsdlContext.getSoapVersion().getFaultDetailNamespace() + "';" + "declare namespace ns='"
                    + typeName.getNamespaceURI() + "';" + "//env:Fault/flt:detail/ns:" + part.getName());

            if (paths.length == 1) {
                SchemaType type = wsdlContext.getSchemaTypeLoader().findType(typeName);
                if (type != null) {
                    validateMessageBody(errors, type, paths[0]);
                } else
                    errors.add(XmlError.forMessage("Missing fault part type [" + typeName + "] for fault ["
                            + part.getName() + "] in associated schema"));

                return;
            }
        }
    }

    // if we get here, no matching fault was found.. this is not an error but
    // should be warned..
    XmlObject[] paths = msgXml.selectPath("declare namespace env='"
            + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "'; declare namespace flt='"
            + wsdlContext.getSoapVersion().getFaultDetailNamespace() + "';//env:Fault/flt:detail");

    if (paths.length == 0)
        log.warn("Missing matching Fault in wsdl for bindingOperation [" + bindingOperation.getName() + "]");
    else {
        String xmlText = paths[0].xmlText(new XmlOptions().setSaveOuter());
        log.warn("Missing matching Fault in wsdl for Fault Detail element ["
                + XmlUtils.removeUnneccessaryNamespaces(xmlText) + "] in bindingOperation ["
                + bindingOperation.getName() + "]");
    }
}

From source file:com.evolveum.midpoint.prism.crypto.ProtectorImpl.java

@Override
public <T> void hash(ProtectedData<T> protectedData) throws EncryptionException, SchemaException {
    if (protectedData.isHashed()) {
        throw new IllegalArgumentException("Attempt to hash protected data that are already hashed");
    }//from  w  w  w  .j a v a  2s.  co m
    String algorithmUri = getDigestAlgorithm();
    QName algorithmQName = QNameUtil.uriToQName(algorithmUri);
    String algorithmNamespace = algorithmQName.getNamespaceURI();
    if (algorithmNamespace == null) {
        throw new SchemaException("No algorithm namespace");
    }

    HashedDataType hashedDataType;
    switch (algorithmNamespace) {
    case PrismConstants.NS_CRYPTO_ALGORITHM_PBKD:
        if (!protectedData.canSupportType(String.class)) {
            throw new SchemaException("Non-string proteted data");
        }
        hashedDataType = hashPbkd((ProtectedData<String>) protectedData, algorithmUri,
                algorithmQName.getLocalPart());
        break;
    default:
        throw new SchemaException("Unknown namespace " + algorithmNamespace);
    }

    protectedData.setHashedData(hashedDataType);
    protectedData.destroyCleartext();
    protectedData.setEncryptedData(null);
}

From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java

public ComplexTypeDefinition findComplexTypeDefinition(QName typeName) {
    if (StringUtils.isEmpty(typeName.getNamespaceURI())) {
        return resolveGlobalTypeDefinitionWithoutNamespace(typeName.getLocalPart());
    }//w w  w.  j  a  v a  2 s .  c o m
    PrismSchema schema = findSchemaByNamespace(typeName.getNamespaceURI());
    if (schema == null) {
        return null;
    }
    return schema.findComplexTypeDefinition(typeName);
}

From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java

public ItemDefinition findItemDefinitionByElementName(QName elementName) {
    if (StringUtils.isEmpty(elementName.getNamespaceURI())) {
        return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), ItemDefinition.class);
    }//w  w w  . j a  va  2s. co  m
    PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI());
    if (schema == null) {
        return null;
    }
    return schema.findItemDefinition(elementName, ItemDefinition.class);
}

From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java

public <T extends Objectable> PrismObjectDefinition<T> findObjectDefinitionByElementName(QName elementName) {
    if (StringUtils.isEmpty(elementName.getNamespaceURI())) {
        return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(),
                PrismObjectDefinition.class);
    }/*from w w w .j  av  a  2  s . c  o m*/
    PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI());
    if (schema == null) {
        return null;
    }
    return schema.findObjectDefinitionByElementName(elementName);
}

From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java

public PrismPropertyDefinition findPropertyDefinitionByElementName(QName elementName) {
    if (StringUtils.isEmpty(elementName.getNamespaceURI())) {
        return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(),
                PrismPropertyDefinition.class);
    }/*w  ww.ja v a2  s.c o m*/
    PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI());
    if (schema == null) {
        return null;
    }
    return schema.findPropertyDefinitionByElementName(elementName);
}

From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java

public PrismReferenceDefinition findReferenceDefinitionByElementName(QName elementName) {
    if (StringUtils.isEmpty(elementName.getNamespaceURI())) {
        return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(),
                PrismReferenceDefinition.class);
    }/*from  ww  w  . j av a 2s.  c  o  m*/
    PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI());
    if (schema == null) {
        return null;
    }
    return schema.findReferenceDefinitionByElementName(elementName);
}