Fix typo in Exception class name
- ModelConvertorException -> ModelConverterException
Change-Id: I065311a004543e2436bc218cb8c8a6478023e488
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DataTreeBuilderHelper.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DataTreeBuilderHelper.java
index 18c7e86..8f7a11b 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DataTreeBuilderHelper.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DataTreeBuilderHelper.java
@@ -427,9 +427,9 @@
obj = getAttributeOfObject(
parentNodeInfo.getYangObject(), name);
} catch (NoSuchMethodException e) {
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"Not processable case node with augment in " +
- "data tree");
+ "data tree", e);
}
parentNodeInfo = new DataTreeNodeInfo();
parentNodeInfo.setYangObject(obj);
@@ -460,7 +460,7 @@
nodeObj = processAugmentNode(curNode, parentNodeInfo);
break;
default:
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"Non processable schema node has arrived for adding " +
"it in data tree");
}
@@ -631,9 +631,9 @@
return getAttributeOfObject(
parentNodeInfo.getYangObject(), name);
} catch (NoSuchMethodException e) {
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"Not processable case node with augment in " +
- "data tree");
+ "data tree", e);
}
}
@@ -658,7 +658,7 @@
return childObj;
}
} catch (ClassNotFoundException | NoSuchMethodException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
return null;
}
@@ -702,7 +702,7 @@
try {
return getAttributeOfObject(parentObj, nodeJavaName);
} catch (NoSuchMethodException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
}
@@ -764,7 +764,7 @@
leafType = getAttributeOfObject(parentObj,
getJavaName(yangLeaf));
} catch (NoSuchMethodException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
Object obj = getLeafObject(yangNode, yangLeaf, parentObj,
leafType, false);
@@ -829,7 +829,7 @@
obj = (List<Object>) getAttributeOfObject(parentObj,
getJavaName(leafList));
} catch (NoSuchMethodException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
if (obj != null) {
Set<Object> objects = getLeafListObject(yangNode, leafList,
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilder.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilder.java
index 59aac5a..7953ee5 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilder.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilder.java
@@ -126,7 +126,7 @@
}
if (converter.isMoIdWithLeaf() && nonEmpty(modelObjects)) {
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"invalid module object data when model object identifier" +
" contains leaf node, no object should be added to" +
" model object list." + modelData);
@@ -155,7 +155,7 @@
processDataNodeConversion((YangNode) curNode, helper,
rscData, modObj);
} else {
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"failed to convert model object in data node" +
modObj);
}
@@ -200,7 +200,7 @@
}
break;
default:
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"Non processable schema node has arrived for adding " +
"it in data tree");
}
@@ -645,7 +645,7 @@
}
}
} catch (NoSuchMethodException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
}
}
@@ -682,7 +682,7 @@
addDataNode(builder, rscData);
}
} catch (NoSuchMethodException e) {
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"Failed to create data node for leaf "
+ leaf.getName());
}
@@ -864,7 +864,7 @@
}
break;
default:
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"Non processable schema node has arrived for adding " +
"it in data tree");
}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModIdToRscIdConverter.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModIdToRscIdConverter.java
index d68d0c0..43612ee 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModIdToRscIdConverter.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModIdToRscIdConverter.java
@@ -248,11 +248,11 @@
}
}
} else {
- throw new ModelConvertorException("invalid model object id." + id);
+ throw new ModelConverterException("invalid model object id." + id);
}
preNode = curNode;
} catch (Exception e) {
- throw new ModelConvertorException("Encountered an Exception processing " + path, e);
+ throw new ModelConverterException("Encountered an Exception processing " + path, e);
}
}
if (!isMoIdWithLeaf) {
@@ -281,7 +281,7 @@
}
}
if (curNode == null) {
- throw new ModelConvertorException("invalid model object id." + id);
+ throw new ModelConverterException("invalid model object id." + id);
}
isMoIdWithLeaf = true;
if (curNode instanceof YangLeaf) {
@@ -344,7 +344,7 @@
try {
return getAttributeOfObject(keys, getCamelCase(keyName, null));
} catch (NoSuchMethodException e) {
- throw new ModelConvertorException("invalid key value in model id for list" +
+ throw new ModelConverterException("invalid key value in model id for list" +
"." + keys.getClass().getName());
}
}
@@ -471,7 +471,7 @@
}
}
if (leaf == null) {
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"The specified key " + key + " is not present in the " +
"YANG schema node.");
}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConverterException.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConverterException.java
new file mode 100644
index 0000000..1c33a08
--- /dev/null
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConverterException.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.impl;
+
+/**
+ * Represents exception that needs to be handled by model converter.
+ */
+// extending ModelConvertorException for backward compatibility,
+// directly extend RuntimeException when removing Exception class with typo
+@SuppressWarnings("deprecation")
+class ModelConverterException
+ extends ModelConvertorException {
+
+ private static final long serialVersionUID = 4586537426529302237L;
+
+ /**
+ * Creates model converter exception with an exception message.
+ *
+ * @param exceptionMessage message with which exception must be thrown
+ */
+ ModelConverterException(String exceptionMessage) {
+ super(exceptionMessage);
+ }
+
+ /**
+ * Creates model converter exception with an exception message and cause.
+ *
+ * @param exceptionMessage message with which exception must be thrown
+ * @param cause cause of the exception
+ */
+ ModelConverterException(String exceptionMessage, Throwable cause) {
+ super(exceptionMessage, cause);
+ }
+
+ /**
+ * Creates model converter exception with the cause for it.
+ *
+ * @param cause cause of the exception
+ */
+ ModelConverterException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConverterUtil.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConverterUtil.java
index 4b5906f..2ba6e78 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConverterUtil.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConverterUtil.java
@@ -127,7 +127,7 @@
getterMethod = nodeClass.getDeclaredMethod(fieldName);
return getterMethod.invoke(nodeObj);
} catch (InvocationTargetException | IllegalAccessException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
}
@@ -148,7 +148,7 @@
getterMethod = nodeClass.getDeclaredMethod(fieldName);
return getterMethod.invoke(nodeObj);
} catch (InvocationTargetException | IllegalAccessException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
}
@@ -169,7 +169,7 @@
return getterMethod.invoke(childClass);
} catch (InvocationTargetException | NoSuchMethodException |
IllegalAccessException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
}
@@ -183,7 +183,7 @@
Class<?>[] interfaces = obj.getClass().getInterfaces();
if (interfaces.length > ONE) {
// TODO: Need to handle when impl class has more than one interface.
- throw new ModelConvertorException("Implementation class having more than one" +
+ throw new ModelConverterException("Implementation class having more than one" +
" interface is not handled");
}
return interfaces[0];
@@ -248,7 +248,7 @@
return (boolean) getterMethod.invoke(nodeObj, value);
} catch (IllegalAccessException | InvocationTargetException |
ClassNotFoundException | NoSuchMethodException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
}
@@ -268,7 +268,7 @@
YangType dataType) {
if (fieldObj == null) {
- throw new ModelConvertorException("Value of " + holder.getName()
+ throw new ModelConverterException("Value of " + holder.getName()
+ " is null");
}
@@ -318,7 +318,7 @@
return ((LeafSchemaContext) leaf).fromString(val);
default:
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"Unsupported data type. Cannot be processed.");
}
}
@@ -350,7 +350,7 @@
return String.valueOf(getterMethod.invoke(null, fieldObj));
} catch (ClassNotFoundException | NoSuchMethodException |
InvocationTargetException | IllegalAccessException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
}
@@ -367,7 +367,7 @@
YangIdentity id = getDerivedIdentity(fieldObj, ir);
if (id == null) {
- throw new ModelConvertorException("Value for identity is invalid");
+ throw new ModelConverterException("Value for identity is invalid");
}
String idName = id.getJavaClassNameOrBuiltInType();
String idPkg = id.getJavaPackage() + PERIOD + getCapitalCase(idName);
@@ -382,7 +382,7 @@
return String.valueOf(method.invoke(fieldObj)).trim();
} catch (ClassNotFoundException | NoSuchMethodException |
InvocationTargetException | IllegalAccessException e) {
- throw new ModelConvertorException(e);
+ throw new ModelConverterException(e);
}
}
@@ -522,7 +522,7 @@
return getNameWithOutSpecialChar(
mil.leafIdentifier().toString().toLowerCase());
default:
- throw new ModelConvertorException("leaf/leaf-list can't be at this " +
+ throw new ModelConverterException("leaf/leaf-list can't be at this " +
"position");
}
}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConvertorException.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConvertorException.java
index c5d3eb4..2d15937 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConvertorException.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModelConvertorException.java
@@ -18,7 +18,10 @@
/**
* Represents exception that needs to be handled by model converter.
+ *
+ * @deprecated use {@link ModelConverterException} instead.
*/
+@Deprecated
class ModelConvertorException extends RuntimeException {
/**
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobHandlerFactory.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobHandlerFactory.java
index 60e2920..a3f9a16 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobHandlerFactory.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobHandlerFactory.java
@@ -61,13 +61,13 @@
*
* @param type data node type
* @return handler to create the object
- * @throws ModelConvertorException if the data node type is not supported in YOB
+ * @throws ModelConverterException if the data node type is not supported in YOB
*/
YobHandler getYobHandlerForContext(DataNode.Type type) {
YobHandler yobHandler = HANDLER_MAP.get(type);
if (yobHandler == null) {
log.error(E_DATA_NODE_TYPE_IS_NOT_SUPPORT);
- throw new ModelConvertorException(E_DATA_NODE_TYPE_IS_NOT_SUPPORT);
+ throw new ModelConverterException(E_DATA_NODE_TYPE_IS_NOT_SUPPORT);
}
return yobHandler;
}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafListNodeHandler.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafListNodeHandler.java
index 5d21258..04d2d51 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafListNodeHandler.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafListNodeHandler.java
@@ -110,7 +110,7 @@
} catch (NoSuchMethodException | InvocationTargetException |
IllegalAccessException | NoSuchFieldException e) {
log.error(L_FAIL_TO_INVOKE_METHOD, parentClass.getName());
- throw new ModelConvertorException(E_FAIL_TO_INVOKE_METHOD + parentClass
+ throw new ModelConverterException(E_FAIL_TO_INVOKE_METHOD + parentClass
.getName());
}
}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafNodeHandler.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafNodeHandler.java
index 76e7d40..51eea48 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafNodeHandler.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobLeafNodeHandler.java
@@ -91,7 +91,7 @@
} catch (NoSuchMethodException | InvocationTargetException |
IllegalAccessException | NoSuchFieldException e) {
log.error(L_FAIL_TO_INVOKE_METHOD, parentClass.getName());
- throw new ModelConvertorException(E_FAIL_TO_INVOKE_METHOD + parentClass
+ throw new ModelConverterException(E_FAIL_TO_INVOKE_METHOD + parentClass
.getName());
}
}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
index ca8284a..7185240 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
@@ -385,7 +385,7 @@
}
Class<?> moduleClass = reg.getRegisteredClass(parent);
if (moduleClass == null) {
- throw new ModelConvertorException(E_FAIL_TO_LOAD_CLASS + parent
+ throw new ModelConverterException(E_FAIL_TO_LOAD_CLASS + parent
.getJavaClassNameOrBuiltInType());
}
return moduleClass.getClassLoader();
@@ -487,7 +487,7 @@
derivedId = getDerivedIdentity(leafValue.toString(), identityRef
.getReferredIdentity());
if (derivedId == null) {
- throw new ModelConvertorException(E_INVALID_IDENTITY_DATA +
+ throw new ModelConverterException(E_INVALID_IDENTITY_DATA +
leafValue.toString());
}
qualifiedClassName = derivedId.getJavaPackage() + PERIOD +
@@ -586,7 +586,7 @@
if (intf != null) {
leafId = intf.getName() + ENUM_LEAF_IDENTIFIER;
} else {
- throw new ModelConvertorException(E_FAIL_TO_LOAD_LEAF_IDENTIFIER_CLASS);
+ throw new ModelConverterException(E_FAIL_TO_LOAD_LEAF_IDENTIFIER_CLASS);
}
Class<Enum> leafIdentifier =
@@ -598,7 +598,7 @@
}
}
} catch (ClassNotFoundException e) {
- throw new ModelConvertorException(E_FAIL_TO_LOAD_CLASS);
+ throw new ModelConverterException(E_FAIL_TO_LOAD_CLASS);
}
return null;
}
@@ -614,7 +614,7 @@
try {
return loader.loadClass(name);
} catch (ClassNotFoundException e) {
- throw new ModelConvertorException(E_FAIL_TO_LOAD_CLASS + name);
+ throw new ModelConverterException(E_FAIL_TO_LOAD_CLASS + name);
}
}
@@ -631,14 +631,14 @@
return defaultClass.newInstance();
} catch (ClassNotFoundException e) {
log.error(L_FAIL_TO_LOAD_CLASS, name);
- throw new ModelConvertorException(E_FAIL_TO_LOAD_CLASS + name);
+ throw new ModelConverterException(E_FAIL_TO_LOAD_CLASS + name);
} catch (NullPointerException e) {
log.error(L_REFLECTION_FAIL_TO_CREATE_OBJ, name);
- throw new ModelConvertorException(E_REFLECTION_FAIL_TO_CREATE_OBJ +
+ throw new ModelConverterException(E_REFLECTION_FAIL_TO_CREATE_OBJ +
name);
} catch (InstantiationException | IllegalAccessException e) {
log.error(L_FAIL_TO_CREATE_OBJ, name);
- throw new ModelConvertorException(E_FAIL_TO_CREATE_OBJ + name);
+ throw new ModelConverterException(E_FAIL_TO_CREATE_OBJ + name);
}
}
@@ -737,20 +737,20 @@
midb = midb.addChild(listClass, keyObj);
}
} catch (NoSuchMethodException e) {
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"Failed to load setter method for " +
javaName + " in key class"
+ keyClassName);
} catch (InvocationTargetException e) {
- throw new ModelConvertorException(
+ throw new ModelConverterException(
"Failed to invoke setter method for " +
javaName + " in key class"
+ keyClassName);
} catch (ClassNotFoundException e) {
- throw new ModelConvertorException("Failed to load key class"
+ throw new ModelConverterException("Failed to load key class"
+ keyClassName);
} catch (IllegalAccessException | InstantiationException e) {
- throw new ModelConvertorException("Failed Instantiation of key class"
+ throw new ModelConverterException("Failed Instantiation of key class"
+ keyClassName);
} catch (NoSuchFieldException e) {
e.printStackTrace();
@@ -800,7 +800,7 @@
}
}
} catch (ClassNotFoundException e) {
- throw new ModelConvertorException("Failed to load leaf identifier class." +
+ throw new ModelConverterException("Failed to load leaf identifier class." +
leafName);
}
}
@@ -870,7 +870,7 @@
}
}
} catch (ClassNotFoundException e) {
- throw new ModelConvertorException(E_FAIL_TO_LOAD_LEAF_IDENTIFIER_CLASS);
+ throw new ModelConverterException(E_FAIL_TO_LOAD_LEAF_IDENTIFIER_CLASS);
}
}
return midb;
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobWorkBench.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobWorkBench.java
index e8ae1e5..ddef955 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobWorkBench.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobWorkBench.java
@@ -242,13 +242,13 @@
method.invoke(parentObj, curObj);
} catch (NoSuchFieldException e) {
log.error(L_FAIL_TO_GET_FIELD, parentClassName);
- throw new ModelConvertorException(E_FAIL_TO_GET_FIELD + parentClassName);
+ throw new ModelConverterException(E_FAIL_TO_GET_FIELD + parentClassName);
} catch (NoSuchMethodException e) {
log.error(L_FAIL_TO_GET_METHOD, parentClassName);
- throw new ModelConvertorException(E_FAIL_TO_GET_METHOD + parentClassName);
+ throw new ModelConverterException(E_FAIL_TO_GET_METHOD + parentClassName);
} catch (InvocationTargetException | IllegalAccessException e) {
log.error(L_FAIL_TO_INVOKE_METHOD, parentClassName);
- throw new ModelConvertorException(E_FAIL_TO_INVOKE_METHOD + parentClassName);
+ throw new ModelConverterException(E_FAIL_TO_INVOKE_METHOD + parentClassName);
}
}
@@ -279,9 +279,9 @@
schemaContext = parentSchema.getChildSchema(targetNode);
} catch (DataModelException e) {
- throw new ModelConvertorException(parentSchema.getName() +
+ throw new ModelConverterException(parentSchema.getName() +
E_HAS_NO_CHILD +
- targetNode.getName());
+ targetNode.getName(), e);
}
nonSchemaHolder = schemaContext.getContextSwitchedNode();
@@ -346,9 +346,9 @@
childContext.getContextSwitchedNode());
} catch (DataModelException e) {
- throw new ModelConvertorException(ctxSwitchedNode.getName() +
+ throw new ModelConverterException(ctxSwitchedNode.getName() +
E_HAS_NO_CHILD +
- targetNode.getName());
+ targetNode.getName(), e);
}
} else if (ctxSwitchedNode.getYangSchemaNodeType() ==
YANG_AUGMENT_NODE) {
@@ -376,10 +376,10 @@
method.invoke(builder, instance);
} catch (NoSuchMethodException e) {
log.error(L_FAIL_TO_GET_METHOD, ADD_AUGMENT_METHOD);
- throw new ModelConvertorException(E_FAIL_TO_GET_METHOD + ADD_AUGMENT_METHOD);
+ throw new ModelConverterException(E_FAIL_TO_GET_METHOD + ADD_AUGMENT_METHOD);
} catch (InvocationTargetException | IllegalAccessException e) {
log.error(L_FAIL_TO_INVOKE_METHOD, ADD_AUGMENT_METHOD);
- throw new ModelConvertorException(E_FAIL_TO_INVOKE_METHOD + ADD_AUGMENT_METHOD);
+ throw new ModelConverterException(E_FAIL_TO_INVOKE_METHOD + ADD_AUGMENT_METHOD);
}
}