Example usage for javax.xml.namespace QName toString

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

Introduction

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

Prototype

public String toString() 

Source Link

Document

<p><code>String</code> representation of this <code>QName</code>.</p> <p>The commonly accepted way of representing a <code>QName</code> as a <code>String</code> was <a href="http://jclark.com/xml/xmlns.htm">defined</a> by James Clark.

Usage

From source file:org.globus.wsrf.tools.wsdl.WSDLPreprocessor.java

public static Map getResourceProperties(QName resourceProperties, Definition def, Map documentLocations,
        boolean quiet) throws Exception {
    HashMap resourcePropertyElements = new HashMap();

    if (resourceProperties != null) {
        Types types = def.getTypes();
        if (types == null) {
            if (!quiet) {
                log.warn("The " + def.getDocumentBaseURI() + " definition does not have a types section");
            }/* www  . j av  a 2s.  c  o m*/
            return resourcePropertyElements;
        }

        List elementList = types.getExtensibilityElements();
        // assume only on schema element for now
        if (elementList.size() > 1) {
            if (!quiet) {
                System.err.println("WARNING: The types section in " + def.getDocumentBaseURI()
                        + " contains more than one top level element.");
            }
            // maybe throw error
        }
        Element schema = ((UnknownExtensibilityElement) elementList.get(0)).getElement();

        XSModel schemaModel = loadSchema(schema, def);

        XSElementDeclaration resourcePropertiesElement = schemaModel
                .getElementDeclaration(resourceProperties.getLocalPart(), resourceProperties.getNamespaceURI());

        if (resourcePropertiesElement != null) {
            XSComplexTypeDecl type = (XSComplexTypeDecl) resourcePropertiesElement.getTypeDefinition();
            XSParticle particle = type.getParticle();
            XSModelGroup sequence = (XSModelGroup) particle.getTerm();
            XSObjectList objectList = sequence.getParticles();

            for (int i = 0; i < objectList.getLength(); i++) {
                XSParticle part = (XSParticle) objectList.item(i);
                Object term = part.getTerm();
                if (term instanceof XSElementDeclaration) {
                    XSElementDeclaration resourceProperty = (XSElementDeclaration) term;
                    resourcePropertyElements
                            .put(new QName(resourceProperty.getNamespace(), resourceProperty.getName()), part);
                } else {
                    throw new Exception(
                            "Invalid resource properties document " + resourceProperties.toString());
                }
            }
        } else {
            Map imports = def.getImports();
            Iterator importNSIterator = imports.values().iterator();
            while (importNSIterator.hasNext() && resourcePropertyElements.isEmpty()) {
                Vector importVector = (Vector) importNSIterator.next();
                Iterator importIterator = importVector.iterator();
                while (importIterator.hasNext() && resourcePropertyElements.isEmpty()) {
                    Import importDef = (Import) importIterator.next();
                    // process imports
                    resourcePropertyElements.putAll(getResourceProperties(resourceProperties,
                            importDef.getDefinition(), documentLocations, quiet));
                }
            }

            if (resourcePropertyElements.isEmpty()) {
                throw new Exception("Unable to resolve resource properties " + resourceProperties.toString());
            }
        }

        populateLocations(schemaModel, documentLocations, def);
    }
    return resourcePropertyElements;
}

From source file:org.jaggeryjs.hostobjects.ws.WSRequestCallback.java

private void processError(Exception ex) {
    if (ex instanceof AxisFault) {
        AxisFault e = (AxisFault) ex;/*from  www. j av a 2  s.c  om*/
        OMElement detail = e.getDetail();
        if (detail != null) {
            wsrequest.error.jsSet_detail(detail.toString());
        }
        QName faultCode = e.getFaultCode();
        if (faultCode != null) {
            wsrequest.error.jsSet_code(faultCode.toString());
        }
        wsrequest.error.jsSet_reason(e.getReason());
    } else {
        Throwable cause = ex.getCause();
        if (cause != null) {
            wsrequest.error.jsSet_detail(cause.toString());
        }
        wsrequest.error.jsSet_code("No SOAP Body.");
        wsrequest.error.jsSet_reason(ex.getMessage());
    }
    this.wsrequest.readyState = 4;
    if (this.wsrequest.onReadyStateChangeFunction != null) {
        Context cx = RhinoEngine.enterContext(this.wsrequest.context.getFactory());
        this.wsrequest.onReadyStateChangeFunction.call(cx, wsrequest, wsrequest, new Object[0]);
        RhinoEngine.exitContext();
    }
}

From source file:org.jaggeryjs.hostobjects.ws.WSRequestHostObject.java

