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.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test/*from ww w .ja  v  a  2s .  c  o  m*/
public void testCreateQNameWithAddNamespaceDeclaration() throws Exception {
    SOAPElement element = saajUtil.createSOAPElement("urn:ns", "test", null);
    element.addNamespaceDeclaration("p", "urn:test");
    QName qname = element.createQName("local", "p");
    assertEquals("p", qname.getPrefix());
    assertEquals("local", qname.getLocalPart());
    assertEquals("urn:test", qname.getNamespaceURI());
}

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

/**
 * Set attribute in the DOM element to a string value.
 * @param element element element where to set attribute
 * @param attr attribute name (QName)/*w  ww .j  a  v a2  s  . c  o m*/
 * @param attrValue attribute value (String)
 */
private void setAttribute(Element element, QName attr, String attrValue) {
    if (attributeQualified) {
        element.setAttributeNS(attr.getNamespaceURI(), attr.getLocalPart(), attrValue);
        addToImport(attr.getNamespaceURI());
    } else {
        element.setAttribute(attr.getLocalPart(), attrValue);
    }
}

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

private Element getOrCreateElement(QName qName, Element parentElement) {
    NodeList elements = parentElement.getElementsByTagNameNS(qName.getNamespaceURI(), qName.getLocalPart());
    if (elements.getLength() == 0) {
        Element element = createElement(qName);
        Element refChild = DOMUtil.getFirstChildElement(parentElement);
        parentElement.insertBefore(element, refChild);
        return element;
    }// w  w w.ja v a2  s.  co  m
    return (Element) elements.item(0);
}

From source file:com.snaplogic.snaps.checkfree.SoapUtils.java

/**
 * Initializes the suggestion provider. Will create the templatizer,
 * extract the operation element and set the http context provider to be able to suggest the
 * template later on./* ww w.j av  a  2  s . c o m*/
 *
 * @param wsdlUrl             the WSDL url
 * @param serviceQName        the service QName
 * @param endpointQName       the endpoint QName
 * @param operationQName      the operation QName
 * @param shouldEncodeAttr    the flag to encode the attributes
 * @param clientBuilder       the client builder
 * @param httpContextProvider the auth contedxt
 *
 * @return the editor suggestion provider
 */
