Fixed dependency problem for RelatedLinkImExporter
parent
e066ac358f
commit
f7ce45621f
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@librecms/ccm-cms",
|
"name": "@librecms/ccm-cms",
|
||||||
"version": "7.0.0-SNAPSHOT.2022-11-07T181703",
|
"version": "7.0.0-SNAPSHOT.2022-11-26T105237",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@librecms/ccm-cms",
|
"name": "@librecms/ccm-cms",
|
||||||
"version": "7.0.0-SNAPSHOT.2022-11-07T181703",
|
"version": "7.0.0-SNAPSHOT.2022-11-26T105237",
|
||||||
"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.2022-11-07T181703",
|
"version": "7.0.0-SNAPSHOT.2022-11-26T105237",
|
||||||
"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",
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import java.util.Set;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
* @param <T> Type of {@link ContactableEntity}.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractContactableEntityImExporter<T extends ContactableEntity>
|
public abstract class AbstractContactableEntityImExporter<T extends ContactableEntity>
|
||||||
extends AbstractAssetImExporter<T> {
|
extends AbstractAssetImExporter<T> {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class RelatedLink extends Asset implements Serializable {
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "TARGET_ITEM")
|
@JoinColumn(name = "TARGET_ITEM")
|
||||||
@JsonIgnore
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private ContentItem targetItem;
|
private ContentItem targetItem;
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ import org.libreccm.imexport.AbstractEntityImExporter;
|
||||||
import org.libreccm.imexport.Processes;
|
import org.libreccm.imexport.Processes;
|
||||||
import org.libreccm.security.Permission;
|
import org.libreccm.security.Permission;
|
||||||
import org.libreccm.security.PermissionImExporter;
|
import org.libreccm.security.PermissionImExporter;
|
||||||
|
import org.librecms.assets.RelatedLink;
|
||||||
|
import org.librecms.assets.RelatedLinkImExporter;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -55,9 +57,14 @@ public abstract class AbstractContentItemImExporter<T extends ContentItem>
|
||||||
@Processes(Permission.class)
|
@Processes(Permission.class)
|
||||||
private PermissionImExporter permissionImExporter;
|
private PermissionImExporter permissionImExporter;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Any
|
||||||
|
@Processes(RelatedLink.class)
|
||||||
|
private RelatedLinkImExporter relatedLinkImExporter;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected final void init() {
|
||||||
addRequiredEntities(
|
addRequiredEntities(
|
||||||
Set.of(
|
Set.of(
|
||||||
Category.class,
|
Category.class,
|
||||||
|
|
@ -67,9 +74,15 @@ public abstract class AbstractContentItemImExporter<T extends ContentItem>
|
||||||
);
|
);
|
||||||
categorizationImExporter.addRequiredEntities(Set.of(getEntityClass()));
|
categorizationImExporter.addRequiredEntities(Set.of(getEntityClass()));
|
||||||
permissionImExporter.addRequiredEntities(Set.of(getEntityClass()));
|
permissionImExporter.addRequiredEntities(Set.of(getEntityClass()));
|
||||||
|
|
||||||
|
// Related link import requires all content items to be imported to
|
||||||
|
// get the target item.
|
||||||
|
relatedLinkImExporter.addRequiredEntities(Set.of(getEntityClass()));
|
||||||
|
|
||||||
|
initContentItemImExporter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract void initContentItemImExporter();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.contentsection;
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
|
|
||||||
|
|
@ -575,6 +577,11 @@ import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
+ " )"
|
+ " )"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = ContentItemIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class ContentItem extends CcmObject implements Serializable, Exportable {
|
public class ContentItem extends CcmObject implements Serializable, Exportable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 5897287630227129653L;
|
private static final long serialVersionUID = 5897287630227129653L;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ContentItemIdResolver 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(ContentItemRepository.class)
|
||||||
|
.findByUuid(id.key.toString())
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No ContentItem with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new ContentItemIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof ContentItemIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -21,6 +21,7 @@ package org.librecms.contenttypes;
|
||||||
import org.libreccm.imexport.Processes;
|
import org.libreccm.imexport.Processes;
|
||||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,6 +32,12 @@ import javax.enterprise.context.RequestScoped;
|
||||||
@Processes(Article.class)
|
@Processes(Article.class)
|
||||||
public class ArticleImExporter extends AbstractContentItemImExporter<Article> {
|
public class ArticleImExporter extends AbstractContentItemImExporter<Article> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PostConstruct
|
||||||
|
protected void initContentItemImExporter() {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<Article> getEntityClass() {
|
public Class<Article> getEntityClass() {
|
||||||
return Article.class;
|
return Article.class;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.librecms.contenttypes;
|
||||||
import org.libreccm.imexport.Processes;
|
import org.libreccm.imexport.Processes;
|
||||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,6 +32,12 @@ import javax.enterprise.context.RequestScoped;
|
||||||
@Processes(Event.class)
|
@Processes(Event.class)
|
||||||
public class EventImExporter extends AbstractContentItemImExporter<Event> {
|
public class EventImExporter extends AbstractContentItemImExporter<Event> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PostConstruct
|
||||||
|
protected void initContentItemImExporter() {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<Event> getEntityClass() {
|
public Class<Event> getEntityClass() {
|
||||||
return Event.class;
|
return Event.class;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import org.libreccm.imexport.Processes;
|
||||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||||
import org.librecms.contentsection.ContentItemRepository;
|
import org.librecms.contentsection.ContentItemRepository;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
@ -35,6 +36,12 @@ import javax.transaction.Transactional;
|
||||||
public class MultiPartArticleImExporter
|
public class MultiPartArticleImExporter
|
||||||
extends AbstractContentItemImExporter<MultiPartArticle> {
|
extends AbstractContentItemImExporter<MultiPartArticle> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PostConstruct
|
||||||
|
protected void initContentItemImExporter() {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ContentItemRepository itemRepository;
|
private ContentItemRepository itemRepository;
|
||||||
|
|
||||||
|
|
@ -46,7 +53,7 @@ public class MultiPartArticleImExporter
|
||||||
return MultiPartArticle.class;
|
return MultiPartArticle.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void saveImportedEntity(final MultiPartArticle entity) {
|
public void saveImportedEntity(final MultiPartArticle entity) {
|
||||||
for (final MultiPartArticleSection section : entity.getSections()) {
|
for (final MultiPartArticleSection section : entity.getSections()) {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.librecms.contenttypes;
|
||||||
import org.libreccm.imexport.Processes;
|
import org.libreccm.imexport.Processes;
|
||||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,6 +32,12 @@ import javax.enterprise.context.RequestScoped;
|
||||||
@Processes(News.class)
|
@Processes(News.class)
|
||||||
public class NewsImExporter extends AbstractContentItemImExporter<News> {
|
public class NewsImExporter extends AbstractContentItemImExporter<News> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PostConstruct
|
||||||
|
protected void initContentItemImExporter() {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<News> getEntityClass() {
|
public Class<News> getEntityClass() {
|
||||||
return News.class;
|
return News.class;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue