diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java
index 2ad26ac34..d8dc09ede 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java
@@ -74,6 +74,7 @@ import org.librecms.contentsection.ContentType;
import org.librecms.dispatcher.ItemResolver;
import java.io.IOException;
+import java.util.Objects;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
@@ -158,7 +159,7 @@ public class ContentItemPage extends CMSPage implements ActionListener {
private final Link m_previewLink;
private final GlobalNavigation m_globalNavigation;
private final ContentItemContextBar m_contextBar;
-
+
private final StringParameter selectedLanguageParam;
private class ItemRequestLocal extends ContentItemRequestLocal {
@@ -203,11 +204,14 @@ public class ContentItemPage extends CMSPage implements ActionListener {
// Add the selected item language as parameter
selectedLanguageParam = new StringParameter(
SELECTED_LANGUAGE);
- selectedLanguageParam.addParameterListener(new NotNullValidationListener(
- SELECTED_LANGUAGE));
+ selectedLanguageParam.addParameterListener(
+ new NotNullValidationListener(
+ SELECTED_LANGUAGE));
addGlobalStateParam(selectedLanguageParam);
selectedLanguageModel = new ParameterSingleSelectionModel<>(
selectedLanguageParam);
+ selectedLanguageParam
+ .setDefaultValue(KernelConfig.getConfig().getDefaultLanguage());
// Add the content type global state parameter
final LongParameter contentType = new LongParameter(CONTENT_TYPE);
@@ -633,14 +637,21 @@ public class ContentItemPage extends CMSPage implements ActionListener {
@Override
protected Element generateXMLHelper(final PageState state,
final Document parent) {
+
+ Objects.requireNonNull(itemRequestLocal.getContentItem(state),
+ "No ContentItem in current request.");
+
final Element page = super.generateXMLHelper(state, parent);
final Element contenttype = page.newChildElement("bebop:contentType",
BEBOP_XML_NS);
- contenttype.setText(itemRequestLocal
- .getContentItem(state)
- .getContentType()
- .getLabel().getValue(KernelConfig.getConfig().getDefaultLocale()));
+ final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
+
+ final ContentItemPageController controller = cdiUtil
+ .findBean(ContentItemPageController.class);
+ contenttype
+ .setText(controller
+ .getContentTypeLabel(itemRequestLocal.getContentItem(state)));
return page;
}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java
new file mode 100644
index 000000000..7f92badad
--- /dev/null
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ui;
+
+import org.libreccm.l10n.GlobalizationHelper;
+import org.librecms.contentsection.ContentItem;
+import org.librecms.contentsection.ContentItemRepository;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.transaction.Transactional;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+public class ContentItemPageController {
+
+ @Inject
+ private GlobalizationHelper globalizationHelper;
+
+ @Inject
+ private ContentItemRepository itemRepo;
+
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String getContentTypeLabel(final ContentItem item) {
+
+ final ContentItem theItem = itemRepo
+ .findById(item.getObjectId())
+ .orElseThrow(() -> new IllegalArgumentException(String
+ .format("No ContentItem with ID %d in the database.",
+ item.getObjectId())));
+
+ return theItem
+ .getContentType()
+ .getLabel()
+ .getValue(globalizationHelper.getNegotiatedLocale());
+ }
+
+}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleAdminController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleAdminController.java
new file mode 100644
index 000000000..a9d9e1976
--- /dev/null
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleAdminController.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ui.lifecycle;
+
+import org.hibernate.boot.archive.scan.spi.ClassDescriptor;
+import org.libreccm.categorization.Categorization;
+import org.libreccm.categorization.Category;
+import org.librecms.contentsection.ContentItem;
+import org.librecms.contentsection.ContentItemRepository;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.transaction.Transactional;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+public class ItemLifecycleAdminController {
+
+ @Inject
+ private ContentItemRepository itemRepo;
+
+ @Transactional(Transactional.TxType.REQUIRED)
+ public boolean isAssignedToAbstractCategory(final ContentItem item) {
+
+ final ContentItem contentItem = itemRepo
+ .findById(item.getObjectId())
+ .orElseThrow(() -> new IllegalArgumentException(String
+ .format("No ContentItem with ID %d in the database.",
+ item.getObjectId())));
+
+ final long count = contentItem
+ .getCategories()
+ .stream()
+ .map(Categorization::getCategory)
+ .filter(Category::isAbstractCategory)
+ .count();
+
+ return count > 0;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleAdminPane.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleAdminPane.java
index df604589c..510d42b65 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleAdminPane.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleAdminPane.java
@@ -41,7 +41,6 @@ import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker;
import org.librecms.contentsection.privileges.ItemPrivileges;
-
/**
* @author Michael Pih
* @author Jack Chung
@@ -205,13 +204,19 @@ public class ItemLifecycleAdminPane extends BaseItemPane {
*/
private boolean isAssignedToAbstractCategory(final ContentItem item) {
- final long count = item.getCategories().stream()
- .filter(categorization -> {
- return categorization.getCategory().isAbstractCategory();
- })
- .count();
+ final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
+ final ItemLifecycleAdminController controller = cdiUtil
+ .findBean(ItemLifecycleAdminController.class);
- return count > 0;
+ return controller.isAssignedToAbstractCategory(item);
+
+// final long count = item.getCategories().stream()
+// .filter(categorization -> {
+// return categorization.getCategory().isAbstractCategory();
+// })
+// .count();
+//
+// return count > 0;
}
}
diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemManager.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemManager.java
index 38a424f3d..cde8096ec 100644
--- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemManager.java
+++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemManager.java
@@ -72,7 +72,6 @@ import javax.transaction.Transactional;
import org.libreccm.security.PermissionChecker;
import org.librecms.contentsection.privileges.TypePrivileges;
-import java.util.Objects;
/**
* Manager class providing several methods to manipulate {@link ContentItem}s.