Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-2313

nicer error handling when Patient Identifier Type regex too long

    Details

    • Complexity:
      Low

      Description

      The database limits a Patient Identifier regex to 50 characters. Entering a value that's too long gives a spectacular, spooky Hibernate exception. The form should limit input to the max length and give a normal error message.

      To reproduce:

      From Admin page > Patients > Manage Identifier Types , create or edit a type.
      In regex format, enter
      [0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]

      This is 51 characters. ( yyyy-123456 ). The max is 50.
      Save.

      Error page:
      An Internal Error has Occurred
      org.hibernate.exception.DataException
      could not insert: [org.openmrs.PatientIdentifierType]

      Consult the help document.
      Contact your friendly neighborhood administrator if it cannot be resolved.

      Hide stack trace
      org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
      org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40)
      org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
      org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
      org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
      org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
      org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
      org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
      org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
      org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
      org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
      org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
      org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
      org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
      org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
      org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
      org.openmrs.api.db.hibernate.HibernatePatientDAO.savePatientIdentifierType(HibernatePatientDAO.java:256)
      org.openmrs.api.impl.PatientServiceImpl.savePatientIdentifierType(PatientServiceImpl.java:466)
      sun.reflect.GeneratedMethodAccessor858.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      $Proxy73.savePatientIdentifierType(Unknown Source)
      sun.reflect.GeneratedMethodAccessor858.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      org.openmrs.aop.LoggingAdvice.invoke(LoggingAdvice.java:107)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      $Proxy74.savePatientIdentifierType(Unknown Source)
      sun.reflect.GeneratedMethodAccessor858.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      $Proxy74.savePatientIdentifierType(Unknown Source)
      org.openmrs.web.controller.patient.PatientIdentifierTypeFormController.onSubmit(PatientIdentifierTypeFormController.java:88)
      org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:272)
      org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:268)
      org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
      org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:65)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:76)
      org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:58)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:112)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:83)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:83)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:83)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      java.lang.Thread.run(Thread.java:680)

      OpenMRS Version: 1.7.1 Build 17223

        Gliffy Diagrams

          Attachments

            Attachments-Category-Modification

              Activity

                People

                • Assignee:
                  jtellez Joel Tellez
                  Reporter:
                  jriley Janet Riley
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: