diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/RelatedLinkForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/RelatedLinkForm.java
new file mode 100644
index 000000000..d589b4a58
--- /dev/null
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/RelatedLinkForm.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 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 com.arsdigita.cms.ui.assets.forms;
+
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.cms.ui.assets.AbstractAssetForm;
+import com.arsdigita.cms.ui.assets.AssetPane;
+
+import org.librecms.assets.RelatedLink;
+import org.librecms.assets.SideNote;
+
+import java.util.Map;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class RelatedLinkForm extends AbstractAssetForm{
+
+ public RelatedLinkForm(final AssetPane assetPane) {
+ super(assetPane);
+ }
+
+ @Override
+ protected Class getAssetClass() {
+ return RelatedLink.class;
+ }
+
+ @Override
+ protected void showLocale(final PageState state) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ protected Map collectData(final FormSectionEvent event) throws
+ FormProcessException {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+}
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 b379dc73b..b0e9503ab 100644
--- a/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java
+++ b/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java
@@ -18,6 +18,9 @@
*/
package org.librecms.assets;
+import com.arsdigita.cms.ui.assets.forms.RelatedLinkForm;
+import com.arsdigita.cms.ui.assets.forms.SideNoteForm;
+
import org.librecms.contentsection.Asset;
import org.hibernate.envers.Audited;
import org.librecms.contentsection.ContentItem;
@@ -31,6 +34,7 @@ import javax.persistence.OneToOne;
import javax.persistence.Table;
import static org.librecms.CmsConstants.*;
+import static org.librecms.assets.AssetConstants.ASSETS_BUNDLE;
/**
* An link to information related to a content item, either to an (external) URL
@@ -42,6 +46,13 @@ import static org.librecms.CmsConstants.*;
@Entity
@Table(name = "RELATED_LINKS", schema = DB_SCHEMA)
@Audited
+@AssetType(
+ assetForm = RelatedLinkForm.class,
+ labelBundle = ASSETS_BUNDLE,
+ labelKey = "relatedlink.label",
+ descriptionBundle = ASSETS_BUNDLE,
+ descriptionKey = "relatededlink.description"
+)
public class RelatedLink extends Asset implements Serializable {
private static final long serialVersionUID = 6933875117588667160L;
diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ItemAttachmentManager.java b/ccm-cms/src/main/java/org/librecms/contentsection/ItemAttachmentManager.java
index c15a5c838..fe279ca82 100644
--- a/ccm-cms/src/main/java/org/librecms/contentsection/ItemAttachmentManager.java
+++ b/ccm-cms/src/main/java/org/librecms/contentsection/ItemAttachmentManager.java
@@ -65,7 +65,7 @@ public class ItemAttachmentManager {
return Optional.empty();
}
}
-
+
@Transactional(Transactional.TxType.REQUIRED)
public void save(final ItemAttachment> attachment) {
if (attachment.getAttachmentId() == 0) {
@@ -73,7 +73,7 @@ public class ItemAttachmentManager {
} else {
entityManager.merge(attachment);
}
- }
+ }
/**
* Adds the provided {@link Asset} to the provided {@link AttachmentList}.
@@ -173,9 +173,14 @@ public class ItemAttachmentManager {
@SuppressWarnings("rawtypes")
final List attachments = query.getResultList();
+ attachments.forEach(
+ (attachment) -> asset.removeItemAttachment(attachment)
+ );
attachments.forEach((attachment) -> entityManager.remove(attachment));
- if (!assetManager.isShared(asset)) {
+ if (assetManager.isShared(asset)) {
+ assetRepo.save(asset);
+ } else {
entityManager.remove(asset);
}
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStep.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStep.java
index 9a282957f..054ca91cb 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStep.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStep.java
@@ -1759,7 +1759,7 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep {
* @param listIdentifierParam The identifier of the {@link AttachmentList}
* to which the attachment belongs.
* @param attachmentUuid The UUID of the attachment to remove.
- * @param confirm The value of the {@code confirm} parameter. If
+ * @param confirmed The value of the {@code confirm} parameter. If
* the value anything other than the string
* {@code true} the method does nothing.
*
@@ -1778,8 +1778,8 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep {
final String listIdentifierParam,
@PathParam("attachmentUuid")
final String attachmentUuid,
- @FormParam("confirm")
- final String confirm
+ @FormParam("confirmed")
+ final String confirmed
) {
try {
init();
@@ -1807,18 +1807,15 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep {
.equals(attachmentUuid))
.findFirst();
- if (result.isPresent() && "true".equalsIgnoreCase(confirm)) {
+ if (result.isPresent() && "true".equalsIgnoreCase(confirmed)) {
final Asset asset = result.get().getAsset();
attachmentManager.unattachAsset(asset, list);
- if (asset instanceof RelatedLink
- && ((RelatedLink) asset).getTargetItem() != null) {
- assetRepo.delete(asset);
- }
+// if (asset instanceof RelatedLink) {
+// assetRepo.delete(asset);
+// }
}
- return buildRedirectPathForStep(
- String.format("/attachmentlists/%s/@details", list.getName())
- );
+ return buildRedirectPathForStep();
} else {
return documentUi.showAccessDenied(
getContentSection(),
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml
index fc87f0984..5d317dab7 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml
@@ -179,11 +179,6 @@
dialogTitle="#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.remove.title']}"
message="#{CmsDefaultStepsMessageBundle.getMessage('relatedinfo.attachmentlists.remove.message', [list.name])}"
/>
-
#{attachment.title}
-