/**
 * <p/> This method invokes the Web service with the requested payload. </p>
 * <p/>/*from   w  ww .j a  va2s  .  c  om*/
 * <pre>
 *   void send ( [in Document payload | in XMLString payload | in XMLString payload ]);
 * </pre>
 * <p/>
 * See <a href="http://www.wso2.org/wiki/display/mashup/WSRequest+Host+Object">WSRequest host
 * object reference</a> & <a href="http://www.wso2.org/wiki/display/wsfajax/wsrequest_specification">WSRequest
 * specification</a> for more details.
 */
public static void jsFunction_send(Context cx, Scriptable thisObj, Object[] arguments, Function funObj)
        throws ScriptException, AxisFault {
    WSRequestHostObject wsRequest = (WSRequestHostObject) thisObj;
    Object payload;
    QName operationName = ServiceClient.ANON_OUT_IN_OP;
    if (wsRequest.wsdlMode && arguments.length != 2) {
        throw new ScriptException("When the openWSDL method of WSRequest is used the send "
                + "function should be called with 2 parameters. The operation to invoke and " + "the payload");
    }
    if (arguments.length == 1) {
        payload = arguments[0];
    } else if (arguments.length == 2) {
        if (arguments[0] instanceof QName) {
            QName qName = (QName) arguments[0];
            String uri = qName.getNamespaceURI();
            String localName = qName.getLocalPart();
            operationName = new QName(uri, localName);
        } else if (arguments[0] instanceof String) {
            if (wsRequest.targetNamespace == null) {
                throw new ScriptException("The targetNamespace of the service is null, please specify a "
                        + "QName for the operation name");
            }
            String localName = (String) arguments[0];
            operationName = new QName(wsRequest.targetNamespace, localName);
        } else {
            throw new ScriptException("Invalid parameter type for the WSRequest.send() method");
        }
        payload = arguments[1];
    } else {
        throw new ScriptException("Invalid no. of parameters for the WSRequest.send() method");
    }

    OMElement payloadElement = null;
    if (wsRequest.readyState != 1) {
        throw new ScriptException("Invalid readyState for the WSRequest Hostobject : " + wsRequest.readyState);
    }
    if (payload instanceof String) {
        try {
            XMLStreamReader parser = XMLInputFactory.newInstance()
                    .createXMLStreamReader(new StringReader((String) payload));
            StAXOMBuilder builder = new StAXOMBuilder(parser);
            payloadElement = builder.getDocumentElement();
        } catch (Exception e) {
            String message = "Invalid input for the payload in WSRequest Hostobject : " + payload;
            log.error(message, e);
            throw new ScriptException(message, e);
        }
    } else if (payload instanceof XMLObject) {
        try {
            OMNode node = AXIOMUtil.stringToOM(payload.toString());
            if (node instanceof OMElement) {
                payloadElement = (OMElement) node;
            } else {
                throw new ScriptException("Invalid input for the payload in WSRequest Hostobject : " + payload);
            }
        } catch (Exception e) {
            String message = "Invalid input for the payload in WSRequest Hostobject : " + payload;
            log.error(message, e);
            throw new ScriptException(message, e);
        }
    }
    // else if (typeof(payload) == "object") {
    // // set DOOMRequired to true
    // DocumentBuilderFactoryImpl.setDOOMRequired(true);
    // try {
    // payload = payload.getFirstChild();
    // } catch(Exception e) {
    // throw new Error("INVALID_INPUT_EXCEPTION");
    // }
    // }
    // else if (payload == undefined) {
    // payload = null;
    // }

    try {
        if (wsRequest.async) { // asynchronous call to send()
            AxisCallback callback = new WSRequestCallback(wsRequest);
            setRampartConfigs(wsRequest, operationName);
            if (wsRequest.wsdlMode) {
                //                    setSSLProperties(wsRequest);
                if (IN_ONLY.equalsIgnoreCase(wsRequest.mep)) {
                    wsRequest.sender.fireAndForget(operationName, payloadElement);
                    wsRequest.readyState = 4;
                } else {
                    wsRequest.sender.sendReceiveNonBlocking(operationName, payloadElement, callback);
                    wsRequest.readyState = 2;
                }
            } else {
                //                    setSSLProperties(wsRequest);
                if (IN_ONLY.equalsIgnoreCase(wsRequest.mep)) {
                    wsRequest.sender.fireAndForget(payloadElement);
                    wsRequest.readyState = 4;
                } else {
                    wsRequest.sender.sendReceiveNonBlocking(payloadElement, callback);
                    wsRequest.readyState = 2;
                }
            }
        } else { // synchronous call to send()
            wsRequest.readyState = 2;
            // TODO do we need to call onreadystatechange here too
            setRampartConfigs(wsRequest, operationName);
            if (wsRequest.wsdlMode) {
                //                    setSSLProperties(wsRequest);
                if (IN_ONLY.equalsIgnoreCase(wsRequest.mep)) {
                    wsRequest.sender.fireAndForget(operationName, payloadElement);
                } else {
                    wsRequest.updateResponse(wsRequest.sender.sendReceive(operationName, payloadElement));
                }
                wsRequest.readyState = 4;
            } else {
                //                    setSSLProperties(wsRequest);
                if (IN_ONLY.equalsIgnoreCase(wsRequest.mep)) {
                    wsRequest.sender.fireAndForget(payloadElement);
                } else {
                    wsRequest.updateResponse(wsRequest.sender.sendReceive(operationName, payloadElement));
                    wsRequest.transportHeaders = (CommonsTransportHeaders) wsRequest.sender
                            .getLastOperationContext().getMessageContext("In")
                            .getProperty(MessageContext.TRANSPORT_HEADERS);

                }

                wsRequest.readyState = 4;
            }
        }
        // Calling onreadystatechange function
        if (wsRequest.onReadyStateChangeFunction != null) {
            wsRequest.onReadyStateChangeFunction.call(cx, wsRequest, wsRequest, new Object[0]);
        }
    } catch (AxisFault e) {
        wsRequest.error = new WebServiceErrorHostObject();
        OMElement detail = e.getDetail();
        if (detail != null) {
            wsRequest.error.jsSet_detail(detail.toString());
        }
        QName faultCode = e.getFaultCode();
        if (faultCode != null) {
            wsRequest.error.jsSet_code(faultCode.toString());
        }
        wsRequest.error.jsSet_reason(e.getReason());
        String message = "Error occured while invoking the service";
        log.error(message, e);
        throw new ScriptException(message, e);
    } catch (Exception e) {
        wsRequest.error = new WebServiceErrorHostObject();
        wsRequest.error.jsSet_detail(e.getMessage());
        String message = "Error occured while invoking the service";
        log.error(message, e);
        throw new ScriptException(message, e);
    } finally {
        wsRequest.sender.cleanupTransport();
    }
}

