From f3ad0e491e88a0577db9a8f3e00d506fe803e7be Mon Sep 17 00:00:00 2001 From: baka Date: Wed, 15 Feb 2017 16:02:24 +0000 Subject: [PATCH] Implements the use of setIndexObject into IndexItemSelectionForm. Is the exception handling correct? git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4573 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/ui/category/IndexItemSelectionForm.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/IndexItemSelectionForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/IndexItemSelectionForm.java index 8f7bdf0e2..ab36e29ef 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/IndexItemSelectionForm.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/IndexItemSelectionForm.java @@ -36,10 +36,7 @@ import com.arsdigita.util.Assert; import com.arsdigita.util.UncheckedWrapperException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.libreccm.categorization.Categorization; -import org.libreccm.categorization.Category; -import org.libreccm.categorization.CategoryManager; -import org.libreccm.categorization.CategoryRepository; +import org.libreccm.categorization.*; import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.core.CcmObject; import org.librecms.contentsection.*; @@ -65,7 +62,6 @@ public class IndexItemSelectionForm extends CMSForm { private static final String NULL_OPTION_VALUE = ""; private static final String NONE_OPTION_VALUE = "None"; - private FormErrorDisplay m_errors; private SaveCancelSection m_saveCancelSection; public IndexItemSelectionForm(CategoryRequestLocal m) { @@ -89,7 +85,7 @@ public class IndexItemSelectionForm extends CMSForm { add(header, ColumnPanel.FULL_WIDTH); // Form errors - m_errors = new FormErrorDisplay(this); + FormErrorDisplay m_errors = new FormErrorDisplay(this); add(m_errors, ColumnPanel.FULL_WIDTH); // Option Group @@ -178,8 +174,12 @@ public class IndexItemSelectionForm extends CMSForm { Optional optionalItem = contentItemRepository.findById(Long.parseLong(selectedValue)); if (optionalItem.isPresent()) { ContentItem item = contentItemManager.getDraftVersion(optionalItem.get(), ContentItem.class); - //category.setIndexObject(item); TODO - categoryRepository.save(category); + try { + categoryManager.setIndexObject(category, item); + categoryRepository.save(category); + } catch (ObjectNotAssignedToCategoryException e) { + throw new FormProcessException(e); + } } }