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

Custom representation bombs on person.preferredName field

    XMLWordPrintable

Details

    • Undetermined

    Description

      I am using jQuery to call RESTWS to search for patients like this:

      var customRep = 'custom:(uuid,identifiers:(identifierType:(name),identifier),person:(preferredName,age,gender))';
                  jq.getJSON('/' + OPENMRS_CONTEXT_PATH + '/ws/rest/v1/patient', {v: customRep, q: query }, function(data) {
      

      I get back a 500 status with the following error:

      {"error":{"message":"Unable to convert object into response content","code":"org.openmrs.module.webservices.rest.web.ConversionUtil:237","detail":"org.openmrs.module.webservices.rest.web.response.ConversionException: converting class org.openmrs.Patient to org.openmrs.module.webservices.rest.web.representation.CustomRepresentation@5dbf973\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convertToRepresentation(ConversionUtil.java:237)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BasePageableResult.toSimpleObject(BasePageableResult.java:45)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource.search(DelegatingCrudResource.java:174)\n\tat org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.get(MainResourceController.java:165)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n\tat java.lang.reflect.Method.invoke(Method.java:597)\n\tat org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)\n\tat org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)\n\tat org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)\n\tat org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:707)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:820)\n\tat org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)\n\tat org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:65)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:76)\n\tat org.openmrs.module.webservices.rest.web.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:100)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:74)\n\tat org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:58)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:74)\n\tat org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:58)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)\n\tat org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:111)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)\n\tat org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:109)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:109)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:109)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)\n\tat org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)\n\tat org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)\n\tat org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)\n\tat org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)\n\tat org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)\n\tat org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)\n\tat org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)\n\tat org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)\n\tat org.mortbay.jetty.Server.handle(Server.java:324)\n\tat org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)\n\tat org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)\n\tat org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)\n\tat org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)\n\tat org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)\n\tat org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)\n\tat org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)\nCaused by: org.openmrs.module.webservices.rest.web.response.ConversionException: converting class org.openmrs.Person to org.openmrs.module.webservices.rest.web.representation.CustomRepresentation@7e8f9a4f\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convertToRepresentation(ConversionUtil.java:237)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription$Property.evaluate(DelegatingResourceDescription.java:225)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.convertDelegateToRepresentation(BaseDelegatingResource.java:534)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.asRepresentation(BaseDelegatingResource.java:318)\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convertToRepresentation(ConversionUtil.java:234)\n\t... 59 more\nCaused by: org.openmrs.module.webservices.rest.web.response.ConversionException: preferredName\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.getProperty(BaseDelegatingResource.java:657)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription$Property.evaluate(DelegatingResourceDescription.java:218)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.convertDelegateToRepresentation(BaseDelegatingResource.java:534)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.asRepresentation(BaseDelegatingResource.java:318)\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convertToRepresentation(ConversionUtil.java:234)\n\t... 63 more\nCaused by: java.lang.NoSuchMethodException: Unknown property 'preferredName'\n\tat org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1122)\n\tat org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:686)\n\tat org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715)\n\tat org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:290)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.getProperty(BaseDelegatingResource.java:651)\n\t... 67 more\n"}}
      

      According to https://wiki.openmrs.org/x/44FNAg the person resource should support a preferredName property.

      Gliffy Diagrams

        Attachments

          Issue Links

            Activity

              People

                lluismf Lluis Martinez
                darius Darius Jazayeri
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Time Tracking

                    Estimated:
                    Original Estimate - 4 hours
                    4h
                    Remaining:
                    Remaining Estimate - 4 hours
                    4h
                    Logged:
                    Time Spent - Not Specified
                    Not Specified