Closed dpancic closed 1 year ago
In GitLab by @tparkola on Mar 24, 2021, 09:25
Hi, @KlausIllmayer. Could you provide what relations do those two mentioned items contain?
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),
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?
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.
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:
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.
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)
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
withobjectId
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
contributors
and properties
which is not an id
/code
, and category
, olderVersions
, newerVersions
, informationContributor
etc.relation.persistendId
to relation.objectId
externalIds.identifierService.code
to externalIds.serviceIdentifier
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?
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
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.
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
In GitLab by @tparkola on Apr 6, 2021, 10:46
I've just make externalIds.identifierService
consistent. Both has code
now. Also for actors.
In GitLab by @stefanprobst on Apr 6, 2021, 11:42
awesome, thank you!
In GitLab by @KlausIllmayer on Apr 12, 2021, 15:47
mentioned in issue data-ingestion#59
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
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
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)
In GitLab by @KlausIllmayer on Apr 19, 2021, 15:33
unassigned @tparkola
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.
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
}
In GitLab by @stefanprobst on May 8, 2021, 09:51
mentioned in issue sshoc-marketplace#82
In GitLab by @vronk on May 10, 2021, 13:25
In GitLab by @tparkola on May 11, 2021, 17:32
also done
In GitLab by @KlausIllmayer on May 11, 2021, 17:59
Great, thanks a lot - already tested it and my example now works as expected
In GitLab by @olanowak on May 26, 2021, 14:31
mentioned in issue data-ingestion#63
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:
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:
If approving the last version we get an error trying it either with PUT or with /revert, here the error:
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:
In the database the situation looks like this:
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.