package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
import org.dom4j.Element;
+import org.dom4j.Namespace;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import java.util.List;
+
import static java.lang.String.format;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.NODE_TYPE_ERR;
break;
case OBJECT_NODE:
+ List cont = element.content();
+ if (cont != null && cont.size() == 2 &&
+ isValueNsForLeaf(cont, element)) {
+ return;
+ }
serializerHelper.addNode(element.getName(),
element.getNamespace().getURI(),
null, null, null);
}
}
+ /**
+ * Returns true if element has value namespace and adds the node to
+ * property tree; false otherwise.
+ *
+ * @param cont content of the element
+ * @param element element
+ * @return true if element has value namespace; false otherwise
+ * @throws SvcLogicException
+ */
+ private boolean isValueNsForLeaf(List cont, Element element)
+ throws SvcLogicException {
+ for (Object c : cont) {
+ if (c instanceof Namespace) {
+ String value = element.getText();
+ if (value != null) {
+ String[] val = value.split(":");
+ String valPrefix = val[0];
+ String actVal = val[1];
+ if (valPrefix != null && actVal != null &&
+ valPrefix.equals(((Namespace) c).getPrefix())) {
+ serializerHelper.addNode(
+ element.getName(),
+ element.getNamespace().getURI(),
+ actVal,
+ ((Namespace) c).getURI(), null);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
@Override
public void exitXmlElement(Element element) throws SvcLogicException {
serializerHelper.exitNode();