public EditorSuggestionProvider initializeSuggestionProvider(String wsdlUrl, QName serviceQName,
        QName endpointQName, QName operationQName, Boolean shouldEncodeAttr, ClientBuilder clientBuilder,
        HttpContextProvider httpContextProvider) {
    URL wsdlURL = introspectionService.urlObjectFor(wsdlUrl);
    Description description = introspectionService.parseWsdl(wsdlURL, httpContextProvider);
    org.ow2.easywsdl.wsdl.api.Binding operationBinding = description.getService(serviceQName)
            .getEndpoint(endpointQName.getLocalPart()).getBinding();
    Operation operation = operationBinding.getBindingOperation(operationQName.getLocalPart()).getOperation();
    Input input = operation.getInput();
    List<SOAPMessageTemplatizer.Input> inputs;
    switch (description.getVersion()) {
    case WSDL11:
        List<Part> parts = input.getParts();
        if (parts == null || parts.isEmpty()) {
            throw new ConfigurationException(ERROR_WHILE_READING_OPERATION_SCHEMA)
                    .withReason(REQUEST_SCHEMA_NOT_AVAILABLE).withResolution(PLEASE_SPECIFY_REQUEST_SCHEMA);
        }
        inputs = inputFactory.createTemplatizerInputListFrom(operationQName, parts);
        break;
    case WSDL20:
        // NOTE: The wsdl 2.0 grammar says that there can be 0 or more inputs in an
        // operation but there doesn't seem to be any methods which can return all of them
        inputs = new ArrayList<>(1);
        inputs.add(inputFactory.createTemplatizerInputFrom(operationQName, input.getElement()));
        break;
    default:
        throw new ConfigurationException(WSDL_VERSION_NOT_SUPPORTED)
                .withReason(WSDL_VERSION_NOT_SUPPORTED_REASON).withResolution(WSDL_VERSION_NOT_SUPPORTED_RES);
    }

    /*Part part = parts.get(0);
    Element element = part.getElement(); // XXX: Hack - don't know what to do with other parts
    QName elemQName;
    QName typeQName;
    if (element == null) {
    // no element means the part does not define the XSD schema as an element with a
    // proper qname, instead we attempt to get the type
    Type type = part.getType();
    if (type != null) {
        elemQName = type.getQName();
    } else {
        // no type means some crappy defined WSDL, we attempt to get the type through the
        // part qname
        elemQName = part.getPartQName();
    }
    typeQName = elemQName;
    } else {
    // well defined WSDL, we have an element and a type of the element
    elemQName = element.getQName();
    typeQName = element.getType().getQName();
    if (typeQName == null) {
        typeQName = element.getQName();
    }
    }
    ((SoapEditorSuggestionsProviderImpl) editorSuggestionProvider)
        .withClientBuilder(clientBuilder)
        .withElementTypeQName(typeQName)
        .withTemplatizer(templatizer)
        .withHttpContextProvider(httpContextProvider);*/

    SOAPMessageTemplatizer.SoapProtocol soapProtocol = null;
    try {
        switch (operationBinding.getTypeOfBinding()) {
        case SOAP_BINDING4WSDL20:
        case SOAP11_BINDING4WSDL11:
            soapProtocol = SOAPMessageTemplatizer.SoapProtocol.SOAP_11;
            break;
        case SOAP12_BINDING4WSDL11:
            soapProtocol = SOAPMessageTemplatizer.SoapProtocol.SOAP_12;
            break;
        default:
            throw new ExecutionException(OPERATION_BINDING_NOT_SUPPORTED)
                    .formatWith(operationBinding.getTypeOfBinding());
        }
    } catch (ClassCastException e) {
        // XXX: Hack
        switch (description.getVersion()) {
        case WSDL11:
            org.ow2.easywsdl.wsdl.impl.wsdl11.BindingImpl bindingImpl11 = (org.ow2.easywsdl.wsdl.impl.wsdl11.BindingImpl) operationBinding;
            List<Object> anyList = bindingImpl11.getModel().getAny();
            for (Object any : anyList) {
                if (any instanceof JAXBElement && (BINDING.equals(((JAXBElement) any).getName().getLocalPart()))
                        && (SOAP_11_NS.equals(((JAXBElement) any).getName().getNamespaceURI()))) {
                    soapProtocol = SOAPMessageTemplatizer.SoapProtocol.SOAP_11;
                    break;
                } else if (any instanceof JAXBElement
                        && (BINDING.equals(((JAXBElement) any).getName().getLocalPart()))
                        && (SOAP_12_NS.equals(((JAXBElement) any).getName().getNamespaceURI()))) {
                    soapProtocol = SOAPMessageTemplatizer.SoapProtocol.SOAP_12;
                    break;
                }
            }
            break;
        case WSDL20:
            org.ow2.easywsdl.wsdl.impl.wsdl20.BindingImpl binding20 = (org.ow2.easywsdl.wsdl.impl.wsdl20.BindingImpl) operationBinding;
            anyList = binding20.getModel().getOperationOrFaultOrAny();
            for (Object any : anyList) {
                if (any instanceof JAXBElement && (BINDING.equals(((JAXBElement) any).getName().getLocalPart()))
                        && (SOAP_11_NS.equals(((JAXBElement) any).getName().getLocalPart()))) {
                    soapProtocol = SOAPMessageTemplatizer.SoapProtocol.SOAP_11;
                    break;
                } else if (any instanceof JAXBElement
                        && (BINDING.equals(((JAXBElement) any).getName().getLocalPart()))
                        && (SOAP_12_NS.equals(((JAXBElement) any).getName().getLocalPart()))) {
                    soapProtocol = SOAPMessageTemplatizer.SoapProtocol.SOAP_12;
                    break;
                }
            }
            break;
        default:
            throw new IllegalArgumentException();
        }
    }
    Document wsdlDocument = domUtil.getResourceAsDocument(wsdlURL, httpContextProvider);
    Types types = typesFactory.generateTypes(wsdlDocument);
    SchemaVisitor schemaVisitor = new SchemaVisitorImpl();
    schemaVisitor.setProperty(SchemaConstants.ENCODE_ATTRIBUTE, shouldEncodeAttr);
    SOAPMessageTemplatizerImpl templatizer = new SOAPMessageTemplatizerImpl(types, schemaVisitor);
    templatizer.setProperty(TemplatizerConstants.ENCODE_ATTRIBUTE, shouldEncodeAttr);
    ((SoapEditorSuggestionsProviderImpl) editorSuggestionProvider).withClientBuilder(clientBuilder)
            .withInputs(inputs)
            .withSoapProtocol(soapProtocol == null ? SOAPMessageTemplatizer.SoapProtocol.SOAP_11 : soapProtocol)
            .shouldEncodeAttr(shouldEncodeAttr).withTemplatizer(templatizer)
            .withHttpContextProvider(httpContextProvider);
    return editorSuggestionProvider;
}

