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.util.QNameUtil.java

public static boolean match(QName a, QName b, boolean caseInsensitive) {
    if (a == null && b == null) {
        return true;
    }/*from ww  w.  j  a v  a 2  s  .c o  m*/
    if (a == null || b == null) {
        return false;
    }
    if (!caseInsensitive) {
        // traditional comparison
        if (StringUtils.isBlank(a.getNamespaceURI()) || StringUtils.isBlank(b.getNamespaceURI())) {
            return a.getLocalPart().equals(b.getLocalPart());
        } else {
            return a.equals(b);
        }
    } else {
        // relaxed (case-insensitive) one
        if (!a.getLocalPart().equalsIgnoreCase(b.getLocalPart())) {
            return false;
        }
        if (StringUtils.isBlank(a.getNamespaceURI()) || StringUtils.isBlank(b.getNamespaceURI())) {
            return true;
        } else {
            return a.getNamespaceURI().equals(b.getNamespaceURI());
        }
    }

}

From source file:com.evolveum.midpoint.model.client.ModelClientUtil.java

public static Element createTextElement(QName qname, String value, Document doc) {
    Element element = doc.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
    element.setTextContent(value);//from   w ww  .  j  a va 2  s .c o  m
    return element;
}

From source file:com.evolveum.midpoint.test.util.MidPointAsserts.java

public static <F extends FocusType> void assertNotAssigned(PrismObject<F> user, String targetOid,
        QName refType) {
    F userType = user.asObjectable();//from  w w w. jav a  2s  .c o  m
    for (AssignmentType assignmentType : userType.getAssignment()) {
        ObjectReferenceType targetRef = assignmentType.getTargetRef();
        if (targetRef != null) {
            if (refType.equals(targetRef.getType())) {
                if (targetOid.equals(targetRef.getOid())) {
                    AssertJUnit.fail(user + " does have assigned " + refType.getLocalPart() + " " + targetOid
                            + " while not expecting it");
                }
            }
        }
    }
}

From source file:com.evolveum.midpoint.repo.sql.util.RUtil.java

public static String qnameToString(QName qname) {
    StringBuilder sb = new StringBuilder();
    if (qname != null) {
        sb.append(qname.getNamespaceURI());
    }//from  w w w  .ja va  2 s  .  c o m
    sb.append(QNAME_DELIMITER);
    if (qname != null) {
        sb.append(qname.getLocalPart());
    }

    return sb.toString();
}

From source file:jp.go.nict.langrid.bpel.ProcessAnalyzer.java

/**
 * /* w w  w  .  j a v  a  2  s.  co m*/
 * 
 */
