Search in sources :

Example 71 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project wso2-synapse by wso2.

the class ResourceFactory method configureSequences.

private static void configureSequences(Resource resource, OMElement resourceElt, Properties properties) {
    OMAttribute inSequenceKeyAtt = resourceElt.getAttribute(new QName("inSequence"));
    OMElement inSequenceElt = resourceElt.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "inSequence"));
    if (inSequenceKeyAtt != null && !"".equals(inSequenceKeyAtt.getAttributeValue())) {
        resource.setInSequenceKey(inSequenceKeyAtt.getAttributeValue());
    } else if (inSequenceElt != null) {
        SequenceMediatorFactory fac = new SequenceMediatorFactory();
        SequenceMediator sequence = fac.createAnonymousSequence(inSequenceElt, properties);
        sequence.setSequenceType(SequenceType.API_INSEQ);
        resource.setInSequence(sequence);
    }
    OMAttribute outSequenceKeyAtt = resourceElt.getAttribute(new QName("outSequence"));
    OMElement outSequenceElt = resourceElt.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "outSequence"));
    if (outSequenceKeyAtt != null && !"".equals(outSequenceKeyAtt.getAttributeValue())) {
        resource.setOutSequenceKey(outSequenceKeyAtt.getAttributeValue());
    } else if (outSequenceElt != null) {
        SequenceMediatorFactory fac = new SequenceMediatorFactory();
        SequenceMediator sequence = fac.createAnonymousSequence(outSequenceElt, properties);
        sequence.setSequenceType(SequenceType.API_OUTSEQ);
        resource.setOutSequence(sequence);
    }
    OMAttribute faultSequenceKeyAtt = resourceElt.getAttribute(new QName("faultSequence"));
    OMElement faultSequenceElt = resourceElt.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "faultSequence"));
    if (faultSequenceKeyAtt != null && !"".equals(faultSequenceKeyAtt.getAttributeValue())) {
        resource.setFaultSequenceKey(faultSequenceKeyAtt.getAttributeValue());
    } else if (faultSequenceElt != null) {
        SequenceMediatorFactory fac = new SequenceMediatorFactory();
        SequenceMediator sequence = fac.createAnonymousSequence(faultSequenceElt, properties);
        sequence.setSequenceType(SequenceType.API_FAULTSEQ);
        resource.setFaultSequence(sequence);
    }
}
Also used : SequenceMediatorFactory(org.apache.synapse.config.xml.SequenceMediatorFactory) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 72 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project wso2-synapse by wso2.

the class VersionStrategyFactory method createVersioningStrategy.

public static VersionStrategy createVersioningStrategy(API api, OMElement apiElt) {
    OMAttribute versionAtt = apiElt.getAttribute(new QName("version"));
    if (versionAtt == null || "".equals(versionAtt.getAttributeValue())) {
    // handleException("Attribute 'version' is required for an API definition");
    }
    OMAttribute versionTypeAtt = apiElt.getAttribute(new QName("version-type"));
    if ((versionAtt != null && !versionAtt.getAttributeValue().isEmpty()) && (versionTypeAtt == null || "".equals(versionTypeAtt.getAttributeValue()))) {
        handleException("Attribute 'version-type' is required for an API definition");
    }
    OMAttribute versionParamAtt = apiElt.getAttribute(new QName("version-param"));
    String version = "";
    if (versionAtt != null) {
        version = versionAtt.getAttributeValue();
    }
    String versionType = "";
    if (versionTypeAtt != null) {
        versionType = versionTypeAtt.getAttributeValue();
    }
    String versionParam = "";
    if (versionParamAtt != null) {
        versionParam = versionParamAtt.getAttributeValue();
    }
    return selectVersionStrategy(api, version, versionType, versionParam);
}
Also used : QName(javax.xml.namespace.QName) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 73 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project carbon-business-process by wso2.

the class AnalyticsServerProfileBuilder method processAnalyticsServerProfileName.

/**
 * Reading Analytics Server profile name and Agent type and setting them to given analyticsServerProfile instance.
 *
 * @param analyticsServerConfig  OMElement of analyticsServerConfig
 * @param analyticsServerProfile AnalyticsServerProfile instance
 */
private void processAnalyticsServerProfileName(OMElement analyticsServerConfig, AnalyticsServerProfile analyticsServerProfile) {
    OMAttribute name = analyticsServerConfig.getAttribute(new QName(AnalyticsConstants.NAME));
    if (name != null && name.getAttributeValue() != null && !AnalyticsConstants.EMPTY.equals(name.getAttributeValue().trim())) {
        analyticsServerProfile.setName(name.getAttributeValue().trim());
    } else {
        String errMsg = AnalyticsConstants.NAME + " attribute not found for Analytics server profile: " + profileLocation;
        handleError(errMsg);
    }
    OMAttribute type = analyticsServerConfig.getAttribute(new QName(AnalyticsConstants.TYPE));
    if (type != null && type.getAttributeValue() != null && !AnalyticsConstants.EMPTY.equals(type.getAttributeValue().trim())) {
        analyticsServerProfile.setType(type.getAttributeValue().trim());
    } else {
        // This value can be null or empty. Then default agent will get selected.
        analyticsServerProfile.setType(null);
    }
}
Also used : QName(javax.xml.namespace.QName) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 74 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project carbon-business-process by wso2.

the class AnalyticsServerProfileBuilder method processConnectionElement.

