SSHOC / sshoc-marketplace-backend

Code for the backend
Apache License 2.0
2 stars 0 forks source link

Problems to approve items with relations to other items #65

Closed dpancic closed 1 year ago

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on Mar 19, 2021, 19:03

When trying today to approve suggested items we run into different problems where it seems, that there is wrong handling with relatedItems.

I try to explain the problems:

We had an item with three relations where I tried to use PUT as administrator to approve an item (see #64). It didn't work and in the log it told me:

19-03-2021 15:28:58.105 [http-nio-8080-exec-5] INFO e.s.m.f.a.JwtTokenAuthenticationFilter.doFilterInternal - Valid Bearer JWT found for username: 'Administrator', 19-03-2021 15:28:58.117 [http-nio-8080-exec-5] WARN o.h.e.i.StatefulPersistenceContext.narrowProxy - HHH000179: Narrowing proxy to class eu.sshopencloud.marketplace.model.tools.Tool - this operation breaks ==, 19-03-2021 15:28:58.152 [http-nio-8080-exec-5] WARN o.h.e.jdbc.spi.SqlExceptionHelper.logExceptions - SQL Error: 0, SQLState: 23505, 19-03-2021 15:28:58.153 [http-nio-8080-exec-5] ERROR o.h.e.jdbc.spi.SqlExceptionHelper.logExceptions - ERROR: duplicate key value violates unique constraint "item_prev_version_item_id_uq", Detail: Key (prev_version_id)=(31237) already exists., 19-03-2021 15:28:58.156 [http-nio-8080-exec-5] ERROR e.s.m.c.MarketplaceExceptionHandler.handleServerError - Runtime exception, org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [item_prev_version_item_id_uq]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement, at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:298), at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255), at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:528), 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:149), at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186), at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95), at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186), at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212), at com.sun.proxy.$Proxy213.findAllBySubjectId(Unknown Source), at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService.copyItemRelations(ItemRelatedItemService.java:270), at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source), at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source), at java.base/java.lang.reflect.Method.invoke(Unknown Source), at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344), at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198), at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:772), at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163), at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747), at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689), at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService$$EnhancerBySpringCGLIB$$e906e6f9.copyItemRelations(), at eu.sshopencloud.marketplace.services.items.ItemCrudService.copyVersionRelations(ItemCrudService.java:230), at eu.sshopencloud.marketplace.services.items.ItemCrudService.revertItemVersion(ItemCrudService.java:300), at eu.sshopencloud.marketplace.services.items.ToolService.revertTool(ToolService.java:70), at eu.sshopencloud.marketplace.services.items.ToolService$$FastClassBySpringCGLIB$$99f858f.invoke(), at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218), at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769), at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163), at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747), at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366), at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99), at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186), at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747), at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689), at eu.sshopencloud.marketplace.services.items.ToolService$$EnhancerBySpringCGLIB$$ec38f03e.revertTool(), at eu.sshopencloud.marketplace.controllers.tools.ToolController.revertTool(ToolController.java:61), at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source), at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source), at java.base/java.lang.reflect.Method.invoke(Unknown Source), at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190), at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138), at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106), at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888), at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793), at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87), at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040), at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943), at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006), at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:920), at javax.servlet.http.HttpServlet.service(HttpServlet.java:663), at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883), at javax.servlet.http.HttpServlet.service(HttpServlet.java:741), at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231), at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166), at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53), at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193), at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166), at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200), at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193), at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166), at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113), at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193), at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320), at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126), at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at eu.sshopencloud.marketplace.filters.auth.JwtTokenAuthenticationFilter.doFilterInternal(JwtTokenAuthenticationFilter.java:45), at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter.doFilterInternal(OAuth2AuthorizationRequestRedirectFilter.java:160), at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92), at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92), at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77), at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56), at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119), at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334), at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215), at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178), at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358), at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271), at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193), at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166), at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100), at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119), at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193), at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166), at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93), at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119), at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193), at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166), at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201), at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119), at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193), at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166), at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202), at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96), at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541), at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139), at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92), at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74), at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747), at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343), at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367), at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65), at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860), at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598), at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49), at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source), at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source), at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61), at java.base/java.lang.Thread.run(Unknown Source),

Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement, at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:109), at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42), at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113), at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99), at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200), at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3226), at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3751), at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:91), at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604), at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478), at java.base/java.util.LinkedHashMap.forEach(Unknown Source), at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475), at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:348), at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:57), at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:108), at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1309), at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1389), at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1558), at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1526), at org.hibernate.query.Query.getResultList(Query.java:165), at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76), at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:126), at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88), at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154), at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142), at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:618), at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605), at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186), at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80), at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186), at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366), at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99), at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186), at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139), ... 133 common frames omitted, Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "item_prev_version_item_id_uq", Detail: Key (prev_version_id)=(31237) already exists., at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2505), at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2241), at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:310), at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:447), at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:368), at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:158), at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:124), at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61), at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java), at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197), ... 162 common frames omitted,