public static void resolve(BPEL bpel, Map<URI, WSDL> wsdls)
        throws ProcessAnalysisException, URISyntaxException {
    // EndpointReference?
    for (WSDL w : wsdls.values()) {
        for (Service s : w.getServices().values()) {
            for (Port p : s.getPorts().values()) {
                EndpointReference epr = new EndpointReference();
                epr.setServiceName(new QName(w.getTargetNamespace().toString(), s.getName()));
                epr.setServicePortName(p.getName());
                epr.setAddress(p.getAddress());

                QName binding = p.getBinding();
                WSDL bw = wsdls.get(new URI(binding.getNamespaceURI()));
                assert bw != null;
                QName bindingType = bw.getBindingTypes().get(binding.getLocalPart());
                WSDL btw = wsdls.get(new URI(bindingType.getNamespaceURI()));
                assert btw != null;
                Map<String, EndpointReference> map = btw.getPortTypeToEndpointReference();
                if (map == null) {
                    map = new HashMap<String, EndpointReference>();
                    btw.setPortTypeToEndpointReference(map);
                }
                map.put(p.getName(), epr);
            }
        }
    }
    Map<QName, EndpointReference> portTypeQNameToEndpointReference = new HashMap<QName, EndpointReference>();
    Map<QName, PartnerLinkType> qnameToPartnerLinkType = new HashMap<QName, PartnerLinkType>();
    Map<QName, QName> bindingNameToServiceName = new HashMap<QName, QName>();
    for (WSDL w : wsdls.values()) {
        String tns = w.getTargetNamespace().toString();
        for (Map.Entry<String, EndpointReference> e : w.getPortTypeToEndpointReference().entrySet()) {
            portTypeQNameToEndpointReference.put(new QName(tns, e.getKey()), e.getValue());
        }
        for (Map.Entry<String, PartnerLinkType> e : w.getPlinks().entrySet()) {
            qnameToPartnerLinkType.put(new QName(tns, e.getKey()), e.getValue());
        }
        for (Service s : w.getServices().values()) {
            for (Port p : s.getPorts().values()) {
                bindingNameToServiceName.put(p.getBinding(), new QName(tns, s.getName()));
            }
        }
    }
    Map<QName, QName> portTypeNameToServiceName = new HashMap<QName, QName>();
    for (WSDL w : wsdls.values()) {
        String tns = w.getTargetNamespace().toString();
        for (Map.Entry<String, QName> e : w.getBindingTypes().entrySet()) {
            portTypeNameToServiceName.put(e.getValue(),
                    bindingNameToServiceName.get(new QName(tns, e.getKey())));
        }
    }

    // PartnerLink -> ServiceName
    // PartnerLink -> EndpointReference
    // ?
    for (PartnerLink p : bpel.getPartnerLinks()) {
        // PartnerLink -> wsdl?plink:partnerLinkType
        QName pltName = p.getPartnerLinkType();
        PartnerLinkType plt = qnameToPartnerLinkType.get(pltName);
        if (plt == null) {
            throw new ProcessAnalysisException("couldn't find partner link type for: " + pltName);
        }

        // myRole?
        String myRole = p.getMyRole();
        if (myRole != null) {
            Role role = plt.getRoles().get(myRole);
            if (role == null) {
                throw new ProcessAnalysisException("The my role \"" + myRole + "\" for partner link name \""
                        + plt.getName() + "\" is not found.");
            }

            QName portTypeName = role.getPortTypeName();
            QName serviceName = portTypeNameToServiceName.get(portTypeName);
            if (serviceName != null) {
                p.setService(serviceName.getLocalPart());
            } else {
                // ???????
                p.setService(bpel.getProcessName());
            }
        }

        // partnerRole?
        String partnerRole = p.getPartnerRole();
        if (partnerRole != null) {
            Role role = plt.getRoles().get(partnerRole);
            if (role == null) {
                throw new ProcessAnalysisException("The partner role \"" + partnerRole
                        + "\" for partner link name \"" + plt.getName() + "\" is not found.");
            }

            QName portTypeName = role.getPortTypeName();
            EndpointReference epr = portTypeQNameToEndpointReference.get(portTypeName);
            if (epr == null) {
                throw new ProcessAnalysisException(
                        "The EndpointReference for port type \"" + portTypeName + "\" is not found.");
            }
            p.setEndpointReference(epr);
        }
    }
}

From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments.AttachmentUtils.java

public static AttachmentEncoding getAttachmentEncoding(WsdlOperation operation, String partName,
        boolean isResponse) {
    // make sure we have access
    if (operation == null || operation.getBindingOperation() == null
            || operation.getBindingOperation().getOperation() == null) {
        return AttachmentEncoding.NONE;
    }//from  w ww.ja  va  2  s .c om

    javax.wsdl.Part part = null;

    if (isResponse) {
        Output output = operation.getBindingOperation().getOperation().getOutput();
        if (output == null || output.getMessage() == null) {
            return AttachmentEncoding.NONE;
        } else {
            part = output.getMessage().getPart(partName);
        }
    } else {
        Input input = operation.getBindingOperation().getOperation().getInput();
        if (input == null || input.getMessage() == null) {
            return AttachmentEncoding.NONE;
        } else {
            part = input.getMessage().getPart(partName);
        }
    }

    if (part != null) {
        QName typeName = part.getTypeName();
        if (typeName.getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema")) {
            if (typeName.getLocalPart().equals("base64Binary")) {
                return AttachmentEncoding.BASE64;
            } else if (typeName.getLocalPart().equals("hexBinary")) {
                return AttachmentEncoding.HEX;
            }
        }
    }

    return AttachmentEncoding.NONE;
}