From source file:com.collabnet.ccf.pi.sfee.v44.SFEETrackerHandler.java

/**
 * Creates an artifact./*from   w w w  .  ja va2s.  co m*/
 * 
 * @throws RemoteException
 *             when an error is encountered in creating the artifact.
 * @return Newly created artifact
 */
public ArtifactSoapDO createArtifact(String sessionId, String trackerId, String description, String category,
        String group, String status, String statusClass, String customer, int priority, int estimatedHours,
        int actualHours, Date closeDate, String assignedTo, String reportedReleaseId, String resolvedReleaseId,
        List<String> flexFieldNames, List<Object> flexFieldValues, List<String> flexFieldTypes, String title,
        String[] comments) throws RemoteException {

    SoapFieldValues flexFields = new SoapFieldValues();
    flexFields.setNames(flexFieldNames.toArray(new String[0]));
    flexFields.setValues(flexFieldValues.toArray());
    flexFields.setTypes(flexFieldTypes.toArray(new String[0]));

    ArtifactSoapDO artifactData = mTrackerApp.createArtifact(sessionId, trackerId, title, description, group,
            category, // category
            status, // status
            customer, // customer
            priority, // priority
            estimatedHours, // estimatedHours
            assignedTo, // assigned user name
            reportedReleaseId, flexFields, null, null, null);
    artifactData.setActualHours(actualHours);
    artifactData.setStatusClass(statusClass);
    artifactData.setCloseDate(closeDate);
    artifactData.setResolvedReleaseId(resolvedReleaseId);
    SoapFieldValues newFlexFields = new SoapFieldValues();
    newFlexFields.setNames(flexFieldNames.toArray(new String[0]));
    newFlexFields.setValues(flexFieldValues.toArray());
    newFlexFields.setTypes(flexFieldTypes.toArray(new String[0]));
    artifactData.setFlexFields(newFlexFields);

    boolean initialUpdated = true;
    while (initialUpdated) {
        try {
            initialUpdated = false;
            mTrackerApp.setArtifactData(sessionId, artifactData, null, null, null, null);
        } catch (AxisFault e) {
            javax.xml.namespace.QName faultCode = e.getFaultCode();
            if (!faultCode.getLocalPart().equals("VersionMismatchFault")) {
                throw e;
            }
            logConflictResolutor.warn("Stale initial update, will override in any case ...:", e);
            artifactData.setVersion(artifactData.getVersion() + 1);
            initialUpdated = true;
        }
    }

    // we have to increase the version number to add the comments
    if (comments.length != 0) {
        artifactData.setVersion(artifactData.getVersion() + 1);
    }

    for (String comment : comments) {
        boolean commentNotUpdated = true;
        while (commentNotUpdated) {
            try {
                commentNotUpdated = false;
                if (StringUtils.isEmpty(comment)) {
                    continue;
                }
                mTrackerApp.setArtifactData(sessionId, artifactData, comment, null, null, null);
                // artifactData = mTrackerApp.getArtifactData(sessionId,
                // artifactData.getId());
                artifactData.setVersion(artifactData.getVersion() + 1);
            } catch (AxisFault e) {
                javax.xml.namespace.QName faultCode = e.getFaultCode();
                if (!faultCode.getLocalPart().equals("VersionMismatchFault")) {
                    throw e;
                }
                logConflictResolutor.warn("Stale comment update, trying again ...:", e);
                artifactData = mTrackerApp.getArtifactData(sessionId, artifactData.getId());
                commentNotUpdated = true;
            }
        }
    }

    // we have to increase the version after the update
    // TODO Find out whether this really works if last modified date differs
    // from actual last modified date
    if (comments.length == 0) {
        artifactData.setVersion(artifactData.getVersion() + 1);
    }
    log.info("Artifact created: " + artifactData.getId());
    return artifactData;
}

From source file:edu.vt.cs.cnd2xsd.Cnd2XsdConverter.java