Using instead the revert-API call it allowed me to APPROVE this item.

The second example is a kind of lock. We took the former approved item and edited it as a contributor, saving it as draft. In the database it looks like this:

category persistent_id status id label last_info_update info_contributor_id prev_version_id
TOOL_OR_SERVICE wDDeLu SUGGESTED 31204 Ethnic and Migrant Minorities (EMM) Survey Registry 2021-03-17 11:12:33.469129 452
TOOL_OR_SERVICE wDDeLu DEPRECATED 31205 Ethnic and Migrant Minorities (EMM) Survey Registry 2021-03-17 11:31:05.381712 1 31204
TOOL_OR_SERVICE wDDeLu SUGGESTED 31208 Ethnic and Migrant Minorities (EMM) Survey Registry 2021-03-17 14:17:36.722169 452 31205
TOOL_OR_SERVICE wDDeLu SUGGESTED 31210 Ethnic and Migrant Minorities (EMM) Survey Registry 2021-03-17 14:23:12.464806 452 31208
TOOL_OR_SERVICE wDDeLu SUGGESTED 31212 Ethnic and Migrant Minorities (EMM) Survey Registry 2021-03-17 14:32:36.724191 452 31210
TOOL_OR_SERVICE wDDeLu SUGGESTED 31214 Ethnic and Migrant Minorities (EMM) Survey Registry 2021-03-17 14:43:27.772587 452 31212
TOOL_OR_SERVICE wDDeLu APPROVED 31237 Ethnic and Migrant Minorities (EMM) Survey Registry 2021-03-19 14:27:10.554653 1 31214
TOOL_OR_SERVICE wDDeLu DRAFT 31240 Ethnic and Migrant Minorities (EMM) Survey Registry 2021-03-19 15:11:35.936289 452 31237

If approving the last version we get an error trying it either with PUT or with /revert, here the error:

19-03-2021 16:54:59.117 [http-nio-8080-exec-2] INFO e.s.m.f.a.JwtTokenAuthenticationFilter.doFilterInternal - Valid Bearer JWT found for username: 'Administrator' 19-03-2021 16:54:59.191 [http-nio-8080-exec-2] ERROR e.s.m.c.MarketplaceExceptionHandler.handleServerError - Runtime exception java.lang.IllegalStateException: Duplicate key wDDeLu (attempted merging values RelatedItemDto(id=31210, persistentId=wDDeLu, category=tool-or-service, label=Ethnic and Migrant Minorities (EMM) Survey Registry, description=The EMM Survey Registry—which has been co-created by COST Action 16111 - ETHMIGSURVEYDATA, the H2020 SSHOC project, and the ANR project FAIRETHMIGQUANT—is a free online tool for discovering and learning about existing quantitative surveys undertaken with EMM (sub)populations in Europe and beyond. This tool not only brings together previously scattered information about these surveys but also offers detailed and structured metadata for each of the surveys. Designed with the end-users in mind, this tool can also easily be leveraged by anyone interested in doing research or policy-related work using quantitative surveys on EMMs' integration and inclusion. The EMM Survey Registry is currently live and available in beta version. This version is fully functional and displays metadata about 870+ surveys from 21 different countries. In the coming months, the tool will not only expand its metadata offerings (to cover at least an additional 100-200 surveys from roughly 10 additional countries), but also enrich its various user-friendly features and functionalities. , relation=ItemRelationDto(code=relates-to, label=Relates to)) and RelatedItemDto(id=31212, persistentId=wDDeLu, category=tool-or-service, label=Ethnic and Migrant Minorities (EMM) Survey Registry, description=The EMM Survey Registry—which has been co-created by COST Action 16111 - ETHMIGSURVEYDATA, the H2020 SSHOC project, and the ANR project FAIRETHMIGQUANT—is a free online tool for discovering and learning about existing quantitative surveys undertaken with EMM (sub)populations in Europe and beyond. This tool not only brings together previously scattered information about these surveys but also offers detailed and structured metadata for each of the surveys. Designed with the end-users in mind, this tool can also easily be leveraged by anyone interested in doing research or policy-related work using quantitative surveys on EMMs' integration and inclusion. The EMM Survey Registry is currently live and available in beta version. This version is fully functional and displays metadata about 870+ surveys from 21 different countries. In the coming months, the tool will not only expand its metadata offerings (to cover at least an additional 100-200 surveys from roughly 10 additional countries), but also enrich its various user-friendly features and functionalities. , relation=ItemRelationDto(code=relates-to, label=Relates to))) at java.base/java.util.stream.Collectors.duplicateKeyException(Unknown Source) at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Unknown Source) at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(Unknown Source) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source) at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService.updateRelatedItems(ItemRelatedItemService.java:97) at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService.updateRelatedItems(ItemRelatedItemService.java:82) at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService$$FastClassBySpringCGLIB$$b3764898.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService$$EnhancerBySpringCGLIB$$e906e6f9.updateRelatedItems() at eu.sshopencloud.marketplace.services.items.ItemCrudService.prepareAndPushItemVersion(ItemCrudService.java:153) at eu.sshopencloud.marketplace.services.items.ItemCrudService.createOrUpdateItemVersion(ItemCrudService.java:132) at eu.sshopencloud.marketplace.services.items.ItemCrudService.updateItem(ItemCrudService.java:128) at eu.sshopencloud.marketplace.services.items.TrainingMaterialService.updateTrainingMaterial(TrainingMaterialService.java:70) at eu.sshopencloud.marketplace.services.items.TrainingMaterialService$$FastClassBySpringCGLIB$$1b740fe6.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) at eu.sshopencloud.marketplace.services.items.TrainingMaterialService$$EnhancerBySpringCGLIB$$67b83da3.updateTrainingMaterial() at eu.sshopencloud.marketplace.controllers.trainings.TrainingMaterialController.updateTrainingMaterial(TrainingMaterialController.java:59) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:920) at javax.servlet.http.HttpServlet.service(HttpServlet.java:663) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at eu.sshopencloud.marketplace.filters.auth.JwtTokenAuthenticationFilter.doFilterInternal(JwtTokenAuthenticationFilter.java:45) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter.doFilterInternal(OAuth2AuthorizationRequestRedirectFilter.java:160) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Unknown Source)

Not sure if the reason is the draft state or the changes.

And the last example is one where there is already an approved version and where editing this approved version as contributor (adding relations) leads to this error in the API:

{ "timestamp": "2021-03-19 14:24:56", "status": 500, "error": "Duplicate key UZGTCS (attempted merging values RelatedItemDto(id=31209, persistentId=UZGTCS, category=training-material, label=COST Action 16111 - ETHMIGSURVEYDATA Youtube Channel, description=COST Action 16111 - ETHMIGSURVEYDATA’s Youtube channel offers videos aimed at improving the access, usability, and dissemination of survey data on the economic, social and political integration of ethnic and migrant minorities (EMMs). The videos are recordings of trainings, webinars, etc. where members of ETHMIGSURVEYDATA-- a research network and COST Action working with quantitative surveys on EMMs’ integration--presented or are content created by members of ETHMIGSURVEYDATA., relation=ItemRelationDto(code=is-related-to, label=Is related to)) and RelatedItemDto(id=31215, persistentId=UZGTCS, category=training-material, label=COST Action 16111 - ETHMIGSURVEYDATA Youtube Channel, description=COST Action 16111 - ETHMIGSURVEYDATA’s Youtube channel offers videos aimed at improving the access, usability, and dissemination of survey data on the economic, social and political integration of ethnic and migrant minorities (EMMs). The videos are recordings of trainings, webinars, etc. where members of ETHMIGSURVEYDATA-- a research network and COST Action working with quantitative surveys on EMMs’ integration--presented or are content created by members of ETHMIGSURVEYDATA., relation=ItemRelationDto(code=is-related-to, label=Is related to)))" }