From source file:org.jaggeryjs.modules.ws.WSRequestHostObject.java

/**
 * <p/> This method invokes the Web service with the requested payload. </p>
 * <p/>//from   w ww .ja  v  a  2 s  .co m
 * <pre>
 *   void send ( [in Document payload | in XMLString payload | in XMLString payload ]);
 * </pre>
 * <p/>
 * See <a href="http://www.wso2.org/wiki/display/mashup/WSRequest+Host+Object">WSRequest host
 * object reference</a> & <a href="http://www.wso2.org/wiki/display/wsfajax/wsrequest_specification">WSRequest
 * specification</a> for more details.
 */
public static void jsFunction_send(Context cx, Scriptable thisObj, Object[] arguments, Function funObj)
        throws ScriptException, AxisFault {
    WSRequestHostObject wsRequest = (WSRequestHostObject) thisObj;
    Object payload;
    QName operationName = ServiceClient.ANON_OUT_IN_OP;
    if (wsRequest.wsdlMode && arguments.length != 2) {
        throw new ScriptException("When the openWSDL method of WSRequest is used the send "
                + "function should be called with 2 parameters. The operation to invoke and " + "the payload");
    }
    if (arguments.length == 1) {
        payload = arguments[0];
    } else if (arguments.length == 2) {
        if (arguments[0] instanceof QName) {
            QName qName = (QName) arguments[0];
            String uri = qName.getNamespaceURI();
            String localName = qName.getLocalPart();
            operationName = new QName(uri, localName);
        } else if (arguments[0] instanceof String) {
            if (wsRequest.targetNamespace == null) {
                throw new ScriptException("The targetNamespace of the service is null, please specify a "
                        + "QName for the operation name");
            }
            String localName = (String) arguments[0];
            operationName = new QName(wsRequest.targetNamespace, localName);
        } else {
            throw new ScriptException("Invalid parameter type for the WSRequest.send() method");
        }
        payload = arguments[1];
    } else {
        throw new ScriptException("Invalid no. of parameters for the WSRequest.send() method");
    }

    OMElement payloadElement = null;
    if (wsRequest.readyState != 1) {
        throw new ScriptException("Invalid readyState for the WSRequest Hostobject : " + wsRequest.readyState);
    }
    if (payload instanceof String) {
        try {
            XMLStreamReader parser = XMLInputFactory.newInstance()
                    .createXMLStreamReader(new StringReader((String) payload));
            StAXOMBuilder builder = new StAXOMBuilder(parser);
            payloadElement = builder.getDocumentElement();
        } catch (Exception e) {
            String message = "Invalid input for the payload in WSRequest Hostobject : " + payload;
            log.error(message, e);
            throw new ScriptException(message, e);
        }
    } else if (payload instanceof XMLObject) {
        try {
            OMNode node = AXIOMUtil.stringToOM(payload.toString());
            if (node instanceof OMElement) {
                payloadElement = (OMElement) node;
            } else {
                throw new ScriptException("Invalid input for the payload in WSRequest Hostobject : " + payload);
            }
        } catch (Exception e) {
            String message = "Invalid input for the payload in WSRequest Hostobject : " + payload;
            log.error(message, e);
            throw new ScriptException(message, e);
        }
    }
    // else if (typeof(payload) == "object") {
    // // set DOOMRequired to true
    // DocumentBuilderFactoryImpl.setDOOMRequired(true);
    // try {
    // payload = payload.getFirstChild();
    // } catch(Exception e) {
    // throw new Error("INVALID_INPUT_EXCEPTION");
    // }
    // }
    // else if (payload == undefined) {
    // payload = null;
    // }

    try {
        if (wsRequest.async) { // asynchronous call to send()
            AxisCallback callback = new WSRequestCallback(wsRequest);
            setRampartConfigs(wsRequest, operationName);
            if (wsRequest.wsdlMode) {
                //                    setSSLProperties(wsRequest);
                if (IN_ONLY.equalsIgnoreCase(wsRequest.mep)) {
                    if (wsRequest.robust) {
                        wsRequest.sender.sendRobust(operationName, payloadElement);
                    } else {
                        wsRequest.sender.fireAndForget(operationName, payloadElement);
                    }
                    wsRequest.readyState = 4;
                } else {
                    wsRequest.sender.sendReceiveNonBlocking(operationName, payloadElement, callback);
                    wsRequest.readyState = 2;
                }
            } else {
                //                    setSSLProperties(wsRequest);
                if (IN_ONLY.equalsIgnoreCase(wsRequest.mep)) {
                    if (wsRequest.robust) {
                        wsRequest.sender.sendRobust(payloadElement);
                    } else {
                        wsRequest.sender.fireAndForget(payloadElement);
                    }
                    wsRequest.readyState = 4;
                } else {
                    wsRequest.sender.sendReceiveNonBlocking(payloadElement, callback);
                    wsRequest.readyState = 2;
                }
            }
        } else { // synchronous call to send()
            wsRequest.readyState = 2;
            // TODO do we need to call onreadystatechange here too
            setRampartConfigs(wsRequest, operationName);
            if (wsRequest.wsdlMode) {
                //                    setSSLProperties(wsRequest);
                if (IN_ONLY.equalsIgnoreCase(wsRequest.mep)) {
                    if (wsRequest.robust) {
                        wsRequest.sender.sendRobust(operationName, payloadElement);
                    } else {
                        wsRequest.sender.fireAndForget(operationName, payloadElement);
                    }
                } else {
                    wsRequest.updateResponse(wsRequest.sender.sendReceive(operationName, payloadElement));
                }
                wsRequest.readyState = 4;
            } else {
                //                    setSSLProperties(wsRequest);
                if (IN_ONLY.equalsIgnoreCase(wsRequest.mep)) {
                    if (wsRequest.robust) {
                        wsRequest.sender.sendRobust(payloadElement);
                    } else {
                        wsRequest.sender.fireAndForget(payloadElement);
                    }
                } else {
                    wsRequest.updateResponse(wsRequest.sender.sendReceive(operationName, payloadElement));
                    wsRequest.transportHeaders = (CommonsTransportHeaders) wsRequest.sender
                            .getLastOperationContext().getMessageContext("In")
                            .getProperty(MessageContext.TRANSPORT_HEADERS);

                }

                wsRequest.readyState = 4;
            }
        }
        // Calling onreadystatechange function
        if (wsRequest.onReadyStateChangeFunction != null) {
            wsRequest.onReadyStateChangeFunction.call(cx, wsRequest, wsRequest, new Object[0]);
        }
    } catch (AxisFault e) {
        wsRequest.error = new WebServiceErrorHostObject();
        OMElement detail = e.getDetail();
        if (detail != null) {
            wsRequest.error.jsSet_detail(detail.toString());
        }
        QName faultCode = e.getFaultCode();
        if (faultCode != null) {
            wsRequest.error.jsSet_code(faultCode.toString());
        }
        wsRequest.error.jsSet_reason(e.getReason());
        throw new ScriptException(e.getMessage(), e);
    } catch (Exception e) {
        wsRequest.error = new WebServiceErrorHostObject();
        wsRequest.error.jsSet_detail(e.getMessage());
        throw new ScriptException(e.getMessage(), e);
    } finally {
        wsRequest.sender.cleanupTransport();
    }
}

