Bug 3010: Improve restconf error clarity. 48/19448/1
authorEvan Zeller <evanrzeller@gmail.com>
Thu, 30 Apr 2015 21:59:25 +0000 (14:59 -0700)
committerTom Pantelis <tpanteli@brocade.com>
Fri, 1 May 2015 20:03:46 +0000 (20:03 +0000)
Change-Id: Ib54e96f1a70a187d940f843ed624f4a0f3c4ead0
Signed-off-by: Evan Zeller <evanrzeller@gmail.com>
(cherry picked from commit b504aaac922e244a24f708f82342e4ce14b29532)

opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonNormalizedNodeBodyReader.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/XmlNormalizedNodeBodyReader.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java

index 4d8463adae66cb1e53ba06b2014b0bc8702fc4b4..3be247a3bbdc71a911570d431dc679c86e1222d4 100644 (file)
@@ -104,6 +104,8 @@ public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPr
                 result = partialResult;
             }
             return new NormalizedNodeContext(path,result);
+        } catch (final RestconfDocumentedException e) {
+            throw e;
         } catch (final Exception e) {
             LOG.debug("Error parsing json input", e);
 
index 74a9bd2d313618be1b090e49c472bd7894457c50..2a9c5bf190cbed62c4756940942436ac8f88682e 100644 (file)
@@ -104,6 +104,8 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
 
             final NormalizedNode<?, ?> result = parse(path,doc);
             return new NormalizedNodeContext(path,result);
+        } catch (final RestconfDocumentedException e){
+            throw e;
         } catch (final Exception e) {
             LOG.debug("Error parsing xml input", e);
 
index 2da58a38203de35102e0cc5e7e667ec83adedeec..6cc62e859c9bade70e4125d2fea72a8addc6f875 100644 (file)
@@ -153,6 +153,11 @@ public class ControllerContext implements SchemaContextListener {
 
         final InstanceIdentifierBuilder builder = YangInstanceIdentifier.builder();
         final Module latestModule = globalSchema.findModuleByName(startModule, null);
+
+        if (latestModule == null) {
+            throw new RestconfDocumentedException("The module named '" + startModule + "' does not exist.", ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
+        }
+
         final InstanceIdentifierContext<?> iiWithSchemaNode = collectPathArguments(builder, pathArgs, latestModule, null,
                 toMountPointIdentifier);