In the database the situation looks like this:

category persistent_id status id label last_info_update info_contributor_id prev_version_id
TRAINING_MATERIAL UZGTCS SUGGESTED 31209 COST Action 16111 - ETHMIGSURVEYDATA Youtube Channel 2021-03-17 14:23:12.328288 452
TRAINING_MATERIAL UZGTCS APPROVED 31215 COST Action 16111 - ETHMIGSURVEYDATA Youtube Channel 2021-03-17 14:50:16.890934 1 31209

I know that you may need some more information and that the format is not very well in this issue, but it is late Friday night ;) - just tell me what more information you need.

dpancic commented 3 years ago

In GitLab by @tparkola on Mar 24, 2021, 09:25

Hi, @KlausIllmayer. Could you provide what relations do those two mentioned items contain?

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on Mar 24, 2021, 13:28

@tparkola you can try it by yoursefl with this item (we deleted the other items for the presentation today): GET https://sshoc-marketplace-api.acdh-dev.oeaw.ac.at/api/training-materials/gIN9Aq When trying to change the title (deleting the " - test" part at the end of the label) with a PUT using the result from the GET you will run into a 400 Bad request:

{
  "timestamp": "2021-03-24 12:22:03",
  "status": 400,
  "error": "Duplicate relation to object with id null"
}

Here the error in the log files:

R e.s.m.c.MarketplaceExceptionHandler.handleBadRequestException - Exception,
java.lang.IllegalArgumentException: Duplicate relation to object with id null,
    at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService.lambda$validateNewRelatedItems$5(ItemRelatedItemService.java:172),
    at java.base/java.util.ArrayList.forEach(Unknown Source),
    at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService.validateNewRelatedItems(ItemRelatedItemService.java:170),
    at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService.updateRelatedItems(ItemRelatedItemService.java:87),
    at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService.updateRelatedItems(ItemRelatedItemService.java:82),
    at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService$$FastClassBySpringCGLIB$$b3764898.invoke(<generated>),
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218),
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769),
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163),
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747),
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366),
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99),
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186),
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747),
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689),
    at eu.sshopencloud.marketplace.services.items.ItemRelatedItemService$$EnhancerBySpringCGLIB$$46d3ef13.updateRelatedItems(<generated>),
    at eu.sshopencloud.marketplace.services.items.ItemCrudService.prepareAndPushItemVersion(ItemCrudService.java:153),
    at eu.sshopencloud.marketplace.services.items.ItemCrudService.createOrUpdateItemVersion(ItemCrudService.java:132),
    at eu.sshopencloud.marketplace.services.items.ItemCrudService.updateItem(ItemCrudService.java:128),
    at eu.sshopencloud.marketplace.services.items.TrainingMaterialService.updateTrainingMaterial(TrainingMaterialService.java:70),
    at eu.sshopencloud.marketplace.services.items.TrainingMaterialService$$FastClassBySpringCGLIB$$1b740fe6.invoke(<generated>),
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218),
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769),
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163),
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747),
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366),
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99),
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186),
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747),
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689),
    at eu.sshopencloud.marketplace.services.items.TrainingMaterialService$$EnhancerBySpringCGLIB$$c58545bd.updateTrainingMaterial(<generated>),
    at eu.sshopencloud.marketplace.controllers.trainings.TrainingMaterialController.updateTrainingMaterial(TrainingMaterialController.java:59),
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method),
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source),
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source),
    at java.base/java.lang.reflect.Method.invoke(Unknown Source),
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190),
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138),
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106),
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888),
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793),
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87),
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040),
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943),
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006),
    at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:920),
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:663),
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883),
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741),
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231),
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53),
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193),
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200),
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193),
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113),
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193),
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320),
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126),
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at eu.sshopencloud.marketplace.filters.auth.JwtTokenAuthenticationFilter.doFilterInternal(JwtTokenAuthenticationFilter.java:45),
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter.doFilterInternal(OAuth2AuthorizationRequestRedirectFilter.java:160),
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92),
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92),
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77),
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56),
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119),
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334),
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215),
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178),
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358),
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271),
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193),
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100),
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119),
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193),
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93),
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119),
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193),
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201),
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119),
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193),
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202),
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96),
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541),
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139),
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92),
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74),
    at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747),
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343),
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367),
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65),
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860),
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598),
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49),
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source),
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source),
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61),
    at java.base/java.lang.Thread.run(Unknown Source),
