Project

General

Profile

Actions

Defect #2108

closed

Unchecking "Main definition" check box in Form definition causes IdM doesn't start

Added by Ondrej Husník about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Ondrej Husník
Category:
Eav
Target version:
Start date:
03/09/2020
Due date:
% Done:

100%

Estimated time:
Affected versions:
Owner:

Description

It is possible to uncheck "Main definition" check box in Form definition causing IdM doesn't start.
An exception is thrown during app initialization. Detected for IdmRole entity, but some other entities may be affected too.
The source of the exception is probably:
/idm-core-impl/src/main/java/eu/bcvsolutions/idm/InitApplicationData.java - lines 122-132, where intializations of particular default entities are invoked.

Detected in version 10.1

org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:296)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:253)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:527)
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:144)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$ExposeRepositoryInvocationInterceptor.invoke(CrudMethodMetadataPostProcessor.java:364)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
    at com.sun.proxy.$Proxy209.saveAndFlush(Unknown Source)
    at eu.bcvsolutions.idm.core.api.service.AbstractReadWriteDtoService.saveInternal(AbstractReadWriteDtoService.java:98)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultIdmFormDefinitionService.saveInternal(DefaultIdmFormDefinitionService.java:103)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultIdmFormDefinitionService.saveInternal(DefaultIdmFormDefinitionService.java:1)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultIdmFormDefinitionService$$FastClassBySpringCGLIB$$59971ef4.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.eav.service.impl.DefaultIdmFormDefinitionService$$EnhancerBySpringCGLIB$$5afcdf33.saveInternal(<generated>)
    at eu.bcvsolutions.idm.core.eav.processor.FormDefinitionSaveProcessor.process(FormDefinitionSaveProcessor.java:44)
    at eu.bcvsolutions.idm.core.api.event.AbstractEntityEventProcessor.onApplicationEvent(AbstractEntityEventProcessor.java:238)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:372)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultEntityEventManager.process(DefaultEntityEventManager.java:228)
    at eu.bcvsolutions.idm.core.model.service.impl.DefaultEntityEventManager$$FastClassBySpringCGLIB$$1694e58f.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.DefaultEntityEventManager$$EnhancerBySpringCGLIB$$42edabe4.process(<generated>)
    at eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService.publish(AbstractEventableDtoService.java:62)
    at eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService.publish(AbstractEventableDtoService.java:51)
    at eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService.save(AbstractEventableDtoService.java:77)
    at eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService$$FastClassBySpringCGLIB$$28b457d3.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.eav.service.impl.DefaultIdmFormDefinitionService$$EnhancerBySpringCGLIB$$5afcdf33.save(<generated>)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultFormService.createDefinition(DefaultFormService.java:311)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultFormService.createDefinition(DefaultFormService.java:348)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultFormService.createDefinition(DefaultFormService.java:336)
    at eu.bcvsolutions.idm.core.eav.service.impl.DefaultFormService$$FastClassBySpringCGLIB$$f7e12749.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.eav.service.impl.DefaultFormService$$EnhancerBySpringCGLIB$$d3045552.createDefinition(<generated>)
    at eu.bcvsolutions.idm.InitApplicationData.init(InitApplicationData.java:126)
    at eu.bcvsolutions.idm.InitApplicationData.onApplicationEvent(InitApplicationData.java:105)
    at eu.bcvsolutions.idm.InitApplicationData.onApplicationEvent(InitApplicationData.java:1)

Files


Related issues

Related to IdStory Identity Manager - Task #2202: Main form definition consistency solved on service level.ClosedRadek Tomiška04/08/2020

Actions
Actions #1

Updated by Vít Švanda about 4 years ago

  • Assignee changed from Radek Tomiška to Ondrej Husník
Actions #2

Updated by Ondrej Husník about 4 years ago

  • Status changed from New to Needs feedback
  • Assignee changed from Ondrej Husník to Vít Švanda
  • % Done changed from 0 to 90

Because at least on definition has to be selected as the main, this solution disables possibility of unchecking the Main definition checkbox. User is expected to select another definition as main which unchecks the preview one. There was also added prevention from deleting main definition and warning that it cannot be deleted.

Please provide me a feedback. Thank you.

https://github.com/bcvsolutions/CzechIdMng/pull/105/commits/e4ab3e8ab74feefb596234f76dbd479fff515ee8

Actions #3

Updated by Vít Švanda about 4 years ago

  • Assignee changed from Vít Švanda to Radek Tomiška
Actions #4

Updated by Radek Tomiška about 4 years ago

  • Status changed from Needs feedback to In Progress
  • Assignee changed from Radek Tomiška to Ondrej Husník
  • % Done changed from 90 to 70

I did test and feedback, the code is awesome (i like rest test, cool!) and it works with one exception.
Could you please add the same validation for update main defition as for delete to backend too (now is check in UI only and rest is not secured)?

Actions #5

Updated by Radek Tomiška about 4 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 70 to 100

I merged check into develop.

Note: Validation for update main defition as for delete on backend will be added in futute in new ticket - is a little complicated, when definition is used internally for system configuration, code lists, reports and there main definition doesn't make a sense (i'm sorry, i didn't see it before).

Actions #6

Updated by Radek Tomiška about 4 years ago

  • Status changed from Resolved to Closed
Actions #7

Updated by Radek Tomiška about 4 years ago

  • Related to Task #2202: Main form definition consistency solved on service level. added
Actions

Also available in: Atom PDF