From 62ae287e53628cdf8c02f2e5077412352f896d79 Mon Sep 17 00:00:00 2001 From: jensp Date: Thu, 6 Jul 2017 08:20:26 +0000 Subject: [PATCH] Missing file git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4845 8810af33-2d31-482b-a856-94f89814c4df --- .../MultiPartArticleFormController.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleFormController.java diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleFormController.java new file mode 100644 index 000000000..a1d9e1703 --- /dev/null +++ b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleFormController.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2017 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.contenttypes.ui.mparticle; + +import org.librecms.contentsection.ContentItem; +import org.librecms.contentsection.ContentItemManager; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.contentsection.Folder; +import org.librecms.contenttypes.MultiPartArticle; + +import java.util.Optional; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.transaction.Transactional; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +public class MultiPartArticleFormController { + + @Inject + private ContentItemRepository itemRepo; + + @Inject + private ContentItemManager itemManager; + + @Transactional(Transactional.TxType.REQUIRED) + protected Optional getArticleFolder(final MultiPartArticle article) { + + final Optional mpa = itemRepo + .findById(article.getObjectId()); + + if (mpa.isPresent()) { + return itemManager.getItemFolder(mpa.get()); + } else { + return Optional.empty(); + } + } + +}