Defect #2542
closedImporting automatic roles by tree nodes may fail for multiple roles (AcceptedException in ImportAutomaticRoleForTreeNodeFromCSVExecutor)
100%
Description
Importing automatic roles by tree nodes may fail for multiple roles (= some of them are not processed) when using extras 2.6.0 with product 10.4.8.
Maybe the same issue will happen when using other versions of the product.
The reason is that ImportAutomaticRoleForTreeNodeFromCSVExecutor saves them directly. But after some issues fixed in versions 10.4.x and 10.5.x (e.g. #2524), multiple automatic roles can not be processed at the same time, so they are processed one by one (the corresponding ProcessAutomaticRoleByTreeTaskExecutor wait for each other in the LRT queue) and the save method throws AcceptedException.
After consultation with Vítek, the reliable way to create automatic roles is using automatic role requests.
There is a helping method automaticRoleManager.createAutomaticRoleByTree.
The exception thrown by ImportAutomaticRoleForTreeNodeFromCSVExecutor when this happens on 10.4.8:
eu.bcvsolutions.idm.core.api.exception.AcceptedException: at eu.bcvsolutions.idm.core.model.service.impl.DefaultIdmRoleTreeNodeService.save(DefaultIdmRoleTreeNodeService.java:107) at eu.bcvsolutions.idm.core.model.service.impl.DefaultIdmRoleTreeNodeService.save(DefaultIdmRoleTreeNodeService.java:57) at eu.bcvsolutions.idm.core.model.service.impl.DefaultIdmRoleTreeNodeService$$FastClassBySpringCGLIB$$b5b44e46.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at eu.bcvsolutions.idm.core.model.service.impl.DefaultIdmRoleTreeNodeService$$EnhancerBySpringCGLIB$$ac263aab.save(<generated>) at eu.bcvsolutions.idm.extras.scheduler.task.impl.ImportAutomaticRoleForTreeNodeFromCSVExecutor.createRoleTreeNode(ImportAutomaticRoleForTreeNodeFromCSVExecutor.java:135)
Updated by Radek Tomiška about 4 years ago
I'm not sure about this. Why you just not wait to LRT completion (e.g. ObserveLongRunningTaskEndProcessor - listen LRT end event => execute next)?
Updated by Alena Peterová about 4 years ago
- Subject changed from Importing automatic roles by tree nodes may fail for multiple roles (use automatic role requests in ImportAutomaticRoleForTreeNodeFromCSVExecutor) to Importing automatic roles by tree nodes may fail for multiple roles (AcceptedException in ImportAutomaticRoleForTreeNodeFromCSVExecutor)
After some more consultation, catching AcceptedException in the import task is also a possible and clean solution.
Updated by Alena Peterová about 4 years ago
- Status changed from New to In Progress
- Assignee set to Alena Peterová
Updated by Alena Peterová about 4 years ago
- Status changed from In Progress to Needs feedback
- % Done changed from 0 to 80
Fixed in commit https://github.com/bcvsolutions/czechidm-extras/commit/8e41d99c97e20e454131c469a7c016f50e95e162 and updated dependency on the product version from 10.4.4 to 10.4.9 https://github.com/bcvsolutions/czechidm-extras/commit/6e6eac471cd9d56b62db7abb2cfa2e29101bb4c1.
I also updated the test ImportAutomaticRoleForTreeNodeFromCSVExecutorTest to run LRT asynchronously - otherwise the test was successful even before the fix.
Tested in our local development environment with example CSV, which originally failed on the 3rd role:
nodename;nodeid;rolecode;recursion
5649;;NT_EC_U;DOWN
5649;;NT_EC_G;DOWN
2091;;NT_EC_U;DOWN
@doischert Would you please make a feedback?
Updated by Tomáš Doischer about 4 years ago
The code looks great and the import worked for me in the test environment, thank you!
Updated by Peter Štrunc about 4 years ago
- Status changed from Needs feedback to Closed
- % Done changed from 80 to 100
Merged to develop. Thanks for the fix!