Merge "BUG 3015 - restconf: Un-helpful error message presented when no service provid...
authorMaros Marsalek <mmarsale@cisco.com>
Tue, 5 Jan 2016 10:22:00 +0000 (10:22 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 5 Jan 2016 10:22:00 +0000 (10:22 +0000)
1  2 
opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java

index bc62b3eff9647be25636ae9689613b42bbbea7b4,bc2d23cd70f052cde95e2a304b40f1786a626b70..5356e75e460eef46fefc2aee69a7240e4a270a66
@@@ -47,6 -47,7 +47,7 @@@ import org.opendaylight.controller.md.s
  import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
  import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
  import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
+ import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
  import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
  import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
  import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
@@@ -488,6 -489,8 +489,8 @@@ public class RestconfImpl implements Re
                  if (cause instanceof IllegalArgumentException) {
                      throw new RestconfDocumentedException(cause.getMessage(), ErrorType.PROTOCOL,
                              ErrorTag.INVALID_VALUE);
+                 } else if (cause instanceof DOMRpcImplementationNotAvailableException) {
+                     throw new RestconfDocumentedException(cause.getMessage(), ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED);
                  }
                  throw new RestconfDocumentedException("The operation encountered an unexpected error while executing.",cause);
              } else {
           * document the behavior).
           */
          int tries = 2;
 +        Status status = Status.NOT_MODIFIED;
          while(true) {
              try {
                  if (mountPoint != null) {
 +                    status = broker.readConfigurationData(mountPoint, normalizedII) != null ? Status.OK : Status.CREATED;
                      broker.commitConfigurationDataPut(mountPoint, normalizedII, payload.getData()).checkedGet();
                  } else {
 +                    status = broker.readConfigurationData(normalizedII) != null ? Status.OK : Status.CREATED;
                      broker.commitConfigurationDataPut(controllerContext.getGlobalSchema(), normalizedII, payload.getData()).checkedGet();
                  }
  
              }
          }
  
 -        return Response.status(Status.OK).build();
 +        return Response.status(status).build();
      }
  
      private static void validateTopLevelNodeName(final NormalizedNodeContext node,