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:ddf.security.pep.interceptor.PEPAuthorizingInterceptor.java

/**
 * This method is an implementation of the WSA-M and WSA-W specs for determining the action URI.<br>
 * <ul>//w w w. j a  v a2s . co  m
 * <li>http://www.w3.org/TR/ws-addr-metadata/#actioninwsdl</li>
 * <li>http://www.w3.org/TR/ws-addr-wsdl/#actioninwsdl</li>
 * </ul>
 * Adapted from {@link org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl} and
 * {@link org.apache.cxf.ws.addressing.impl.InternalContextUtils}
 *
 * @param message
 * @return
 */
private String getActionUri(Message message) {
    String actionURI = null;

    /**
     * See if the action is explicitly defined in the WSDL message service model. Retrieves one
     * of the Action attribute in the wsdl:input message.
     */
    MessageInfo msgInfo = (MessageInfo) message.get(MessageInfo.class.getName());
    if (msgInfo != null && msgInfo.getExtensionAttributes() != null) {
        // wsaw:Action
        Object attr = msgInfo.getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME);
        // wsam:Action
        if (attr == null) {
            attr = msgInfo.getExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME);
        }
        // support for older usages
        if (attr == null) {
            attr = msgInfo.getExtensionAttributes()
                    .get(new QName(JAXWSAConstants.NS_WSA, Names.WSAW_ACTION_NAME));
        }
        if (attr == null) {
            attr = msgInfo.getExtensionAttributes()
                    .get(new QName(Names.WSA_NAMESPACE_WSDL_NAME_OLD, Names.WSAW_ACTION_NAME));
        }
        if (attr instanceof QName) {
            actionURI = ((QName) attr).getLocalPart();
        } else {
            actionURI = attr == null ? null : attr.toString();
        }
    }

    /**
     * See if the action is explicitly defined in the WSDL operation service model. Retrieves
     * the operation soap:soapAction property.
     */
    if (StringUtils.isEmpty(actionURI)) {
        BindingOperationInfo bindingOpInfo = message.getExchange().get(BindingOperationInfo.class);
        SoapOperationInfo soi = bindingOpInfo.getExtensor(SoapOperationInfo.class);
        if (soi == null && bindingOpInfo.isUnwrapped()) {
            soi = bindingOpInfo.getWrappedOperation().getExtensor(SoapOperationInfo.class);
        }
        actionURI = soi == null ? null : soi.getAction();
        actionURI = StringUtils.isEmpty(actionURI) ? null : actionURI;
    }

    /**
     * If the service model doesn't explicitly defines the action, we'll construct the default
     * URI string.
     */
    if (StringUtils.isEmpty(actionURI)) {
        QName op = (QName) message.get(MessageContext.WSDL_OPERATION);
        QName port = (QName) message.get(MessageContext.WSDL_PORT);
        if (op != null && port != null) {
            actionURI = port.getNamespaceURI();
            actionURI = addPath(actionURI, port.getLocalPart());
            actionURI = addPath(actionURI, op.getLocalPart() + "Request");
        }
    }

    return actionURI;
}

From source file:ee.ria.xroad.common.message.SoapMessageTest.java

/**
 * Test that request with are quest suffix is correctly converted to a request.
 * @throws Exception in case of any unexpected errors
 */// w w w  . j a va 2s  . co  m
@Test
public void removeRequestSuffixFromResponse() throws Exception {
    SoapMessageImpl request = createRequest("request-suffix.query");

    SoapMessageImpl response = SoapUtils.toResponse(request);

    QName responseChild = getResponseChild(response);
    assertEquals("testQueryResponse", responseChild.getLocalPart());
}

From source file:com.ibm.soatf.component.soap.builder.SampleXmlUtil.java

private static String formatQName(XmlCursor xmlc, QName qName) {
    XmlCursor parent = xmlc.newCursor();
    parent.toParent();/*from w w w . jav a 2 s. com*/
    String prefix = parent.prefixForNamespace(qName.getNamespaceURI());
    parent.dispose();
    String name;
    if (prefix == null || prefix.length() == 0)
        name = qName.getLocalPart();
    else
        name = prefix + ":" + qName.getLocalPart();
    return name;
}

From source file:mp.platform.cyclone.webservices.AuthInterceptor.java

/**
 * Resolve the possible operations for the current request
 *///from  www  .  j  a v  a  2 s.  co  m