private void convert(OutputStream stream) {
    OutputStream fout = stream;//  w  w w . j av a 2s . c  o m
    try {

        SchemaElement schemaRoot = new SchemaElement();

        schemaRoot.setElementFormDefault(FormChoice.QUALIFIED);
        schemaRoot.setTargetNamespace(this.namespace);
        JAXBContext jc = JAXBContext.newInstance(SchemaElement.class);
        Marshaller m = jc.createMarshaller();
        List<OpenAttrs> rootAttrList = schemaRoot.getIncludesAndImportsAndRedefines();
        ElementElement rootElement = new ElementElement();
        QName qname = new QName(this.namespace, this.rootType);
        rootElement.setType(qname);
        rootElement.setName(this.root);
        rootAttrList.add(rootElement);

        //the first level nodes that are children of rsrRoot are those nodes that
        //do not have any parent nodes in the cnd.

        for (NodeType nt : ntypes) {

            log.debug("NodeType:" + nt.getName());

            //check if we already have that node - if we have then update it

            QName name = getQualifiedName(nt.getName());

            ComplexTypeElement ctype = (ComplexTypeElement) getComplexType(rootAttrList, name.getLocalPart(),
                    attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);

            for (NodeType pt : nt.getDeclaredSupertypes()) {
                log.debug("  DeclaredSuperType:" + pt.getName());
                //based on the supertypes we will have to make decisions
                if (attrMap.containsKey(pt.getName())) {
                    //check if we have to create a node
                    String[] attrs = attrMap.get(pt.getName());
                    if (attrs != null) {
                        //get the qualified name
                        QName ename = getQualifiedName(pt.getName());
                        //create a complex type
                        //check if the complex type already there in the rootAttrList
                        ComplexType ctf = findComplexType(rootAttrList, ename.getLocalPart());

                        if (ctf == null) {
                            ctf = new ComplexTypeElement();
                            ctf.setName(ename.getLocalPart());
                            //add the attributes
                            for (String attr : attrs) {
                                Attribute attribute = new Attribute();
                                QName type = new QName(Constants.XML_NAMESPACE, Constants.STRING);
                                attribute.setType(type);
                                attribute.setName(attr);
                                ctf.getAttributesAndAttributeGroups().add(attribute);
                            }

                            //add this complex type to the attribute list of the root element
                            rootAttrList.add(ctf);
                        }

                        //create an element of the above complex type and add as element
                        ElementElement element = new ElementElement();
                        element.setName(ename.getLocalPart());
                        element.setType(new QName(this.namespace, ctf.getName()));
                        element.setMinOccurs(BigInteger.ONE);
                        element.setMaxOccurs("1");
                        //element.setType(new QName(ctf.));
                        //now add this element to the top level complex type's sequence
                        ctype.getSequence().getElementsAndGroupsAndAlls().add(element);

                    }
                }
                //the supertype is not a pre-define type - we then have to add it as an element
                else {

                    QName qn = getQualifiedName(pt.getName());
                    ComplexType ctf = getComplexType(rootAttrList, qn.getLocalPart(),
                            attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);

                    //create an element of the above type and add as element
                    ElementElement element = new ElementElement();
                    element.setName(qn.getLocalPart());
                    element.setType(new QName(this.namespace, ctf.getName()));
                    element.setMinOccurs(BigInteger.ONE);
                    element.setMaxOccurs("1");

                    //element.setType(new QName(ctf.));
                    //now add this element to the top level complex type's sequence
                    ctype.getSequence().getElementsAndGroupsAndAlls().add(element);

                }
            }

            for (NodeDefinition nd : nt.getDeclaredChildNodeDefinitions()) {
                log.debug("  Declared ChildNode Definition:" + nd.getName());
                //check default primary type
                NodeType defaultNT = nd.getDefaultPrimaryType();
                if (defaultNT == null) {
                    log.debug("Default Primary Type for the node:" + nd.getName() + " is null");
                    //look for the primary type
                    NodeType[] nts = nd.getRequiredPrimaryTypes();
                    if (ntypes == null) {
                        log.debug("No required primary type for node:" + nd.getName());
                    } else {
                        defaultNT = nts[0];
                        log.debug("Assuming first primary  type:" + defaultNT.getName() + " for node:"
                                + nd.getName());
                    }

                }
                log.debug("  Default Primary Type Name:" + defaultNT.getName());
                ElementElement element = new ElementElement();
                if (nd.getName().equals("*")) {
                    QName qn = getQualifiedName(defaultNT.getName());
                    ComplexType ct = getComplexType(rootAttrList, qn.getLocalPart(),
                            attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);

                    //QName ename = getQualifiedName(ct.getName());
                    element.setName(ct.getName());
                    element.setType(new QName(this.namespace, ct.getName()));
                    element.setMinOccurs(nd.isMandatory() ? BigInteger.ONE : BigInteger.ZERO);
                    //add an attribute called nodename so that it can be used to identify the node
                    QName type = new QName(Constants.XML_NAMESPACE, Constants.STRING);
                    Attribute attribute = new Attribute();
                    attribute.setType(type);
                    attribute.setName("nodename");
                    ct.getAttributesAndAttributeGroups().add(attribute);

                    if (nd.allowsSameNameSiblings()) {
                        element.setMaxOccurs(Constants.UNBOUNDED);
                    }

                } else {

                    QName qn = getQualifiedName(defaultNT.getName());
                    ComplexType ct = getComplexType(rootAttrList, qn.getLocalPart(),
                            attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);

                    QName ename = getQualifiedName(nd.getName());
                    element.setName(ename.getLocalPart());
                    element.setType(new QName(this.namespace, ct.getName()));
                    element.setMinOccurs(nd.isMandatory() ? BigInteger.ONE : BigInteger.ZERO);

                    if (nd.allowsSameNameSiblings()) {
                        element.setMaxOccurs(Constants.UNBOUNDED);
                    }

                }
                ctype.getSequence().getElementsAndGroupsAndAlls().add(element);

            }

            for (PropertyDefinition pDef : nt.getPropertyDefinitions()) {
                log.debug("    Attr Name:" + pDef.getName());
                log.debug("    Req type:" + pDef.getRequiredType());
                log.debug("    Declaring Node type:" + pDef.getDeclaringNodeType().getName());
                if (pDef.getDeclaringNodeType().getName().equals(nt.getName())) {

                    QName qn = getQualifiedName(pDef.getName());
                    if (!pDef.isMultiple()) {
                        Attribute attr = new Attribute();
                        if (isUnsupportedType(pDef.getRequiredType())) {
                            attr.setType(new QName(Constants.XML_NAMESPACE, Constants.STRING));

                        } else {
                            attr.setType(new QName(Constants.XML_NAMESPACE,
                                    PropertyType.nameFromValue(pDef.getRequiredType()).toLowerCase()));
                        }
                        attr.setName(qn.getLocalPart());
                        //handle default value
                        Value[] defaultValues = pDef.getDefaultValues();
                        if (defaultValues != null && defaultValues.length > 0) {
                            attr.setDefault(defaultValues[0].getString());
                        }

                        ctype.getAttributesAndAttributeGroups().add(attr);
                    } else {
                        ComplexType ctf = getComplexType(rootAttrList, qn.getLocalPart(),
                                attrMap.containsKey(nt.getName()) ? attrMap.get(nt.getName()) : null);
                        if (ctf != null) {
                            ElementElement element = new ElementElement();
                            element.setName(qn.getLocalPart());
                            element.setMinOccurs(BigInteger.ZERO);
                            element.setMaxOccurs(Constants.UNBOUNDED);
                            if (isUnsupportedType(pDef.getRequiredType())) {
                                element.setType(new QName(Constants.XML_NAMESPACE, Constants.STRING));

                            } else {
                                element.setType(new QName(Constants.XML_NAMESPACE,
                                        PropertyType.nameFromValue(pDef.getRequiredType()).toLowerCase()));
                            }
                            ctf.getSequence().getElementsAndGroupsAndAlls().add(element);

                        }

                        //now create an element of the above type
                        ElementElement element = new ElementElement();
                        element.setName(qn.getLocalPart());
                        element.setType(new QName(this.namespace, ctf.getName()));
                        ctype.getSequence().getElementsAndGroupsAndAlls().add(element);

                    }

                }

            }

        }
        //decide what to put under rootNode

        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        //fout = new FileOutputStream(fileName);
        m.marshal(schemaRoot, fout);

    } catch (Exception ex) {
        log.debug("Exception:" + ex.getMessage());
        ex.printStackTrace();
    } finally {
        if (fout != null) {
            try {
                fout.close();
            } catch (IOException ex) {
                log.error("Exception caught: {}", ex.getMessage());
            }
        }
    }

}