dpancic commented 3 years ago

In GitLab by @tparkola on Mar 31, 2021, 15:39

@KlausIllmayer, the only (?) case where this error message occurs ("Duplicate relation to object with id null") is when the input contains duplicate objectIds. Here, it seems that the null values are passed. Is the request body correct?

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on Mar 31, 2021, 16:24

I still get the same error. The workflow for an update seems to be wrong from my side but I'm not sure how I should do it different:

As there is a lot of data coming from the GET I don't like to process this manually (and I don't know what to kick out or to change so that it will work) so I hoped that by copy&pasting it, everything will still work. But it doesn't look like this so I wonder, what could be the cause of my problems.

dpancic commented 3 years ago

In GitLab by @stefanprobst on Apr 1, 2021, 09:12

@KlausIllmayer the reason you're seeing this error is that relatedItems has a persistentId property in the GET payload, but expects a objectId property (which is the persistent id) in POST/PUT. the following worked for me:

request body ```json { "accessibleAt": ["https://zenodo.org/communities/ethmigsurveydata/"], "contributors": [ { "actor": { "id": 6708 }, "role": { "code": "contributor" } } ], "description": "The COST Action 16111 - ETHMIGSURVEYDATA Zenodo Community is a collection of materials (presentations, reports) produced by members of ETHMIGSURVEYDATA, a research network and COST Action that brings together researchers from all sectors (academic, think tanks, government, civil society organizations, private companies) to improve access, usability, and dissemination of survey data on the economic, social and political integration of ethnic and migrant minorities (EMMs). The materials have been created so that they can be leveraged and used by various users and stakeholders of quantitative survey data on EMMs’ integration.", "label": "COST Action 16111 - ETHMIGSURVEYDATA Zenodo Community", "persistentId": "gIN9Aq", "properties": [ { "id": 186817, "type": { "code": "see-also" }, "value": "https://ethmigsurveydatahub.eu/publications/" }, { "id": 186818, "type": { "code": "see-also" }, "value": "https://ethmigsurveydatahub.eu/ethmig-survey-data-hub/" }, { "id": 186819, "type": { "code": "media" }, "value": "https://gitlab.gwdg.de/sshoc/sshoc-marketplace/-/raw/master/images/Zenodo_community/Screenshot%20of%20the%20Zenodo%20Community%20page.png?inline=false" }, { "id": 186820, "type": { "code": "thumbnail" }, "value": "https://ethmigsurveydatahub.eu/wp-content/uploads/2019/04/ethimg_logo_110.png" }, { "concept": { "code": "https://vocabs.dariah.eu/tadirah/disseminating", "vocabulary": { "code": "tadirah2" } }, "id": 186821, "type": { "code": "activity" } }, { "concept": { "code": "https://vocabs.dariah.eu/tadirah/teaching", "vocabulary": { "code": "tadirah2" } }, "id": 186822, "type": { "code": "activity" } }, { "concept": { "code": "Sharing", "vocabulary": { "code": "tadirah-activity" } }, "id": 186823, "type": { "code": "activity" } }, { "concept": { "code": "Publishing", "vocabulary": { "code": "tadirah-activity" } }, "id": 186824, "type": { "code": "activity" } }, { "concept": { "code": "https://vocabs.dariah.eu/tadirah/creating", "vocabulary": { "code": "tadirah2" } }, "id": 186825, "type": { "code": "activity" } }, { "concept": { "code": "Writing", "vocabulary": { "code": "tadirah-activity" } }, "id": 186826, "type": { "code": "activity" } }, { "concept": { "code": "https://vocabs.dariah.eu/tadirah/storing", "vocabulary": { "code": "tadirah2" } }, "id": 186827, "type": { "code": "activity" } }, { "concept": { "code": "Identifying", "vocabulary": { "code": "tadirah-activity" } }, "id": 186828, "type": { "code": "activity" } }, { "concept": { "code": "https://vocabs.dariah.eu/tadirah/preserving", "vocabulary": { "code": "tadirah2" } }, "id": 186829, "type": { "code": "activity" } }, { "concept": { "code": "Organizing", "vocabulary": { "code": "tadirah-activity" } }, "id": 186830, "type": { "code": "activity" } }, { "id": 186831, "type": { "code": "keyword" }, "value": "Migration" }, { "id": 186832, "type": { "code": "keyword" }, "value": "Migrants" }, { "id": 186833, "type": { "code": "keyword" }, "value": "Immigrants" }, { "id": 186834, "type": { "code": "keyword" }, "value": "Emigrants" }, { "id": 186835, "type": { "code": "keyword" }, "value": "Refugees" }, { "id": 186836, "type": { "code": "keyword" }, "value": "Displaced persons" }, { "id": 186837, "type": { "code": "keyword" }, "value": "Minorities" }, { "id": 186838, "type": { "code": "keyword" }, "value": "Ethnic minorities" }, { "id": 186839, "type": { "code": "keyword" }, "value": "Integration" }, { "id": 186840, "type": { "code": "keyword" }, "value": "Migration studies" }, { "id": 186841, "type": { "code": "keyword" }, "value": "Ethnic studies" }, { "id": 186842, "type": { "code": "keyword" }, "value": "Social sciences" }, { "id": 186843, "type": { "code": "keyword" }, "value": "Open Science" }, { "id": 186844, "type": { "code": "keyword" }, "value": "FAIR principles" }, { "id": 186845, "type": { "code": "keyword" }, "value": "Europe" }, { "id": 186846, "type": { "code": "keyword" }, "value": "(Quantitative) survey research" }, { "id": 186847, "type": { "code": "keyword" }, "value": "(Meta)data" }, { "concept": { "code": "eng", "vocabulary": { "code": "iso-639-3" } }, "id": 186848, "type": { "code": "language" } }, { "id": 186849, "type": { "code": "terms-of-use" }, "value": "A Creative Commons-based license is selected and applied to each material included in the COST Action 16111 - ETHMIGSURVEYDATA Zenodo Community" } ], "relatedItems": [ { "objectId": "h8UTUS", "relation": { "code": "is-related-to" } }, { "objectId": "sEgN0B", "relation": { "code": "is-related-to" } }, { "objectId": "yHAkCK", "relation": { "code": "relates-to" } } ] } ```
dpancic commented 3 years ago

