Example usage for javax.xml.namespace QName getPrefix

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

Introduction

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

Prototype

public String getPrefix() 

Source Link

Document

Get the prefix of this QName.

The prefix assigned to a QName might NOT be valid in a different context.

Usage

From source file:org.wso2.appserver.webapp.security.utils.SSOUtils.java

/**
 * Builds a SAML 2.0 based XML object using the fully qualified name.
 *
 * @param objectQualifiedName fully qualified name
 * @return a SAML 2.0 based XML object/* ww w. j a v  a2s.co  m*/
 * @throws SSOException if an error occurs while retrieving the builder for the fully qualified name
 */
private static XMLObject buildXMLObject(QName objectQualifiedName) throws SSOException {
    XMLObjectBuilder builder = XMLObjectProviderRegistrySupport.getBuilderFactory()
            .getBuilder(objectQualifiedName);
    if (builder == null) {
        throw new SSOException("Unable to retrieve builder for object QName " + objectQualifiedName);
    }
    return builder.buildObject(objectQualifiedName.getNamespaceURI(), objectQualifiedName.getLocalPart(),
            objectQualifiedName.getPrefix());
}

From source file:org.wso2.carbon.cep.core.mapping.output.mapping.ElementOutputMapping.java

private static OMElement toOM(Object object, QName parentQname) {

    OMElement omElement = null;//w w w  .  jav a2  s  .  com
    if (SimpleTypeMapper.isSimpleType(object)) {
        OMFactory omFactory = OMAbstractFactory.getOMFactory();
        OMNamespace omNamespace = omFactory.createOMNamespace(parentQname.getNamespaceURI(),
                parentQname.getPrefix());
        omElement = omFactory.createOMElement(parentQname.getLocalPart(), omNamespace);
        omElement.addChild(omFactory.createOMText(SimpleTypeMapper.getStringValue(object)));
    } else {
        XMLStreamReader xmlStreamReader = BeanUtil.getPullParser(object, parentQname, null, true, false);
        StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(new StreamWrapper(xmlStreamReader));
        omElement = stAXOMBuilder.getDocumentElement();
    }
    return omElement;
}

From source file:org.wso2.carbon.cep.core.mapping.output.mapping.ElementOutputMapping.java

private static OMAttribute toOMAttribute(Object object, QName parentQname) {
    OMAttribute omAttribute = null;//from   w  w w .ja  v a  2 s .c  o m
    if (SimpleTypeMapper.isSimpleType(object)) {
        OMFactory omFactory = OMAbstractFactory.getOMFactory();
        OMNamespace omNamespace = omFactory.createOMNamespace(parentQname.getNamespaceURI(),
                parentQname.getPrefix());
        omAttribute = omFactory.createOMAttribute(parentQname.getLocalPart(), omNamespace,
                SimpleTypeMapper.getStringValue(object));
    }
    return omAttribute;
}

From source file:org.wso2.carbon.discovery.DiscoveryOMUtils.java

private static OMElement serializeQNamesList(QName[] qnames, QName topElement, OMFactory factory) {

    OMElement wrapperElement = factory.createOMElement(topElement);
    StringBuffer qnamesTxt = new StringBuffer();
    boolean firstEntry = true;
    for (QName qname : qnames) {
        if (!firstEntry) {
            qnamesTxt.append(" ");
        }//ww w .  j av a  2s  . com

        OMNamespace ns = wrapperElement.declareNamespace(qname.getNamespaceURI(), qname.getPrefix());
        qnamesTxt.append(ns.getPrefix() + ":" + qname.getLocalPart());
        firstEntry = false;
    }
    wrapperElement.setText(qnamesTxt.toString());
    return wrapperElement;
}

From source file:org.wso2.carbon.forum.registry.RegistryForumManager.java

