diff --git a/ccm-cms/src/main/java/org/librecms/assets/AbstractAssetImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/AbstractAssetImExporter.java new file mode 100644 index 000000000..69aef32bd --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/AbstractAssetImExporter.java @@ -0,0 +1,62 @@ +/* + * 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.assets; + +import org.libreccm.imexport.AbstractEntityImExporter; +import org.librecms.contentsection.Asset; +import org.librecms.contentsection.AssetRepository; + +import java.util.Objects; + +import javax.inject.Inject; + +/** + * + * @author Jens Pelzetter + * @param Type of asset to process. + */ +public abstract class AbstractAssetImExporter + extends AbstractEntityImExporter { + + @Inject + private AssetRepository assetRepo; + + @Override + protected void saveImportedEntity(T asset) { + assetRepo.save(asset); + } + + @Override + protected T reloadEntity(T asset) { + return assetRepo + .findById(Objects.requireNonNull(asset.getObjectId()), + getEntityClass() + ) + .orElseThrow( + () -> new IllegalArgumentException( + String.format( + "No asset of type %s with ID %d found in the database.", + getEntityClass().getName(), + asset.getObjectId() + ) + ) + ); + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/AbstractBinaryAssetImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/AbstractBinaryAssetImExporter.java new file mode 100644 index 000000000..9cbd2cc27 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/AbstractBinaryAssetImExporter.java @@ -0,0 +1,29 @@ +/* + * 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.assets; + +/** + * + * @author Jens Pelzetter + * @param Type of {@link BinaryAsset> to process + */ +public abstract class AbstractBinaryAssetImExporter + extends AbstractAssetImExporter { + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/AbstractBookmarkImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/AbstractBookmarkImExporter.java new file mode 100644 index 000000000..49634594a --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/AbstractBookmarkImExporter.java @@ -0,0 +1,29 @@ +/* + * 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.assets; + +/** + * + * @author Jens Pelzetter + * @param Type of {@link Bookmark} to process. + */ +public abstract class AbstractBookmarkImExporter + extends AbstractAssetImExporter { + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/AbstractContactableEntityImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/AbstractContactableEntityImExporter.java new file mode 100644 index 000000000..b3c5877d1 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/AbstractContactableEntityImExporter.java @@ -0,0 +1,37 @@ +/* + * 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.assets; + +import java.util.Set; + +/** + * + * @author Jens Pelzetter + */ +public abstract class AbstractContactableEntityImExporter + extends AbstractAssetImExporter { + + @Override + protected final void init() { + addRequiredEntities(Set.of(PostalAddress.class)); + } + + protected abstract void initContactableEntityImExporter(); + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/AudioAsset.java b/ccm-cms/src/main/java/org/librecms/assets/AudioAsset.java index a6bf98331..ba59beef6 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/AudioAsset.java +++ b/ccm-cms/src/main/java/org/librecms/assets/AudioAsset.java @@ -19,6 +19,7 @@ package org.librecms.assets; +import com.fasterxml.jackson.annotation.JsonIdentityReference; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.AudioAssetCreateStep; import org.librecms.ui.contentsections.assets.AudioAssetEditStep; @@ -59,6 +60,7 @@ public class AudioAsset extends BinaryAsset implements Serializable { @OneToOne @JoinColumn(name = "LEGAL_METADATA_ID") + @JsonIdentityReference(alwaysAsId = true) private LegalMetadata legalMetadata; public LegalMetadata getLegalMetadata() { diff --git a/ccm-cms/src/main/java/org/librecms/assets/AudioAssetImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/AudioAssetImExporter.java new file mode 100644 index 000000000..0abd8848b --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/AudioAssetImExporter.java @@ -0,0 +1,45 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import java.util.Set; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(AudioAsset.class) +public class AudioAssetImExporter extends AbstractBinaryAssetImExporter { + + @Override + public Class getEntityClass() { + return AudioAsset.class; + } + + @Override + protected void init() { + addRequiredEntities(Set.of(LegalMetadata.class)); + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/BookmarkImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/BookmarkImExporter.java new file mode 100644 index 000000000..245602c7b --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/BookmarkImExporter.java @@ -0,0 +1,44 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(Bookmark.class) +public class BookmarkImExporter + extends AbstractBookmarkImExporter { + + @Override + public Class getEntityClass() { + return Bookmark.class; + } + + @Override + protected void init() { + // Nothing + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAsset.java b/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAsset.java index bf2c39c48..bd473a7d5 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAsset.java +++ b/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAsset.java @@ -19,6 +19,7 @@ package org.librecms.assets; +import com.fasterxml.jackson.annotation.JsonIdentityReference; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.ExternalAudioAssetCreateStep; import org.librecms.ui.contentsections.assets.ExternalAudioAssetEditStep; @@ -62,6 +63,7 @@ public class ExternalAudioAsset extends Bookmark implements Serializable { @OneToOne @JoinColumn(name = "LEGAL_METADATA_ID") + @JsonIdentityReference(alwaysAsId = true) private LegalMetadata legalMetadata; public LegalMetadata getLegalMetadata() { diff --git a/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAssetImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAssetImExporter.java new file mode 100644 index 000000000..c54c48188 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAssetImExporter.java @@ -0,0 +1,46 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import java.util.Set; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(ExternalAudioAsset.class) +public class ExternalAudioAssetImExporter + extends AbstractBookmarkImExporter { + + @Override + public Class getEntityClass() { + return ExternalAudioAsset.class; + } + + @Override + protected void init() { + addRequiredEntities(Set.of(LegalMetadata.class)); + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAsset.java b/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAsset.java index 223800d88..451f91c41 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAsset.java +++ b/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAsset.java @@ -19,6 +19,7 @@ package org.librecms.assets; +import com.fasterxml.jackson.annotation.JsonIdentityReference; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.ExternalVideoAssetCreateStep; import org.librecms.ui.contentsections.assets.ExternalVideoAssetEditStep; @@ -59,6 +60,7 @@ public class ExternalVideoAsset extends Bookmark implements Serializable { @OneToOne @JoinColumn(name = "LEGAL_METADATA_ID") + @JsonIdentityReference(alwaysAsId = true) private LegalMetadata legalMetadata; public LegalMetadata getLegalMetadata() { diff --git a/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAssetImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAssetImExporter.java new file mode 100644 index 000000000..8c06b42db --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAssetImExporter.java @@ -0,0 +1,46 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import java.util.Set; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(ExternalVideoAsset.class) +public class ExternalVideoAssetImExporter + extends AbstractBookmarkImExporter { + + @Override + public Class getEntityClass() { + return ExternalVideoAsset.class; + } + + @Override + protected void init() { + addRequiredEntities(Set.of(LegalMetadata.class)); + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/FileAssetImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/FileAssetImExporter.java new file mode 100644 index 000000000..30a84d126 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/FileAssetImExporter.java @@ -0,0 +1,38 @@ +/* + * 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.assets; + +/** + * + * @author Jens Pelzetter + */ +public class FileAssetImExporter + extends AbstractBinaryAssetImExporter { + + @Override + public Class getEntityClass() { + return FileAsset.class; + } + + @Override + protected void init() { + // Nothing + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/Image.java b/ccm-cms/src/main/java/org/librecms/assets/Image.java index ae1d31b01..35ae21438 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/Image.java +++ b/ccm-cms/src/main/java/org/librecms/assets/Image.java @@ -18,6 +18,8 @@ */ package org.librecms.assets; +import com.fasterxml.jackson.annotation.JsonIdentityReference; + import java.io.Serializable; import java.util.Objects; @@ -67,6 +69,7 @@ public class Image extends BinaryAsset implements Serializable { @OneToOne @JoinColumn(name = "LEGAL_METADATA_ID") + @JsonIdentityReference(alwaysAsId = true) private LegalMetadata legalMetadata; public Image() { diff --git a/ccm-cms/src/main/java/org/librecms/assets/ImageImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/ImageImExporter.java new file mode 100644 index 000000000..062726687 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/ImageImExporter.java @@ -0,0 +1,45 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import java.util.Set; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(Image.class) +public class ImageImExporter extends AbstractBinaryAssetImExporter { + + @Override + public Class getEntityClass() { + return Image.class; + } + + @Override + protected void init() { + addRequiredEntities(Set.of(LegalMetadata.class)); + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/LegalMetadataImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/LegalMetadataImExporter.java new file mode 100644 index 000000000..771c7f387 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/LegalMetadataImExporter.java @@ -0,0 +1,44 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(LegalMetadata.class) +public class LegalMetadataImExporter + extends AbstractAssetImExporter { + + @Override + public Class getEntityClass() { + return LegalMetadata.class; + } + + @Override + protected void init() { + // Nothing + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/OrganizationImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/OrganizationImExporter.java new file mode 100644 index 000000000..ea86f8fad --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/OrganizationImExporter.java @@ -0,0 +1,44 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(Organization.class) +public class OrganizationImExporter + extends AbstractContactableEntityImExporter { + + @Override + public Class getEntityClass() { + return Organization.class; + } + + @Override + protected void initContactableEntityImExporter() { + // Nothing + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/PersonImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/PersonImExporter.java new file mode 100644 index 000000000..42a6e9c37 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/PersonImExporter.java @@ -0,0 +1,38 @@ +/* + * 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.assets; + +/** + * + * @author Jens Pelzetter + */ +public class PersonImExporter + extends AbstractContactableEntityImExporter { + + @Override + public Class getEntityClass() { + return Person.class; + } + + @Override + protected void initContactableEntityImExporter() { + // Nothing + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/PostalAddressImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/PostalAddressImExporter.java new file mode 100644 index 000000000..6522ecffb --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/PostalAddressImExporter.java @@ -0,0 +1,40 @@ +/* + * 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.assets; + +import org.librecms.contentsection.Asset; + +/** + * + * @author Jens Pelzetter + */ +public class PostalAddressImExporter + extends AbstractAssetImExporter { + + @Override + public Class getEntityClass() { + return PostalAddress.class; + } + + @Override + protected void init() { + // Nothing + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java b/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java index 3dfed2f9e..0f7523406 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java +++ b/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java @@ -19,6 +19,8 @@ package org.librecms.assets; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.JsonIgnore; import org.librecms.contentsection.Asset; import org.hibernate.envers.Audited; import org.librecms.contentsection.ContentItem; @@ -56,10 +58,12 @@ public class RelatedLink extends Asset implements Serializable { @OneToOne @JoinColumn(name = "TARGET_ITEM") + @JsonIgnore private ContentItem targetItem; @OneToOne @JoinColumn(name = "BOOKMARK_ID") + @JsonIdentityReference(alwaysAsId = true) private Bookmark bookmark; public ContentItem getTargetItem() { diff --git a/ccm-cms/src/main/java/org/librecms/assets/RelatedLinkImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/RelatedLinkImExporter.java new file mode 100644 index 000000000..57cc06759 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/RelatedLinkImExporter.java @@ -0,0 +1,47 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import java.util.Set; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(RelatedLink.class) +public class RelatedLinkImExporter extends AbstractAssetImExporter { + + @Override + public Class getEntityClass() { + return RelatedLink.class; + } + + @Override + protected void init() { + addRequiredEntities(Set.of(Bookmark.class)); + } + + + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/SideNoteImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/SideNoteImExporter.java new file mode 100644 index 000000000..23bcbb2db --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/SideNoteImExporter.java @@ -0,0 +1,45 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(SideNote.class) +public class SideNoteImExporter extends AbstractAssetImExporter{ + + @Override + public Class getEntityClass() { + return SideNote.class; + } + + @Override + protected void init() { + // Nothing + } + + + +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/VideoAsset.java b/ccm-cms/src/main/java/org/librecms/assets/VideoAsset.java index 680b2867b..676c66172 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/VideoAsset.java +++ b/ccm-cms/src/main/java/org/librecms/assets/VideoAsset.java @@ -19,6 +19,7 @@ package org.librecms.assets; +import com.fasterxml.jackson.annotation.JsonIdentityReference; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.MvcAssetEditKit; import org.librecms.ui.contentsections.assets.VideoAssetCreateStep; @@ -66,6 +67,7 @@ public class VideoAsset extends BinaryAsset implements Serializable { @OneToOne @JoinColumn(name = "LEGAL_METADATA_ID") + @JsonIdentityReference(alwaysAsId = true) private LegalMetadata legalMetadata; public long getWidth() { diff --git a/ccm-cms/src/main/java/org/librecms/assets/VideoAssetImExporter.java b/ccm-cms/src/main/java/org/librecms/assets/VideoAssetImExporter.java new file mode 100644 index 000000000..1e64560b1 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/assets/VideoAssetImExporter.java @@ -0,0 +1,48 @@ +/* + * 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.assets; + +import org.libreccm.imexport.Processes; + +import java.util.Set; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(VideoAsset.class) +public class VideoAssetImExporter + extends AbstractBinaryAssetImExporter { + + @Override + public Class getEntityClass() { + return VideoAsset.class; + } + + @Override + protected void init() { + addRequiredEntities( + Set.of(LegalMetadata.class) + ); + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/Asset.java b/ccm-cms/src/main/java/org/librecms/contentsection/Asset.java index b5942dbb4..ca8edd772 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/Asset.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/Asset.java @@ -18,6 +18,7 @@ */ package org.librecms.contentsection; +import com.fasterxml.jackson.annotation.JsonIgnore; import org.hibernate.envers.Audited; import org.libreccm.categorization.Categorization; import org.libreccm.core.CcmObject; @@ -418,6 +419,7 @@ public class Asset extends CcmObject { @OneToMany(mappedBy = "asset") @OrderBy("sortKey ASC") + @JsonIgnore private List> itemAttachments; @Embedded