private ServiceOperation[] resolveOperations(final SoapMessage message) {
    final MessageInfo messageInfo = message.get(MessageInfo.class);
    final OperationInfo operation = messageInfo.getOperation();
    final QName operationQName = operation.getName();
    // Try to find the operations in the cache
    ServiceOperation[] operations = cachedOperations.get(operationQName);
    if (operations == null) {
        // Cache miss... find the interface method
        final String operationName = operationQName.getLocalPart();
        final String serviceName = operation.getInterface().getService().getName().getLocalPart();
        final Class<?> serviceInterface = CyclosWebServicesClientFactory.serviceInterfaceForName(serviceName);
        for (final Method m : serviceInterface.getMethods()) {
            if (m.getName().equals(operationName)) {
                final Permission permission = m.getAnnotation(Permission.class);
                operations = permission == null ? new ServiceOperation[0] : permission.value();
                break;
            }
        }
        // Store the operations on the cache for further access
        cachedOperations.put(operationQName, operations);
    }
    return operations;
}

From source file:com.catify.processengine.core.nodes.eventdefinition.EventDefinitionFactory.java

/**
 * Creates a new {@link LinkEventDefinition}.
 * //from  ww w.j  a  v  a2s  . co m
 * @param params
 * @param link
 * @return
 */
private EventDefinition createLinkEventDefinition(EventDefinitionParameter params, TLinkEventDefinition link) {
    ActorRef actorRef = new ActorReferenceService().getActorReference(params.getUniqueFlowNodeId());

    if (params.flowNodeJaxb instanceof TThrowEvent) {
        /*
         * if it is a throwing event we need the 
         * target (where to go). 
         */
        String target = "";
        if (link.getTarget() != null) {
            target = link.getTarget().getLocalPart();
        } else {
            LOG.warn(String.format("The throwing signal event '%s' has no target element. This will not work.",
                    params.getUniqueFlowNodeId()));
        }

        return new LinkEventDefinition(target, params.getUniqueProcessId(), actorRef);
    } else {
        /*
         * if it is a catching event we need the 
         * sources (where the link comes from)
         */
        List<String> sources = new ArrayList<String>();
        if (link.getSource() != null) {
            List<QName> source = link.getSource();
            for (QName qName : source) {
                sources.add(qName.getLocalPart());
            }
        } else {
            LOG.warn(String.format("The catching signal event '%s' has no source element. This will not work.",
                    params.getUniqueFlowNodeId()));
        }
        return new LinkEventDefinition(sources, params.getUniqueProcessId(), actorRef);
    }

}

From source file:edu.jhu.hlt.concrete.ingesters.bolt.BoltForumPostIngester.java

/**
 * Moves the rdr "iterator" past any img tags or quote tags.
 *
 * @param rdr/*w w  w.j  a  v  a 2 s. c  om*/
 * @throws XMLStreamException
 */
private int handleNonPostStartElement(final XMLEventReader rdr) throws XMLStreamException {
    // Next is a start element. Throw if not.
    StartElement se = rdr.nextEvent().asStartElement();
    QName seqn = se.getName();
    String part = seqn.getLocalPart();

    if (part.equals(QUOTE_LOCAL_NAME)) {
        return this.handleQuote(rdr);
    } else if (part.equals(IMG_LOCAL_NAME)) {
        return this.handleImg(rdr);
    } else if (part.equals(LINK_LOCAL_NAME)) {
        return this.handleLink(rdr);
    } else
        throw new IllegalArgumentException("Unhandled tag: " + part);
}

From source file:com.centeractive.ws.server.matcher.SoapOperationMatcher.java

/**
 * rpc-style -> operation name is always encoded in the request
 *///from   ww  w.  j  av  a 2s.com
private BindingOperation matchElementNameToOperationName(final QName elementName) {
    AggregatingVisitor<BindingOperation> visitor = new AggregatingVisitor<BindingOperation>() {
        @Override
        public void visit(BindingOperation operation) {
            if (operation.getOperation().getName().equals(elementName.getLocalPart())) {
                addResult(operation);
            }
        }
    };
    visitOperation(visitor);
    return visitor.getUniqueResult();
}

From source file:eu.delving.sip.xml.SourceConverter.java

