Uploaded image for project: 'Webservices REST Module'
  1. Webservices REST Module
  2. RESTWS-483

REST API shouldn't depend on the attribute order in the JSON string which sends from the client side.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Must
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.13
    • Labels:
      None
    • Complexity:
      Undetermined

      Description

      REST API shouldn't depend on the attribute order in the JSON string which sends from the client side.
      Related dev list discussion: https://groups.google.com/a/openmrs.org/d/msg/dev/3wYrOAMiZys/E_x62yhQw4cJ

      For example: the first JSON works fine, but the second one causes an exception.

      {
        "encounterType": "67a71486-1a54-468f-ac3e-7091a9a79584",
        "patient": "f149555e-69c5-4129-9b8d-57a9f47d248a",
        "encounterDatetime": "2014-12-23T19:08:12.480-0700",
        "location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
        "obs": [
          {
            "concept": "5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
            "value": "132",
            "obsDatetime": "2014-12-23T19:08:12.472-0700",
            "person": "f149555e-69c5-4129-9b8d-57a9f47d248a"
          }
        ]
      }
      
      {
        "encounterDatetime": "2014-12-23T19:02:36.479-0700",
        "encounterType": "67a71486-1a54-468f-ac3e-7091a9a79584",
        "location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
        "patient": "f149555e-69c5-4129-9b8d-57a9f47d248a",
        "obs": [
          {
            "person": "f149555e-69c5-4129-9b8d-57a9f47d248a",
            "value": "132",
            "obsDatetime": "2014-12-23T19:02:36.478-0700",
            "concept": "5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
          }
        ]
      }
      

      Log:

      org.openmrs.module.webservices.rest.web.response.ConversionException: obs on class org.openmrs.Encounter
      at org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:792)
      at org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setConvertedProperties(BaseDelegatingResource.java:642)
      at org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource.create(DelegatingCrudResource.java:93)
      at org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.create(MainResourceController.java:86)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
      at org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest.handle(MainResourceControllerTest.java:155)
      at org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9.EncounterController1_9Test.createEncounter_shouldCreateANewEncounterWithObs(EncounterController1_9Test.java:81)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: org.openmrs.module.webservices.rest.web.response.ConversionException: value on class org.openmrs.Obs
      at org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:792)
      at org.openmrs.module.webservices.rest.web.ConversionUtil.convertMap(ConversionUtil.java:215)
      at org.openmrs.module.webservices.rest.web.ConversionUtil.convert(ConversionUtil.java:187)
      at org.openmrs.module.webservices.rest.web.ConversionUtil.convert(ConversionUtil.java:127)
      at org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:767)
      ... 43 more
      Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:768)
      ... 47 more
      Caused by: java.lang.NullPointerException
      at org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ObsResource1_8.setValue(ObsResource1_8.java:277)
      ... 52 more

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                lluismf Lluis Martinez
                Reporter:
                harshadura Harsha Siriwardena
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 2 days
                    2d
                    Remaining:
                    Remaining Estimate - 2 days
                    2d
                    Logged:
                    Time Spent - Not Specified
                    Not Specified