Missing file

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4845 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2017-07-06 08:20:26 +00:00
parent fcea2c3fa1
commit 9d8857ac8e
1 changed files with 59 additions and 0 deletions

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class MultiPartArticleFormController {
@Inject
private ContentItemRepository itemRepo;
@Inject
private ContentItemManager itemManager;
@Transactional(Transactional.TxType.REQUIRED)
protected Optional<Folder> getArticleFolder(final MultiPartArticle article) {
final Optional<ContentItem> mpa = itemRepo
.findById(article.getObjectId());
if (mpa.isPresent()) {
return itemManager.getItemFolder(mpa.get());
} else {
return Optional.empty();
}
}
}