In GitLab by @tparkola on Apr 1, 2021, 10:25

Stefan is right.

Regarding the mistake with multiple drafts and approving, Szymon made a fix before leaving. I've just merged it. Klaus please check one more time your scenario after deployment.

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on Apr 1, 2021, 14:46

I see, thanks @stefanprobst for looking into this. That implies that I need to do a pre-processing of the body that I GET by replacing persistentId with objectId. I'm somehow confused about this, @tparkola can you explain to me the motivation behind using persistentId in the GET result and using objectId in the PUT call? Why not always use persistentId?

@stefanprobst does this mean that you will currently do a find&replace in the frontend when approving an item: first doing the GET, then find&replace persistentId with objectId and then doing the PUT?

And generally, do we think this is a good practive for approving items with relations (also keeping in mind the discussion in #64)? (including @vronk)

dpancic commented 3 years ago

In GitLab by @stefanprobst on Apr 1, 2021, 17:42

does this mean that you will currently do a find&replace in the frontend when approving an item: first doing the GET, then find&replace persistentId with objectId and then doing the PUT?

i'm converting the Dto objects (received via GET) to Core objects, and use these as initial values to populate the edit form. conversion means

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on Apr 1, 2021, 17:49

Thanks for this background information - seems that i need to start thinking more in OpenAPI objects/schemas ;)

Does the schema also describe the change from relation.persistentId to relation.objectId or is this something you implement manually?

dpancic commented 3 years ago

In GitLab by @stefanprobst on Apr 1, 2021, 18:05