From source file:org.kalypso.ui.catalogs.FeatureTypePropertiesCatalog.java

public synchronized Properties getProperties2(final URL context, final QName qname) {
    /* Try to get cached properties */
    final String contextStr = context == null ? "null" : context.toExternalForm(); //$NON-NLS-1$
    final String qnameStr = qname == null ? "null" : qname.toString(); //$NON-NLS-1$
    final String cacheKey = contextStr + '#' + qnameStr;

    if (m_propertiesCache.containsKey(cacheKey))
        return m_propertiesCache.get(cacheKey);

    final Properties properties = new Properties();
    /* Allways add properties, so this lookup takes only place once (not finding anything is very expensive) */
    m_propertiesCache.put(cacheKey, properties);

    final URL url = FeatureTypeCatalog.getURL(BASETYPE, context, qname);
    if (url == null)
        return properties;

    try (InputStream is = url.openStream()) {
        properties.load(is);//from   w  ww. j a v  a2  s. co m
        is.close();
    } catch (final IOException e) {
        final IStatus status = StatusUtilities.statusFromThrowable(e);
        KalypsoCorePlugin.getDefault().getLog().log(status);
    }

    return properties;
}

From source file:org.kalypso.ui.rrm.internal.utils.featureBinding.FeatureBean.java

