indexItem = manager.getIndexObject(m_category
- .getCategory(state))
- .stream()
- .findFirst();
- if (!indexItem.isPresent()) {
- return false;
- } else {
- return permissionChecker.isPermitted(ItemPrivileges.EDIT,
- indexItem.get());
- }
- }
-
- };
-
- private class MoveLink extends ActionLink {
-
- private final Label alternativeLabel;
-
- public MoveLink(final Label label) {
- super(label);
- alternativeLabel = new Label(new GlobalizedMessage(
- "cms.ui.category.cantmoved",
- CmsConstants.CMS_BUNDLE));
- }
-
- @Override
- public void generateXML(final PageState state, final Element parent) {
- if (!isVisible(state)) {
- return;
- }
-
- final Category category = m_category.getCategory(state);
- if (category.getParentCategory() == null) {
- alternativeLabel.generateXML(state, parent);
- } else {
- super.generateXML(state, parent);
- }
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryItemsBrowser.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryItemsBrowser.java
deleted file mode 100755
index 1b11b83d7..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryItemsBrowser.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-
-import com.arsdigita.bebop.*;
-import com.arsdigita.bebop.List;
-import com.arsdigita.bebop.list.ListModel;
-import com.arsdigita.bebop.list.ListModelBuilder;
-import com.arsdigita.bebop.table.TableCellRenderer;
-import com.arsdigita.bebop.util.GlobalizationUtil;
-import com.arsdigita.cms.CMS;
-
-import com.arsdigita.cms.ui.CMSContainer;
-import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
-import com.arsdigita.util.Assert;
-import com.arsdigita.util.LockableImpl;
-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.cdi.utils.CdiUtil;
-import org.libreccm.core.CcmObject;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.ContentSectionManager;
-import org.librecms.dispatcher.ItemResolver;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * Displays a list of items for the given category
- *
- * WARNING: The code to actually list the items is currently a travesty.
- * It needs to be re-written from scratch, by using custom data queries.
- * @version $Id: CategoryItemsBrowser.java 2090 2010-04-17 08:04:14Z pboy $
- */
-public class CategoryItemsBrowser extends Grid {
-
- private static final Logger LOGGER = LogManager.getLogger(
- CategoryItemsBrowser.class);
-
- private RequestLocal m_resolver;
-
- private String m_context;
-
- /**
- * Construct a new CategoryItemsBrowser
- *
- * The {@link SingleSelectionModel} which will provide the
- * current category
- *
- * @param sel the {@link ACSObjectSelectionModel} which will maintain
- * the current category
- *
- * @param numCols the number of columns in the browser
- *
- * @param context the context for the retrieved items. Should be
- * "draft" or "live"
- */
- public CategoryItemsBrowser(ACSObjectSelectionModel sel, int numCols,
- String context) {
- super(null, numCols);
- super.setModelBuilder(new CategoryItemModelBuilder(sel));
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentSectionManager sectionManager = cdiUtil.findBean(ContentSectionManager.class);
- m_context = context;
-
- setRowSelectionModel(sel);
- setEmptyView(new Label(GlobalizationUtil.globalize
- ("cms.ui.category.item.none")));
-
- // Cache the item resolver
- m_resolver = new RequestLocal() {
- public Object initialValue(PageState s) {
- ContentSection section =
- CMS.getContext().getContentSection();
- final ItemResolver itemResolver = sectionManager.getItemResolver(section);
- LOGGER.warn("Item resolver is" + itemResolver.getClass());
- return itemResolver;
- }
- };
-
- setDefaultCellRenderer(new ItemSummaryCellRenderer());
- }
-
- /**
- * @return the current context
- */
- public String getContext() {
- return m_context;
- }
-
- public void setContext(String context) {
- Assert.isUnlocked(this);
- m_context = context;
- }
-
- /**
- * Iterates through all the children of the given Category
- */
- private class CategoryItemModelBuilder extends LockableImpl
- implements ListModelBuilder {
-
- private ACSObjectSelectionModel m_sel;
-
- public CategoryItemModelBuilder(ACSObjectSelectionModel sel) {
- m_sel = sel;
- }
-
-// public DataQuery getDataQuery(PageState s) {
-// Category cat = (Category)m_sel.getSelectedObject(s);
-//
-// ContentSection section = CMS.getContext().getContentSection();
-// User user = (User)Kernel.getContext().getParty();
-// OID oid = null;
-// if (user != null) {
-// oid = user.getOID();
-// }
-// // If the category is the root, list all items
-// if(cat == null || (cat.equals(section.getRootCategory()))) {
-// return ContentPage.getPagesInSectionQuery
-// (section, getContext(), oid);
-// } else {
-// return ContentPage.getPagesInSectionQuery
-// (section, getContext(), cat, oid);
-// }
-// }
-
- @Override
- public ListModel makeModel(List l, PageState state) {
- Category category = (Category) m_sel.getSelectedObject(state);
- java.util.List objects = category
- .getObjects()
- .stream().map(Categorization::getCategorizedObject)
- .filter(x -> x instanceof ContentItem)
- .map(x -> (ContentItem) x)
- .collect(Collectors.toList());
- return new ContentItemListModel(objects);
- }
-
- private class ContentItemListModel implements ListModel {
-
- private final Iterator iterator;
-
- private ContentItem current;
-
- public ContentItemListModel(java.util.List list) {
- this.iterator = list.iterator();
- }
-
- @Override
- public boolean next() {
- if (iterator.hasNext()) {
- current = iterator.next();
- return true;
- }
- return false;
- }
-
- @Override
- public Object getElement() {
- return current;
- }
-
- @Override
- public String getKey() {
- return current.getItemUuid();
- }
- }
- }
-
- /**
- * Renders a ContentItem in preview mode
- */
- private class ItemSummaryCellRenderer
- implements TableCellRenderer {
-
- @Override
- public Component getComponent(Table table, PageState state, Object value,
- boolean isSelected, Object key,
- int row, int column) {
-
-// if(value == null)
- return new Label(GlobalizationUtil.globalize(" "), false);
-
-// DomainObject d = DomainObjectFactory.newInstance((DataObject)value);
-//
-// Assert.isTrue(d instanceof ContentPage);
-// ContentPage p = (ContentPage)d;
-//
-// CMSContainer box = new CMSContainer();
-// Component c;
-//
-// ContentSection section =
-// CMS.getContext().getContentSection();
-//
-// ItemResolver resolver = (ItemResolver)m_resolver.get(state);
-//
-// final String url = resolver.generateItemURL
-// (state, p.getID(), p.getName(), section,
-// resolver.getCurrentContext(state));
-// c = new Link(p.getTitle(), url);
-//
-// c.setClassAttr("title");
-// box.add(c);
-//
-// String summary = p.getSearchSummary();
-// if(summary != null && summary.length() > 0) {
-// c = new Label(summary);
-// c.setClassAttr("summary");
-// box.add(c);
-// }
-//
-// ContentType t = p.getContentType();
-// if(t != null) {
-// c = new Label(t.getName());
-// } else {
-// c = new Label(GlobalizationUtil.globalize("cms.ui.category.item"));
-// }
-// c.setClassAttr("type");
-// box.add(c);
-//
-// box.setClassAttr("itemSummary");
-
-// return box;
- }
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryIteratorListModel.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryIteratorListModel.java
deleted file mode 100755
index f51c86ec3..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryIteratorListModel.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.list.ListModel;
-import org.libreccm.categorization.Category;
-
-import java.util.Iterator;
-
-/**
- * A {@link ListModel} that iterates over categories via an iterator
- *
- * @author Yannick Bülter
- */
-public class CategoryIteratorListModel implements ListModel {
-
- private Iterator m_iter;
- private Category m_cat;
-
- /**
- * Construct a new CategoryIteratorListModel
- *
- * @param iter an {@link Iterator} over all the categories
- * which this model will supply
- */
- public CategoryIteratorListModel(Iterator iter) {
- m_iter = iter;
- m_cat = null;
- }
-
- public boolean next() {
- if(m_iter.hasNext()) {
- m_cat = (Category)m_iter.next();
- return true;
- } else {
- return false;
- }
- }
-
- public Object getElement() {
- return m_cat.getName();
- }
-
- public String getKey() {
- return m_cat.getUniqueId();
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLinks.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLinks.java
deleted file mode 100755
index e7a550231..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLinks.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.List;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.ParameterSingleSelectionModel;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.event.ActionEvent;
-import com.arsdigita.bebop.event.ActionListener;
-import com.arsdigita.bebop.list.ListModel;
-import com.arsdigita.bebop.list.ListModelBuilder;
-import com.arsdigita.bebop.parameters.BigDecimalParameter;
-import com.arsdigita.bebop.util.GlobalizationUtil;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.util.LockableImpl;
-
-import org.libreccm.categorization.Category;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.CmsConstants;
-
-import java.util.ArrayList;
-
-/**
- * A List of all secondary parents of the current category.
- *
- * @author Stanislav Freidin (stas@arsdigita.com)
- * @author Michael Pih (pihman@arsdigita.com)
- * @author Yannick Bülter
- */
-public class CategoryLinks extends List {
-
- public final static String SUB_CATEGORY = "sc";
-
- private final CategoryRequestLocal m_parent;
- private final SingleSelectionModel m_model;
-
- public CategoryLinks(final CategoryRequestLocal parent,
- final SingleSelectionModel model) {
- super(new ParameterSingleSelectionModel(new BigDecimalParameter(
- SUB_CATEGORY)));
- setIdAttr("category_links_list");
-
- m_parent = parent;
- m_model = model;
-
- setModelBuilder(new LinkedCategoryModelBuilder());
-
- // Select the category in the main tree when the
- // user selects it here
- addActionListener(new ActionListener() {
-
- public void actionPerformed(ActionEvent e) {
- final PageState state = e.getPageState();
- final String id = (String) getSelectedKey(state);
-
- if (id != null) {
- m_model.setSelectedKey(state, id);
- }
- }
-
- });
-
- final Label label = new Label(new GlobalizedMessage(
- "cms.ui.category.linked_none",
- CmsConstants.CMS_BUNDLE));
- label.setFontWeight(Label.ITALIC);
- setEmptyView(label);
- }
-
- // Since this part is for non default parents, but there is only one... this is not needed anymore, i guess
- private class LinkedCategoryModelBuilder extends LockableImpl
- implements ListModelBuilder {
-
- @Override
- public ListModel makeModel(List list, PageState state) {
- final Category category = m_parent.getCategory(state);
-
- if (category != null && category.getParentCategory() != null) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryController controller = cdiUtil
- .findBean(CategoryController.class);
- final GlobalizationHelper globalizationHelper = cdiUtil
- .findBean(GlobalizationHelper.class);
- final Category parent = controller
- .getParentCategory(category).get();
-
- java.util.List categories = new ArrayList<>();
- final CategoryListItem parentItem = new CategoryListItem();
- parentItem.setCategoryId(parent.getObjectId());
- final String label = globalizationHelper
- .getValueFromLocalizedString(parent.getTitle(),
- parent::getName);
- parentItem.setLabel(label);
-
- categories.add(parentItem);
-
- return new CategoryListModel(
- categories,
- parent.getObjectId());
-
-// return new CategoryListModel(categories,
-// category.getParentCategory()
-// == null ? null : Long
-// .parseLong(
-// parent
-// .getUniqueId()));
- } else {
- return List.EMPTY_MODEL;
- }
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryListItem.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryListItem.java
deleted file mode 100644
index 23594b1b9..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryListItem.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.category;
-
-import java.util.Objects;
-
-/**
- *
- * @author Jens Pelzetter
- */
-class CategoryListItem implements Comparable {
-
- private long categoryId;
- private String label;
-
- public long getCategoryId() {
- return categoryId;
- }
-
- public void setCategoryId(final long categoryId) {
- this.categoryId = categoryId;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(final String label) {
- this.label = label;
- }
-
- @Override
- public int compareTo(final CategoryListItem other) {
-
- final int result = label.compareTo(other.getLabel());
- if (result == 0) {
- return Long.compare(categoryId, other.getCategoryId());
- } else {
- return result;
- }
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 67 * hash + (int) (categoryId ^ (categoryId >>> 32));
- hash = 67 * hash + Objects.hashCode(label);
- return hash;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof CategoryListItem)) {
- return false;
- }
- final CategoryListItem other = (CategoryListItem) obj;
- if (!other.canEqual(this)) {
- return false;
- }
-
- if (categoryId != other.getCategoryId()) {
- return false;
- }
- return Objects.equals(label, other.getLabel());
- }
-
- public boolean canEqual(final Object obj) {
- return obj instanceof CategoryListItem;
- }
-
- @Override
- public final String toString() {
- return toString("");
- }
-
- public String toString(final String data) {
- return String.format("%s{ "
- + "categoryId = %d,"
- + "label = \"%s\"%s"
- + " }",
- super.toString(),
- categoryId,
- label,
- data);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryListModel.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryListModel.java
deleted file mode 100755
index 8b0217b58..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryListModel.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import java.util.List;
-
-import com.arsdigita.bebop.list.ListModel;
-
-import java.util.Iterator;
-
-/**
- * A {@link ListModel} that iterates over categories via a cursor.
- *
- * @author Yannick Bülter
- * @author Jens Pelzetter
- */
-class CategoryListModel implements ListModel {
-
- private final Iterator iterator;
- private CategoryListItem currentCategory;
- private Long excludedCategoryId;
-
- /**
- * Constructs a new CategoryListModel
- *
- * @param categories
- */
- public CategoryListModel(final List categories) {
- this(categories, null);
- }
-
- /**
- * Constructs a new CategoryListModel
- */
- public CategoryListModel(final List categories,
- final Long excludedCategoryId) {
-
- iterator = categories.iterator();
- this.excludedCategoryId = excludedCategoryId;
- }
-
- @Override
- public boolean next() {
- if (iterator.hasNext()) {
-
- final CategoryListItem next = iterator.next();
- if (excludedCategoryId != null
- && next.getCategoryId() == excludedCategoryId) {
-
- return next();
- } else {
- currentCategory = next;
- return true;
- }
- } else {
- return false;
- }
- }
-
- /**
- * Reads the label of the {@link CategoryListItem}.
- *
- *
- */
- @Override
- public Object getElement() {
- return currentCategory.getLabel();
- }
-
- @Override
- public String getKey() {
- return Long.toString(currentCategory.getCategoryId());
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationAddForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationAddForm.java
deleted file mode 100755
index e3a1bc353..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationAddForm.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2008 Sören Bernstein All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.Text;
-import com.arsdigita.bebop.event.FormInitListener;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.util.GlobalizationUtil;
-import com.arsdigita.dispatcher.AccessDeniedException;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.kernel.KernelConfig;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.categorization.Category;
-import org.libreccm.categorization.CategoryRepository;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.configuration.ConfigurationManager;
-import org.libreccm.security.PermissionChecker;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-
-import java.util.Collection;
-import java.util.Locale;
-
-/**
- * Generates a form for creating new localisations for the given category.
- *
- * This class is part of the admin GUI of CCM and extends the standard form in
- * order to present forms for managing the multi-language categories.
- *
- * @author Sören Bernstein
- * @author Yannick Bülter
- */
-public class CategoryLocalizationAddForm extends CategoryLocalizationForm {
-
- private static final Logger LOGGER = LogManager.getLogger(
- CategoryLocalizationAddForm.class);
-
- /**
- * Creates a new instance of CategoryLocalizationAddForm
- */
- public CategoryLocalizationAddForm(final CategoryRequestLocal category) {
-
- super("AddCategoryLocalization",
- gz("cms.ui.category.localization_add"), category);
-
- super.addInitListener(new InitListener());
- super.addProcessListener(new ProcessListener());
-
- }
-
- // Deaktivate this widget, if category is root
-// public boolean isVisible(PageState state) {
-// return !m_category.getCategory(state).isRoot();
-// }
- private class InitListener implements FormInitListener {
-
- public final void init(final FormSectionEvent e)
- throws FormProcessException {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ConfigurationManager manager = cdiUtil.findBean(
- ConfigurationManager.class);
- final KernelConfig config = manager.findConfiguration(
- KernelConfig.class);
-
- final PageState state = e.getPageState();
- final Category category = m_category.getCategory(state);
-
- // Select one entry
- m_locale.addOption(new Option("",
- new Label(new GlobalizedMessage(
- "cms.ui.select_one",
- CmsConstants.CMS_BUNDLE))),
- state);
- final Collection locales = config.getSupportedLanguages();
- if (locales != null) {
- for (String locale : locales) {
- m_locale.addOption(new Option(locale,
- new Text(new Locale(locale)
- .getDisplayLanguage())),
- state);
- }
- }
- }
-
- }
-
- private final class ProcessListener implements FormProcessListener {
-
- public final void process(final FormSectionEvent e)
- throws FormProcessException {
- LOGGER.debug("Adding a categoryLocalization to category "
- + m_category);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
- final CategoryRepository categoryRepository = cdiUtil.findBean(
- CategoryRepository.class);
-
- final PageState state = e.getPageState();
-
- final Category category = m_category.getCategory(state);
- final Locale locale = new Locale((String) m_locale.getValue(state));
- final String title = (String) m_title.getValue(state);
- final String description = (String) m_description.getValue(state);
-// final String url = (String) m_url.getValue(state);
-// final String isEnabled = (String) m_isEnabled.getValue(state);
-
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Adding localization for locale " + locale
- + " to category " + category);
- }
-
- if (permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_CATEGORIES, category)) {
- category.getTitle().putValue(locale, title);
- category.getDescription().putValue(locale, description);
-// category.setEnabled(isEnabled.equals("yes"));
- categoryRepository.save(category);
-
- } else {
- // XXX user a better exception here.
- // PermissionException doesn't work for this case.
- throw new AccessDeniedException();
- }
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationEditForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationEditForm.java
deleted file mode 100755
index 51525a0f0..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationEditForm.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2008 Sören Bernstein All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.Text;
-import com.arsdigita.bebop.event.FormInitListener;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.dispatcher.AccessDeniedException;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.categorization.Category;
-import org.libreccm.categorization.CategoryRepository;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.security.PermissionChecker;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-
-import java.util.Locale;
-
-/**
- * Generates a form for editing an existing localisation for the given category.
- *
- * This class is part of the admin GUI of CCM and extends the standard form
- * in order to present forms for managing the multi-language categories.
- *
- * @author Sören Bernstein
- * @author Yannick Bülter
- */
-public class CategoryLocalizationEditForm extends CategoryLocalizationForm {
-
- private static final Logger LOGGER = LogManager.getLogger(
- CategoryLocalizationAddForm.class);
-
- private final SingleSelectionModel m_catLocale;
- /**
- * Creates a new instance of CategoryLocalizationEditForm
- */
- public CategoryLocalizationEditForm(final CategoryRequestLocal category, SingleSelectionModel catLocale) {
-
- super("EditCategoryLocalization", gz(
- "cms.ui.category.localization_edit"), category);
-
- m_catLocale = catLocale;
-
- addInitListener(new InitListener());
- addProcessListener(new ProcessListener());
-
- }
-
- /**
- * please add: purpose of this class
- */
- private class InitListener implements FormInitListener {
- public final void init(final FormSectionEvent e)
- throws FormProcessException {
-
- final PageState state = e.getPageState();
- final Category category = m_category.getCategory(state);
-
- final String categoryLocalizationLocale = (String) m_catLocale.getSelectedKey(state);
- final Locale locale = new Locale(categoryLocalizationLocale);
-
- // Hide Locale-Widget and lock it (read-only)
- m_locale.addOption(new Option(categoryLocalizationLocale,
- new Text(locale.getDisplayLanguage())), state);
- m_locale.setValue(state, categoryLocalizationLocale);
-// m_locale.setVisible(state, false);
- m_locale.lock();
-
- m_title.setValue(state, category.getTitle().getValue(locale));
- m_description.setValue(state, category.getDescription().getValue(locale));
-// m_url.setValue(state, category.getName());
-
-// if (category.isEnabled()) {
-// m_isEnabled.setValue(state, "yes");
-// } else {
-// m_isEnabled.setValue(state, "no");
-// }
- }
- }
-
- /**
- * ##todo: document purpose of this
- */
- private class ProcessListener implements FormProcessListener {
- public final void process(final FormSectionEvent e)
- throws FormProcessException {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(PermissionChecker.class);
- final CategoryRepository categoryRepository = cdiUtil.findBean(CategoryRepository.class);
-
- final PageState state = e.getPageState();
- final Category category = m_category.getCategory(state);
-
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Editing localization for locale " + m_locale +
- " for category " + category);
- }
-
- if (permissionChecker.isPermitted(AdminPrivileges.ADMINISTER_CATEGORIES, category)) {
- final Locale locale = new Locale((String) m_locale.getValue(state));
- category.getTitle().putValue(locale, (String) m_title.getValue(state));
- category.getDescription().putValue(locale, (String) m_description.getValue(state));
-// category.setName((String) m_url.getValue(state));
-// category.setEnabled("yes".equals(m_isEnabled.getValue(state)));
- categoryRepository.save(category);
- } else {
- throw new AccessDeniedException();
- }
- }
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationForm.java
deleted file mode 100755
index 6e4d39c69..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationForm.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (C) 2008 Sören Bernstein All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.Embedded;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.event.ParameterEvent;
-import com.arsdigita.bebop.event.ParameterListener;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.form.Hidden;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.RadioGroup;
-import com.arsdigita.bebop.form.SingleSelect;
-import com.arsdigita.bebop.form.TextArea;
-import com.arsdigita.bebop.form.TextField;
-import com.arsdigita.bebop.form.Widget;
-import com.arsdigita.bebop.parameters.NotNullValidationListener;
-import com.arsdigita.bebop.parameters.ParameterData;
-import com.arsdigita.bebop.parameters.ParameterModel;
-import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.bebop.parameters.TrimmedStringParameter;
-import com.arsdigita.bebop.util.GlobalizationUtil;
-import com.arsdigita.cms.ui.BaseForm;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.web.Web;
-import com.arsdigita.xml.Element;
-import org.apache.logging.log4j.LogManager;
-import org.libreccm.categorization.Category;
-
-import java.util.List;
-import java.util.TooManyListenersException;
-
-/**
- * Base class for CategoryLocalizationAddForm and CategoryLocalizationEditForm.
- *
- * This class is part of the admin GUI of CCM and extends the standard form in order to present
- * forms for managing the multi-language categories.
- *
- * @author Sören Bernstein
- * @author Yannick Bülter
- */
-public class CategoryLocalizationForm extends BaseForm {
-
- private static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger(
- CategoryLocalizationForm.class);
-
- final CategoryRequestLocal m_category;
- final SingleSelect m_locale;
- final TextField m_title;
- final TextArea m_description;
- //final TextField m_url;
-// final Hidden m_url;
-// final RadioGroup m_isEnabled;
-// private Embedded m_script = new Embedded(String.format(
-// "",
-// Web.getWebappContextPath()),
-// false);
-
- private final static String LOCALE = "locale";
- private final static String TITLE = "title";
- private final static String DESCRIPTION = "description";
- private final static String URL = "url";
- private final static String IS_ENABLED = "isEnabled";
-
- /**
- * Creates a new instance of CategoryLocalizationForm.
- *
- * @param key
- * @param heading
- * @param category
- */
- public CategoryLocalizationForm(final String key,
- final GlobalizedMessage heading,
- final CategoryRequestLocal category) {
-
- super(key, heading);
-
- m_category = category;
-
- // Parameter-Model for SingleSelect
- ParameterModel localeParam = new StringParameter(LOCALE);
- localeParam.addParameterListener(new StringInRangeValidationListener(0, 2));
-
- m_locale = new SingleSelect(localeParam);
- m_locale.addValidationListener(e -> {
-
- // the --select one-- option is not allowed
- ParameterData data = e.getParameterData();
- String code = (String) data.getValue();
- if (code == null || code.length() == 0) {
- data.addError(
- GlobalizationUtil.globalize(
- "cms.ui.category.localization_error_locale"));
- }
- });
-
- addField(gz("cms.ui.category.localization_locale"), m_locale);
-
- m_title = new TextField(new TrimmedStringParameter(TITLE));
- addField(gz("cms.ui.title"), m_title);
-
- m_title.setSize(30);
- m_title.setMaxLength(200);
- m_title.addValidationListener(new NotNullValidationListener());
- m_title.setOnFocus("if (this.form." + URL + ".value == '') { "
- + " defaulting = true; this.form." + URL
- + ".value = urlize(this.value); }");
- m_title.setOnKeyUp("if (defaulting) { this.form." + URL + ".value = urlize(this.value) }");
-
- // is enabled?
-// m_isEnabled = new RadioGroup(IS_ENABLED);
-// m_isEnabled.addOption(new Option("no", new Label(gz("cms.ui.no"))));
-// m_isEnabled.addOption(new Option("yes", new Label(gz("cms.ui.yes"))));
-// addField(gz("cms.ui.category.is_enabled"), m_isEnabled);
-
- m_description = new TextArea(new TrimmedStringParameter(DESCRIPTION));
- addField(gz("cms.ui.description"), m_description);
-
- m_description.setWrap(TextArea.SOFT);
- m_description.setRows(5);
- m_description.setCols(40);
-
- // URL
- // JavaScript auto-url generation is off by default.
- // It is turned on under the following circumstances
- //
- // * If the url is null, upon starting edit of the title
- // * If the url is null, upon finishing edit of name
- //
- // The rationale is that, auto-url generation is useful
- // if the url is currently null, but once a name has been
- // created you don't want to subsequently change it since
- // it breaks URLs & potentially overwrites the user's
- // customizations.
-// m_url = new TextField(new TrimmedStringParameter(URL));
-// m_url.setSize(30);
-// m_url.setMaxLength(200);
-// m_url.addValidationListener(new NotNullValidationListener());
-// m_url.setOnFocus("defaulting = false");
-// m_url.setOnBlur("if (this.value == '') "
-// + "{ defaulting = true; this.value = urlize(this.form." + TITLE
-// + ".value) } " + "else { this.value = urlize(this.value); }");
-// addField(gz("cms.ui.category.url"), m_url);
- //jensp 2014-09-16: Localisation of URLs is not useful but causes problems when resolving
- //the URLs. Also, a category is the same resource for every language variant therefore
- //the URL should be the same.
- //Changed field to Hidden, initalised with URL of category itself.
-// m_url = new Hidden(new TrimmedStringParameter(URL));
-// try {
-// m_url.addPrintListener(new PrintListener() {
-//
-// @Override
-// public void prepare(final PrintEvent event) {
-// final Hidden target = (Hidden) event.getTarget();
-// final PageState state = event.getPageState();
-//
-// final Category cat = m_category.getCategory(state);
-//
-// target.setValue(state, cat.getName());
-// }
-//
-// });
-// } catch (TooManyListenersException | IllegalArgumentException ex) {
-// LOGGER.fatal(ex);
-// }
-// addField(gz("cms.ui.category.url"), m_url);
-
- addAction(new Finish());
- addAction(new Cancel());
-
- }
-
- @Override
- public void generateXML(PageState ps, Element parent) {
-// m_script.generateXML(ps, parent);
- super.generateXML(ps, parent);
- }
-
- /**
- * Purpose:
- *
- * XXXToDo: Should be extended with the function: Names have to be unambiguous in the selected
- * language
- */
- class NameUniqueListener implements ParameterListener {
-
- private final CategoryRequestLocal m_category;
- private final Widget m_widget;
- private final int m_type;
- final static int NAME_FIELD = 1;
- public final static int URL_FIELD = 2;
-
- NameUniqueListener(final CategoryRequestLocal category) {
- this(category, m_title, NAME_FIELD);
- }
-
- NameUniqueListener(final CategoryRequestLocal category,
- Widget widget, int type) {
- m_category = category;
- m_widget = widget;
- m_type = type;
- }
-
- /**
- * Purpose:
- *
- * XXX provisional, has to be adapted
- *
- * @param e
- *
- * @throws com.arsdigita.bebop.FormProcessException
- */
- @Override
- public final void validate(final ParameterEvent e)
- throws FormProcessException {
- final PageState state = e.getPageState();
- final String title = (String) m_widget.getValue(state);
-
- final Category category = m_category.getCategory(state);
-
- final List children = category.getSubCategories();
-
- for (Category child : children) {
- String compField = child.getName();
- if (compField.equalsIgnoreCase(title)
- || !m_category.getCategory(state).equals(child)) {
- throw new FormProcessException(GlobalizationUtil.globalize("cms.ui.category.name_not_unique"));
- }
- }
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationTable.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationTable.java
deleted file mode 100755
index 600e01150..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationTable.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (C) 2008 Sören Bernstein All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.ControlLink;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.Table;
-import com.arsdigita.bebop.event.TableActionEvent;
-import com.arsdigita.bebop.event.TableActionListener;
-import com.arsdigita.bebop.table.TableCellRenderer;
-import com.arsdigita.bebop.table.TableColumn;
-import com.arsdigita.bebop.table.TableColumnModel;
-import com.arsdigita.bebop.table.TableModel;
-import com.arsdigita.bebop.table.TableModelBuilder;
-import com.arsdigita.bebop.util.GlobalizationUtil;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.util.LockableImpl;
-
-import org.libreccm.categorization.Category;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.libreccm.l10n.GlobalizedMessagesUtil;
-import org.libreccm.security.PermissionChecker;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Lists all existing localizations for a selected category.
- *
- * This class is part of the admin GUI of CCM and extends the standard form in
- * order to present forms for managing the multi-language categories.
- *
- * @author Sören Bernstein
- * @author Yannick Bülter
- */
-public class CategoryLocalizationTable extends Table implements
- TableActionListener {
-
- private static final String TABLE_COL_LANG = "table_col_lang";
- private static final String TABLE_COL_DEL = "table_col_del";
-
- private static final int COL_LOCALE = 0;
- private static final int COL_TITLE = 1;
- private static final int COL_DESCRIPTION = 2;
- private static final int COL_EDIT = 3;
- private static final int COL_DEL = 4;
-
- private final CategoryRequestLocal m_category;
- private final SingleSelectionModel m_model;
- private final SingleSelectionModel m_catLocale;
-
- /**
- * Creates a new instance of CategoryLocalizationTable
- */
- public CategoryLocalizationTable(final CategoryRequestLocal category,
- final SingleSelectionModel model,
- final SingleSelectionModel catLocale) {
-
- super();
-
- m_category = category;
- m_model = model;
- m_catLocale = catLocale;
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final GlobalizationHelper globalizationHelper = cdiUtil
- .findBean(GlobalizationHelper.class);
- final GlobalizedMessagesUtil messagesUtil = globalizationHelper
- .getGlobalizedMessagesUtil(CmsConstants.CMS_BUNDLE);
-
- // if table is empty:
- setEmptyView(new Label(messagesUtil
- .getGlobalizedMessage("cms.ui.category.localization_none")));
- final TableColumnModel columnModel = getColumnModel();
-
- // define columns
- columnModel.add(new TableColumn(
- COL_LOCALE,
- messagesUtil.getGlobalizedMessage(
- "cms.ui.category.localization.locale"),
- TABLE_COL_LANG));
- columnModel.add(new TableColumn(
- COL_TITLE,
- messagesUtil
- .getGlobalizedMessage("cms.ui.category.localization_title")));
- columnModel.add(new TableColumn(
- COL_DESCRIPTION,
- messagesUtil.getGlobalizedMessage(
- "cms.ui.category.localization_description")));
- columnModel.add(new TableColumn(
- COL_EDIT,
- messagesUtil
- .getGlobalizedMessage("cms.ui.category.localization_edit")));
- columnModel.add(new TableColumn(
- COL_DEL,
- messagesUtil
- .getGlobalizedMessage("cms.ui.category.localization_action"),
- TABLE_COL_DEL));
-
- super.setModelBuilder(new CategoryLocalizationTableModelBuilder());
-
- columnModel.get(0).setCellRenderer(new EditCellRenderer());
- columnModel.get(4).setCellRenderer(new DeleteCellRenderer());
-
- super.addTableActionListener(this);
-
- }
-
- private class CategoryLocalizationTableModelBuilder extends LockableImpl
- implements TableModelBuilder {
-
- @Override
- public TableModel makeModel(final Table table, final PageState state) {
-
- final Category category = m_category.getCategory(state);
-
- if (category == null) {
- return Table.EMPTY_MODEL;
- } else {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryLocalizationTableController controller = cdiUtil
- .findBean(CategoryLocalizationTableController.class);
-
- final List rows = controller
- .getCategoryLocalizations(category);
- return new CategoryLocalizationTableModel(table, rows);
- }
- }
-
- }
-
- private class CategoryLocalizationTableModel implements TableModel {
-
- private final Table table;
- private final Iterator iterator;
- private CategoryLocalizationTableRow currentRow;
-
- private CategoryLocalizationTableModel(
- final Table table,
- final List rows) {
-
- this.table = table;
- iterator = rows.iterator();
- }
-
- @Override
- public int getColumnCount() {
- return table.getColumnModel().size();
- }
-
- @Override
- public boolean nextRow() {
-
- if (iterator.hasNext()) {
- currentRow = iterator.next();
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public Object getElementAt(final int columnIndex) {
-
- switch (columnIndex) {
- case COL_LOCALE:
- return currentRow.getLocale();
- case COL_TITLE:
- return currentRow.getTitle();
- case COL_DESCRIPTION:
- return currentRow.getDescription();
- case COL_EDIT:
- return new GlobalizedMessage("cms.ui.edit",
- CmsConstants.CMS_BUNDLE);
- case COL_DEL:
- return new GlobalizedMessage("cms.ui.delete",
- CmsConstants.CMS_BUNDLE);
- default:
- throw new IllegalArgumentException("Illegal Column Index");
- }
- }
-
- /**
- *
- * @see com.arsdigita.bebop.table.TableModel#getKeyAt(int)
- */
- @Override
- public Object getKeyAt(final int columnIndex) {
- return currentRow.getLocale();
- }
-
- }
-
- private class EditCellRenderer extends LockableImpl implements
- TableCellRenderer {
-
- @Override
- public Component getComponent(final Table table,
- final PageState state,
- final Object value,
- final boolean isSelected,
- final Object key,
- final int row,
- final int column) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
-
- if (permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_CATEGORIES, m_category.getCategory(
- state))) {
- return new ControlLink(value.toString());
- } else {
- return new Label(GlobalizationUtil.globalize(value.toString()));
- }
- }
-
- }
-
- private class DeleteCellRenderer extends LockableImpl implements
- TableCellRenderer {
-
- @Override
- public Component getComponent(final Table table,
- final PageState state,
- final Object value,
- final boolean isSelected,
- final Object key,
- final int row,
- final int column) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
-
- if (permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_CATEGORIES, m_category.getCategory(
- state))) {
- ControlLink link = new ControlLink(value.toString());
- link.setConfirmation(GlobalizationUtil.globalize(
- "cms.ui.category.localization_confirm_delete"));
- return link;
- } else {
- return null;
- }
- }
-
- }
-
- /**
- * Provide implementation to TableActionListener method. Code that comes
- * into picture when a link on the table is clicked. Handles edit and delete
- * event.
- */
- @Override
- public void cellSelected(final TableActionEvent event) {
-
- PageState state = event.getPageState();
-
-// // Get selected CategoryLocalization
-// CategoryLocalization categoryLocalization =
-// new CategoryLocalization(new BigDecimal(evt.getRowKey().toString()));
-//
-// // Get Category
-// Category category = m_category.getCategory(state);
-//
-// // Get selected column
-// TableColumn col = getColumnModel().get(evt.getColumn().intValue());
-//
-// // Edit
-// if (col.getHeaderKey().toString().equals(TABLE_COL_LANG)) {
-// m_catLocale.setSelectedKey(state, categoryLocalization.getLocale());
-// }
-//
-// // Delete
-// if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
-// category.delLanguage(categoryLocalization.getLocale());
-// }
- }
-
- /**
- * provide Implementation to TableActionListener method. Does nothing in our
- * case.
- */
- @Override
- public void headSelected(final TableActionEvent event) {
- //Nothing
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationTableController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationTableController.java
deleted file mode 100644
index 2700dfa43..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationTableController.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2018 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.category;
-
-import org.libreccm.categorization.Category;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import javax.enterprise.context.RequestScoped;
-import javax.transaction.Transactional;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-class CategoryLocalizationTableController {
-
- @Transactional(Transactional.TxType.REQUIRED)
- protected List getCategoryLocalizations(
- final Category forCategory) {
-
- final Map localizations
- = new HashMap<>();
-
- final Set locales = new HashSet<>();
- locales.addAll(forCategory.getTitle().getAvailableLocales());
- locales.addAll(forCategory.getDescription().getAvailableLocales());
-
- return locales
- .stream()
- .map(locale -> generateRow(locale, forCategory))
- .sorted()
- .collect(Collectors.toList());
- }
-
- private CategoryLocalizationTableRow generateRow(final Locale locale,
- final Category category) {
-
- final CategoryLocalizationTableRow row
- = new CategoryLocalizationTableRow(
- locale);
-
- if (category.getTitle().hasValue(locale)) {
- row.setTitle(category.getTitle().getValue(locale));
- }
-
- if (category.getDescription().hasValue(locale)) {
- row.setDescription(category.getDescription().getValue(locale));
- }
-
- return row;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationTableRow.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationTableRow.java
deleted file mode 100644
index 7bf6bd3fd..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLocalizationTableRow.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2018 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.category;
-
-import java.util.Locale;
-import java.util.Objects;
-
-/**
- *
- * @author Jens Pelzetter
- */
-class CategoryLocalizationTableRow
- implements Comparable {
-
- private final Locale locale;
- private String title;
- private String description;
-
- public CategoryLocalizationTableRow(final Locale locale) {
- this.locale = locale;
- }
-
- public Locale getLocale() {
- return locale;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(final String title) {
- this.title = title;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(final String description) {
- this.description = description;
- }
-
- @Override
- public int compareTo(final CategoryLocalizationTableRow other) {
- return locale.toString().compareTo(other.getLocale().toString());
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 53 * hash + Objects.hashCode(locale);
- hash = 53 * hash + Objects.hashCode(title);
- hash = 53 * hash + Objects.hashCode(description);
- return hash;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof CategoryLocalizationTableRow)) {
- return false;
- }
- final CategoryLocalizationTableRow other
- = (CategoryLocalizationTableRow) obj;
- if (!other.canEqual(this)) {
- return false;
- }
- if (!Objects.equals(title, other.getTitle())) {
- return false;
- }
- if (!Objects.equals(description, other.getDescription())) {
- return false;
- }
- return Objects.equals(locale, other.getLocale());
- }
-
- public boolean canEqual(final Object obj) {
- return obj instanceof CategoryLocalizationTableRow;
- }
-
- @Override
- public String toString() {
- return toString("");
- }
-
- public String toString(final String data) {
- return String.format("%s{ "
- + "locale = \"%s\", "
- + "title = \"%s\", "
- + "description = \"%s\"%s"
- + " }",
- super.toString(),
- Objects.toString(locale),
- title,
- description,
- data);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryMoveForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryMoveForm.java
deleted file mode 100644
index 3e908f7d1..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryMoveForm.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2013 Jens Pelzetter All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.*;
-import com.arsdigita.bebop.event.ChangeEvent;
-import com.arsdigita.bebop.event.ChangeListener;
-import com.arsdigita.bebop.event.FormInitListener;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.parameters.ParameterModel;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.bebop.util.GlobalizationUtil;
-import com.arsdigita.cms.ui.BaseTree;
-import com.arsdigita.cms.ui.CMSForm;
-import com.arsdigita.cms.ui.FormSecurityListener;
-import com.arsdigita.util.Assert;
-import org.libreccm.categorization.Category;
-import org.libreccm.categorization.CategoryManager;
-import org.libreccm.categorization.CategoryRepository;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-
-import java.math.BigDecimal;
-import java.util.Optional;
-
-/**
- *
- * @author Jens Pelzetter
- */
-public class CategoryMoveForm extends CMSForm {
-
- public static final String CONTEXT_SELECTED = "sel_context";
- //private static final String DEFAULT_USE_CONTEXT =
- // CategoryUseContextModelBuilder.DEFAULT_USE_CONTEXT;
- private final CategoryRequestLocal selectedCategory;
- private final SaveCancelSection saveCancelSection;
- private final ChangeListener changeListener;
- private final SingleSelectionModel selectionModel;
- private final Tree categoryTree;
-
- public CategoryMoveForm(final CategoryRequestLocal selectedCategory,
- final SingleSelectionModel contextModel) {
-
- super("MoveCategory");
- setMethod(Form.POST);
- this.selectedCategory = selectedCategory;
-
- final Label header = new Label(GlobalizationUtil.globalize("cms.ui.category.move"));
- //final Label header = new Label();
- header.addPrintListener(new PrintListener() {
- @Override
- public void prepare(final PrintEvent event) {
- final String[] args = new String[1];
- args[0] = selectedCategory.getCategory(event.getPageState()).getName();
-
- final Label target = (Label) event.getTarget();
- target.setLabel(GlobalizationUtil.globalize("cms.ui.move.category", args));
- }
-
- });
-
- header.setFontWeight(Label.BOLD);
- add(header, ColumnPanel.FULL_WIDTH);
-
- changeListener = new TreeChangeListener();
- selectionModel = new ParameterSingleSelectionModel(new StringParameter("selectedCategory"));
- categoryTree = new BaseTree(new CategoryTreeModelBuilder(contextModel));
- categoryTree.addChangeListener(changeListener);
-
- add(categoryTree);
-
- saveCancelSection = new SaveCancelSection();
- add(saveCancelSection);
-
- addInitListener(new InitListener());
- addProcessListener(new ProcessListener());
- addSubmissionListener(new FormSecurityListener(AdminPrivileges.ADMINISTER_CATEGORIES));
-
- }
-
- protected Submit getCancelButton() {
- return saveCancelSection.getCancelButton();
- }
-
- protected Category getCategory(final PageState state) {
- final Category category = selectedCategory.getCategory(state);
- Assert.exists(category);
- return category;
- }
-
- private class TreeChangeListener implements ChangeListener {
-
- public TreeChangeListener() {
- //Nothing
- }
-
- @Override
- public void stateChanged(final ChangeEvent event) {
- //Nothing for now
- }
-
- }
-
- private class InitListener implements FormInitListener {
-
- public InitListener() {
- //Nothing
- }
-
- @Override
- public void init(final FormSectionEvent event) throws FormProcessException {
- //Nothing
- }
-
- }
-
- private class ProcessListener implements FormProcessListener {
-
- public ProcessListener() {
- //Nothing
- }
-
- @Override
- public void process(final FormSectionEvent event) throws FormProcessException {
- final PageState state = event.getPageState();
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryRepository categoryRepository = cdiUtil.findBean(CategoryRepository.class);
- final CategoryManager categoryManager = cdiUtil.findBean(CategoryManager.class);
-
- if (saveCancelSection.getSaveButton().isSelected(state)
- && !(categoryTree.getSelectedKey(state).equals(selectedCategory.getCategory(state).getUniqueId()))) {
-
- final Category categoryToMove = selectedCategory.getCategory(state);
- final String targetKey = (String) categoryTree.getSelectedKey(state);
-
- final Optional categoryOptional = categoryRepository.findById(Long.parseLong(targetKey));
- if (categoryOptional.isPresent()) {
- final Category target = categoryOptional.get();
-
- final Category parent = categoryToMove.getParentCategory();
-
- categoryManager.removeSubCategoryFromCategory(categoryToMove, parent);
- categoryRepository.save(parent);
-
- categoryManager.addSubCategoryToCategory(categoryToMove, target);
- categoryToMove.setParentCategory(target);
-
- categoryRepository.save(target);
- categoryRepository.save(categoryToMove);
- } else {
- throw new FormProcessException(GlobalizationUtil.globalize("Category with id" + targetKey + " does not exist!"));
- }
- }
-
- categoryTree.clearSelection(state);
- categoryTree.clearExpansionState(state);
- }
-
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryRequestLocal.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryRequestLocal.java
deleted file mode 100755
index 9169018d0..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryRequestLocal.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.RequestLocal;
-
-import org.libreccm.categorization.Category;
-
-public class CategoryRequestLocal extends RequestLocal {
-
- public final Category getCategory(final PageState state) {
- return (Category) get(state);
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryTreeModelBuilder.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryTreeModelBuilder.java
deleted file mode 100755
index 5175a25cb..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryTreeModelBuilder.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.Tree;
-import com.arsdigita.bebop.tree.TreeModel;
-import com.arsdigita.bebop.tree.TreeModelBuilder;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.util.LockableImpl;
-
-import org.libreccm.categorization.Category;
-import org.libreccm.categorization.CategoryTreeModelLite;
-import org.libreccm.categorization.Domain;
-import org.libreccm.categorization.DomainOwnership;
-import org.libreccm.categorization.DomainRepository;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.contentsection.ContentSection;
-
-/**
- * Lists category tree.
- *
- * @author Tri Tran (tri@arsdigita.com)
- * @author Yannick Bülter
- */
-class CategoryTreeModelBuilder extends LockableImpl
- implements TreeModelBuilder {
-
-// private static String DEFAULT_USE_CONTEXT = "";
- private final SingleSelectionModel selectedCategorySystem;
-
- public CategoryTreeModelBuilder() {
- this(null);
- }
-
- public CategoryTreeModelBuilder(
- final SingleSelectionModel selectedCategorySystem) {
-
- super();
- this.selectedCategorySystem = selectedCategorySystem;
- }
-
- @Override
- public final TreeModel makeModel(final Tree tree, final PageState state) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final Category root;
-
- if (selectedCategorySystem.getSelectedKey(state) == null) {
- final ContentSection section = CMS.getContext().getContentSection();
- final CategoryAdminController controller = cdiUtil
- .findBean(CategoryAdminController.class);
- final java.util.List ownerships
- = controller
- .retrieveDomains(section);
- if (ownerships == null || ownerships.isEmpty()) {
- root = null;
- } else {
- root = ownerships.get(0).getDomain().getRoot();
- }
- } else {
- final DomainRepository domainRepo = cdiUtil
- .findBean(DomainRepository.class);
- final Domain categorySystem = domainRepo
- .findById(Long.parseLong(selectedCategorySystem
- .getSelectedKey(state)))
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No Domain with ID %s in the database.",
- selectedCategorySystem.getSelectedKey(state))));
-
- root = categorySystem.getRoot();
- }
-
-// if (DEFAULT_USE_CONTEXT.equals(selectedCategorySystem.getSelectedKey(
-// state))) {
-// final ContentSection section = CMS
-// .getContext()
-// .getContentSection();
-//
-// final CategoryAdminController controller = cdiUtil
-// .findBean(CategoryAdminController.class);
-// final java.util.List ownerships
-// = controller
-// .retrieveDomains(section);
-// root = ownerships.get(0).getDomain().getRoot();
-// } else {
-// final CategoryRepository categoryRepo = cdiUtil
-// .findBean(CategoryRepository.class);
-// root = categoryRepo
-// .findById(Long.parseLong((String) m_contextModel
-// .getSelectedKey(state)))
-// .orElseThrow(() -> new UnexpectedErrorException(String
-// .format("No Category with ID %s in the database.",
-// m_contextModel.getSelectedKey(state))));
-// }
- return new CategoryTreeModelLite(root);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryUseContextModelBuilder.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryUseContextModelBuilder.java
deleted file mode 100755
index b77ac0021..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryUseContextModelBuilder.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.List;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.list.AbstractListModelBuilder;
-import com.arsdigita.bebop.list.ListModel;
-import com.arsdigita.cms.CMS;
-
-import org.libreccm.categorization.Domain;
-import org.libreccm.categorization.DomainOwnership;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.contentsection.ContentSection;
-
-import java.util.Iterator;
-
-/**
- * Builds a list of category use contexts for the current content section.
- *
- * @author Yannick Bülter
- * @author Scott Seago
- */
-class CategoryUseContextModelBuilder extends AbstractListModelBuilder {
-
- @Override
- public final ListModel makeModel(final List list, final PageState state) {
- return new Model();
- }
-
- private class Model implements ListModel {
-
- private final Iterator roots;
- private DomainOwnership current;
-
- public Model() {
- final ContentSection section = CMS
- .getContext()
- .getContentSection();
-
- final CategoryAdminController controller = CdiUtil
- .createCdiUtil()
- .findBean(CategoryAdminController.class);
-
- roots = controller.retrieveDomains(section).iterator();
- current = null;
- }
-
- @Override
- public boolean next() {
- if (roots.hasNext()) {
- current = roots.next();
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public Object getElement() {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final GlobalizationHelper globalizationHelper = cdiUtil
- .findBean(GlobalizationHelper.class);
- final Domain categorySystem = current.getDomain();
- if (categorySystem
- .getTitle()
- .hasValue(globalizationHelper.getNegotiatedLocale())) {
-
- return globalizationHelper
- .getValueFromLocalizedString(current.getDomain().getTitle());
- } else {
- return categorySystem.getDomainKey();
- }
-
- }
-
- @Override
- public String getKey() {
-
- return Long.toString(current.getDomain().getObjectId());
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/ContentItemListModel.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/ContentItemListModel.java
deleted file mode 100755
index e4646a434..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/ContentItemListModel.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.list.ListModel;
-import org.librecms.contentsection.ContentItem;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * A {@link ListModel} that iterates over content items via a cursor.
- *
- * @author Yannick Bülter
- */
-public final class ContentItemListModel implements ListModel {
-
- private ContentItem m_contentItem;
- private long m_excludedID;
- private Iterator iterator;
-
-
- /**
- * Constructs a new ContentItemListModel
- */
- public ContentItemListModel(List coll) {
- this(coll, -1); //Hopefully a decent replacement for null in BigDecimal. Negative ids would be weird...
- }
-
- /**
- * Constructs a new ContentItemListModel
- */
- public ContentItemListModel(List coll,
- long excludedID) {
-
- m_excludedID = excludedID;
- m_contentItem = null;
- iterator = coll.iterator();
- }
-
- public boolean next() {
- if (iterator.hasNext()) {
- final ContentItem contentItem = iterator.next();
- if (Long.parseLong(contentItem.getItemUuid()) == m_excludedID) {
- return next();
- } else {
- m_contentItem = contentItem;
- return true;
- }
- } else {
- return false;
- }
- }
-
- private ContentItem getContentItem() {
- if ( m_contentItem == null ) {
- throw new IllegalStateException("call next() first");
- }
- return m_contentItem;
- }
-
- /**
- * Reads the name of the content item.
- *
- */
- public Object getElement() {
- return getContentItem().getName();
- }
-
- public String getKey() {
- return getContentItem().getItemUuid();
- }
-}
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
deleted file mode 100755
index c944e0062..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/IndexItemSelectionForm.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.ColumnPanel;
-import com.arsdigita.bebop.Form;
-import com.arsdigita.bebop.FormData;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.Link;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SaveCancelSection;
-import com.arsdigita.bebop.Text;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.form.FormErrorDisplay;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.RadioGroup;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.parameters.ParameterData;
-import com.arsdigita.bebop.parameters.StringParameter;
-
-import com.arsdigita.cms.CMS;
-import com.arsdigita.cms.ui.CMSForm;
-import com.arsdigita.cms.ui.FormSecurityListener;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.categorization.Category;
-import org.libreccm.categorization.CategoryManager;
-import org.libreccm.categorization.CategoryRepository;
-import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.core.CcmObject;
-import org.libreccm.core.UnexpectedErrorException;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.libreccm.l10n.GlobalizedMessagesUtil;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentItemManager;
-import org.librecms.contentsection.ContentItemRepository;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.ContentSectionManager;
-
-import org.librecms.contentsection.privileges.AdminPrivileges;
-import org.librecms.dispatcher.ItemResolver;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.TooManyListenersException;
-
-/**
- * Allows the user to select an index item to display when the front end user is
- * browsing by Category
- *
- * @author Randy Graebner (randyg@alum.mit.edu)
- * @author Yannick Bülter
- * @author Jens Pelzetter
- */
-public class IndexItemSelectionForm extends CMSForm {
-
- private static final Logger LOGGER = LogManager.getLogger(
- IndexItemSelectionForm.class);
-
- private static final String NULL_OPTION_VALUE = "";
- private static final String NONE_OPTION_VALUE = "None";
-
- private final CategoryRequestLocal selectedCategory;
- private RadioGroup optionsGroup;
- private final SaveCancelSection saveCancelSection;
-
- public IndexItemSelectionForm(final CategoryRequestLocal selectedCategory) {
-
- super("EditCategory");
- super.setMethod(Form.POST);
-
- this.selectedCategory = selectedCategory;
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final GlobalizationHelper globalizationHelper = cdiUtil
- .findBean(GlobalizationHelper.class);
- final GlobalizedMessagesUtil messagesUtil = globalizationHelper
- .getGlobalizedMessagesUtil(CmsConstants.CMS_BUNDLE);
-
- // Form header
- final Label header = new Label(messagesUtil
- .getGlobalizedMessage("cms.ui.category.select_index_item"));
- header.setFontWeight(Label.BOLD);
- super.add(header, ColumnPanel.FULL_WIDTH);
-
- // Form errors
- final FormErrorDisplay errorsDisplay = new FormErrorDisplay(this);
- super.add(errorsDisplay, ColumnPanel.FULL_WIDTH);
-
- // Option Group
- optionsGroup = new RadioGroup(new StringParameter("items"));
- try {
- optionsGroup.addPrintListener(this::printOptionsGroup);
- } catch (TooManyListenersException ex) {
- LOGGER.error("Error adding init listener to Radio Group", ex);
- throw new UnexpectedErrorException(ex);
- }
- optionsGroup.setLayout(RadioGroup.VERTICAL);
- super.add(optionsGroup);
-
- // Save and cancel buttons
- saveCancelSection = new SaveCancelSection();
- super.add(saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
-
- super.addSubmissionListener(new FormSecurityListener(
- AdminPrivileges.ADMINISTER_CATEGORIES));
-
- // Process listener
- super.addProcessListener(this::process);
- }
-
- private void printOptionsGroup(final PrintEvent event) {
-
- final RadioGroup group = (RadioGroup) event.getTarget();
- final PageState state = event.getPageState();
- final Category category = getCategory(event.getPageState());
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryAdminController controller = cdiUtil
- .findBean(CategoryAdminController.class);
- final ContentItemManager itemManager = cdiUtil
- .findBean(ContentItemManager.class);
- final CategoryManager categoryManager = cdiUtil
- .findBean(CategoryManager.class);
- final ContentSectionManager sectionManager = cdiUtil
- .findBean(ContentSectionManager.class);
- final GlobalizationHelper globalizationHelper = cdiUtil
- .findBean(GlobalizationHelper.class);
- final GlobalizedMessagesUtil messagesUtil = globalizationHelper
- .getGlobalizedMessagesUtil(CmsConstants.CMS_BUNDLE);
-
- group.clearOptions();
-
- // option for NO index Object
- group.addOption(
- new Option(NONE_OPTION_VALUE,
- new Label(messagesUtil
- .getGlobalizedMessage("cms.ui.category.non_option"))));
-
- // option for inheriting from the parent category
- if (category.getParentCategory() != null) {
- group.addOption(
- new Option(NULL_OPTION_VALUE,
- new Label(messagesUtil
- .getGlobalizedMessage(
- "cms.ui.category.inherit_parent"))));
- }
-
- final ContentSection section = CMS.getContext()
- .getContentSection();
- final ItemResolver itemResolver = sectionManager
- .getItemResolver(section);
-
- final List assignedItems = controller
- .retrieveAssignedContentItems(category);
- for (final ContentItem item : assignedItems) {
-
- final Link link = new Link(
- new Text(item.getDisplayName()),
- itemResolver.generateItemURL(
- state,
- item.getObjectId(),
- item.getDisplayName(),
- section,
- item.getVersion().name()
- )
- );
- //add the option with the link
- group.addOption(new Option(Long.toString(item.getObjectId()), link));
- }
-
- // get currently selected item
- final Optional optionalIndexObject = categoryManager
- .getIndexObject(category)
- .stream()
- .findFirst();
- if (optionalIndexObject.isPresent()) {
- final ContentItem indexItem
- = (ContentItem) optionalIndexObject
- .get();
- final ContentItem liveItem = itemManager
- .getLiveVersion(indexItem, ContentItem.class)
- .get();
- group.setValue(
- state,
- Long.toString(liveItem.getObjectId()));
- } else {
- final String value;
- if (category.getParentCategory() == null) {
- value = NULL_OPTION_VALUE;
- } else {
- value = NONE_OPTION_VALUE;
- }
- group.setValue(state, value);
- }
- }
-
- private void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final FormData data = event.getFormData();
- final ParameterData param = data
- .getParameter(optionsGroup.getParameterModel().getName());
- final String selectedValue = (String) param.getValue();
-
- final Category category = getCategory(event.getPageState());
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryManager categoryManager = cdiUtil
- .findBean(CategoryManager.class);
- final CategoryRepository categoryRepository = cdiUtil
- .findBean(CategoryRepository.class);
- final ContentItemManager contentItemManager = cdiUtil
- .findBean(ContentItemManager.class);
- final ContentItemRepository contentItemRepository = cdiUtil
- .findBean(ContentItemRepository.class);
-
- if (selectedValue != null) {
- final Optional optionalItem = contentItemRepository
- .findById(Long.parseLong(selectedValue));
- if (optionalItem.isPresent()) {
- final ContentItem item = contentItemManager
- .getLiveVersion(optionalItem.get(),
- ContentItem.class)
- .get();
- try {
- categoryManager.setIndexObject(category, item);
- categoryRepository.save(category);
- } catch (ObjectNotAssignedToCategoryException ex) {
- throw new FormProcessException(ex);
- }
- }
- }
- }
-
- /**
- * Get the cancel button.
- *
- * @return The cancel button
- */
- protected Submit getCancelButton() {
- return saveCancelSection.getCancelButton();
- }
-
- /**
- * Fetch the selected category.
- *
- * @param state The page state
- *
- * @return The selected category
- *
- * @pre ( state != null )
- */
- protected Category getCategory(final PageState state) {
- return selectedCategory.getCategory(state);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/LinkForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/LinkForm.java
deleted file mode 100755
index 3a89d6113..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/LinkForm.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.ColumnPanel;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.cms.ui.CategoryForm;
-import com.arsdigita.cms.ui.FormSecurityListener;
-import com.arsdigita.toolbox.ui.Cancellable;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.categorization.Category;
-import org.libreccm.categorization.CategoryManager;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.core.CcmObject;
-import org.libreccm.security.PermissionChecker;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-
-/**
- * A form which edits secondary parents
- *
- * @author Michael Pih
- * @author Stanislav Freidin
- * @author Yannick Bülter
- */
-public class LinkForm extends CategoryForm implements Cancellable {
-
- private static final Logger LOGGER = LogManager.getLogger(
- LinkForm.class);
-
- private final CategoryRequestLocal m_category;
- private final Submit m_cancelButton;
-
- public LinkForm(final CategoryRequestLocal category) {
- super("LinkForm");
-
- m_category = category;
-
- m_cancelButton = new Submit("Finish");
- add(m_cancelButton, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
-
- setAssignedCaption("Linked Categories");
-
- addSubmissionListener
- (new FormSecurityListener(AdminPrivileges.ADMINISTER_CATEGORIES));
- }
-
- public final boolean isCancelled(final PageState state) {
- return m_cancelButton.isSelected(state);
- }
-
- /**
- * Load all categories which are assigned to the current item.
- */
- protected void initAssignedCategories(PageState state, CategoryMap m) {
- final Category category = m_category.getCategory(state);
- m.add(category.getParentCategory());
- /*final BigDecimal parentID = category.getDefaultParentCategory().getID();
- CategoryCollection links = category.getParents();
-
- while ( links.next() ) {
- Category cat = links.getCategory();
-
- if ( !cat.getID().equals(parentID) ) {
- m.add(cat);
- }
- }
- links.close();*/
- }
-
- /**
- * Assign a secondary parent.
- */
- public void assignCategory(PageState state, Category category) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(PermissionChecker.class);
- final CategoryManager categoryManager = cdiUtil.findBean(CategoryManager.class);
- final Category child = m_category.getCategory(state);
- if (permissionChecker.isPermitted(AdminPrivileges.ADMINISTER_CATEGORIES, category)) {
- categoryManager.addSubCategoryToCategory(child, category);
- }
- }
-
- /**
- * Unassign a secondary parent.
- */
- public void unassignCategory(PageState state, Category category) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(PermissionChecker.class);
- final CategoryManager categoryManager = cdiUtil.findBean(CategoryManager.class);
- final Category child = m_category.getCategory(state);
- if (permissionChecker.isPermitted(AdminPrivileges.ADMINISTER_CATEGORIES, category)) {
- categoryManager.removeSubCategoryFromCategory(child, category);
- }
- }
-
- /**
- * The category cannot be its own parent. Its children cannot
- * be parents either.
- */
- @Override
- public Category getExcludedCategory(PageState state) {
- return m_category.getCategory(state);
- }
-
- /**
- * This method returns the URL for the given item to make sure that
- * there are not two objects in the same category with the same URL.
- */
- protected final String getItemURL(final PageState state) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryManager categoryManager = cdiUtil.findBean(CategoryManager.class);
- return categoryManager.getCategoryPath(m_category.getCategory(state));
- }
-
- protected final CcmObject getObject(final PageState state) {
- return (Category) m_category.getCategory(state);
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/SortableCategoryList.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/SortableCategoryList.java
deleted file mode 100755
index ea9ca199f..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/SortableCategoryList.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.ParameterSingleSelectionModel;
-import com.arsdigita.bebop.parameters.BigDecimalParameter;
-
-import com.arsdigita.cms.ui.SortableList;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.categorization.Category;
-
-import javax.servlet.ServletException;
-
-
-/**
- * This list offers the option for the code to provide the developer
- * with links to sort the given categories.
- *
- * NOTE: This UI currently does not scale well with large numbers of
- * items since it just lists all of them. It would probably be nice
- * to integrate a paginator as well to as to allow the user to move an
- * item in large distances and to insert an item in the middle. Right
- * now, when you add an item it is just placed at the end. However,
- * if you want the item to appear in the middle then you must hit the
- * "up" arrow n/2 times where n is the number of items in the list.
- * This clearly is not a good setup.
- *
- * @author Randy Graebner (randyg@alum.mit.edu)
- * @author Yannick Bülter
- */
-abstract class SortableCategoryList extends SortableList {
-
- private static final Logger LOGGER = LogManager.getLogger
- (SortableCategoryList.class);
-
- public final static String CHILDREN = "ch";
-
- private final CategoryRequestLocal m_parent;
-
- /**
- * This just makes a standard
- * {@link SortableList}
- */
- public SortableCategoryList(final CategoryRequestLocal parent) {
- super(new ParameterSingleSelectionModel
- (new BigDecimalParameter(CHILDREN)), false);
-
- m_parent = parent;
-
- setIdAttr("categorized_objects_list");
- }
-
- protected final Category getCategory(final PageState state) {
- return m_parent.getCategory(state);
- }
-
- /**
- * This actually performs the sorting
- */
- public void respond(PageState ps) throws ServletException {
- String event = ps.getControlEventName();
- /* TODO Do actual sorting
- if (NEXT_EVENT.equals(event) || PREV_EVENT.equals(event)) {
- try {
- ACSObject child =
- (ACSObject)DomainObjectFactory.newInstance
- (new OID(ACSObject.BASE_DATA_OBJECT_TYPE,
- new BigDecimal(ps.getControlEventValue())));
- Category parent = m_parent.getCategory(ps);
-
- if (CMS.getContext().getSecurityManager().canAccess
- (SecurityManager.CATEGORY_ADMIN)) {
- if (NEXT_EVENT.equals(event)) {
- parent.swapWithNext(child);
- } else {
- parent.swapWithPrevious(child);
- }
-
- parent.save();
- }
- } catch (DataObjectNotFoundException e) {
- s_log.error("Trying to create categories with state = " + ps, e);
- throw new ServletException(e);
- }
- } else {
- super.respond(ps);
- }*/
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/SubcategoryList.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/SubcategoryList.java
deleted file mode 100755
index 561ed2111..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/SubcategoryList.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.category;
-
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.List;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.event.ActionEvent;
-import com.arsdigita.bebop.list.ListModel;
-import com.arsdigita.bebop.list.ListModelBuilder;
-import com.arsdigita.bebop.util.GlobalizationUtil;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.util.LockableImpl;
-
-import org.libreccm.categorization.Category;
-import org.libreccm.categorization.CategoryManager;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.CmsConstants;
-
-/**
- * A List of all subcategories of the current category.
- *
- *
- * @author Stanislav Freidin (stas@arsdigita.com)
- * @author Michael Pih (pihman@arsdigita.com)
- * @author Yannick Bülter
- * @author Jens Pelzetter
- */
-public class SubcategoryList extends SortableCategoryList {
-
- private final CategoryRequestLocal parentCategory;
- private final SingleSelectionModel selectedCategoryId;
-
- public SubcategoryList(
- final CategoryRequestLocal parentCategory,
- final SingleSelectionModel selectedCategoryId) {
-
- super(parentCategory);
-
- this.parentCategory = parentCategory;
- this.selectedCategoryId = selectedCategoryId;
-
- super.setIdAttr("subcategories_list");
-
- setModelBuilder(new SubcategoryModelBuilder());
-
- // Select the category in the main tree when the
- // user selects it here
- super.addActionListener(this::actionPerformed);
-
- Label label = new Label(new GlobalizedMessage(
- "cms.ui.category.subcategory.none",
- CmsConstants.CMS_BUNDLE));
- label.setFontWeight(Label.ITALIC);
- setEmptyView(label);
- }
-
- /**
- * Select the category in the main tree when the user selects it here
- *
- * @param event
- */
- private void actionPerformed(final ActionEvent event) {
-
- final PageState state = event.getPageState();
- final String categoryId = (String) getSelectedKey(state);
-
- if (categoryId != null) {
- selectedCategoryId.setSelectedKey(state, categoryId);
- }
- }
-
- public ListModel makeMake(final List list, final PageState state) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryManager categoryManager = cdiUtil
- .findBean(CategoryManager.class);
- final Category category = parentCategory.getCategory(state);
-
- if (category != null
- && categoryManager.hasSubCategories(category)) {
-
- final CategoryAdminController controller = cdiUtil.findBean(
- CategoryAdminController.class);
- final java.util.List children = controller
- .generateSubCategoryList(category);
-
- return new CategoryListModel(children);
- } else {
- return List.EMPTY_MODEL;
- }
-
- }
-
- private class SubcategoryModelBuilder extends LockableImpl
- implements ListModelBuilder {
-
- @Override
- public ListModel makeModel(final List list, final PageState state) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryManager categoryManager = cdiUtil
- .findBean(CategoryManager.class);
- final Category category = parentCategory.getCategory(state);
-
- if (category != null
- && categoryManager.hasSubCategories(category)) {
-
- final CategoryAdminController controller = cdiUtil.findBean(
- CategoryAdminController.class);
- final java.util.List children = controller
- .generateSubCategoryList(category);
-
- return new CategoryListModel(children);
- } else {
- return List.EMPTY_MODEL;
- }
- }
-
- }
-
-}