i basically compared https://sshoc-marketplace-api.acdh-dev.oeaw.ac.at/swagger-ui/index.html?url=/v3/api-docs#model-ToolDto with https://sshoc-marketplace-api.acdh-dev.oeaw.ac.at/swagger-ui/index.html?url=/v3/api-docs#model-ToolCore

dpancic commented 3 years ago

In GitLab by @tparkola on Apr 2, 2021, 18:03

I've just changed relation.objectId to relation.persistentId in ToolCore. Now persistentId will work in PUT. It was a mistake because of our inattention.

dpancic commented 3 years ago

In GitLab by @stefanprobst on Apr 2, 2021, 21:21

thanks! while you're at it, could you maybe change externalIds.identifierService.code vs externalIds.serviceIdentifier as well? i.e. ItemExternalIdCore has serviceIdentifier, but ItemExternalIdDto has identifierService.code

dpancic commented 3 years ago

In GitLab by @tparkola on Apr 6, 2021, 10:46

I've just make externalIds.identifierService consistent. Both has code now. Also for actors.

dpancic commented 3 years ago

In GitLab by @stefanprobst on Apr 6, 2021, 11:42

awesome, thank you!

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on Apr 12, 2021, 15:47

mentioned in issue data-ingestion#59

dpancic commented 3 years ago

In GitLab by @stefanprobst on Apr 14, 2021, 10:41

@tparkola i think there's still an inconsistency between:

type ActorExternalIdCore = {
  serviceIdentifier: ActorSourceId
  identifier: string
}

export type ActorExternalIdDto = {
  identifierService?: ActorSourceDto
  identifier?: string
}

=> serviceIdentifier vs identifierService

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on Apr 19, 2021, 14:52

I can confirm this inconsistency and it would be great to solve it. Ola does has the same problem with the updates of the "Humanities Data" source, see the message on Basecamp: https://3.basecamp.com/4165192/buckets/10902638/messages/3670642246#__recording_3680615803

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on Apr 19, 2021, 15:06

and it also seems to be broken when trying to approve an item:

{
  "timestamp": "2021-04-19 13:03:36",
  "status": 500,
  "error": "could not execute statement; SQL [n/a]; constraint [item_external_ids_identifier_service_code_identifier_key]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement"
}

In the logs:

19-04-2021 13:03:36.275 [http-nio-8080-exec-7] ERROR o.h.e.jdbc.spi.SqlExceptionHelper.logExceptions - ERROR: duplicate key value violates unique constraint "item_external_ids_identifier_service_code_identifier_key"
  Detail: Key (identifier_service_code, identifier)=(doi, https://zenodo.org/record/45028) already exists.
19-04-2021 13:03:36.296 [http-nio-8080-exec-7] ERROR e.s.m.c.MarketplaceExceptionHandler.handleServerError - Runtime exception
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [item_external_ids_identifier_service_code_identifier_key]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement

Calling PUT on /api/datasets/vMi9YY (taken the data fom GET /api/datasets/vMi9YY/versions/31579)

(in the database the only doi identifier with the value https://zenodo.org/record/45028 is the one to approve (id = 31579)

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on Apr 19, 2021, 15:33

unassigned @tparkola

dpancic commented 3 years ago

In GitLab by @olanowak on Apr 19, 2021, 15:54

I can confirm the issue posted by Klaus. Moreover problem with broken constraint persist even after deleting the first (unapproved) dataset entry.

dpancic commented 3 years ago

In GitLab by @stefanprobst on May 4, 2021, 12:19

i think the new media properties have a similar inconsistency as above:

type ItemMediaDto  {
  metadata: { mediaId: string }
  caption: string
}
type ItemMediaCore {
  mediaId: string
  caption: string
}
dpancic commented 3 years ago

In GitLab by @stefanprobst on May 8, 2021, 09:51

mentioned in issue sshoc-marketplace#82

dpancic commented 3 years ago

In GitLab by @vronk on May 10, 2021, 13:25

dpancic commented 3 years ago

In GitLab by @tparkola on May 11, 2021, 17:32

also done

dpancic commented 3 years ago

In GitLab by @KlausIllmayer on May 11, 2021, 17:59

Great, thanks a lot - already tested it and my example now works as expected

dpancic commented 3 years ago

In GitLab by @olanowak on May 26, 2021, 14:31

mentioned in issue data-ingestion#63