Cannot update project attribute via the REST API

Dear Community members,

I am encountering the following issue when try to update a project attribute using the REST API. I am using the end point "/attributeValues" and a most method.

I am passing the following body which - to me at least - seems correctly formatted and correspond to the example provided in the REST API documentation:

[

{

"value": true,

"attribute": {

"id": 1178,

"name": "EPO_Project_Formatted",

"displayName": "Formatted",

"resourceType": "PROJECT",

"type": "BOOLEAN"

},

"resource": { "id": 2094 }

}

]

 

After the Post is sent, I receive a response saying that method ran to completion but returned the following error:

{

"errors": [

{

"code": 500,

"type": "SERVER",

"message": "java.lang.NullPointerException"

}

]

}

 

When I check in the system log of the application, I can see that the following messages:

[2017-02-21 19:03:15,347] INFO http-apr-443-exec-8 com.sdl.lt.worldserver.service.permission.PermissionStageRouter: Checking permission for PermissionKey[resourceType=ATTRIBUTE_VALUE,permissionType=WRITE,auxPermission=CHANGE_PROJECT_ATTRIBUTES] [CHANGE_PROJECT_ATTRIBUTES]
[2017-02-21 19:03:15,353] INFO http-apr-443-exec-8 com.sdl.lt.worldserver.service.permission.PermissionStageRouter: Checking permission for PermissionKey[resourceType=<null>,permissionType=NONE,auxPermission=<null>] []
[2017-02-21 19:03:15,359] INFO http-apr-443-exec-8 com.sdl.lt.worldserver.service.permission.PermissionStageRouter: Checking permission for PermissionKey[resourceType=<null>,permissionType=NONE,auxPermission=<null>] []
[2017-02-21 19:03:15,392] ERROR http-apr-443-exec-8 com.sdl.lt.worldserver.api.rest.error.ExceptionControllerAdvice: Exception intercepted:
java.lang.NullPointerException

Any idea why this is not working? Why is the resourceType "null" in the checking

Thanks in advance for your support.

Regards,

Laurent

Parents
  • Hi Laurent,

    can you please add the full stacktrace of the NullPointerException. You should see more lines in the logs.

    Thanks,
    Stefan.
  • Hi Stefan,

    Thank you for your prompt reaction. Here is the full stack trace of the null pointer.

    Regards,

    Laurent

     

    [2017-02-21 19:03:15,392] ERROR http-apr-443-exec-8 com.sdl.lt.worldserver.api.rest.error.ExceptionControllerAdvice: Exception intercepted:
    java.lang.NullPointerException
    	at com.sdl.lt.worldserver.service.attribute.action.ChangeAttributesAction.getAttributesMap(ChangeAttributesAction.java:87)
    	at com.sdl.lt.worldserver.service.attribute.action.ChangeAttributesAction.doExecute(ChangeAttributesAction.java:58)
    	at com.sdl.lt.worldserver.service.attribute.action.ChangeAttributesAction.doExecute(ChangeAttributesAction.java:37)
    	at com.sdl.lt.worldserver.action.GenericAction.executeInsidePermissions(GenericAction.java:69)
    	at com.sdl.lt.worldserver.action.PermissionExecutor.executeWithPermissions(PermissionExecutor.java:52)
    	at com.sdl.lt.worldserver.action.PermissionExecutor.execute(PermissionExecutor.java:39)
    	at com.sdl.lt.worldserver.action.GenericAction.actionExecution(GenericAction.java:63)
    	at com.sdl.lt.worldserver.action.GenericAction.lambda$execute$0(GenericAction.java:58)
    	at com.sdl.lt.worldserver.service.util.PerformanceLogger.withPerformanceLog(PerformanceLogger.java:19)
    	at com.sdl.lt.worldserver.action.GenericAction.execute(GenericAction.java:58)
    	at com.sdl.lt.worldserver.action.BatchAction.executeRequest(BatchAction.java:59)
    	at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1612)
    	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    	at com.sdl.lt.worldserver.action.BatchAction.execute(BatchAction.java:47)
    	at com.sdl.lt.worldserver.service.attribute.AttributeValueServiceLegacy.changeAttributes(AttributeValueServiceLegacy.java:109)
    	at com.sdl.lt.worldserver.service.attribute.AttributeValueServiceLegacy$$FastClassBySpringCGLIB$$e3e319f.invoke(<generated>)
    	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
    	at com.sdl.lt.worldserver.service.attribute.AttributeValueServiceLegacy$$EnhancerBySpringCGLIB$$1fe1057a.changeAttributes(<generated>)
    	at com.sdl.lt.worldserver.api.rest.attribute.AttributeValueControllerLegacy.update(AttributeValueControllerLegacy.java:33)
    	at com.sdl.lt.worldserver.api.rest.attribute.AttributeValueControllerLegacy$$FastClassBySpringCGLIB$$15855ff3.invoke(<generated>)
    	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
    	at com.sdl.lt.worldserver.transaction.LegacyTransactionManager.runInTransaction(LegacyTransactionManager.java:35)
    	at com.sdl.lt.worldserver.api.rest.RestOperationExecutor.doRestOperation(RestOperationExecutor.java:48)
    	at sun.reflect.GeneratedMethodAccessor465.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:497)
    	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
    	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
    	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
    	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
    	at com.sdl.lt.worldserver.api.rest.attribute.AttributeValueControllerLegacy$$EnhancerBySpringCGLIB$$dbac24f6.update(<generated>)
    	at sun.reflect.GeneratedMethodAccessor1648.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:497)
    	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
    	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
    	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
    	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
    	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at com.sdl.lt.worldserver.api.rest.spring.compression.GZIPRequestFilter.doFilterInternal(GZIPRequestFilter.java:23)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at com.sdl.lt.worldserver.api.rest.spring.ErrorFilter.doFilterInternal(ErrorFilter.java:20)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at com.sdl.lt.worldserver.api.rest.spring.SecurityConfigurationFilter.doFilterInternal(SecurityConfigurationFilter.java:33)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:208)
    	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
    	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2503)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2492)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    	at java.lang.Thread.run(Thread.java:745)

  • You need to specify an aditional information: inside the attribute: readOnly and required.
    readOnly: It needs to be set to false in order for the change to work. If it is readOnly true in the system, but you give it readOnly=false, it will fail. But I suppose, this is not a readOnly attribute.
    required: also has to match the system setting.

    so something like so:
    [

    {

    "value": true,

    "attribute": {

    "id": 1178,

    "name": "EPO_Project_Formatted",

    "displayName": "Formatted",

    "resourceType": "PROJECT",

    "type": "BOOLEAN",
    "required":false,
    "readOnly":false


    },

    "resource": { "id": 2094 }

    }

    ]

    I know that this is not something you feel you should do. I agree with that and we'll remove this requirement in next releases.

    Thanks,
    Stefan.
  • Dear Stefan,

    Thank your for the solution which I could only test this afternoon.

    It does work with these two additional parameters. Maybe it should be added to the documentation or in the examples illustrating the documentation.

    Regards,
    Laurent
Reply Children
No Data