Assign dataSets by using the Web API

I am facing a problem while trying to create an orgUnit and assign a dataSet.

Specifically, I have tried two options:

  • Assign the dataSet while creating the orgUnit, here some sample json:
    {“organisationUnits”:[{“name”:“Hospitalization Ward112”,“shortName”:“Hospitalization Ward112”,“level”:7,“parent”:{“id”:“Qa2YaAbgBdd”},“dataSets”:[{“id”:“uceRzlqmJeg”}]}]}

… the orgUnit is created but nor dataSet assigned

  • Assign the orgUnit to the dataSet, here some sample json:

{“dataSets”:[{“id”:“uceRzlqmJeg”,“organisationUnits”:[{“id”:“bJgURXB4miQ”}]}]}

… the original dataset is overwrite and dataElemts and previous assigned orgUnits are losed.

Then, I realized the posibility of “Adding and removing objects to/from collections” using this syntax : /api/{collection-object}/{collection-object-id}/{collection-name}/{object-id}. Therefore, I tried :

Nov 04, 2014 11:03:06 AM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Servlet.service() for servlet [webapi] in context with path [/dhis216] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

I am sure, that one of these options has to work but I can not figure out my pitfall. Any help is welcome.

Thanks in advance.

Regards,

Octavio.

Hi all there,

Hi,

Can you provide the full stack trace?

···

On Tue, Nov 4, 2014 at 5:16 PM, Octavio GLORIO Octavio.GLORIO@barcelona.msf.org wrote:

I am facing a problem while trying to create an orgUnit and assign a dataSet.

Specifically, I have tried two options:

  • Assign the dataSet while creating the orgUnit, here some sample json:
    {“organisationUnits”:[{“name”:“Hospitalization Ward112”,“shortName”:“Hospitalization Ward112”,“level”:7,“parent”:{“id”:“Qa2YaAbgBdd”},“dataSets”:[{“id”:“uceRzlqmJeg”}]}]}

… the orgUnit is created but nor dataSet assigned

  • Assign the orgUnit to the dataSet, here some sample json:

{“dataSets”:[{“id”:“uceRzlqmJeg”,“organisationUnits”:[{“id”:“bJgURXB4miQ”}]}]}

… the original dataset is overwrite and dataElemts and previous assigned orgUnits are losed.

Then, I realized the posibility of “Adding and removing objects to/from collections” using this syntax : /api/{collection-object}/{collection-object-id}/{collection-name}/{object-id}. Therefore, I tried :

Nov 04, 2014 11:03:06 AM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Servlet.service() for servlet [webapi] in context with path [/dhis216] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

I am sure, that one of these options has to work but I can not figure out my pitfall. Any help is welcome.

Thanks in advance.

Regards,

Octavio.

Hi all there,


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp


Morten

Hi Morten,

Here you have:

Nov 04, 2014 11:03:53 AM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Servlet.service() for servlet [webapi] in context with path [/dhis216] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

java.lang.NullPointerException

  • at org.hisp.dhis.acl.DefaultAclService.canCreate(DefaultAclService.java:212)*

  • at org.hisp.dhis.webapi.controller.AbstractCrudController.postJsonObject(AbstractCrudController.java:348)*

  • at org.hisp.dhis.webapi.controller.AbstractCrudController$$FastClassBySpringCGLIB$$92e3cd00.invoke()*

  • at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)*

  • at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:629)*

  • at org.hisp.dhis.webapi.controller.FilteredMetaDataController$$EnhancerBySpringCGLIB$$327ac759.postJsonObject()*

  • at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)*

  • at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)*

  • at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)*

  • at java.lang.reflect.Method.invoke(Method.java:606)*

  • at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)*

  • at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)*

  • at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)*

  • at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)*

  • at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:685)*

  • at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)*

  • at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919)*

  • at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)*

  • at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)*

  • at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855)*

  • at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)*

  • at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)*

  • at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)*

  • at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)*

  • at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)*

  • at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)*

  • at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:201)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.hisp.dhis.security.filter.CustomAuthenticationFilter.doFilter(CustomAuthenticationFilter.java:64)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.hisp.dhis.security.filter.AutomaticAccessFilter.doFilter(AutomaticAccessFilter.java:113)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)*

  • at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)*

  • at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)*

  • at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)*

  • at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)*

  • at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)*

  • at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)*

  • at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)*

  • at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)*

  • at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151)*

  • at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)*

  • at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)*

  • at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)*

  • at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)*

  • at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)*

  • at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)*

  • at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)*

  • at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)*

  • at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)*

  • at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)*

  • at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)*

  • at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)*

  • at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)*

  • at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)*

  • at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)*

  • at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)*

  • at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)*

  • at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)*

  • at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)*

  • at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)*

  • at java.lang.Thread.run(Thread.java:744)*

Para: Octavio GLORIO Octavio.GLORIO@barcelona.msf.org
De: Morten Olav Hansen mortenoh@gmail.com
Fecha: 04/11/2014 11:25
cc: dhis2-users dhis2-users@lists.launchpad.net
Asunto: Re: [Dhis2-users] Assign dataSets by using the Web API

Hi,

Can you provide the full stack trace?

-----Morten Olav Hansen mortenoh@gmail.com escribió: -----

···

On Tue, Nov 4, 2014 at 5:16 PM, Octavio GLORIO Octavio.GLORIO@barcelona.msf.org wrote:

I am facing a problem while trying to create an orgUnit and assign a dataSet.

Specifically, I have tried two options:

  • Assign the dataSet while creating the orgUnit, here some sample json:
    {“organisationUnits”:[{“name”:“Hospitalization Ward112”,“shortName”:“Hospitalization Ward112”,“level”:7,“parent”:{“id”:“Qa2YaAbgBdd”},“dataSets”:[{“id”:“uceRzlqmJeg”}]}]}

… the orgUnit is created but nor dataSet assigned

  • Assign the orgUnit to the dataSet, here some sample json:

{“dataSets”:[{“id”:“uceRzlqmJeg”,“organisationUnits”:[{“id”:“bJgURXB4miQ”}]}]}

… the original dataset is overwrite and dataElemts and previous assigned orgUnits are losed.

Then, I realized the posibility of “Adding and removing objects to/from collections” using this syntax : /api/{collection-object}/{collection-object-id}/{collection-name}/{object-id}. Therefore, I tried :

Nov 04, 2014 11:03:06 AM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Servlet.service() for servlet [webapi] in context with path [/dhis216] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

I am sure, that one of these options has to work but I can not figure out my pitfall. Any help is welcome.

Thanks in advance.

Regards,

Octavio.

Hi all there,


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp


Morten