private void handleAttribute(Path path, Attribute attr) {
    Path extended = path.child(Tag.attribute(attr.getName()));
    if (extended.equals(uniqueElementPath)) {
        unique = attr.getValue();//from ww  w  .j  a  v  a 2s .  com
    } else if (path.equals(recordRootPath)) {
        QName a = attr.getName();
        QName attrName = new QName(a.getNamespaceURI(), "_" + a.getLocalPart(), a.getPrefix());
        eventBuffer.add(eventFactory.createStartElement(attrName, null, null));
        eventBuffer.add(eventFactory.createCharacters(attr.getValue()));
        eventBuffer.add(eventFactory.createEndElement(attrName, null));
        eventBuffer.add(eventFactory.createCharacters("\n"));
    }
}

From source file:com.revolsys.record.io.format.xml.XmlProcessor.java

/**
 * <p>/* w  w w  . ja  v  a  2  s .co m*/
 * The process method is used to return an object representation of the
 * current XML element and subtree from the {@link StaxReader}. The
 * method finds the process method in the subclass that has the method name
 * with the prefix "process" followed by the XML element name, have only an
 * {@link StaxReader} parameter and return an Object (any subclass of
 * Object can be returned).
 * </p>
 * <p>
 * For example the process method for the XML element BankAccount would have
 * the following signature.
 * </p>
 *
 * <pre>
 * public BankAccount processBankAccount(StaxReader parser);
 * </pre>
 * <p>
 * For example the process method for the XML element firstName would have the
 * following signature. <b>Note that the part of the method name for the XML
 * element must have the same case as the XML element name.
 * </p>
 *
 * <pre>
 * public String processfirstName(StaxReader parser);
 * </pre>
 *
 * @param parser The STAX XML parser.
 * @return The object representation of the XML subtree.
 * @throws IOException If an I/O exception occurs.
 * @throws XMLStreamException If an exception processing the XML occurs.
 */
@SuppressWarnings("unchecked")
public <T> T process(final StaxReader parser) throws IOException {
    final QName element = parser.getName();

    final String tagName = element.getLocalPart();
    final QName xsiName = parser.getQNameAttribute(XsiConstants.TYPE);
    boolean hasMapping = false;
    Class<?> objectClass = null;
    if (xsiName == null) {
        objectClass = this.tagNameClassMap.get(tagName);
        if (this.tagNameClassMap.containsKey(tagName)) {
            objectClass = this.tagNameClassMap.get(tagName);
            hasMapping = true;
        }
    } else {
        final String xsiLocalName = xsiName.getLocalPart();
        final Converter converter = this.typePathConverterMap.get(xsiName);
        if (converter != null) {
            final String text = parser.getElementText();
            return (T) converter.convert(null, text);
        } else if (this.tagNameClassMap.containsKey(xsiLocalName)) {
            objectClass = this.tagNameClassMap.get(xsiLocalName);
            hasMapping = true;
        } else if (this.tagNameClassMap.containsKey(tagName)) {
            objectClass = this.tagNameClassMap.get(tagName);
            hasMapping = true;
        }
    }
    if (hasMapping) {
        return (T) parseObject(parser, objectClass);
    } else {
        try {
            final Method method = getProcessMethod(element);
            if (method == null) {
                return (T) parser.getElementText();
            } else {
                return (T) method.invoke(this, new Object[] { parser });
            }
        } catch (final IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (final InvocationTargetException e) {
            final Throwable t = e.getTargetException();
            if (t instanceof RuntimeException) {
                throw (RuntimeException) t;
            } else if (t instanceof Error) {
                throw (Error) t;
            } else if (t instanceof IOException) {
                throw (IOException) t;
            } else {
                throw Exceptions.wrap(e);
            }
        }
    }
}

From source file:com.evolveum.midpoint.util.DOMUtil.java

public static void setQNameAttribute(Element element, QName attributeName, QName attributeValue) {
    Document doc = element.getOwnerDocument();
    Attr attr = doc.createAttributeNS(attributeName.getNamespaceURI(), attributeName.getLocalPart());
    String namePrefix = lookupOrCreateNamespaceDeclaration(element, attributeName.getNamespaceURI(),
            attributeName.getPrefix(), element, true);
    attr.setPrefix(namePrefix);/*  w  w  w .  j  a v  a  2 s  . c o  m*/
    setQNameAttribute(element, attr, attributeValue, element);
}