From source file:eu.planets_project.tb.gui.backing.admin.wsclient.util.ComponentBuilder.java

/**
 * Populates a ServiceInfo instance from the specified Service definiition
 *
 * @param   component      The component to populate
 * @param   service        The Service to populate from
 *
 * @return The populated component is returned representing the Service parameter
 *///from   w  ww  . ja v  a  2 s.  c  o m
private ServiceInfo populateComponent(ServiceInfo component, Service service) {
    // Get the qualified service name information
    QName qName = service.getQName();

    // Get the service's namespace URI
    String namespace = qName.getNamespaceURI();

    // Use the local part of the qualified name for the component's name
    String name = qName.getLocalPart();

    // Set the name
    component.setName(name);
    // Get the defined ports for this service
    Map ports = service.getPorts();

    // Use the Ports to create OperationInfos for all request/response messages defined
    Iterator portIter = ports.values().iterator();

    while (portIter.hasNext()) {
        // Get the next defined port
        Port port = (Port) portIter.next();

        // Get the Port's Binding
        Binding binding = port.getBinding();

        // Now we will create operations from the Binding information
        List<?> operations = buildOperations(binding);

        // Process objects built from the binding information
        Iterator<?> operIter = operations.iterator();

        while (operIter.hasNext()) {
            OperationInfo operation = (OperationInfo) operIter.next();

            // Set the namespace URI for the operation.
            operation.setNamespaceURI(namespace);

            // Find the SOAP target URL
            ExtensibilityElement addrElem = findExtensibilityElement(port.getExtensibilityElements(),
                    "address");

            if (addrElem != null && addrElem instanceof SOAPAddress) {
                // Set the SOAP target URL
                SOAPAddress soapAddr = (SOAPAddress) addrElem;
                operation.setTargetURL(soapAddr.getLocationURI());
            }

            // Add the operation info to the component
            component.addOperation(operation);
        }
    }

    return component;
}