private static GenericArtifact createTopicArtifactContent(GenericArtifact artifact, ForumTopicDTO forumTopicDTO)
        throws ForumException {

    try {/*w  ww  . jav  a 2s  .  com*/
        QName qName = artifact.getQName();
        artifact.setQName(new QName(qName.getNamespaceURI(), forumTopicDTO.getSubject(), qName.getPrefix()));
        artifact.setAttribute(ForumConstants.OVERVIEW_TOPIC_ID, artifact.getId());
        artifact.setAttribute(ForumConstants.OVERVIEW_SUBJECT, forumTopicDTO.getSubject());
        artifact.setAttribute(ForumConstants.OVERVIEW_TOPIC_OWNER_TENANT_DOMAIN,
                forumTopicDTO.getTopicOwnerTenantDomain());
        artifact.setAttribute(ForumConstants.OVERVIEW_TOPIC_OWNER, forumTopicDTO.getTopicOwner());

        String location = forumTopicDTO.getTopicResourceIdentifier();

        if (location == null) {
            log.error("Resource Identifier not set. Please provide a value for the Resource Identifier");
            throw new ForumException(
                    "Resource Identifier not set. Please provide a value for the Resource Identifier");
        }
        location = location.replaceAll("@", "-AT-");
        artifact.setAttribute(ForumConstants.OVERVIEW_RESOURCE_IDENTIFIER, location);
        DateFormat df = new SimpleDateFormat(ForumConstants.FORUM_DATE_FORMAT);
        artifact.setAttribute(ForumConstants.OVERVIEW_CREATED_DATE, df.format(forumTopicDTO.getCreatedDate()));

        Calendar calendar = new GregorianCalendar();
        calendar.setTimeInMillis(forumTopicDTO.getTimestamp());
        df = new SimpleDateFormat(ForumConstants.FORUM_DATE_TIME_FORMAT);
        artifact.setAttribute(ForumConstants.OVERVIEW_TOPIC_TIMESTAMP, df.format(calendar.getTime()));

        return artifact;
    } catch (GovernanceException e) {
        log.error("Could not create Generic Artifact from DTO " + e.getMessage());
        throw new ForumException("Could not create Generic Artifact from DTO", e);
    }
}

From source file:org.wso2.carbon.identity.application.authenticator.samlsso.util.SSOUtils.java

/**
 * Builds SAML Elements/*from  ww  w .  ja  v  a  2s  . co m*/
 *
 * @param objectQName
 * @return
 * @throws SAMLSSOException
 */
private static XMLObject buildXMLObject(QName objectQName) throws SAMLSSOException {
    XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
    if (builder == null) {
        throw new SAMLSSOException("Unable to retrieve builder for object QName " + objectQName);
    }
    return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
            objectQName.getPrefix());
}

From source file:org.wso2.carbon.identity.auth.saml2.common.SAML2AuthUtils.java

public static XMLObject buildXMLObject(QName objectQName) throws IdentityRuntimeException {

    XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
    if (builder == null) {
        throw new IdentityRuntimeException("Unable to retrieve builder for object QName " + objectQName);
    }//  ww  w . ja v a  2s .  com
    return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
            objectQName.getPrefix());
}

From source file:org.wso2.carbon.identity.authenticator.saml2.sso.ui.Util.java

public static XMLObject buildXMLObject(QName objectQName) throws SAML2SSOUIAuthenticatorException {

    XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
    if (builder == null) {
        throw new SAML2SSOUIAuthenticatorException(
                "Unable to retrieve builder for object QName " + objectQName);
    }//w w  w.  ja  v a2s.co  m
    return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
            objectQName.getPrefix());
}

From source file:org.wso2.carbon.identity.entitlement.pep.agent.wsxacml.WSXACMLEntitlementServiceClient.java

/**
 * Create XMLObject from a given QName/*from   w w w .  j  a va 2 s. c  om*/
 *
 * @param objectQName: QName of the object to be built into a XMLObject
 * @return built xmlObject
 * @throws EntitlementAgentException
 */
private XMLObject buildXMLObject(QName objectQName) throws EntitlementAgentException {
    XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
    if (builder == null) {
        throw new EntitlementAgentException("Unable to retrieve builder for object QName " + objectQName);
    }
    return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
            objectQName.getPrefix());
}

From source file:org.wso2.carbon.identity.entitlement.proxy.wsxacml.WSXACMLEntitlementServiceClient.java

/**
 * Create XMLObject from a given QName/*from   w w  w.j a  v a 2s .com*/
 *
 * @param objectQName: QName of the object to be built into a XMLObject
 * @return built xmlObject
 * @throws EntitlementProxyException
 */
private XMLObject buildXMLObject(QName objectQName) throws EntitlementProxyException {

    XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
    if (builder == null) {
        throw new EntitlementProxyException("Unable to retrieve builder for object QName " + objectQName);
    }
    return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
            objectQName.getPrefix());
}