public void setProperty(final QName property, final Object value) {
    final Object oldValue = getProperty(property);

    m_properties.put(property, value);//from  w  w w .j a va2 s  . co  m

    if (m_feature != null) {
        final Object oldFeatureValue = m_feature.getProperty(property);
        if (!ObjectUtils.equals(value, oldFeatureValue))
            m_dirtyProperties.add(property);
    }

    doFirePropertyChanged(property.toString(), oldValue, value);
}

From source file:org.kuali.rice.core.framework.resourceloader.SpringResourceLoader.java

@Override
public Object getService(QName serviceName) {
    if (!isStarted()) {
        return null;
    }/*from  ww w . ja v  a 2s. co m*/
    if (this.getContext().containsBean(serviceName.toString())) {
        Object service = this.getContext().getBean(serviceName.toString());
        return postProcessService(serviceName, service);
    }
    return super.getService(serviceName);
}

From source file:org.kuali.rice.ksb.impl.registry.ServiceRegistryImpl.java

@Override
public List<ServiceInfo> getOnlineServicesByName(QName serviceName) throws RiceIllegalArgumentException {
    if (serviceName == null) {
        throw new RiceIllegalArgumentException("serviceName cannot be null");
    }//w  w w . ja  v  a  2s  . c o  m

    QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
    builder.setPredicates(equal("serviceName", serviceName.toString()),
            equal("statusCode", ServiceEndpointStatus.ONLINE.getCode()));
    List<ServiceInfoBo> serviceInfoBos = getDataObjectService()
            .findMatching(ServiceInfoBo.class, builder.build()).getResults();
    return convertServiceInfoBoList(serviceInfoBos);
}

From source file:org.kuali.rice.ksb.messaging.bam.service.impl.BAMServiceImpl.java

public List<BAMTargetEntry> getCallsForService(QName serviceName, String methodName) {
    QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
    List<Predicate> predicates = new ArrayList<Predicate>();
    predicates.add(equal("serviceName", serviceName.toString()));
    if (StringUtils.isNotBlank(methodName)) {
        predicates.add(equal("methodName", methodName));
    }/*from   ww  w  .j  a va  2  s  .c om*/
    builder.setPredicates(predicates.toArray(new Predicate[predicates.size()]));
    return dataObjectService.findMatching(BAMTargetEntry.class, builder.build()).getResults();
}

From source file:org.kuali.rice.ksb.messaging.bam.service.impl.BAMServiceImpl.java

public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef, String methodName) {
    QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
    List<Predicate> predicates = new ArrayList<Predicate>();
    QName qname = new QName(objDef.getApplicationId(), objDef.getClassName());
    predicates.add(like("serviceName", qname.toString() + "*"));
    if (StringUtils.isNotBlank(methodName)) {
        predicates.add(equal("methodName", methodName));
    }/*from   w  w w.  ja v  a2  s .  c o  m*/
    builder.setPredicates(predicates.toArray(new Predicate[predicates.size()]));
    return dataObjectService.findMatching(BAMTargetEntry.class, builder.build()).getResults();
}