From source file:com.evolveum.midpoint.web.page.admin.server.PageTaskAdd.java

private Iterator<String> prepareObjectClassChoiceList(String input) {
    List<String> choices = new ArrayList<>();

    if (model.getObject().getResource() == null) {
        return choices.iterator();
    }/*from   w ww  . ja v a2  s. co m*/

    if (Strings.isEmpty(input)) {
        for (QName q : model.getObject().getObjectClassList()) {
            choices.add(q.getLocalPart());
            Collections.sort(choices);
        }
    } else {
        for (QName q : model.getObject().getObjectClassList()) {
            if (q.getLocalPart().startsWith(input)) {
                choices.add(q.getLocalPart());
            }
            Collections.sort(choices);
        }
    }

    return choices.iterator();
}

From source file:com.evolveum.midpoint.prism.PrismReferenceValue.java

private boolean compareLocalPart(QName a, QName b) {
    if (a == null && b == null) {
        return true;
    }/* w w  w . j  a v  a 2s.  co  m*/
    if (a == null || b == null) {
        return false;
    }
    return a.getLocalPart().equals(b.getLocalPart());
}

From source file:eu.playproject.platform.service.bootstrap.DSBTopicManager.java

@Override
public Subscription subscribe(String producer, QName topic, String subscriber) throws BootstrapFault {
    Subscription subscription = null;/*from  w w w. ja  va 2 s .c om*/

    logger.info("Subscribe to topic '" + topic + "' on producer '" + producer + "' for subscriber '"
            + subscriber + "'");

    HTTPProducerClient client = new HTTPProducerClient(producer);
    try {
        String id = client.subscribe(topic, subscriber);
        logger.info("Subscribed to topic " + topic + " and ID is " + id);

        subscription = new Subscription();
        subscription.setDate(System.currentTimeMillis());
        subscription.setId(id);
        subscription.setProvider(producer);
        subscription.setSubscriber(subscriber);
        Topic t = new Topic();
        t.setName(topic.getLocalPart());
        t.setNs(topic.getNamespaceURI());
        t.setPrefix(topic.getPrefix());
        subscription.setTopic(t);

        this.subscriptionRegistry.addSubscription(subscription);

    } catch (NotificationException e) {
        logger.log(Level.SEVERE, "Problem while subscribing", e);
        throw new BootstrapFault(e);
    } catch (GovernanceExeption e) {
        logger.log(Level.WARNING, "Problem while saving subscription", e);
        //throw new BootstrapFault(e);
    }
    return subscription;
}