Fixed missing JSONIdentityInfo for AttachmentList
parent
97afa16b46
commit
fe74176563
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@librecms/ccm-cms",
|
"name": "@librecms/ccm-cms",
|
||||||
"version": "7.0.0-SNAPSHOT.2023-02-23T193303",
|
"version": "7.0.0-SNAPSHOT.2023-02-26T075448",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@librecms/ccm-cms",
|
"name": "@librecms/ccm-cms",
|
||||||
"version": "7.0.0-SNAPSHOT.2023-02-23T193303",
|
"version": "7.0.0-SNAPSHOT.2023-02-26T075448",
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tiptap/core": "^2.0.0-beta.127",
|
"@tiptap/core": "^2.0.0-beta.127",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@librecms/ccm-cms",
|
"name": "@librecms/ccm-cms",
|
||||||
"version": "7.0.0-SNAPSHOT.2023-02-23T193303",
|
"version": "7.0.0-SNAPSHOT.2023-02-26T075448",
|
||||||
"description": "JavaScript stuff for ccm-cms",
|
"description": "JavaScript stuff for ccm-cms",
|
||||||
"main": "target/generated-resources/assets/@content-sections/cms-admin.js",
|
"main": "target/generated-resources/assets/@content-sections/cms-admin.js",
|
||||||
"types": "target/generated-resources/assets/@content-sections/cms-admin.d.ts",
|
"types": "target/generated-resources/assets/@content-sections/cms-admin.d.ts",
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.contentsection;
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.core.Identifiable;
|
import org.libreccm.core.Identifiable;
|
||||||
import org.libreccm.imexport.Exportable;
|
import org.libreccm.imexport.Exportable;
|
||||||
|
|
@ -89,6 +92,12 @@ import static org.librecms.CmsConstants.DB_SCHEMA;
|
||||||
+ "AND l.item = :item "
|
+ "AND l.item = :item "
|
||||||
+ "ORDER BY l.listOrder")
|
+ "ORDER BY l.listOrder")
|
||||||
})
|
})
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = AttachmentListIdResolver.class,
|
||||||
|
property = "uuid",
|
||||||
|
scope = AttachmentList.class
|
||||||
|
)
|
||||||
public class AttachmentList implements Comparable<AttachmentList>,
|
public class AttachmentList implements Comparable<AttachmentList>,
|
||||||
Identifiable,
|
Identifiable,
|
||||||
Exportable,
|
Exportable,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class AttachmentListIdResolver
|
||||||
|
implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey id,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(AttachmentListRepository.class)
|
||||||
|
.findByUuid(id.key.toString())
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No AttachmentList with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new AttachmentListIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof AttachmentListIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -23,7 +23,6 @@ import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.contentsection;
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.core.Identifiable;
|
import org.libreccm.core.Identifiable;
|
||||||
import org.libreccm.imexport.Exportable;
|
import org.libreccm.imexport.Exportable;
|
||||||
|
|
@ -97,6 +99,7 @@ public class ItemAttachment<T extends Asset>
|
||||||
*/
|
*/
|
||||||
@ManyToOne(cascade = {CascadeType.PERSIST})
|
@ManyToOne(cascade = {CascadeType.PERSIST})
|
||||||
@JoinColumn(name = "ATTACHMENT_LIST_ID")
|
@JoinColumn(name = "ATTACHMENT_LIST_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private AttachmentList attachmentList;
|
private AttachmentList attachmentList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue