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);
}
}
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);
}
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);
}
}
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);
}
}
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);
}
}
Aggregations