/**
 * Reading Analytics Server profile connections URLs and setting them to given analyticsServerProfile instance.
 *
 * @param analyticsServerConfig  OMElement of analyticsServerConfig
 * @param analyticsServerProfile AnalyticsServerProfile instance
 */
private void processConnectionElement(OMElement analyticsServerConfig, AnalyticsServerProfile analyticsServerProfile) {
    OMElement connectionElement = analyticsServerConfig.getFirstChildWithName(new QName(BPELConstants.ANALYTICS_SERVER_PROFILE_NS, AnalyticsConstants.CONNECTION));
    if (connectionElement != null) {
        OMAttribute receiverURLsSet = connectionElement.getAttribute(new QName(AnalyticsConstants.CONNECTION_RECEIVER_URL_SET));
        OMAttribute authURLsSet = connectionElement.getAttribute(new QName(AnalyticsConstants.CONNECTION_AUTH_URL_SET));
        if (receiverURLsSet != null && receiverURLsSet.getAttributeValue() != null && !AnalyticsConstants.EMPTY.equals(receiverURLsSet.getAttributeValue().trim())) {
            analyticsServerProfile.setReceiverURLSet(receiverURLsSet.getAttributeValue().trim());
        } else {
            String errMsg = "Connection details are missing for Analytics server profile: " + profileLocation;
            handleError(errMsg);
        }
        // AuthURLsSet can be null or empty.
        if (authURLsSet != null && authURLsSet.getAttributeValue() != null && !AnalyticsConstants.EMPTY.equals(authURLsSet.getAttributeValue().trim())) {
            analyticsServerProfile.setAuthURLSet(authURLsSet.getAttributeValue().trim());
        } else {
            analyticsServerProfile.setAuthURLSet(null);
        }
    } else {
        String errMsg = "Connection details not found for Analytics server profile: " + profileLocation;
        handleError(errMsg);
    }
}
Also used : QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 75 with OMAttribute

use of org.apache.axiom.om.OMAttribute in project carbon-business-process by wso2.

the class AnalyticsServerProfileBuilder method processCredentialElement.

/**
 * Reading Analytics Server profile credentials and setting them to given analyticsServerProfile instance.
 *
 * @param analyticsServerConfig  OMElement of analyticsServerConfig
 * @param analyticsServerProfile AnalyticsServerProfile instance
 * @throws CryptoException
 */
private void processCredentialElement(OMElement analyticsServerConfig, AnalyticsServerProfile analyticsServerProfile) throws CryptoException {
    OMElement credentialElement = analyticsServerConfig.getFirstChildWithName(new QName(BPELConstants.ANALYTICS_SERVER_PROFILE_NS, AnalyticsConstants.CREDENTIAL));
    if (credentialElement != null) {
        OMAttribute userNameAttr = credentialElement.getAttribute(new QName(AnalyticsConstants.CREDENTIAL_USER_NAME));
        OMAttribute passwordAttr = credentialElement.getAttribute(new QName(AnalyticsConstants.CREDENTIAL_PASSWORD));
        OMAttribute encryptPasswordAttr = credentialElement.getAttribute(new QName(AnalyticsConstants.CREDENTIAL_ENCRYPT_PASSWORD));
        if (userNameAttr != null && passwordAttr != null && userNameAttr.getAttributeValue() != null && passwordAttr.getAttributeValue() != null && !AnalyticsConstants.EMPTY.equals(userNameAttr.getAttributeValue().trim()) && !AnalyticsConstants.EMPTY.equals(passwordAttr.getAttributeValue().trim())) {
            analyticsServerProfile.setUserName(userNameAttr.getAttributeValue().trim());
            if (encryptPasswordAttr != null && encryptPasswordAttr.getAttributeValue() != null && "TRUE".equals(encryptPasswordAttr.getAttributeValue().trim().toUpperCase())) {
                analyticsServerProfile.setPassword(new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt(passwordAttr.getAttributeValue())));
            } else {
                analyticsServerProfile.setPassword(passwordAttr.getAttributeValue().trim());
            }
        } else {
            String errMsg = AnalyticsConstants.CREDENTIAL_USER_NAME + " or " + AnalyticsConstants.CREDENTIAL_PASSWORD + " not found for Analytics server profile: " + profileLocation;
            handleError(errMsg);
        }
    } else {
        String errMsg = AnalyticsConstants.CREDENTIAL + " element not found for Analytics server profile: " + profileLocation;
        handleError(errMsg);
    }
}
Also used : QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) OMAttribute(org.apache.axiom.om.OMAttribute)

Aggregations

OMAttribute (org.apache.axiom.om.OMAttribute)187 OMElement (org.apache.axiom.om.OMElement)116 QName (javax.xml.namespace.QName)82 Iterator (java.util.Iterator)41 OMFactory (org.apache.axiom.om.OMFactory)31 OMNamespace (org.apache.axiom.om.OMNamespace)28 SynapseException (org.apache.synapse.SynapseException)28 JaxenException (org.jaxen.JaxenException)28 OMNode (org.apache.axiom.om.OMNode)13 Value (org.apache.synapse.mediators.Value)12 SynapseXPath (org.apache.synapse.util.xpath.SynapseXPath)11 ArrayList (java.util.ArrayList)8 Endpoint (org.apache.synapse.endpoints.Endpoint)7 IOException (java.io.IOException)6 List (java.util.List)6 OMText (org.apache.axiom.om.OMText)6 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)6 StringReader (java.io.StringReader)5 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)5 EndpointDefinition (org.apache.synapse.endpoints.EndpointDefinition)5