Source:
private void populateSource(Source source, OMElement sourceEle) { OMAttribute typeAttr = sourceEle.getAttribute(ATT_TYPE); if (typeAttr != null && typeAttr.getAttributeValue() != null) { source.setSourceType(convertTypeToInt(typeAttr.getAttributeValue())); } OMAttribute cloneAttr = sourceEle.getAttribute(ATT_CLONE); if (cloneAttr != null && cloneAttr.getAttributeValue() != null) { source.setClone(Boolean.parseBoolean(cloneAttr.getAttributeValue())); } if (source.getSourceType() == EnrichMediator.CUSTOM) { OMAttribute xpathAttr = sourceEle.getAttribute(ATT_XPATH); if (xpathAttr != null && xpathAttr.getAttributeValue() != null) { try { source.setXpath(SynapseXPathFactory.getSynapseXPath(sourceEle, ATT_XPATH)); } catch (JaxenException e) { handleException("Invalid XPath expression: " + xpathAttr); } } else { handleException("xpath attribute is required for CUSTOM type"); } } else if (source.getSourceType() == EnrichMediator.PROPERTY) { OMAttribute propertyAttr = sourceEle.getAttribute(ATT_PROPERTY); if (propertyAttr != null && propertyAttr.getAttributeValue() != null) { source.setProperty(propertyAttr.getAttributeValue()); } else { handleException("xpath attribute is required for CUSTOM type"); } } else if (source.getSourceType() == EnrichMediator.INLINE) { OMElement inlineElem = null; if (sourceEle.getFirstElement() != null) { inlineElem = sourceEle.getFirstElement().cloneOMElement(); } if (inlineElem != null) { source.setInlineOMNode(inlineElem); } else if (sourceEle.getText() != null && (!sourceEle.getText().equals(""))) { source.setInlineOMNode(OMAbstractFactory.getOMFactory().createOMText(sourceEle.getText())); } else if (sourceEle.getAttributeValue(ATT_KEY) != null) { source.setInlineKey(sourceEle.getAttributeValue(ATT_KEY)); } else { handleException("XML element is required for INLINE type"); } } }

Target:
private void populateSource(Source source, OMElement sourceEle) { OMAttribute typeAttr = sourceEle.getAttribute(ATT_TYPE); if (typeAttr != null && typeAttr.getAttributeValue() != null) { source.setSourceType(convertTypeToInt(typeAttr.getAttributeValue())); } OMAttribute cloneAttr = sourceEle.getAttribute(ATT_CLONE); if (cloneAttr != null && cloneAttr.getAttributeValue() != null) { source.setClone(Boolean.parseBoolean(cloneAttr.getAttributeValue())); } if (source.getSourceType() == EnrichMediator.CUSTOM) { OMAttribute xpathAttr = sourceEle.getAttribute(ATT_XPATH); if (xpathAttr != null && xpathAttr.getAttributeValue() != null) { try { source.setXpath(SynapseXPathFactory.getSynapseXPath(sourceEle, ATT_XPATH)); } catch (JaxenException e) { handleException("Invalid XPath expression: " + xpathAttr); } } else { handleException("xpath attribute is required for CUSTOM type"); } } else if (source.getSourceType() == EnrichMediator.PROPERTY) { OMAttribute propertyAttr = sourceEle.getAttribute(ATT_PROPERTY); if (propertyAttr != null && propertyAttr.getAttributeValue() != null) { source.setProperty(propertyAttr.getAttributeValue()); } else { handleException("xpath attribute is required for CUSTOM type"); } } else if (source.getSourceType() == EnrichMediator.INLINE) { OMElement inlineElem = null; if (sourceEle.getFirstElement() != null) { inlineElem = sourceEle.getFirstElement().cloneOMElement(); } if (inlineElem != null) { source.setInlineOMNode(inlineElem); } else if (!StringUtils.isBlank(sourceEle.getText())) { source.setInlineOMNode(OMAbstractFactory.getOMFactory().createOMText(sourceEle.getText())); } else if (sourceEle.getAttributeValue(ATT_KEY) != null) { source.setInlineKey(sourceEle.getAttributeValue(ATT_KEY)); } else { handleException("XML element is required for INLINE type"); } } }