From source file:com.evolveum.midpoint.test.util.MidPointAsserts.java

public static <F extends FocusType> void assertAssigned(PrismObject<F> user, String targetOid, QName refType) {
    F userType = user.asObjectable();//from  w ww. j a  v a2 s  . c o m
    for (AssignmentType assignmentType : userType.getAssignment()) {
        ObjectReferenceType targetRef = assignmentType.getTargetRef();
        if (targetRef != null) {
            if (refType.equals(targetRef.getType())) {
                if (targetOid.equals(targetRef.getOid())) {
                    return;
                }
            }
        }
    }
    AssertJUnit.fail(user + " does not have assigned " + refType.getLocalPart() + " " + targetOid);
}

From source file:com.evolveum.midpoint.testing.wstest.AbstractWebserviceTest.java

protected static Element createTextElement(QName qname, String value, Document doc) {
    Element element = doc.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
    element.setTextContent(value);//from  w ww  .  j a  v a  2  s  . co m
    return element;
}

From source file:com.evolveum.midpoint.schema.util.PolicyRuleTypeUtil.java

public static String toShortString(PolicyConstraintsType constraints, char join) {
    if (constraints == null) {
        return "null";
    }//w  ww  .  ja  v  a 2  s  .  c om
    StringBuilder sb = new StringBuilder();
    // we ignore refs to be able to dump even unresolved policy rules
    for (JAXBElement<AbstractPolicyConstraintType> constraint : toConstraintsList(constraints, false, true)) {
        QName name = constraint.getName();
        String abbreviation = CONSTRAINT_NAMES.get(name.getLocalPart());
        if (sb.length() > 0) {
            sb.append(join);
        }
        if (QNameUtil.match(name, PolicyConstraintsType.F_AND)) {
            sb.append('(');
            sb.append(toShortString((PolicyConstraintsType) constraint.getValue(), JOIN_AND));
            sb.append(')');
        } else if (QNameUtil.match(name, PolicyConstraintsType.F_OR)) {
            sb.append('(');
            sb.append(toShortString((PolicyConstraintsType) constraint.getValue(), JOIN_OR));
            sb.append(')');
        } else if (QNameUtil.match(name, PolicyConstraintsType.F_NOT)) {
            sb.append('(');
            sb.append(toShortString((PolicyConstraintsType) constraint.getValue(), JOIN_AND));
            sb.append(')');
        } else if (QNameUtil.match(name, PolicyConstraintsType.F_TRANSITION)) {
            TransitionPolicyConstraintType trans = (TransitionPolicyConstraintType) constraint.getValue();
            sb.append(SYMBOL_TRANSITION);
            sb.append(toTransSymbol(trans.isStateBefore()));
            sb.append(toTransSymbol(trans.isStateAfter()));
            sb.append('(');
            sb.append(toShortString(trans.getConstraints(), JOIN_AND));
            sb.append(')');
        } else {
            sb.append(abbreviation != null ? abbreviation : name.getLocalPart());
        }
    }
    for (PolicyConstraintReferenceType ref : constraints.getRef()) {
        if (sb.length() > 0) {
            sb.append(join);
        }
        sb.append("ref:").append(ref.getName());
    }
    return sb.toString();
}

From source file:com.evolveum.liferay.usercreatehook.ws.ModelPortWrapper.java

private static Element createTextElement(QName qname, String value, Document doc) {
    Element element = doc.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
    element.setTextContent(value);//from  w  w  w .  j a  v  a  2  s .co m
    return element;
}