user = shiro.getUser();
- // User user = Web.getWebContext().getUser();
- if (user.isPresent()) {
- pageElement.addAttribute("name", user.get().getName());
- }
-
- return pageElement;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CMSContainer.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/CMSContainer.java
deleted file mode 100755
index e9b898b2a..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CMSContainer.java
+++ /dev/null
@@ -1,40 +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;
-
-import com.arsdigita.bebop.SimpleContainer;
-
-
-
-/**
- * A simple container with XML wrapper tags.
- *
- * @author Michael Pih (pihman@arsdigita.com)
- * @version $Id$
- */
-public class CMSContainer extends SimpleContainer {
-
- public final static String CMS_XML_NS = "http://www.arsdigita.com/cms/1.0";
-
-
- public CMSContainer() {
- super("cms:container", CMS_XML_NS);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CMSDHTMLEditor.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/CMSDHTMLEditor.java
deleted file mode 100755
index f26d5d37f..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CMSDHTMLEditor.java
+++ /dev/null
@@ -1,81 +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;
-
-import com.arsdigita.bebop.form.DHTMLEditor;
-import com.arsdigita.bebop.parameters.ParameterModel;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.cms.CMS;
-
-import org.librecms.CMSConfig;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.contentsection.ContentSection;
-
-/**
- *
- *
- */
-public class CMSDHTMLEditor extends DHTMLEditor {
-
- public CMSDHTMLEditor(final String name) {
- super(new StringParameter(name),
- CMSConfig.getConfig().getDHTMLEditorConfig());
- addPlugins();
- hideButtons();
-
- final ContentSection section = CMS.getContext().getContentSection();
- final GlobalizationHelper globalizationHelper = CdiUtil
- .createCdiUtil()
- .findBean(GlobalizationHelper.class);
- setAttribute("current-contentsection-id",
- Long.toString(section.getObjectId()));
- setAttribute("current-contentsection-primaryurl",
- section.getPrimaryUrl());
- setAttribute("current-contentsection-title",
- globalizationHelper
- .getValueFromLocalizedString(section.getTitle()));
-
- }
-
- public CMSDHTMLEditor(final ParameterModel model) {
- super(model,
- CMSConfig.getConfig().getDHTMLEditorConfig());
-
- addPlugins();
- hideButtons();
- }
-
- private void addPlugins() {
-
- CMSConfig
- .getConfig()
- .getDhtmlEditorPlugins()
- .forEach(plugin -> addPlugin(plugin));
- }
-
- private void hideButtons() {
-
- CMSConfig
- .getConfig()
- .getDhtmlEditorHiddenButtons()
- .forEach(hiddenButton -> hideButton(hiddenButton));
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CMSForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/CMSForm.java
deleted file mode 100755
index 782190e37..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CMSForm.java
+++ /dev/null
@@ -1,62 +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;
-
-import com.arsdigita.bebop.Container;
-import com.arsdigita.bebop.Form;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.toolbox.ui.Cancellable;
-
-/**
- * A convenience class for CMS forms. The "CMS Admin" class eliminates
- * the nested tables created by the Bebop ColumnPanel. This is mainly
- * to increase form rendering.
- *
- * @author Michael Pih
- */
-public class CMSForm extends Form implements Cancellable {
-
- public static final String CLASS = "CMS Admin";
-
- public CMSForm(final String name) {
- super(name);
-
- setClassAttr(CLASS);
- getPanel().setClassAttr(CLASS);
- }
-
- public CMSForm(final String name, final Container panel) {
- super(name, panel);
-
- setClassAttr(CLASS);
- panel.setClassAttr(CLASS);
- }
-
- /**
- * Determines whether the form has been cancelled.
- * Override this method if the form can be cancelled.
- *
- * @param state The page state
- * @return true if the form is cancelled, false otherwise
- */
- @Override
- public boolean isCancelled(final PageState state) {
- return false;
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CategoryForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/CategoryForm.java
deleted file mode 100755
index 5b4a66e00..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CategoryForm.java
+++ /dev/null
@@ -1,481 +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;
-
-import com.arsdigita.bebop.*;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.FormValidationListener;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.OptionGroup;
-import com.arsdigita.bebop.form.SingleSelect;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.parameters.BigDecimalParameter;
-import com.arsdigita.bebop.util.GlobalizationUtil;
-import com.arsdigita.bebop.util.SequentialMap;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.cms.ui.authoring.BasicItemForm;
-import com.arsdigita.globalization.Globalization;
-import com.arsdigita.util.StringUtils;
-import com.arsdigita.util.UncheckedWrapperException;
-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.cdi.utils.CdiUtil;
-import org.libreccm.core.CcmObject;
-
-import javax.enterprise.inject.spi.CDI;
-import java.math.BigDecimal;
-import java.util.*;
-
-/**
- * This is an abstract class which displays the category assignment UI.
- *
- * Displays two listboxes for assigning categories to items, with two
- * submit buttons to move categories back and forth. The left
- * listbox displays all available categories which have not been
- * assigned to the current item. The right listbox displays all categories
- * assigned to the current item.
- *
- *
- *
- * @author Stanislav Freidin (sfreidin@arsdigita.com)
- * @author Yannick Bülter
- */
-public abstract class CategoryForm extends Form
- implements FormProcessListener, FormValidationListener {
-
- private static final Logger LOGGER = LogManager.getLogger(
- CategoryForm.class);
- private static final String SEPARATOR = ">";
- public static final String FREE = "free";
- public static final String ASSIGNED = "assigned";
- public static final String ASSIGN = "assign";
- public static final String REMOVE = "remove";
- public static final int SELECT_WIDTH = 30;
- public static final int SELECT_HEIGHT = 10;
- public static final String FILLER_OPTION = StringUtils.repeat("_", SELECT_WIDTH);
-
- private final RequestLocal m_assigned;
- private Submit m_assign, m_remove;
-
- private final Label m_freeLabel;
- private final Label m_assignedLabel;
-
- /**
- * Construct a new CategoryForm component
- *
- * @param name the name of the form
- */
- public CategoryForm(String name) {
- super(name, new ColumnPanel(3));
-
- ColumnPanel panel = (ColumnPanel) getPanel();
- panel.setBorder(false);
- panel.setPadColor("#FFFFFF");
- panel.setColumnWidth(1, "0%");
- panel.setColumnWidth(2, "0%");
- panel.setColumnWidth(3, "0");
- panel.setWidth("0%");
- panel.setClassAttr("CMS Admin");
-
- // Create the request local
- m_assigned = new RequestLocal() {
-
- @Override
- public Object initialValue(PageState state) {
- CategoryMap m = new CategoryMap();
- initAssignedCategories(state, m);
- return m;
- }
- };
-
- // Top row
- m_freeLabel = new Label(GlobalizationUtil.globalize("cms.ui.item.categories.available"), false);
- m_freeLabel.setFontWeight(Label.BOLD);
- add(m_freeLabel, ColumnPanel.LEFT);
-
- //add(new Label(" ", false));
- add(new Embedded(" ", false));
-
- m_assignedLabel = new Label(GlobalizationUtil.globalize("cms.ui.item.categories.assigned"), false);
- m_assignedLabel.setFontWeight(Label.BOLD);
- add(m_assignedLabel, ColumnPanel.LEFT);
-
- // Middle Row
- SingleSelect freeWidget = new SingleSelect(new BigDecimalParameter(FREE));
- try {
- freeWidget.addPrintListener(new FreePrintListener());
- } catch (TooManyListenersException e) {
- UncheckedWrapperException.throwLoggedException(getClass(), "Too many listeners", e);
- }
- freeWidget.setSize(SELECT_HEIGHT);
- add(freeWidget);
-
- BoxPanel box = new BoxPanel(BoxPanel.VERTICAL, true);
- box.setWidth("2%");
- addSubmitButtons(box);
- add(box, ColumnPanel.CENTER | ColumnPanel.MIDDLE);
-
- SingleSelect assignedWidget =
- new SingleSelect(new BigDecimalParameter(ASSIGNED));
- try {
- assignedWidget.addPrintListener(new AssignedPrintListener());
- } catch (TooManyListenersException e) {
- UncheckedWrapperException.throwLoggedException(getClass(), "Too many listeners", e);
- }
- assignedWidget.setSize(SELECT_HEIGHT);
- add(assignedWidget);
-
- // Add listeners
- addProcessListener(this);
- addValidationListener(this);
-
- setClassAttr("CategoryForm");
- }
-
- protected void addSubmitButtons(Container c) {
- addAssignButton(c);
- addRemoveButton(c);
- }
-
- protected void addAssignButton(Container c) {
- m_assign = new Submit(ASSIGN, ">>");
- m_assign.setSize(10);
- c.add(m_assign);
- }
-
- protected void addRemoveButton(Container c) {
- m_remove = new Submit(REMOVE, "<<");
- m_remove.setSize(10);
- c.add(m_remove);
- }
-
- /**
- * Set the caption of the unassigned categories label
- *
- * @param caption the new caption
- */
- public void setUnassignedCaption(String caption) {
- m_freeLabel.setLabel(caption);
- }
-
- /**
- * Set the caption of the assigned categories label
- *
- * @param caption the new caption
- */
- public void setAssignedCaption(String caption) {
- m_assignedLabel.setLabel(caption);
- }
-
- /**
- * @param s the page state
- * @return a {@link CategoryMap} of all assigned categories
- */
- public CategoryMap getAssignedCategories(PageState s) {
- return (CategoryMap) m_assigned.get(s);
- }
-
- // A print listener which populates the listbox with all
- // unassigned categories, apart from result of getExcludedCategory()
- // (if not null), and the root category.
- // Ordering is alphabetical based on qualified path, so entries are
- // ordered like a tree with all nodes expanded.
- // Ideally ordering should be like an expanded tree but based on
- // the sortkey order of the categories. However, I don't know
- // if it would be possible to write a comparison function that
- // could do this efficiently, and I'm not even going to try
- // chris.gilbert@westsussex.gov.uk
- //
- private class FreePrintListener implements PrintListener {
-
- @Override
- public void prepare(PrintEvent e) {
-
- OptionGroup target = (OptionGroup) e.getTarget();
- target.clearOptions();
- PageState state = e.getPageState();
-// Category root = getRootCategory(state);
-// if (root == null) {
-// return;
-// }
-
- // exclude children of the excluded category (as per javadoc on
- // getExcludedCategory() method. This prevents attempts
- // to create circular category graph (which causes
- // exception in Category during addMapping if not checked here
- Category excludedCat = getExcludedCategory(state);
- CategoryMap excluded = new CategoryMap();
- if (excludedCat != null) {
- java.util.List excludedSubTree = getExcludedCategory(state).getSubCategories();
- excludedSubTree.forEach(excluded::add);
- }
- CategoryMap assigned = getAssignedCategories(state);
- SortedMap sortedCats = new TreeMap();
-// java.util.List children = root.getSubCategories();
-// children.forEach(x -> sortedCats.put(x.getName(), x.getUniqueId()));
-
- Iterator it = sortedCats.entrySet().iterator();
- Map.Entry entry;
- String path;
- String id;
- boolean notExcluded;
- boolean notAlreadyAssigned;
-// boolean notRoot;
-
- while (it.hasNext()) {
- entry = (Map.Entry) it.next();
- path = (String) entry.getKey();
- id = (String) entry.getValue();
-
- notExcluded = !excluded.containsKey(id);
- notAlreadyAssigned = !assigned.containsKey(id);
-// notRoot = !id.equals(root.getUniqueId());
-
- if (notExcluded && notAlreadyAssigned) {// && notRoot) {
- target.addOption(new Option(id, new Text(path)));
- }
-
- }
-
- addFillerOption(target);
- }
- }
-
- /**
- * Populate a {@link CategoryMap} with all categories which are assigned to
- * the item. Child classes should override this method to do the right thing.
- *
- * @param map The sequential map of all categories which are assigned to
- * the current item. Overridden method should repeatedly
- * call map.addCategory(someCategory);
- * @param state The page state
- */
- protected abstract void initAssignedCategories(PageState state, CategoryMap map);
-
- /**
- * Assign a category, moving it from the list on the left
- * to the list on the right
- *
- * @param s the page state
- * @param cat the category to assign
- */
- protected abstract void assignCategory(PageState s, Category cat);
-
- /**
- * Unassign a category, moving it from the list on the right
- * to the list on the left
- *
- * @param s the page state
- * @param cat the category to unassign
- */
- protected abstract void unassignCategory(PageState s, Category cat);
-
- /**
- * This method returns the URL for the givne item to make sure that
- * the item it is not possible to have two objects in the same category
- * with the same URL.
- * @param state The Page State
- */
- protected abstract String getItemURL(PageState state);
-
- /**
- * This allows the validation code to validate the properties of the
- * object
- */
- protected abstract CcmObject getObject(PageState state);
-
- /**
- * Get the category which will act as the root for the lists
- * of assigned and unassigned categories. The default implementation
- * returns the root category for the content section. Child classes
- * should override this method if they wish to provide an alternate root category.
- *
- * @param state the page state
- * @return the root category which should be used to populate the lists
- * of assigned and unassigned categories
- */
-// public Category getRootCategory(PageState state) {
-// return null;
-// return CMS.getContext().getContentSection().getRootCategory();
-// }
-
- /**
- * Return a category which should be excluded from the list of
- * free categories. It is permissible to return null
- *
- * @param s the page state
- * @return a category whose subtree will not be shown in the
- * category list
- */
- protected Category getExcludedCategory(PageState s) {
- return null;
- }
-
- // Populates the "assigned categories" widget
- @Deprecated
- private class AssignedPrintListener implements PrintListener {
-
- @Override
- public void prepare(PrintEvent e) {
- OptionGroup o = (OptionGroup) e.getTarget();
- o.clearOptions();
- PageState state = e.getPageState();
- CategoryMap m = getAssignedCategories(state);
-
- if (!m.isEmpty()) {
- for (Iterator i = m.values().iterator(); i.hasNext();) {
- Category c = (Category) i.next();
- o.addOption(new Option(c.getUniqueId(), new Text(getCategoryPath(c))));
- }
- } else {
- o.addOption(new Option("", new Text("-- none --")));
- }
-
- addFillerOption(o);
- }
- }
-
- // Process the form: assign/unassign categories
- @Override
- public void process(FormSectionEvent e) throws FormProcessException {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryRepository categoryRepository = cdiUtil.findBean(CategoryRepository.class);
-
- PageState state = e.getPageState();
- FormData data = e.getFormData();
- Long id;
-
- if (m_assign.isSelected(state)) {
- id = ((BigDecimal) data.get(FREE)).longValue();
- Optional optional = categoryRepository.findById(id);
- if (optional.isPresent()) {
- Category cat = optional.get();
- assignCategory(state, cat);
- data.put(ASSIGNED, id);
- } else {
- throw new FormProcessException(GlobalizationUtil.globalize(String.format("Can't find category with id %d", id)));
- }
- } else if (m_remove.isSelected(state)) {
- id = ((BigDecimal) data.get(ASSIGNED)).longValue();
- Optional optional = categoryRepository.findById(id);
- if (optional.isPresent()) {
- Category cat = optional.get();
- unassignCategory(state, cat);
- data.put(FREE, id);
- } else {
- throw new FormProcessException(GlobalizationUtil.globalize(String.format("Can't find category with id %d", id)));
- }
- }
- }
-
- // Validate the form: make sure that a category is selected
- // for the remove/assign buttons
- @Override
- public void validate(FormSectionEvent e) throws FormProcessException {
- PageState state = e.getPageState();
- FormData data = e.getFormData();
- if (m_assign.isSelected(state)) {
- if (data.get(FREE) == null) {
- data.addError(GlobalizationUtil.globalize("cms.ui.category.assign_select_missing"));
- } else {
- // we need to make sure that no other item in this
- // category has the same name (url)
- Long id = ((BigDecimal) data.get(FREE)).longValue();
-
- // Assign a new category
-// try {
-// String url = getItemURL(state);
-//
-// if (url != null) {
-// DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.categorization.getAllItemURLsForCategory");
-// query.setParameter("categoryID", id);
-// query.addEqualsFilter("lower(url)", url.toLowerCase());
-//
-// if (query.size() > 0) {
-// // we need to make sure that there is not an item
-// ACSObject item = getObject(state);
-// Collection list;
-// if (item instanceof ContentItem) {
-// list = BasicItemForm.getAllVersionIDs((ContentItem) item);
-// } else {
-// list = new ArrayList();
-// list.add(item.getID());
-// }
-// BigDecimal itemID;
-// while (query.next()) {
-// itemID = (BigDecimal) query.get("itemID");
-// if (!list.contains(itemID)) {
-// data.addError("There is already an item "
-// + "with the url " + url
-// + " in the category "
-// + cat.getName());
-// break;
-// }
-// }
-// }
-// }
-// } catch (DataObjectNotFoundException ex) {
-// s_log.error("Error processing category. Unable to find "
-// + "category with id " + id);
-// throw new FormProcessException(ex);
-// }
- }
- } else if (m_remove.isSelected(state)) {
- if (data.get(ASSIGNED) == null) {
- data.addError(GlobalizationUtil.globalize("cms.ui.category.assign_select_missing"));
- }
- }
- }
-
- // Add a "filler" option to the option group in order to ensure
- // the correct horizontal width
- private static void addFillerOption(OptionGroup o) {
- o.addOption(new Option("", FILLER_OPTION));
- }
-
- /**
- * @return the full path to a category
- */
- public static String getCategoryPath(Category c) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryManager categoryManager = cdiUtil.findBean(CategoryManager.class);
- return categoryManager.getCategoryPath(c);
- }
-
- /**
- * A convenience method that abstracts SequentialMap
- * to deal with categories
- */
- protected static class CategoryMap extends SequentialMap {
-
- public CategoryMap() {
- super();
- }
-
- public void add(Category c) {
- super.put(c.getUniqueId(), c);
- }
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CcmObjectRequestLocal.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/CcmObjectRequestLocal.java
deleted file mode 100755
index 204e60c85..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/CcmObjectRequestLocal.java
+++ /dev/null
@@ -1,32 +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;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.RequestLocal;
-
-import org.libreccm.core.CcmObject;
-
-
-public class CcmObjectRequestLocal extends RequestLocal {
-
- public final CcmObject getACSObject(final PageState state) {
- return (CcmObject) get(state);
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemContextBar.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemContextBar.java
deleted file mode 100755
index ea833518b..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemContextBar.java
+++ /dev/null
@@ -1,120 +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;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.cms.CMS;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-
-import com.arsdigita.cms.ItemSelectionModel;
-import com.arsdigita.cms.PageLocations;
-import com.arsdigita.kernel.KernelConfig;
-import com.arsdigita.web.ParameterMap;
-import com.arsdigita.web.URL;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.contentsection.ContentItemL10NManager;
-
-import java.util.List;
-import java.util.Locale;
-
-/**
- *
- * The context bar of the content section UI.
- *
- * @author Justin Ross
- * @author Jens Pelzetter
- */
-class ContentItemContextBar extends ContentSectionContextBar {
-
- private final ItemSelectionModel itemSelectionModel;
- private final StringParameter selectedLanguageParam;
-
- ContentItemContextBar(final ItemSelectionModel itemSelectionModel,
- final StringParameter selectedLanguageParam) {
- super();
-
- this.itemSelectionModel = itemSelectionModel;
- this.selectedLanguageParam = selectedLanguageParam;
- }
-
- @Override
- protected final List entries(final PageState state) {
- final List entries = super.entries(state);
- final ContentItem item = itemSelectionModel.getSelectedObject(state);
- final ContentSection section = CMS.getContext().getContentSection();
-
- final URL url = URL.there(state.getRequest(),
- section.getPrimaryUrl() + "/"
- + PageLocations.ITEM_PAGE,
- params(item));
-
- final StringBuilder title = new StringBuilder();
- title.append(localize("cms.ui.content_item"));
- title.append(": ")
- .append(item.getDisplayName());
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemL10NManager l10nManager = cdiUtil
- .findBean(ContentItemL10NManager.class);
- final String selectedLanguage = (String) state
- .getValue(selectedLanguageParam);
- final Locale selectedLocale;
- if (selectedLanguage == null
- || selectedLanguage.isEmpty()) {
- selectedLocale = KernelConfig.getConfig().getDefaultLocale();
- } else {
- selectedLocale = new Locale(selectedLanguage);
- }
-
- final String language;
- if (l10nManager.hasLanguage(item, selectedLocale)) {
- language = selectedLanguage;
- } else {
- state.setValue(selectedLanguageParam,
- KernelConfig.getConfig().getDefaultLanguage());
- language = KernelConfig.getConfig().getDefaultLanguage();
- }
- if (language != null) {
- title.append(" (")
- .append(language)
- .append(")");
- }
-
- entries.add(new Entry(title.toString(), url));
-
- return entries;
- }
-
- private static ParameterMap params(final ContentItem item) {
- final ParameterMap params = new ParameterMap();
-
- params.setParameter(ContentItemPage.ITEM_ID, item.getObjectId());
-
- return params;
- }
-
- private static String localize(final String key) {
- return (String) ContentSectionPage.globalize(key).localize();
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java
deleted file mode 100755
index fbbec5045..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java
+++ /dev/null
@@ -1,698 +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;
-
-import com.arsdigita.bebop.Component;
-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.ParameterSingleSelectionModel;
-import com.arsdigita.bebop.Resettable;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.TabbedPane;
-import com.arsdigita.bebop.event.ActionEvent;
-import com.arsdigita.bebop.event.ActionListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.FormValidationListener;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.parameters.LongParameter;
-import com.arsdigita.bebop.parameters.NotNullValidationListener;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.cms.ItemSelectionModel;
-import com.arsdigita.cms.PageLocations;
-import com.arsdigita.cms.dispatcher.CMSPage;
-import com.arsdigita.cms.ui.authoring.WizardSelector;
-import com.arsdigita.cms.ui.item.ContentItemRequestLocal;
-import com.arsdigita.cms.ui.item.CustomizedPreviewLink;
-import com.arsdigita.cms.ui.item.ItemLanguages;
-import com.arsdigita.cms.ui.item.Summary;
-import com.arsdigita.cms.ui.lifecycle.ItemLifecycleAdminPane;
-import com.arsdigita.cms.ui.revision.ItemRevisionAdminPane;
-import com.arsdigita.cms.ui.templates.ItemTemplates;
-import com.arsdigita.cms.ui.workflow.ItemWorkflowAdminPane;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.kernel.KernelConfig;
-import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
-import com.arsdigita.util.Assert;
-import com.arsdigita.xml.Document;
-import com.arsdigita.xml.Element;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.librecms.CMSConfig;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentItemL10NManager;
-import org.librecms.contentsection.ContentItemRepository;
-import org.librecms.contentsection.ContentItemVersion;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.ContentType;
-
-import java.io.IOException;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.Optional;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Page for administering a content item.
- *
- * @author Michael Pih
- * @author Stanislav Freidin
- * @author Jack Chung
- * @author Sören Bernstein
- * @author Jens Pelzetter
- *
- */
-public class ContentItemPage extends CMSPage implements ActionListener {
-
- /**
- * Private Logger instance for debugging purpose.
- */
- private static final Logger LOGGER = LogManager.getLogger(
- ContentItemPage.class);
- /**
- * The URL parameter that must be passed in in order to set the current tab.
- * This is a KLUDGE right now because the TabbedDialog's current tab is
- * selected with a local state parameter
- */
- public static final String SET_TAB = "set_tab";
- /**
- * The name of the global state parameter that holds the item id.
- */
- public static final String ITEM_ID = "item_id";
- /**
- * The name of th global state parameter that holds the selected language.
- */
- public static final String SELECTED_LANGUAGE = "selected_language";
- /**
- * The name of the global state parameter which holds the return URL.
- */
- public static final String RETURN_URL = "return_url";
- /**
- * The name of the global state parameter that determines whether or not to
- * use the streamlined authoring process (assuming the option is turned on).
- *
- */
- public static final String STREAMLINED_CREATION = "streamlined_creation";
- public static final String STREAMLINED_CREATION_ACTIVE = "active";
- public static final String STREAMLINED_CREATION_INACTIVE = "active";
- /**
- * Index of the summary tab
- */
- public static final int SUMMARY_TAB = 0;
- /**
- *
- * The name of the state parameter which indicates the content type of the
- * item the user wishes to create. or edit.
- *
- *
- * The parameter must be a BigDecimalParameter which encodes the id of the
- * content type.
- */
- public static final String CONTENT_TYPE = "content_type";
- public static final int AUTHORING_TAB = 1;
- public static final int LANGUAGE_TAB = 2;
- public static final int WORKFLOW_TAB = 3;
- public static final int PUBLISHING_TAB = 4;
- public static final int HISTORY_TAB = 5;
- public static final int TEMPLATES_TAB = 6;
-
- private final TabbedPane tabbedPane;
- private final StringParameter returnUrlParameter;
- private final ItemSelectionModel itemSelectionModel;
-// private final SingleSelectionModel selectedLanguageModel;
- private final ACSObjectSelectionModel typeSelectionModel;
- private final ContentItemRequestLocal itemRequestLocal;
- private final Summary summaryPane;
- private final ItemWorkflowAdminPane workflowPane;
- private final ItemLifecycleAdminPane lifecyclePane;
- private final WizardSelector wizardPane;
- private final ItemLanguages languagesPane;
- private final ItemRevisionAdminPane revisionsPane;
- private final ItemTemplates templatesPane;
- private final Link previewLink;
- private final GlobalNavigation globalNavigation;
- private final ContentItemContextBar contextBar;
-
- private final StringParameter selectedLanguageParam;
-
- private class ItemRequestLocal extends ContentItemRequestLocal {
-
- @Override
- protected final Object initialValue(final PageState state) {
- return CMS.getContext().getContentItem();
- }
-
- }
-
- private class TitlePrinter implements PrintListener {
-
- @Override
- public final void prepare(final PrintEvent event) {
-
- final PageState state = event.getPageState();
-
- final Label label = (Label) event.getTarget();
- final ContentItem item = itemRequestLocal.getContentItem(event.
- getPageState());
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemL10NManager l10nManager = cdiUtil
- .findBean(ContentItemL10NManager.class);
- final String selectedLanguage = (String) state
- .getValue(selectedLanguageParam);
- final Locale selectedLocale;
- if (selectedLanguage == null
- || selectedLanguage.isEmpty()) {
- selectedLocale = KernelConfig.getConfig().getDefaultLocale();
- } else {
- selectedLocale = new Locale(selectedLanguage);
- }
-
- final String language;
- if (l10nManager.hasLanguage(item, selectedLocale)) {
- language = selectedLanguage;
- } else {
- state.setValue(selectedLanguageParam,
- KernelConfig.getConfig().getDefaultLanguage());
- language = KernelConfig.getConfig().getDefaultLanguage();
- }
-
- final StringBuffer title = new StringBuffer(item.getDisplayName());
- if (language != null) {
- title
- .append(" (")
- .append(language)
- .append(")");
- }
-
- label.setLabel(title.toString());
- }
-
- }
-
- /**
- * Constructs a new ContentItemPage.
- */
- public ContentItemPage() {
- super("", new SimpleContainer());
-
- itemRequestLocal = new ItemRequestLocal();
-
- setClassAttr("cms-admin");
- setTitle(new Label(new TitlePrinter()));
-
- // Add the item id global state parameter
- final LongParameter itemId = new LongParameter(ITEM_ID);
- itemId.addParameterListener(new NotNullValidationListener(ITEM_ID));
- addGlobalStateParam(itemId);
- itemSelectionModel = new ItemSelectionModel(itemId);
-
- // Add the selected item language as parameter
- selectedLanguageParam = new StringParameter(SELECTED_LANGUAGE);
- selectedLanguageParam.addParameterListener(
- new NotNullValidationListener(SELECTED_LANGUAGE));
- addGlobalStateParam(selectedLanguageParam);
-// selectedLanguageModel = new ParameterSingleSelectionModel<>(
-// selectedLanguageParam);
-// selectedLanguageParam
-// .setDefaultValue(KernelConfig.getConfig().getDefaultLanguage());
-
- // Add the content type global state parameter
- final LongParameter contentType = new LongParameter(CONTENT_TYPE);
- addGlobalStateParam(contentType);
-
- // Add the streamlined creation global state parameter
- final StringParameter streamlinedCreation = new StringParameter(
- STREAMLINED_CREATION);
- addGlobalStateParam(streamlinedCreation);
-
- typeSelectionModel = new ACSObjectSelectionModel(ContentType.class
- .getName(),
- ContentType.class
- .getName(),
- contentType);
-
- // Validate the item ID parameter (caches the validation).
- getStateModel().addValidationListener(
- event -> validateItemID(event.getPageState()));
-
- // Add the return url global state parameter
- returnUrlParameter = new StringParameter(RETURN_URL);
- addGlobalStateParam(returnUrlParameter);
-
- globalNavigation = new GlobalNavigation();
- add(globalNavigation);
-
- contextBar = new ContentItemContextBar(itemSelectionModel,
- selectedLanguageParam);
- add(contextBar);
-
- // Create panels.
- summaryPane = new Summary(itemSelectionModel);
- wizardPane = new WizardSelector(itemSelectionModel, typeSelectionModel);
- languagesPane = new ItemLanguages(itemSelectionModel,
-// selectedLanguageModel,
- selectedLanguageParam);
- workflowPane = new ItemWorkflowAdminPane(itemId); // Make this use m_item XXX
- lifecyclePane = new ItemLifecycleAdminPane(itemRequestLocal);
- revisionsPane = new ItemRevisionAdminPane(itemRequestLocal);
- templatesPane = new ItemTemplates(itemSelectionModel);
-
- // Create tabbed pane.
- tabbedPane = new TabbedPane();
- add(tabbedPane);
-
- tabbedPane.setIdAttr("page-body");
-
- tabbedPane.addTab(new Label(gz("cms.ui.item.summary")), summaryPane);
- tabbedPane.
- addTab(new Label(gz("cms.ui.item.authoring")), wizardPane);
- tabbedPane.addTab(new Label(gz("cms.ui.item.languages")),
- languagesPane);
- tabbedPane.addTab(new Label(gz("cms.ui.item.workflow")),
- workflowPane);
- tabbedPane.addTab(new Label(gz("cms.ui.item.lifecycles")),
- lifecyclePane);
- tabbedPane.addTab(new Label(gz("cms.ui.item.history")),
- revisionsPane);
- tabbedPane.addTab(new Label(gz("cms.ui.item.templates")),
- templatesPane);
-
- tabbedPane.addActionListener(new ActionListener() {
-
- @Override
- public final void actionPerformed(final ActionEvent event) {
-
- final PageState state = event.getPageState();
- final Component pane = tabbedPane.getCurrentPane(state);
-
- if (pane instanceof Resettable) {
- ((Resettable) pane).reset(state);
- }
- }
-
- });
-
- // Build the preview link.
- previewLink = new Link(new Label(gz("cms.ui.preview")),
- new PrintListener() {
-
- @Override
- public final void prepare(
- final PrintEvent event) {
- final Link link = (Link) event.getTarget();
- link.setTarget(getPreviewURL(event.
- getPageState()));
- link.setTargetFrame(Link.NEW_FRAME);
- }
-
- });
- previewLink.setIdAttr("preview_link");
- add(previewLink);
-
- addActionListener(this);
-
- // Add validation to make sure we are not attempting to edit a live item
- getStateModel().addValidationListener(new FormValidationListener() {
-
- @Override
- public void validate(final FormSectionEvent event)
- throws FormProcessException {
-
- PageState s = event.getPageState();
- FormData data = event.getFormData();
- final ContentItem item = itemRequestLocal.getContentItem(s);
- if (item != null
- && ContentItemVersion.LIVE == item.getVersion()) {
- LOGGER.error(String.format(
- "The item %d is live and cannot be edited.", item.
- getObjectId()));
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.live_item_not_editable",
- CmsConstants.CMS_BUNDLE));
- }
- }
-
- });
- }
-
- /**
- * Ensures that the item_id parameter references a valid {@link
- * com.arsdigita.cms.ContentItem}.
- *
- * @param state The page state
- *
- * @pre state != null
- * @exception FormProcessException if the item_id is not valid
- */
- protected void validateItemID(final PageState state) throws
- FormProcessException {
- final ContentItem item = itemRequestLocal.getContentItem(state);
-
- if (item == null) {
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.invalid_item_id", CmsConstants.CMS_BUNDLE));
- }
- }
-
- /**
- * Fetch the request-local content section.
- *
- * @deprecated use com.arsdigita.cms.CMS.getContext().getContentSection()
- * instead
- * @param request The HTTP request
- *
- * @return The current content section
- */
- @Override
- public ContentSection getContentSection(final HttpServletRequest request) {
- // Resets all content sections associations.
- ContentSection section = super.getContentSection(request);
- Assert.exists(section);
- return section;
- }
-
- /**
- * Overrides CMSPage.getContentItem(PageState state) to get the current
- * content item from the page state.
- *
- * @deprecated Use the ItemSelectionModel
- * @param state The page state
- *
- * @return The current content item, null if there is none
- */
- @Override
- public ContentItem getContentItem(final PageState state) {
- return (ContentItem) itemSelectionModel.getSelectedObject(state);
- }
-
- /**
- * Set the current tab, if necessary
- *
- * @param event
- */
- @Override
- public void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
- final String setTab = state.getRequest().getParameter(SET_TAB);
-
- // Hide the templates tab, the workflow tab, and the preview
- // link if the current item is a template.
- final ContentItem item = itemRequestLocal.getContentItem(state);
-
- // ToDo: Reenable when Templates have been ported. Not clear yet if
- // Templates will be ContentItems in LibreCMS...
-// if (item instanceof Template) {
-// tabbedPane.setTabVisible(state, templatesPane, false);
-// tabbedPane.setTabVisible(state, workflowPane, false);
-// tabbedPane.setTabVisible(state, languagesPane, false);
-// m_previewLink.setVisible(state, false);
-// } else {
-// tabbedPane.setTabVisible(state,
-// templatesPane,
-// !ContentSectionConfig.getConfig().getHideTemplatesTab());
-// }
- // Set the current tab based on parameters
- if (setTab != null) {
- Integer tab;
-
- try {
- tab = Integer.valueOf(setTab);
- } catch (NumberFormatException ex) {
- // Stop processing set_tab parameter.
- LOGGER.warn("Stopping processing of set_tab parameter.", ex);
- return;
- }
-
- if (tab < tabbedPane.size()) {
- tabbedPane.setSelectedIndex(state, tab);
- }
- }
- }
-
- /**
- * Construct a URL for displaying a certain item
- *
- * @param nodeURL The URL where this page is mounted
- * @param itemId The id of the item to display
- * @param tab The index of the tab to display
- *
- * @return
- */
- public static String getItemURL(final String nodeURL,
- final Long itemId,
- final int tab) {
- return getItemURL(nodeURL, itemId, tab, false);
- }
-
- /**
- * Construct a URL for displaying a certain item
- *
- * @param nodeURL The URL where this page is mounted
- * @param itemId The id of the item to display
- * @param tab The index of the tab to display
- * @param streamlinedCreation Whether to activate Streamlined item authoring
- *
- * @return
- */
- public static String getItemURL(final String nodeURL,
- final Long itemId,
- final int tab,
- final boolean streamlinedCreation) {
- final StringBuilder urlBuilder = new StringBuilder();
-
- urlBuilder
- .append(nodeURL)
- .append(PageLocations.ITEM_PAGE)
- .append("?")
- .append(ITEM_ID)
- .append("=")
- .append(itemId.toString())
- .append("&")
- .append(SET_TAB)
- .append("=")
- .append(tab);
-
- if (streamlinedCreation
- && CMSConfig.getConfig().isUseStreamlinedCreation()) {
-
- urlBuilder
- .append("&")
- .append(STREAMLINED_CREATION)
- .append("=")
- .append(STREAMLINED_CREATION_ACTIVE);
- }
-
- return urlBuilder.toString();
- }
-
- /**
- * @param itemId
- * @param tab
- *
- * @return
- *
- * @deprecated Use getItemURL instead
- */
- public static String getRelativeItemURL(final Long itemId, final int tab) {
- final StringBuilder url = new StringBuilder();
- url
- .append(PageLocations.ITEM_PAGE)
- .append("?")
- .append(ITEM_ID)
- .append("=")
- .append(itemId.toString())
- .append("&")
- .append(SET_TAB)
- .append("=")
- .append(tab);
-
- return url.toString();
- }
-
- /**
- * Constructs a URL for displaying a certain item.
- *
- * @param item the ContentItem object to display
- * @param tab The index of the tab to display
- *
- * @return
- */
- public static String getItemURL(final ContentItem item,
- final int tab) {
-
- final ContentSection section = item.getContentType().getContentSection();
-
- if (section == null) {
- return null;
- } else {
- final String nodeURL = section.getPrimaryUrl() + "/";
-
- return getItemURL(nodeURL, item.getObjectId(), tab);
- }
- }
-
- /**
- * Constructs a URL for displaying a certain item.
- *
- * @param itemId the id of the ContentItem object to display
- * @param tab The index of the tab to display
- *
- * @return
- */
- public static String getItemURL(final long itemId,
- final int tab) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemRepository itemRepo = cdiUtil.findBean(
- ContentItemRepository.class);
-
- final Optional item = itemRepo.findById(itemId);
-
- if (item.isPresent()) {
- return getItemURL(item.get(), tab);
- } else {
- return null;
- }
- }
-
- /**
- * Redirect back to wherever the user came from, using the value of the
- * return_url parameter.
- *
- * @param state The current page state
- */
- public void redirectBack(final PageState state) {
- try {
- final String returnUrl = (String) state.getValue(returnUrlParameter);
- state.getResponse().sendRedirect(returnUrl);
- } catch (IOException ex) {
- LOGGER.error("IO Error redirecting back", ex);
- // do nothing
- }
- }
-
- /**
- * Fetch the preview URL.
- */
- private String getPreviewURL(final PageState state) {
- final ContentItem item = itemRequestLocal.getContentItem(state);
-
- if (item instanceof CustomizedPreviewLink) {
- final String previewLink = ((CustomizedPreviewLink) item).
- getPreviewUrl(
- state);
- if ((previewLink == null) || previewLink.isEmpty()) {
- return getDefaultPreviewLink(state, item);
- } else {
- return previewLink;
- }
- } else {
- return getDefaultPreviewLink(state, item);
- }
- }
-
- /**
- *
- * @param state
- * @param item
- *
- * @return
- */
- private String getDefaultPreviewLink(final PageState state,
- final ContentItem item) {
- final ContentSection section = CMS.getContext().getContentSection();
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
-// final ContentSectionManager sectionManager = cdiUtil.findBean(
-// ContentSectionManager.class);
-// final ItemResolver itemResolver = sectionManager
-// .getItemResolver(section);
-
- // Pass in the "Live" context since we need it for the preview
-// return itemResolver.generateItemURL(state,
-// item,
-// section,
-// CMSDispatcher.PREVIEW);
- final ContentItemPageController controller = cdiUtil
- .findBean(ContentItemPageController.class);
-
- return controller.getDefaultPreviewLink(section, item, state);
- }
-
- protected final static GlobalizedMessage gz(final String key) {
- return new GlobalizedMessage(key, CmsConstants.CMS_BUNDLE);
- }
-
- protected final static String lz(final String key) {
- return (String) gz(key).localize();
- }
-
- public static boolean isStreamlinedCreationActive(final PageState state) {
- return CMSConfig.getConfig().isUseStreamlinedCreation()
- && STREAMLINED_CREATION_ACTIVE.equals(state.getRequest().
- getParameter(STREAMLINED_CREATION));
- }
-
- protected TabbedPane getTabbedPane() {
- return tabbedPane;
- }
-
- protected WizardSelector getWizardPane() {
- return wizardPane;
- }
-
- /**
- * Adds the content type to the output.
- *
- * @param state PageState
- * @param parent Parent document
- *
- * @return page
- */
- @Override
- protected Element generateXMLHelper(final PageState state,
- final Document parent) {
-
- Objects.requireNonNull(itemRequestLocal.getContentItem(state),
- "No ContentItem in current request.");
-
- final Element page = super.generateXMLHelper(state, parent);
- final Element contenttype = page.newChildElement("bebop:contentType",
- BEBOP_XML_NS);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
-
- final ContentItemPageController controller = cdiUtil
- .findBean(ContentItemPageController.class);
- contenttype
- .setText(controller
- .getContentTypeLabel(itemRequestLocal.getContentItem(state)));
-
- return page;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java
deleted file mode 100644
index 8d504dd12..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java
+++ /dev/null
@@ -1,96 +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;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.cms.dispatcher.CMSDispatcher;
-
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentItemRepository;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.ContentSectionManager;
-import org.librecms.contentsection.ContentSectionRepository;
-import org.librecms.dispatcher.ItemResolver;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.transaction.Transactional;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-class ContentItemPageController {
-
- @Inject
- private GlobalizationHelper globalizationHelper;
-
- @Inject
- private ContentSectionRepository sectionRepo;
-
- @Inject
- private ContentSectionManager sectionManager;
- @Inject
- private ContentItemRepository itemRepo;
-
- @Transactional(Transactional.TxType.REQUIRED)
- protected String getContentTypeLabel(final ContentItem item) {
-
- final ContentItem theItem = itemRepo
- .findById(item.getObjectId())
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No ContentItem with ID %d in the database.",
- item.getObjectId())));
-
- return theItem
- .getContentType()
- .getLabel()
- .getValue(globalizationHelper.getNegotiatedLocale());
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- protected String getDefaultPreviewLink(final ContentSection section,
- final ContentItem item,
- final PageState state) {
-
- final ContentSection contentSection = sectionRepo
- .findById(section.getObjectId())
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No ContentSectio with ID %d in the database.",
- section.getObjectId())));
-
- final ContentItem contentItem = itemRepo
- .findById(item.getObjectId())
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No ContentItem with ID %d in the database.",
- item.getObjectId())));
-
- final ItemResolver itemResolver = sectionManager
- .getItemResolver(contentSection);
-
- return itemResolver.generateItemURL(state,
- contentItem,
- contentSection,
- CMSDispatcher.PREVIEW);
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionContextBar.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionContextBar.java
deleted file mode 100755
index ebaec6d78..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionContextBar.java
+++ /dev/null
@@ -1,154 +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;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.cms.PageLocations;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-
-import com.arsdigita.web.ParameterMap;
-import com.arsdigita.web.URL;
-
-import org.apache.logging.log4j.LogManager;
-
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Stack;
-
-import org.apache.logging.log4j.Logger;
-
-/**
- * The context bar of the content section UI.
- *
- * @author Justin Ross
- * @author Jens Pelzetter
- */
-public class ContentSectionContextBar extends WorkspaceContextBar {
-
- private static final Logger LOGGER = LogManager.getLogger(
- ContentSectionContextBar.class);
-
- @Override
- protected List entries(final PageState state) {
-
- /* Include breadcrumb entries already set by content-center (i.e. the
- * URL of the content center itself */
- final List entries = super.entries(state);
-
- final ContentSection section = CMS.getContext().getContentSection();
- final Stack folderEntryStack = new Stack<>();
- String currentFolderLabel = null;
- ParameterMap params = new ParameterMap();
- boolean isTemplate = false;
- BigDecimal templateID = null;
-
- if (CMS.getContext().hasContentItem()) {
- final ContentItem item = CMS.getContext().getContentItem();
- if (item == null) {
- LOGGER.warn("item is null");
- } else if (item.getContentType() == null) {
- LOGGER.warn(
- "item.getContentType() returns null. item.class.getName(): "
- + item.getClass().getName());
- }
-
- //ToDo NG - Not sure what happens here...
-// final Optional parent = item.getParent();
-//
-// while (!isTemplate
-// && parent.isPresent()
-// && parent.get() instanceof ContentItem) {
-// if (currentFolderLabel != null) {
-// final URL folderURL = URL.there
-// (state.getRequest(),
-// section.getPath() + "/" + PageLocations.SECTION_PAGE,
-// params);
-// folderEntryStack.push(new Entry(currentFolderLabel, folderURL));
-// currentFolderLabel = null;
-// params = new ParameterMap();
-// }
-// final ContentItem pitem = (ContentItem) parent;
-//
-// if (pitem instanceof Folder) {
-// final Folder folder = (Folder) pitem;
-// parent = folder.getParent();
-//
-// currentFolderLabel = folder.getLabel();
-// if (parent != null || folder.equals(section.getRootFolder())) {
-// params.setParameter
-// (ContentSectionPage.SET_FOLDER, folder.getID());
-// }
-// } else if (pitem instanceof ContentBundle) {
-// final ACSObject ppitem = pitem.getParent();
-//
-// if (ppitem != null && ppitem instanceof Folder) {
-// final Folder folder = (Folder) ppitem;
-//
-// parent = folder.getParent();
-// currentFolderLabel = folder.getLabel();
-// if (parent != null || folder.equals(section
-// .getRootFolder())) {
-// params.setParameter
-// (ContentSectionPage.SET_FOLDER, folder.getID());
-// }
-// } else {
-// parent = null;
-// }
-// } else {
-// parent = null;
-// }
-// }
- }
-
- if (isTemplate) {
- params.setParameter(ContentSectionPage.SET_TAB,
- new BigDecimal(
- ContentSectionPage.CONTENTTYPES_TAB));
- params.setParameter(ContentSectionPage.SET_TEMPLATE, templateID);
- }
-
- // add section-level entry. if this is for an item page, the URL
- // will be for the root folder.
- final URL url = URL.there(
- state.getRequest(),
- String.format("%s/" + PageLocations.SECTION_PAGE,
- section.getPrimaryUrl()),
- params);
-
- final String sectionTitle = lz("cms.ui.content_section");
- final String title = sectionTitle + ": " + section.getLabel();
-
- entries.add(new Entry(title, url));
-
- // add any folders to the path now
- while (!folderEntryStack.empty()) {
- entries.add(folderEntryStack.pop());
- }
-
- return entries;
- }
-
- private static String lz(final String key) {
- return (String) ContentSectionPage.globalize(key).localize();
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionPage.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionPage.java
deleted file mode 100755
index 94b4d4701..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionPage.java
+++ /dev/null
@@ -1,537 +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;
-
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SimpleComponent;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.TabbedPane;
-import com.arsdigita.bebop.event.ActionEvent;
-import com.arsdigita.bebop.event.ActionListener;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.cms.PageLocations;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-
-import com.arsdigita.cms.dispatcher.CMSPage;
-import com.arsdigita.cms.ui.assets.AssetPane;
-import com.arsdigita.cms.ui.category.CategoryAdminPane;
-//ToDo NG import com.arsdigita.cms.ui.category.CategoryAdminPane;
-import com.arsdigita.cms.ui.cse.ContentSoonExpiredPane;
-import com.arsdigita.cms.ui.folder.FolderAdminPane;
-import com.arsdigita.cms.ui.lifecycle.LifecycleAdminPane;
-import com.arsdigita.cms.ui.role.RoleAdminPane;
-import com.arsdigita.cms.ui.type.ContentTypeAdminPane;
-import com.arsdigita.cms.ui.workflow.WorkflowAdminPane;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.toolbox.ui.LayoutPanel;
-import com.arsdigita.util.Assert;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.librecms.CMSConfig;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.security.PermissionChecker;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentItemVersion;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-
-/**
- * Contains the entire admin UI for a content section.
- *
- * Developers Note: It is based on the dispatcher model is is going to be
- * replaced by the newer servlet based model. @see
- * c.ad.cms.ui.contentsection.MainPage (currently not active).
- *
- * @author Jack Chung
- * @author Michael Pih
- * @author Xixi D'Moon
- * @author Justin Ross
- * @author Jens Pelzetter
- */
-public class ContentSectionPage extends CMSPage implements ActionListener {
-
- /**
- * The URL parameter that can be passed in in order to set the current
- * folder. This is used in getting back to the correct level of folder
- * expansion from content item page.
- */
- public static final String SET_FOLDER = "set_folder";
- /**
- * The URL parameter that can be passed in in order to set the current
- * template (for setting the content type)
- */
- public static final String SET_TEMPLATE = "set_template";
- /**
- * The URL parameter that can be passed in in order to set the current tab.
- * This is a KLUDGE right now because the TabbedDialog's current tab is
- * selected with a local state parameter.
- */
- public static final String SET_TAB = "set_tab";
- /**
- * Index of the search tab
- */
- public static final int SEARCH_TAB = 0;
- /**
- * Index of the browse tab
- */
- public static final int BROWSE_TAB = 1;
- /**
- * Index of the roles tab
- */
- public static final int ROLES_TAB = 2;
- /**
- * Index of the workflows tab
- */
- public static final int WORKFLOW_TAB = 3;
- /**
- * Index of the lifecycles tab
- */
- public static final int LIFECYCLES_TAB = 4;
- /**
- * Index of the categories tab
- */
- public static final int CATEGORIES_TAB = 5;
- /**
- * Index of the content types tab
- */
- public static final int CONTENTTYPES_TAB = 6;
- public static final int USER_ADMIN_TAB = 7;
-
- private TabbedPane m_tabbedPane;
- private FolderAdminPane m_folderPane;
- private BrowsePane m_browsePane;
- private ItemSearch m_searchPane;
- private AssetPane m_assetPane;
-//ToDo NG private ImagesPane m_imagesPane;
- private RoleAdminPane m_rolePane;
- private WorkflowAdminPane m_workflowPane;
- private LifecycleAdminPane m_lifecyclePane;
- private CategoryAdminPane m_categoryPane;
- private ContentTypeAdminPane m_typePane;
- //private LayoutPanel m_userAdminPane;
- private LayoutPanel m_csePane;
- private ReportPane m_reportPane;
-
- /**
- * Creates the content section index page containing - a Navigaton bar for
- * the various tasks (items, search, images, ....) - a breadcrumb - ....
- * Contains the UI for administering a content section.
- */
- public ContentSectionPage() {
- super(new Label(new TitlePrinter()), new SimpleContainer());
-
- setClassAttr("cms-admin");
-
- add(new GlobalNavigation());
- add(new ContentSectionContextBar());
-
- // Initialize the individual panes
- m_folderPane = getFolderAdminPane();
- m_browsePane = getBrowsePane();
- m_searchPane = getSearchPane();
- m_assetPane = getAssetPane();
-//ToDo NG m_imagesPane = getImagesPane();
- m_rolePane = getRoleAdminPane();
- m_workflowPane = getWorkflowAdminPane();
- m_lifecyclePane = getLifecycleAdminPane();
- m_categoryPane = getCategoryAdminPane();
- m_typePane = getContentTypeAdminPane();
- // userAdminPane removed, used to contain just one item (reset user
- // folder) which moved to the FolderAdminPane
- //m_userAdminPane = getUserAdminPane();
- m_csePane = getCSEPane();
- m_reportPane = getReportPane();
-
- // The panes
- m_tabbedPane = createTabbedPane();
- m_tabbedPane.setIdAttr("page-body");
- m_tabbedPane.addActionListener(this);
- add(m_tabbedPane);
-
- addActionListener(new ActionListener() {
-
- @Override
- public final void actionPerformed(ActionEvent e) {
- final PageState state = e.getPageState();
-
- final String tab = state.getRequest().getParameter(SET_TAB);
-
- if (tab != null) {
- m_tabbedPane.setSelectedIndex(state, Integer.valueOf(tab)
- .intValue());
- }
-
- final PermissionChecker permissionChecker = CdiUtil
- .createCdiUtil().findBean(PermissionChecker.class);
-
- if (CMSConfig.getConfig().isHideAdminTabs()) {
- m_tabbedPane.setTabVisible(
- state,
- m_workflowPane,
- permissionChecker.isPermitted(AdminPrivileges.ADMINISTER_WORKFLOWS));
- m_tabbedPane.setTabVisible(
- state,
- m_categoryPane,
- permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_CATEGORIES));
- m_tabbedPane.setTabVisible(
- state,
- m_lifecyclePane,
- permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_LIFECYLES));
- m_tabbedPane.setTabVisible(
- state,
- m_typePane,
- permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_CONTENT_TYPES));
-
- m_tabbedPane.setTabVisible(
- state,
- m_rolePane,
- permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_ROLES));
- // csePane: should check permission
- m_tabbedPane.setTabVisible(state, m_csePane, true);
- // TODO Check for reportPane as well
- }
- }
-
- });
- }
-
- /**
- * Creates, and then caches, the browse pane. Overriding this method to
- * return null will prevent this tab from appearing.
- *
- * @return
- */
- protected FolderAdminPane getFolderAdminPane() {
- if (m_folderPane == null) {
- m_folderPane = new FolderAdminPane();
- }
- return m_folderPane;
- }
-
- /**
- * Creates, and then caches, the browse pane. Overriding this method to
- * return null will prevent this tab from appearing.
- *
- * @return
- */
- protected BrowsePane getBrowsePane() {
- if (m_browsePane == null) {
- m_browsePane = new BrowsePane();
- }
- return m_browsePane;
- }
-
- /**
- * Creates, and then caches, the search pane. Overriding this method to
- * return null will prevent this tab from appearing.
- *
- * @return
- */
- protected ItemSearch getSearchPane() {
- if (m_searchPane == null) {
- m_searchPane
- = new ItemSearch(
- ContentItemVersion.DRAFT.toString(),
- CMSConfig.getConfig().isLimitItemSearchToContentSection());
- }
- return m_searchPane;
- }
-
- protected AssetPane getAssetPane() {
- if (m_assetPane == null) {
- m_assetPane = new AssetPane();
- }
-
- return m_assetPane;
- }
-
-// ToDo NG
-// protected ImagesPane getImagesPane() {
-// if (m_imagesPane == null) {
-// m_imagesPane = new ImagesPane();
-// }
-// return m_imagesPane;
-// }
- protected RoleAdminPane getRoleAdminPane() {
- if (m_rolePane == null) {
- m_rolePane = new RoleAdminPane();
- }
- return m_rolePane;
- }
-
- /**
- * Creates, and then caches, the workflow administration pane. Overriding
- * this method to return null will prevent this tab from appearing.
- */
- protected WorkflowAdminPane getWorkflowAdminPane() {
- if (m_workflowPane == null) {
- m_workflowPane = new WorkflowAdminPane();
- }
- return m_workflowPane;
- }
-
- /**
- * Creates, and then caches, the lifecycle administration pane. Overriding
- * this method to return null will prevent this tab from appearing.
- */
- protected LifecycleAdminPane getLifecycleAdminPane() {
- if (m_lifecyclePane == null) {
- m_lifecyclePane = new LifecycleAdminPane();
- }
- return m_lifecyclePane;
- }
-
- /**
- * Creates, and then caches, the category administration pane. Overriding
- * this method to return null will prevent this tab from appearing.
- */
- protected CategoryAdminPane getCategoryAdminPane() {
- if (m_categoryPane == null) {
- m_categoryPane = new CategoryAdminPane();
- }
- return m_categoryPane;
- }
-
- /**
- * Creates, and then caches, the content type administration pane.
- * Overriding this method to return null will prevent this tab from
- * appearing.
- *
- * @return
- */
- protected ContentTypeAdminPane getContentTypeAdminPane() {
- if (m_typePane == null) {
- m_typePane = new ContentTypeAdminPane();
- }
- return m_typePane;
- }
-
-// protected LayoutPanel getUserAdminPane() {
-// if (m_userAdminPane == null) {
-// m_userAdminPane = new LayoutPanel();
-// m_userAdminPane.setLeft(new SimpleComponent());
-// m_userAdminPane.setBody(new UserAdminPane());
-// }
-// return m_userAdminPane;
-// }
- protected LayoutPanel getCSEPane() {
- if (m_csePane == null) {
- m_csePane = new LayoutPanel();
- m_csePane.setLeft(new SimpleComponent());
- m_csePane.setBody(new ContentSoonExpiredPane());
- }
- return m_csePane;
- }
-
- protected ReportPane getReportPane() {
- if (m_reportPane == null) {
- m_reportPane = new ReportPane();
- }
- return m_reportPane;
- }
-
- /**
- * Adds the specified component, with the specified tab name, to the tabbed
- * pane only if it is not null.
- *
- * @param pane The pane to which to add the tab
- * @param tabName The name of the tab if it's added
- * @param comp The component to add to the pane
- */
- protected void addToPane(final TabbedPane pane,
- final String tabName,
- final Component comp) {
- if (comp != null) {
- pane.addTab(new Label(tabName), comp);
- }
- }
-
- private void tab(final TabbedPane pane,
- final String key,
- final Component tab) {
- if (tab != null) {
- pane.addTab(new Label(gz(key)), tab);
- }
- }
-
- /**
- *
- * Created the TabbedPane to use for this page. Adds the tabs to the pane.
- * The default implementation uses a {@link
- * com.arsdigita.bebop.TabbedPane}. This implementation also adds browse,
- * search, staff admin, viewers admin, workflow admin, category admin, and
- * content type panes.
- *
- *
- * Developers can override this method to add only the tabs they want, or to
- * add additional tabs after the default CMS tabs are added.
- *
- * @return
- */
- protected TabbedPane createTabbedPane() {
- final TabbedPane pane = new TabbedPane();
-
- //tab(pane, "cms.ui.folders", getFolderAdminPane());
- tab(pane, "cms.ui.browse", getBrowsePane());
- tab(pane, "cms.ui.search", getSearchPane());
- tab(pane, "cms.ui.assets", getAssetPane());
-// ToDo NG replace with media tab tab(pane, "cms.ui.images", getImagesPane());
- tab(pane, "cms.ui.roles", getRoleAdminPane());
- tab(pane, "cms.ui.workflows", getWorkflowAdminPane());
- tab(pane, "cms.ui.lifecycles", getLifecycleAdminPane());
- tab(pane, "cms.ui.categories", getCategoryAdminPane());
- tab(pane, "cms.ui.content_types", getContentTypeAdminPane());
- tab(pane, "cms.ui.cse", getCSEPane());
- tab(pane, "cms.ui.reports", getReportPane());
-
- return pane;
- }
-
- /**
- * Fetch the request-local content section.
- *
- * @param request The HTTP request
- *
- * @return The current content section
- */
- @Override
- public ContentSection getContentSection(final HttpServletRequest request) {
- // Resets all content sections associations.
- ContentSection section = super.getContentSection(request);
- Assert.exists(section);
- return section;
- }
-
- /**
- * When a new tab is selected, reset the state of the formerly-selected
- * pane.
- *
- * @param event The event fired by selecting a tab
- */
- @Override
- public void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
-
- final Component pane = m_tabbedPane.getCurrentPane(state);
-
-//ToDo NG if (pane == m_searchPane) {
-// m_searchPane.reset(state);
-// } else if (pane == m_imagesPane) {
-// m_imagesPane.reset(state);
-// } else
- if (pane == m_assetPane) {
- m_assetPane.reset(state);
- } else if (pane == m_folderPane) {
- m_folderPane.reset(state);
-//ToDo NG } else if (pane == m_browsePane) {
-// m_browsePane.reset(state);
-// } else if (pane == m_rolePane) {
-// m_rolePane.reset(state);
- } else if (pane == m_workflowPane) {
- m_workflowPane.reset(state);
- } else if (pane == m_lifecyclePane) {
- m_lifecyclePane.reset(state);
- } else if (pane == m_categoryPane) {
- m_categoryPane.reset(state);
- } else if (pane == m_typePane) {
- m_typePane.reset(state);
-// } else if (pane == m_userAdminPane) {
- //m_userAdminPane.reset(state);
- } else if (pane == m_csePane) {
- m_csePane.reset(state);
- }
- }
-
- /**
- * Construct a URL for displaying the tab
- *
- * @param item The item from which we get the corresponding content section
- * @param tab The index of the tab to display
- *
- * @return
- */
- public static String getSectionURL(final ContentItem item, final int tab) {
- // Get the content section associated with the content item.
- final ContentSection section = item.getContentType().getContentSection();
-
- final String url = section.getPrimaryUrl() + PageLocations.SECTION_PAGE
- + "?" + SET_TAB + "=" + tab;
-
- return url;
- }
-
- private static GlobalizedMessage gz(final String key) {
- return new GlobalizedMessage(key, CmsConstants.CMS_BUNDLE);
- }
-
- /**
- * Getting the GlobalizedMessage using a CMS Class targetBundle.
- *
- * @param key The resource key
- *
- * @return
- *
- * @pre key != null
- */
- public static GlobalizedMessage globalize(final String key) {
- return new GlobalizedMessage(key, CmsConstants.CMS_BUNDLE);
- }
-
- /**
- *
- * @param key
- * @param args
- *
- * @return
- */
- public static GlobalizedMessage globalize(final String key,
- final Object[] args) {
- return new GlobalizedMessage(key, CmsConstants.CMS_BUNDLE, args);
- }
-
- /**
- * Helper class to be able to use a PrintListener to set the titel of the
- * page.
- */
- private static class TitlePrinter implements PrintListener {
-
- /**
- *
- * @param event
- */
- @Override
- public void prepare(final PrintEvent event) {
- final Label l = (Label) event.getTarget();
-
- l.setLabel(CMS.getContext().getContentSection().getLabel());
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionRequestLocal.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionRequestLocal.java
deleted file mode 100755
index a01e36cf4..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionRequestLocal.java
+++ /dev/null
@@ -1,40 +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;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.RequestLocal;
-import com.arsdigita.cms.CMS;
-
-import org.librecms.contentsection.ContentSection;
-
-/**
- *
- */
-public final class ContentSectionRequestLocal extends RequestLocal {
-
- @Override
- protected Object initialValue(final PageState state) {
- return CMS.getContext().getContentSection();
- }
-
- public final ContentSection getContentSection(final PageState state) {
- return (ContentSection) get(state);
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/FileUploadSection.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/FileUploadSection.java
deleted file mode 100755
index 90439fecb..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/FileUploadSection.java
+++ /dev/null
@@ -1,488 +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;
-
-import com.arsdigita.bebop.ColumnPanel;
-import com.arsdigita.bebop.Container;
-import com.arsdigita.bebop.FormData;
-import com.arsdigita.bebop.FormSection;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.form.FileUpload;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.OptionGroup;
-import com.arsdigita.bebop.form.SingleSelect;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.dispatcher.MultipartHttpServletRequest;
-import java.io.File;
-import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
-import javax.activation.MimetypesFileTypeMap;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import org.librecms.CmsConstants;
-
-/**
- * A form section with two widgets: a mime-type selection widget and a file
- * upload widget. The section will attempt to automatically guess the mime type
- * from the filename (if necessary), and return the mime type.
- *
- * @author Stanislav Freidin (sfreidin@arsdigita.com)
- * @author Jens Pelzetter
- */
-public class FileUploadSection extends FormSection {
-
- private SingleSelect mimeWidget;
- private FileUpload fileWidget;
- private String mimePrefix;
- private String defaultMimeType;
- private String parameterPrefix;
-
- /**
- * The mime type widget
- */
- public static final String MIME_TYPE = "mime_type";
-
- /**
- * The file upload widget
- */
- public static final String FILE_UPLOAD = "file_upload";
-
- /**
- * Automatically guess the mime type
- */
- public static final String GUESS_MIME = "-guess-";
-
- /**
- * Construct a new FileUploadSection
- *
- * @param mimeLabel The label for the mime type widget
- *
- * @param mimePrefix Populate the mime type widget with all mime types that
- * match the prefix. Some of the possible prefixes are "text", "image",
- * "binary", etc.
- *
- * @param defaultMimeType The default mime type that should be assumed if
- * the guessing fails
- *
- * @param panel The panel that is to be used to lay out the components
- *
- */
- public FileUploadSection(final GlobalizedMessage mimeLabel,
- final String mimePrefix,
- final String defaultMimeType,
- final Container panel) {
- this(mimeLabel, mimePrefix, defaultMimeType, "", panel);
- }
-
- /**
- * Construct a new FileUploadSection
- *
- * @param mimeLabel The label for the mime type widget
- *
- * @param mimePrefix Populate the mime type widget with all mime types that
- * match the prefix. Some of the possible prefixes are "text", "image",
- * "binary", etc.
- *
- * @param defaultMimeType The default mime type that should be assumed if
- * the guessing fails
- *
- * @param panel The panel that is to be used to lay out the components
- *
- * @deprecated use the same constructor but with the GlobalizedMessage for
- * the mimeLabel
- */
- public FileUploadSection(final String mimeLabel,
- final String mimePrefix,
- final String defaultMimeType,
- final Container panel) {
- // This takes advantage of the fact that the "key" is returned
- // when it is not present in the message bundle
- this(new GlobalizedMessage(mimeLabel),
- mimePrefix,
- defaultMimeType,
- panel);
- }
-
- /**
- * Construct a new FileUploadSection
- *
- * @param mimeLabel The label for the mime type widget
- *
- * @param mimePrefix Populate the mime type widget with all mime types that
- * match the prefix. Some of the possible prefixes are "text", "image",
- * "binary", etc.
- *
- * @param defaultMimeType The default mime type that should be assumed if
- * the guessing fails
- *
- * @param parameterPrefix Prepended to MIME_TYPE and FILE_UPLOAD for
- * parameter names so that more than 1 file upload widgets may be used per
- * form
- *
- * @param panel The panel that is to be used to lay out the components
- *
- * @deprecated use the same constructor but with the GlobalizedMessage for
- * the mimeLabel
- */
- public FileUploadSection(final String mimeLabel,
- final String mimePrefix,
- final String defaultMimeType,
- final String parameterPrefix,
- final Container panel
- ) {
- // This takes advantage of the fact that the "key" is returned
- // when it is not present in the message bundle
- this(new GlobalizedMessage(mimeLabel, CmsConstants.CMS_BUNDLE),
- mimePrefix,
- defaultMimeType,
- parameterPrefix,
- panel);
- }
-
- /**
- * Construct a new FileUploadSection
- *
- * @param mimeLabel The label for the mime type widget
- *
- * @param mimePrefix Populate the mime type widget with all mime types that
- * match the prefix. Some of the possible prefixes are "text", "image",
- * "binary", etc.
- *
- * @param defaultMimeType The default mime type that should be assumed if
- * the guessing fails
- *
- * @param parameterPrefix Prepended to MIME_TYPE and FILE_UPLOAD for
- * parameter names so that more than 1 file upload widgets may be used per
- * form
- *
- * @param panel The panel that is to be used to lay out the components
- *
- */
- public FileUploadSection(final GlobalizedMessage mimeLabel,
- final String mimePrefix,
- final String defaultMimeType,
- final String parameterPrefix,
- final Container panel) {
-
- super(panel);
-
- this.mimePrefix = mimePrefix;
- this.defaultMimeType = defaultMimeType;
- if (parameterPrefix == null) {
- this.parameterPrefix = "";
- } else {
- this.parameterPrefix = parameterPrefix;
- }
-
- add(new Label(mimeLabel, false));
- mimeWidget = new SingleSelect(getMimeTypeWidgetName());
- addMimeOptions(mimeWidget, mimePrefix);
- mimeWidget
- .addOption(new Option(GUESS_MIME,
- new Label(new GlobalizedMessage(
- "cms.ui.authoring.file_upload.auto_detect",
- CmsConstants.CMS_BUNDLE))));
-
- mimeWidget.setDefaultValue(GUESS_MIME);
- add(mimeWidget);
-
- add(new Label(new GlobalizedMessage("cms.ui.upload_new_content",
- CmsConstants.CMS_BUNDLE)));
- fileWidget = new FileUpload(getFileUploadWidgetName());
- add(fileWidget);
- }
-
- /**
- * Construct a new FileUploadSection
- *
- * @param mimeLabel The label for the mime type widget
- *
- * @param mimePrefix Populate the mime type widget with all mime types that
- * match the prefix. Some of the possible prefixes are "text", "image",
- * "binary", etc.
- *
- * @param defaultMimeType The default mime type that should be assumed if
- * the guessing fails
- *
- * @param parameterPrefix Prepended to MIME_TYPE and FILE_UPLOAD for
- * parameter names so that more than 1 file upload widgets may be used per
- * form
- *
- */
- public FileUploadSection(final GlobalizedMessage mimeLabel,
- final String mimePrefix,
- final String defaultMimeType,
- final String parameterPrefix) {
- this(mimeLabel,
- mimePrefix,
- defaultMimeType,
- parameterPrefix,
- new ColumnPanel(2, true));
- final ColumnPanel panel = (ColumnPanel) getPanel();
- panel.setBorder(false);
- panel.setPadColor("#FFFFFF");
- }
-
- /**
- * Construct a new FileUploadSection
- *
- * @param mimeLabel The label for the mime type widget
- *
- * @param mimePrefix Populate the mime type widget with all mime types that
- * match the prefix. Some of the possible prefixes are "text", "image",
- * "binary", etc.
- *
- * @param defaultMimeType The default mime type that should be assumed if
- * the guessing fails
- *
- * @param parameterPrefix Prepended to MIME_TYPE and FILE_UPLOAD for
- * parameter names so that more than 1 file upload widgets may be used per
- * form
- *
- * @deprecated use the same constructor but with the GlobalizedMessage for
- * the mimeLabel
- */
- public FileUploadSection(final String mimeLabel,
- final String mimePrefix,
- final String defaultMimeType,
- final String parameterPrefix) {
- // This takes advantage of the fact that the "key" is returned
- // when it is not present in the message bundle
- this(new GlobalizedMessage(mimeLabel, CmsConstants.CMS_BUNDLE),
- mimePrefix,
- defaultMimeType,
- parameterPrefix);
- }
-
- /**
- * Construct a new FileUploadSection
- *
- * @param mimeLabel The label for the mime type widget
- *
- * @param mimePrefix Populate the mime type widget with all mime types that
- * match the prefix. Some of the possible prefixes are "text", "image",
- * "binary", etc.
- *
- * @param defaultMimeType The default mime type that should be assumed if
- * the guessing fails
- *
- * @deprecated use the same constructor but with the GlobalizedMessage for
- * the mimeLabel
- */
- public FileUploadSection(final String mimeLabel,
- final String mimePrefix,
- final String defaultMimeType) {
-
- // This takes advantage of the fact that the "key" is returned
- // when it is not present in the message bundle
- this(new GlobalizedMessage(mimeLabel, CmsConstants.CMS_BUNDLE),
- mimePrefix,
- defaultMimeType,
- "");
- }
-
- /**
- * Construct a new FileUploadSection
- *
- * @param mimeLabel The GlobalizedMessage for the label for the mime type
- * widget
- *
- * @param mimePrefix Populate the mime type widget with all mime types that
- * match the prefix. Some of the possible prefixes are "text", "image",
- * "binary", etc.
- *
- * @param defaultMimeType The default mime type that should be assumed if
- * the guessing fails
- *
- */
- public FileUploadSection(GlobalizedMessage mimeLabel,
- String mimePrefix,
- String defaultMimeType) {
- this(mimeLabel, mimePrefix, defaultMimeType, "");
- }
-
- /**
- * Try to guess the mime type from the filename, and return it. The parent
- * form should call this method in its process listener. Note that this
- * method may return null if the mime type could not be guessed.
- *
- * @param event The form section event
- * @return The mime type of the file.
- */
- public MimeType getMimeType(final FormSectionEvent event) {
-
- final FormData data = event.getFormData();
-
- final String fileName = (String) data.get(getFileUploadWidgetName());
- final String mimeTypeName = (String) data.get(getMimeTypeWidgetName());
-
- // Guess the mime type from the filename
- MimeType mimeType = null;
- if (fileName != null) {
- try {
- if (GUESS_MIME.equals(mimeTypeName)) {
- // Guess the mime type from the file extension
- mimeType = new MimeType(MimetypesFileTypeMap
- .getDefaultFileTypeMap()
- .getContentType(fileName));
- } else {
- mimeType = new MimeType(mimeTypeName);
- }
- } catch (MimeTypeParseException ex) {
- mimeType = null;
- }
- }
-
- // Failed to guess it, failed to load it, fall back on the default
- if (mimeType == null) {
- try {
- mimeType = new MimeType(defaultMimeType);
- } catch (MimeTypeParseException ex) {
- mimeType = null;
- }
- }
-
- return mimeType;
- }
-
- /**
- * Obtain a File object from the file upload widget. The containing form
- * should call this method in its process listener.
- *
- * @param event The form section event
- * @return
- */
- public File getFile(final FormSectionEvent event) {
-
- final String fileName = getFileName(event);
-
- if (fileName != null && fileName.length() > 0) {
- return ((MultipartHttpServletRequest) unwrapRequest(event
- .getPageState()
- .getRequest()))
- .getFile(getFileUploadWidgetName());
- }
-
- return null;
- }
-
- private ServletRequest unwrapRequest(final HttpServletRequest request) {
-
- ServletRequest current = request;
- while (current instanceof HttpServletRequestWrapper) {
- current = ((HttpServletRequestWrapper) current).getRequest();
- }
-
- return current;
- }
-
- /**
- * Obtain a filename from the file upload widget. The containing form should
- * call this method in its process listener.
- *
- * @param event The form section event
- * @return
- */
- public String getFileName(final FormSectionEvent event) {
-
- return event
- .getFormData()
- .getString(getFileUploadWidgetName());
- }
-
- /**
- * Set the value for the mime type widget. The containing form should call
- * this method in its init listener
- *
- * @param event The form section event
- * @param mimeType The mime type to set, such as "text/html" or "img/jpeg"
- *
- */
- public void setMimeType(final FormSectionEvent event,
- final String mimeType) {
- event
- .getFormData()
- .put(getMimeTypeWidgetName(), mimeType);
- }
-
- /**
- * @return the mime type widget
- */
- public SingleSelect getMimeTypeWidget() {
- return mimeWidget;
- }
-
- /**
- * @return the file upload widget
- */
- public FileUpload getFileUploadWidget() {
- return fileWidget;
- }
-
- /**
- * @return the parameter name prefix
- */
- public String getParameterPrefix() {
- return parameterPrefix;
- }
-
- /**
- * @return the file upload parameter name
- */
- public String getFileUploadWidgetName() {
- return parameterPrefix + FILE_UPLOAD;
- }
-
- /**
- * @return the mime typeparameter name
- */
- public String getMimeTypeWidgetName() {
- return parameterPrefix + MIME_TYPE;
- }
-
- /**
- * Add mime-type options to the option group by loading all mime types which
- * match a certain prefix from the database
- *
- * @param mimeTypeOptions The mime type widget to which options should be
- * added
- *
- * @param mimePrefix Populate the mime type widget with all mime types that
- * match the prefix. Some of the possible prefixes are "text", "image",
- * "binary", etc.
- *
- */
- public static void addMimeOptions(final OptionGroup mimeTypeOptions,
- final String mimePrefix) {
-
-// MimeTypeCollection types;
-// if (mimePrefix == null || mimePrefix.equals("")) {
-// types = MimeType.getAllMimeTypes();
-// } else {
-// types = MimeType.searchMimeTypes(mimePrefix + "/");
-// }
-// while (types.next()) {
-// MimeType type = types.getMimeType();
-// mimeTypeOptions.addOption(new Option(type.getMimeType(), type.getLabel()));
-// }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/FlatItemList.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/FlatItemList.java
deleted file mode 100755
index e20ccb72b..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/FlatItemList.java
+++ /dev/null
@@ -1,468 +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;
-
-import com.arsdigita.bebop.ActionLink;
-import com.arsdigita.bebop.Form;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.Page;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.ParameterSingleSelectionModel;
-import com.arsdigita.bebop.Resettable;
-import com.arsdigita.bebop.SegmentedPanel;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.event.ActionEvent;
-import com.arsdigita.bebop.event.ActionListener;
-import com.arsdigita.bebop.event.ChangeEvent;
-import com.arsdigita.bebop.event.ChangeListener;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.FormSubmissionListener;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.parameters.LongParameter;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.cms.CMS;
-
-import org.librecms.contentsection.ContentSection;
-
-import com.arsdigita.cms.ui.authoring.CreationSelector;
-import com.arsdigita.cms.ui.authoring.news.NewItemForm;
-import com.arsdigita.cms.ui.folder.FolderCreateForm;
-import com.arsdigita.cms.ui.folder.FolderEditorForm;
-import com.arsdigita.cms.ui.folder.FolderManipulator;
-import com.arsdigita.cms.ui.folder.FolderPath;
-import com.arsdigita.cms.ui.folder.FolderRequestLocal;
-import com.arsdigita.cms.ui.folder.FolderSelectionModel;
-import com.arsdigita.cms.ui.permissions.CMSPermissionsPane;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import com.arsdigita.toolbox.ui.ActionGroup;
-import com.arsdigita.ui.CcmObjectSelectionModel;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.security.PermissionChecker;
-import org.libreccm.security.PermissionManager;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.Folder;
-import org.librecms.contentsection.privileges.ItemPrivileges;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Encapsulates a {@link FolderManipulator} in order to create a flat item
- * listing. Also contains a new item form.
- *
- * @author Stanislav Freidin
- * @author Jens Pelzetter
- */
-public class FlatItemList extends SegmentedPanel implements FormProcessListener,
- ChangeListener,
- FormSubmissionListener,
- Resettable,
- ActionListener {
-
- private static final String CONTENT_TYPE_ID = "ct";
- // The folder selectors
- private final FolderSelectionModel folderSelectionModel;
- private final FolderRequestLocal folderRequestLocal;
- private final NewItemForm newItemForm;
- private final SingleSelectionModel typeSelectionModel;
- private final CreationSelector creationSelector;
- private final FolderManipulator folderManipulator;
- private final FolderCreateForm folderCreator;
-// private final ActionLink m_setHomeFolderAction;
-// private final ActionLink m_removeHomeFolderAction;
- private final ActionLink createFolderAction;
-// private final ActionLink togglePrivateAction;
-// private final Label m_homeFolderLabel;
- private final Segment browseSegment;
- private final Segment newItemSegment;
- private final Segment newFolderSegment;
- private final Segment editFolderSegment;
- private final Segment permissionsSegment;
- private final CMSPermissionsPane permissionsPane;
- // Folder edit/rename functionality.
- private final ActionLink editFolderAction;
- private final FolderEditorForm folderEditor;
- private final Label contentLabel;
- private final FolderPath folderPath;
- private final Label chooseLabel;
- private final StringParameter selectedLanguageParam;
-
- /**
- * Construct a new item listing pane. The provided folder selection model is
- * used to keep track of the currently displayed folder.
- *
- * @param folderRequestLocal
- * @param folderSelectionModel maintains the currently displayed folder.
- */
- @SuppressWarnings("unchecked")
- public FlatItemList(final FolderRequestLocal folderRequestLocal,
- final FolderSelectionModel folderSelectionModel) {
- this.folderRequestLocal = folderRequestLocal;
- this.folderSelectionModel = folderSelectionModel;
- folderSelectionModel.addChangeListener(event -> reset(event
- .getPageState()));
-
- setIdAttr("flat-item-list");
-
- newItemSegment = addSegment();
- newItemSegment.setIdAttr("folder-new-item");
-
- newFolderSegment = addSegment();
- newFolderSegment.setIdAttr("folder-new-folder");
-
- editFolderSegment = addSegment();
- editFolderSegment.setIdAttr("folder-edit-folder");
-
- browseSegment = addSegment();
- browseSegment.setIdAttr("folder-browse");
-
- final ActionGroup browseActions = new ActionGroup();
- browseSegment.add(browseActions);
-
- // The top 'browse' segment
- contentLabel = new Label(globalize("cms.ui.contents_of"), false);
- browseSegment.addHeader(contentLabel);
- chooseLabel = new Label(globalize("cms.ui.choose_target_folder"),
- false);
- browseSegment.addHeader(chooseLabel);
- folderPath = new FolderPath(folderSelectionModel);
-
- browseSegment.addHeader(folderPath);
- folderManipulator = new FolderManipulator(folderSelectionModel);
- folderManipulator.getItemView().addProcessListener(this);
- folderManipulator.getTargetSelector().addProcessListener(this);
- folderManipulator.getTargetSelector().addSubmissionListener(this);
-
- browseActions.setSubject(folderManipulator);
-
- createFolderAction = new ActionLink(new Label(globalize(
- "cms.ui.new_folder")));
- createFolderAction.addActionListener(this);
- browseActions.addAction(createFolderAction);
-
- editFolderAction = new ActionLink(new Label(globalize(
- "cms.ui.edit_folder")));
- editFolderAction.addActionListener(this);
- browseActions.addAction(editFolderAction);
-
- newItemForm = new SectionNewItemForm("newItem");
- newItemForm.addProcessListener(this);
- browseActions.addAction(newItemForm);
-
- permissionsSegment = addSegment();
- permissionsSegment.setIdAttr("folder-permissions");
-
- final ActionGroup permissionActions = new ActionGroup();
- permissionsSegment.add(permissionActions);
-
- permissionsSegment.addHeader(new Label(new GlobalizedMessage(
- "cms.ui.permissions", CmsConstants.CMS_BUNDLE)));
-
- selectedLanguageParam = new StringParameter(ContentItemPage.SELECTED_LANGUAGE);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionManager permissionManager = cdiUtil.findBean(
- PermissionManager.class);
- final List privileges = permissionManager
- .listDefiniedPrivileges(ItemPrivileges.class);
- final Map privNameMap = new HashMap<>();
- privileges.forEach(privilege -> privNameMap.put(privilege, privilege));
-
- permissionsPane = new CMSPermissionsPane(
- privileges.toArray(new String[]{}),
- privNameMap,
- (CcmObjectSelectionModel) folderSelectionModel);
- permissionActions.setSubject(permissionsPane);
-
- newItemSegment.addHeader(new Label(globalize("cms.ui.new_item")));
- typeSelectionModel = new ParameterSingleSelectionModel<>(
- new LongParameter(CONTENT_TYPE_ID));
- typeSelectionModel.addChangeListener(this);
-
- creationSelector = new CreationSelector(typeSelectionModel,
- folderSelectionModel,
- selectedLanguageParam);
- newItemSegment.add(creationSelector);
- //m_newItemSeg.add(new Label("
", false));
-
- // The 'new folder' segment
- newFolderSegment.addHeader(new Label(globalize("cms.ui.new_folder")));
-// final Form folderCreate = new Form("fcreat");
- folderCreator = new FolderCreateForm("fcreat", folderSelectionModel);
- folderCreator.addSubmissionListener(this);
- folderCreator.addProcessListener(this);
- //folderCreator.add(folderCreator);
- newFolderSegment.add(folderCreator);
- newFolderSegment.add(new Label("
", false));
-
- editFolderSegment.addHeader(new Label(globalize("cms.ui.edit_folder")));
- folderEditor = new FolderEditorForm("fedit", folderSelectionModel);
- folderEditor.addSubmissionListener(this);
- folderEditor.addProcessListener(this);
- //Form folderEditorForm = new Form("fedit_form");
- //folderEditorForm.add(folderEditor);
- editFolderSegment.add(folderEditor);
- editFolderSegment.add(new Label("
", false));
- }
-
- @Override
- public void register(final Page page) {
- super.register(page);
-
- page.setVisibleDefault(chooseLabel, false);
-// page.setVisibleDefault(browseSegment, true);
- page.setVisibleDefault(newItemSegment, false);
- page.setVisibleDefault(newFolderSegment, false);
- page.setVisibleDefault(editFolderSegment, false);
-
- page.addComponentStateParam(this,
- typeSelectionModel.getStateParameter());
- page.addGlobalStateParam(selectedLanguageParam);
-
- page.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
-
- if (state.isVisibleOnPage(FlatItemList.this)) {
- showHideSegments(state);
- }
- }
-
- });
- }
-
- /**
- * Show/hide segments based on access checks.
- *
- * @param state The page state
- *
- * @pre ( state != null )
- */
- private void showHideSegments(final PageState state) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
- final Folder folder = folderRequestLocal.getFolder(state);
-
- // MP: This should be checked on the current folder instead of just
- // the content section.
- final boolean newItem = permissionChecker.isPermitted(
- ItemPrivileges.CREATE_NEW, folder);
-
- if (!newItem) {
- browseMode(state);
- }
-
- createFolderAction.setVisible(state, newItem);
- newItemForm.setVisible(state, newItem);
-
- final boolean editItem = permissionChecker.isPermitted(
- ItemPrivileges.EDIT, folder);
-
- editFolderAction.setVisible(state, editItem);
-// chooseLabel.setVisible(state, editItem);
-// editFolderSegment.setVisible(state, editItem);
-
- if (permissionChecker.isPermitted(ItemPrivileges.ADMINISTER, folder)) {
- permissionsSegment.setVisible(state, true);
- } else {
- permissionsSegment.setVisible(state, false);
- }
- }
-
- private void browseMode(final PageState state) {
- browseSegment.setVisible(state, true);
- permissionsSegment.setVisible(state, true);
- chooseLabel.setVisible(state, false);
- contentLabel.setVisible(state, true);
- folderPath.setVisible(state, true);
- newItemSegment.setVisible(state, false);
- newFolderSegment.setVisible(state, false);
- editFolderSegment.setVisible(state, false);
-
- typeSelectionModel.clearSelection(state);
- }
-
- private void newItemMode(final PageState state) {
- permissionsSegment.setVisible(state, false);
- newItemSegment.setVisible(state, true);
- }
-
- private void newFolderMode(final PageState state) {
- permissionsSegment.setVisible(state, false);
- newFolderSegment.setVisible(state, true);
- }
-
- @Override
- public void submitted(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- if (event.getSource() == folderCreator
- && folderCreator.isCancelled(state)) {
- browseMode(state);
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.cancelled", CmsConstants.CMS_BUNDLE));
- } else if (event.getSource() == folderEditor
- && folderEditor.isCancelled(state)) {
- browseMode(state);
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.cancelled", CmsConstants.CMS_BUNDLE));
- } else if (event.getSource() == folderManipulator.getTargetSelector()) {
- // This only works if this submission listener is run
- // after the target selector's one
- if (!folderManipulator.getTargetSelector().isVisible(state)) {
- browseMode(state);
- }
- }
- }
-
- @Override
- public void process(final FormSectionEvent event) {
- final PageState state = event.getPageState();
- final Object source = event.getSource();
- if (source == newItemForm) {
- final Long typeID = newItemForm.getTypeID(state);
- typeSelectionModel.setSelectedKey(state, typeID);
- newItemMode(state);
- } else if (source == folderCreator || source == folderEditor) {
- browseMode(state);
- } else if (source == folderManipulator.getItemView()) {
- // Hide everything except for the browseSeg
- permissionsSegment.setVisible(state, false);
- chooseLabel.setVisible(state, true);
- contentLabel.setVisible(state, false);
- folderPath.setVisible(state, false);
- } else if (source == folderManipulator.getTargetSelector()) {
- browseMode(state);
- }
- }
-
- @Override
- public void stateChanged(final ChangeEvent event) {
- final PageState state = event.getPageState();
- if (event.getSource().equals(typeSelectionModel)) {
- if (!typeSelectionModel.isSelected(state)) {
- browseMode(state);
- }
- }
- }
-
- @Override
- public void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
- final Object source = event.getSource();
- if (source == createFolderAction) {
- newFolderMode(state);
- } else if (source == editFolderAction) {
- permissionsSegment.setVisible(state, false);
- editFolderSegment.setVisible(state, true);
- }
-// else if (source == togglePrivateAction) {
-// togglePermissions(state);
-// }
-// } else if (source == m_setHomeFolderAction) {
-// User user = Web.getWebContext().getUser();
-// Folder folder = m_folder.getFolder(state);
-// user = (User) DomainObjectFactory.newInstance(user.getOID());
-// Folder.setUserHomeFolder(user, folder);
-// } else if (source == m_removeHomeFolderAction) {
-// User user = Web.getWebContext().getUser();
-// ContentSection section = CMS.getContext().getContentSection();
-// UserHomeFolderMap map = UserHomeFolderMap
-// .findUserHomeFolderMap(user, section);
-// if (map != null) {
-// map.delete();
-// }
-// }
- }
-
- private void togglePermissions(final PageState state) {
- final Folder currentFolder = folderRequestLocal.getFolder(state);
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
- permissionChecker.checkPermission(ItemPrivileges.ADMINISTER,
- currentFolder);
-
- permissionsPane.reset(state);
- }
-
- @Override
- public void reset(final PageState state) {
- browseMode(state);
- folderManipulator.reset(state);
- // switching between folders used to keep showing the permission pane
- // in the same perm mode (direct or inherited) regardless
- // of the folder status
- permissionsPane.reset(state);
- }
-
- public final FolderManipulator getManipulator() {
- return folderManipulator;
- }
-
- public final CMSPermissionsPane getPermissionsPane() {
- return permissionsPane;
- }
-
- public void setPermissionLinkVis(final PageState state) {
-// final Folder currentFolder = folderRequestLocal.getFolder(state);
-// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
-// final PermissionChecker permissionChecker = cdiUtil.findBean(
-// PermissionChecker.class);
-// if (!permissionChecker.isPermitted(ItemPrivileges.ADMINISTER,
-// currentFolder)) {
-// togglePrivateAction.setVisible(state, false);
-// }
- }
-
- private static class SectionNewItemForm extends NewItemForm {
-
- public SectionNewItemForm(final String name) {
- super(name);
- }
-
- @Override
- public ContentSection getContentSection(final PageState state) {
- return CMS.getContext().getContentSection();
- }
-
- }
-
- /**
- * Getting the GlobalizedMessage using a CMS Class targetBundle.
- *
- * @param key The resource key
- *
- * @pre ( key != null )
- */
- private static GlobalizedMessage globalize(final String key) {
- return ContentSectionPage.globalize(key);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/FormSecurityListener.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/FormSecurityListener.java
deleted file mode 100755
index e9e0577b4..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/FormSecurityListener.java
+++ /dev/null
@@ -1,81 +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;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.FormSubmissionListener;
-
-import org.librecms.contentsection.ContentItem;
-
-import com.arsdigita.cms.ui.item.ContentItemRequestLocal;
-import com.arsdigita.dispatcher.AccessDeniedException;
-
-import com.arsdigita.util.Assert;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.security.PermissionChecker;
-
-/**
- * @author Justin Ross <jross@redhat.com>
- */
-public class FormSecurityListener implements FormSubmissionListener {
-
- private final String m_action;
- private final ContentItemRequestLocal m_item;
-
- public FormSecurityListener(final String action,
- final ContentItemRequestLocal item) {
- Assert.exists(action, String.class);
-
- m_action = action;
- m_item = item;
- }
-
- public FormSecurityListener(final String action) {
- this(action, null);
- }
-
- @Override
- public final void submitted(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
-
- if (m_item == null) {
- if (permissionChecker.isPermitted(m_action)) {
- return;
- }
- } else {
- final ContentItem item = m_item.getContentItem(state);
-
- if (permissionChecker.isPermitted(m_action, item)) {
- return;
- }
- }
-
- throw new AccessDeniedException();
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/GlobalNavigation.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/GlobalNavigation.java
deleted file mode 100755
index a0b22979c..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/GlobalNavigation.java
+++ /dev/null
@@ -1,154 +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;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SimpleComponent;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.ui.UI;
-import com.arsdigita.ui.admin.AdminUiConstants;
-import com.arsdigita.ui.login.LoginServlet;
-import com.arsdigita.web.URL;
-import com.arsdigita.xml.Element;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.core.CoreConstants;
-import org.libreccm.security.PermissionChecker;
-import org.libreccm.web.ApplicationManager;
-import org.libreccm.web.ApplicationRepository;
-import org.libreccm.web.ApplicationType;
-import org.libreccm.web.CcmApplication;
-import org.librecms.CmsConstants;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- *
- * Global navigation elements for the CMS admin UIs.
- *
- * @author Justin Ross <jross@redhat.com>
- */
-// Made public (instead of unspecified, resulting in protected) in 6.6.8
-public class GlobalNavigation extends SimpleComponent {
-
-
- private final String m_adminPath;
- private final String m_centerPath;
- private final String m_changePasswordPath;
- private final String m_helpPath;
- private final String m_signOutPath;
- private final String m_wspcPath;
-
- /**
- *
- */
- public GlobalNavigation() {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ApplicationManager appManager = cdiUtil.findBean(
- ApplicationManager.class);
- final ApplicationRepository appRepo = cdiUtil.findBean(
- ApplicationRepository.class);
- final Map appTypes = appManager
- .getApplicationTypes();
- final ApplicationType adminAppType = appTypes.get(
- AdminUiConstants.ADMIN_APP_TYPE);
- final List adminApps = appRepo.findByType(adminAppType
- .name());
- final ApplicationType contentCenterAppType = appTypes.get(
- CmsConstants.CONTENT_CENTER_APP_TYPE);
- final List contentCenterApps = appRepo.findByType(
- contentCenterAppType.name());
-
- m_adminPath = adminApps.get(0).getPrimaryUrl();
- m_centerPath = contentCenterApps.get(0).getPrimaryUrl();
- m_changePasswordPath = LoginServlet.getChangePasswordPageURL();
- m_helpPath = "/nowhere"; // We don't have this yet XXX.
- m_signOutPath = LoginServlet.getLogoutPageURL();
- m_wspcPath = UI.getWorkspaceURL();
- }
-
- /**
- *
- * @param state
- * @param parent
- */
- @Override
- public void generateXML(final PageState state, final Element parent) {
- if (isVisible(state)) {
- final HttpServletRequest sreq = state.getRequest();
-
- final Element nav = parent.newChildElement("cms:globalNavigation",
- CMS.CMS_XML_NS);
- final String centerTitle = (String) new GlobalizedMessage(
- "cms.ui.content_center", CmsConstants.CMS_BUNDLE).localize();
- final String adminTitle = (String) new GlobalizedMessage(
- "cms.ui.admin_center", CmsConstants.CMS_BUNDLE).localize();
- final String wspcTitle = (String) new GlobalizedMessage(
- "cms.ui.my_workspace", CmsConstants.CMS_BUNDLE).localize();
- final String signOutTitle = (String) new GlobalizedMessage(
- "cms.ui.sign_out", CmsConstants.CMS_BUNDLE).localize();
- final String helpTitle = (String) new GlobalizedMessage(
- "cms.ui.help", CmsConstants.CMS_BUNDLE).localize();
- final String changePasswordTitle = (String) new GlobalizedMessage(
- "cms.ui.change_password", CmsConstants.CMS_BUNDLE).localize();
-
- link(sreq, nav, "cms:contentCenter", m_centerPath, centerTitle);
-
- /* If the current user has admin permissions, insert a link to the admin center */
- if (CdiUtil.createCdiUtil().findBean(PermissionChecker.class)
- .isPermitted(CoreConstants.PRIVILEGE_ADMIN)) {
- link(sreq, nav, "cms:adminCenter", m_adminPath, adminTitle);
- }
-
- link(sreq, nav, "cms:workspace", m_wspcPath, wspcTitle);
- link(sreq, nav, "cms:changePassword", m_changePasswordPath,
- changePasswordTitle);
- link(sreq, nav, "cms:signOut", m_signOutPath, signOutTitle);
- link(sreq, nav, "cms:help", m_helpPath, helpTitle);
- }
- }
-
- /**
- *
- * @param sreq
- * @param parent
- * @param name
- * @param path
- * @param title
- *
- * @return
- */
- private static Element link(final HttpServletRequest sreq,
- final Element parent,
- final String name,
- final String path,
- final String title) {
- final Element link = parent.newChildElement(name, CMS.CMS_XML_NS);
-
- link.addAttribute("href", URL.there(sreq, path).toString());
- link.addAttribute("title", title);
-
- return link;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ImagesPane.java.todo b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ImagesPane.java.todo
deleted file mode 100644
index 897899eb4..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ImagesPane.java.todo
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.arsdigita.cms.ui;
-
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.FormModel;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.List;
-import com.arsdigita.bebop.MapComponentSelectionModel;
-import com.arsdigita.bebop.Page;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.ParameterSingleSelectionModel;
-import com.arsdigita.bebop.Resettable;
-import com.arsdigita.bebop.SegmentedPanel;
-import com.arsdigita.bebop.SegmentedPanel.Segment;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.event.ChangeEvent;
-import com.arsdigita.bebop.event.ChangeListener;
-import com.arsdigita.bebop.list.ListModel;
-import com.arsdigita.bebop.list.ListModelBuilder;
-import com.arsdigita.bebop.parameters.ParameterModel;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.cms.util.GlobalizationUtil;
-import com.arsdigita.toolbox.ui.ActionGroup;
-import com.arsdigita.toolbox.ui.LayoutPanel;
-import com.arsdigita.toolbox.ui.Section;
-import com.arsdigita.util.Assert;
-import com.arsdigita.util.LockableImpl;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.log4j.Logger;
-
-/**
- * A {@link LayoutPanel} to insert into {@link ContentSectionPage}.
- *
- * @author Sören Bernstein
- */
-public class ImagesPane extends LayoutPanel implements Resettable {
-
- public static final Logger S_LOG = Logger.getLogger(ImagesPane.class);
- private final StringParameter m_imageComponentKey;
- private final MapComponentSelectionModel m_imageComponent;
- private final ImageComponentAdminListener m_adminListener;
- final private SegmentedPanel m_body;
- private HashMap m_bodySegments = new HashMap();
- private final ResettableParameterSingleSelectionModel m_model;
- private final List m_links;
- private final LinksSection m_modes;
-
- public ImagesPane() {
- super();
-
- m_model = new ResettableParameterSingleSelectionModel(new
- StringParameter(List.SELECTED));
- m_model.setDefaultSelection(ImageComponent.LIBRARY);
- m_model.addChangeListener(new ImageAdminSelectionListener());
-
- m_links = new List(new ImageAdminListModelBuilder());
- m_links.setSelectionModel(m_model);
-
- final SimpleContainer left = new SimpleContainer();
- setLeft(left);
-
- m_modes = new LinksSection();
- left.add(m_modes);
-
- m_body = new SegmentedPanel();
- setBody(m_body);
-
- m_imageComponentKey = new StringParameter("imageComponent");
-
- final ParameterSingleSelectionModel componentModel = new
- ParameterSingleSelectionModel(m_imageComponentKey);
- m_imageComponent = new MapComponentSelectionModel(componentModel,
- new HashMap());
-
- final Map selectors = m_imageComponent.getComponentsMap();
- m_adminListener = new ImageComponentAdminListener(m_imageComponent, this);
-
- // Image library component
- final ImageLibraryComponent library = new
- ImageLibraryComponent(ImageComponent.ADMIN_IMAGES);
- library.getForm().addInitListener(m_adminListener);
- library.getForm().addProcessListener(m_adminListener);
- selectors.put(ImageComponent.LIBRARY, library);
- m_bodySegments.put(ImageComponent.LIBRARY, m_body.addSegment(
- new Label(GlobalizationUtil.globalize(
- "cms.contentasset.image.ui.image_library")),
- library));
-
- // Image upload component
- final ImageUploadComponent upload = new
- ImageUploadComponent(ImageComponent.ADMIN_IMAGES);
- upload.getForm().addInitListener(m_adminListener);
- upload.getForm().addSubmissionListener(m_adminListener);
- upload.getForm().addProcessListener(m_adminListener);
- selectors.put(ImageComponent.UPLOAD, upload);
- m_bodySegments.put(ImageComponent.UPLOAD, m_body.addSegment(
- new Label(GlobalizationUtil.globalize(
- "cms.contentasset.image.ui.image_upload")),
- upload));
-
- }
-
- @Override
- public final void register(final Page page) {
- super.register(page);
-
- Iterator keys = m_bodySegments.keySet().iterator();
-
- while (keys.hasNext()) {
- String key = keys.next();
- page.setVisibleDefault(m_bodySegments.get(key),
- m_model.getDefaultSelection().equals(key));
- }
-
- page.addComponentStateParam(this, m_imageComponentKey);
- }
-
- /**
- * Resets this pane and all its resettable components.
- *
- * @param state Page state
- */
- @Override
- public final void reset(final PageState state) {
- super.reset(state);
-
- m_model.reset(state);
- this.setActiveImageComponent(state, m_model.getDefaultSelection());
- }
-
- public final void setActiveImageComponent(PageState state, String activeComp) {
-
- Iterator keys = m_bodySegments.keySet().iterator();
- m_imageComponent.setSelectedKey(state, activeComp);
-
- while (keys.hasNext()) {
-
- String key = keys.next();
- final boolean visibility = key.equals(activeComp);
- state.setVisible(m_bodySegments.get(key), visibility);
-
- for (int index = 0; index < m_bodySegments.get(key).size(); index++) {
-
- Component component = m_bodySegments.get(key).get(index);
-
- // Reset all components if they are of type Resettable
- if (component instanceof Resettable) {
- ((Resettable) component).reset(state);
- }
-
- // Set visibility
- component.setVisible(state, visibility);
- }
- }
- }
-
- /**
- *
- */
- private class ResettableParameterSingleSelectionModel
- extends ParameterSingleSelectionModel
- implements Resettable {
-
- private String defaultKey;
-
- public ResettableParameterSingleSelectionModel(ParameterModel m) {
- super(m);
- }
-
- public void setDefaultSelection(String selKey) {
- this.defaultKey = selKey;
- }
-
- public String getDefaultSelection() {
- return defaultKey;
- }
-
- public void reset(PageState state) {
-
- if (Assert.isEnabled()) {
- final FormModel model = state.getPage().getStateModel();
- Assert.isTrue(model.containsFormParam(getStateParameter()));
- }
-
- state.setValue(getStateParameter(), this.defaultKey);
- }
- }
-
- /**
- *
- */
- private class ImageAdminListModel implements ListModel {
-
- private ArrayList m_keys;
- private int m_index = -1;
-
- public ImageAdminListModel(ArrayList keys) {
- m_keys = keys;
- }
-
- public boolean next() {
- return (m_index++ < m_keys.size() - 1);
- }
-
- public Object getElement() {
- return GlobalizationUtil.globalize(
- "cms.contentasset.image.ui.image_" + m_keys.get(m_index)).localize();
- }
-
- public String getKey() {
- return m_keys.get(m_index);
- }
- }
-
- private class ImageAdminListModelBuilder extends LockableImpl
- implements ListModelBuilder {
-
- public ListModel makeModel(final List list, final PageState state) {
- ArrayList keys = new ArrayList(2);
- keys.add(ImageComponent.LIBRARY);
- keys.add(ImageComponent.UPLOAD);
- return new ImageAdminListModel(keys);
- }
- }
-
- private class ImageAdminSelectionListener implements ChangeListener {
-
- public final void stateChanged(final ChangeEvent e) {
- S_LOG.debug("Selection state changed; I may change "
- +"the body's visible pane");
-
- final PageState state = e.getPageState();
-
-// ImagesPane.this.reset(state);
-
- if (m_model.isSelected(state)) {
- S_LOG.debug("The selection model is selected; displaying "
- +"the item pane");
-
- ImagesPane.this.setActiveImageComponent(
- state,
- state.getControlEventValue());
- }
- }
- }
-
- private class LinksSection extends Section {
-
- LinksSection() {
- setHeading(GlobalizationUtil.globalize(
- "cms.contentasset.image.ui.images"));
-
- final ActionGroup group = new ActionGroup();
- setBody(group);
-
- group.setSubject(m_links);
- }
- }
-}
\ No newline at end of file
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ItemSearch.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ItemSearch.java
deleted file mode 100755
index 05b157226..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ItemSearch.java
+++ /dev/null
@@ -1,77 +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;
-
-import com.arsdigita.bebop.Form;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.Resettable;
-import com.arsdigita.bebop.SimpleContainer;
-
-import org.librecms.contentsection.ContentItem;
-
-/**
- * A wrapper around the {@link ItemSearchSection} which embeds the form section
- * in a form.
- *
- * @author Stanislav Freidin (sfreidin@arsdigita.com)
- * @author Jens Pelzetter
- */
-public class ItemSearch extends Form implements Resettable {
-
- public static final String SINGLE_TYPE_PARAM = ItemSearchSection.SINGLE_TYPE_PARAM;
-
- private ItemSearchSection itemSearchSection;
-
- /**
- * Construct a new ItemSearch component Default to limit the
- * search to current content section
- *
- * @param context the context for the retrieved items. Should be
- * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
- */
- public ItemSearch(String context) {
- this(context, true);
- }
-
- /**
- * Construct a new ItemSearch component
- *
- * @param context the context for the retrieved items. Should be
- * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
- * @param limitToContentSection limit the search to the current content
- * section
- */
- public ItemSearch(final String context,
- final boolean limitToContentSection) {
- super("itemSearch", new SimpleContainer());
- //setMethod("GET");
- itemSearchSection = createSearchSection(context, limitToContentSection);
- super.add(itemSearchSection);
- }
-
- protected ItemSearchSection createSearchSection(final String context,
- boolean limitToContentSection) {
- return new ItemSearchSection(context, limitToContentSection);
- }
-
- @Override
- public void reset(final PageState state) {
- itemSearchSection.reset(state);
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ItemSearchSection.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ItemSearchSection.java
deleted file mode 100755
index 11f6a1381..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ItemSearchSection.java
+++ /dev/null
@@ -1,189 +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;
-
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.Container;
-import com.arsdigita.bebop.Resettable;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.FormSection;
-import com.arsdigita.bebop.Page;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.parameters.BigDecimalParameter;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentType;
-
-import com.arsdigita.cms.ui.search.ItemQueryComponent;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import com.arsdigita.search.ui.ResultsPane;
-import com.arsdigita.search.ui.QueryGenerator;
-import com.arsdigita.toolbox.ui.LayoutPanel;
-
-import org.librecms.CmsConstants;
-
-/**
- * Contains a form for specifying search parameters, as well as a
- * {@link com.arsdigita.search.ui.ResultsPane} which will perform the search and
- * display the results
- *
- * @author Stanislav Freidin (sfreidin@arsdigita.com)
- * @version $Id: ItemSearchSection.java 1940 2009-05-29 07:15:05Z terry $
- */
-public class ItemSearchSection extends FormSection implements Resettable {
-
- public static final String SINGLE_TYPE_PARAM = "single_type";
-
- private ItemQueryComponent itemQueryComponent;
- private Component resultsComponent;
-
- /**
- * Construct a new ItemSearchSection component
- *
- * @param context the context for the retrieved items. Should be
- * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
- * @param limitToContentSection limit the search to the current content
- * section
- */
- public ItemSearchSection(final String context,
- final boolean limitToContentSection) {
- this(null, context, limitToContentSection);
- }
-
- /**
- * Construct a new ItemSearchSection component
- *
- * @param context the context for the retrieved items. Should be
- * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
- * @param name The name of the search parameter for the particular
- * FormSection
- * @param limitToContentSection limit the search to the current content
- * section
- */
- public ItemSearchSection(final String name,
- final String context,
- final boolean limitToContentSection) {
- this(name, context, limitToContentSection, null);
- }
-
- public ItemSearchSection(final String name,
- final String context,
- final boolean limitToContentSection,
- final ContentType type) {
- super(new SimpleContainer());
- final String thisName;
- if (name == null) {
- thisName = "itemSearch";
- } else {
- thisName = name;
- }
-
- if (type == null) {
- itemQueryComponent = createQueryGenerator(context,
- limitToContentSection);
- } else {
- itemQueryComponent = createQueryGenerator(context,
- limitToContentSection,
- type);
- }
- resultsComponent = createResultsPane(itemQueryComponent);
-
- LayoutPanel searchPanel = new LayoutPanel();
- searchPanel.setLeft(itemQueryComponent);
- searchPanel.setBody(resultsComponent);
- this.add(searchPanel);
-
- addQueryGenerator(this);
- addResultsPane(this);
- addFormListener();
-
- setClassAttr("itemSearch");
- }
-
-
- @Override
- public void reset(final PageState state) {
- resultsComponent.setVisible(state, false);
- }
-
- protected ItemQueryComponent createQueryGenerator(
- final String context, final boolean limitToContentSection) {
- return new ItemQueryComponent(context, limitToContentSection);
- }
-
- protected ItemQueryComponent createQueryGenerator(
- final String context,
- final boolean limitToContentSection,
- final ContentType type) {
-
- return new ItemQueryComponent(context, limitToContentSection, type);
- }
-
- protected Component createResultsPane(QueryGenerator generator) {
- ResultsPane pane = new ResultsPane(generator);
- pane.setRelativeURLs(true);
- pane.setSearchHelpMsg(new GlobalizedMessage("cms.ui.search.help",
- CmsConstants.CMS_BUNDLE));
- pane.setNoResultsMsg(new GlobalizedMessage("cms.ui.search.no_results",
- CmsConstants.CMS_BUNDLE));
- return pane;
- }
-
- protected void addResultsPane(final Container container) {
- container.add(resultsComponent);
- }
-
- protected void addQueryGenerator(final Container container) {
- container.add(itemQueryComponent);
- }
-
- protected void processQuery(final PageState state) {
- resultsComponent.setVisible(state, itemQueryComponent.hasQuery(state));
- }
-
- protected void addFormListener() {
- addProcessListener(new SearchFormProcessListener());
- }
-
- // Hide results by default
- @Override
- public void register(final Page page) {
- super.register(page);
- page.setVisibleDefault(resultsComponent, false);
- page.addGlobalStateParam(new BigDecimalParameter(SINGLE_TYPE_PARAM));
- }
-
- /**
- * Displays the "keywords" and "content types" widgets
- */
- private class SearchFormProcessListener implements FormProcessListener {
-
- @Override
- public void process(final FormSectionEvent event)
- throws FormProcessException {
-
- PageState s = event.getPageState();
- processQuery(s);
- }
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ListOptionPrintListener.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ListOptionPrintListener.java
deleted file mode 100755
index 82a6fa705..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ListOptionPrintListener.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;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.OptionGroup;
-
-import java.util.List;
-
-/**
- * Migrated from the {@code DataQueryOptionPrintListener} in the old system.
- * Renamed and refactored to operate on a list.
- *
- * @author Jens Pelzetter
- *
- * @param Type of the objects in the list.
- */
-public abstract class ListOptionPrintListener implements PrintListener {
-
- public ListOptionPrintListener() {
- }
-
- protected abstract List getDataQuery(final PageState state);
-
- @Override
- public void prepare(final PrintEvent event) {
- final PageState state = event.getPageState();
- final OptionGroup target = (OptionGroup) event.getTarget();
- final List dataQuery = getDataQuery(state);
-
- target.clearOptions();
-
- dataQuery.forEach(item -> target.addOption(
- new Option(getKey(item),
- getValue(item))));
- }
-
- public abstract String getKey(final T object);
-
- public String getValue(final T object) {
- return getKey(object);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/PartyAddForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/PartyAddForm.java
deleted file mode 100755
index f8ffdbbcd..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/PartyAddForm.java
+++ /dev/null
@@ -1,295 +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;
-
-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.PageState;
-import com.arsdigita.bebop.RequestLocal;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.event.FormInitListener;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.form.CheckboxGroup;
-import com.arsdigita.bebop.form.Hidden;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.OptionGroup;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.form.Widget;
-import com.arsdigita.bebop.parameters.NotNullValidationListener;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.xml.Element;
-
-import org.libreccm.core.UnexpectedErrorException;
-import org.libreccm.security.Party;
-import org.librecms.CmsConstants;
-
-import java.util.List;
-import java.util.TooManyListenersException;
-
-/**
- * Form for adding multiple parties to a role.
- *
- * @author Scott Seago (scott@arsdigita.com)
- * @author Yannick Bülter
- */
-public abstract class PartyAddForm extends SimpleContainer
- implements FormInitListener, FormProcessListener {
-
- private final static String SEARCH_QUERY = "searchQuery";
- private final static String PARTIES = "parties";
- private final static String SUBMIT = "addSubmit";
- private final static String CANCEL = "addCancel";
-
- private Widget searchWidget;
- private RequestLocal queryRequestLocal;
-
- private CMSContainer noMatchesContainer;
- private CMSContainer matchesContainer;
-
- private Form form;
- private Hidden searchQueryField;
- private Submit cancelButton;
-
- /**
- * Private access prevents this constructor from ever being called directly.
- */
- private PartyAddForm() {
- super();
- }
-
- /**
- * Constructor.
- *
- * @param searchWidget The widget on the search form that contains the value
- * of the search string.
- */
- public PartyAddForm(final Widget searchWidget) {
-
- this();
-
- this.searchWidget = searchWidget;
-
- queryRequestLocal = new RequestLocal() {
-
- @Override
- protected Object initialValue(final PageState state) {
- return makeQuery(state);
- }
-
- };
-
- form = makeForm();
-
- final Label title = new Label(new GlobalizedMessage("cms.ui.matches",
- CmsConstants.CMS_BUNDLE));
- title.setFontWeight(Label.BOLD);
-
- final Label label = new Label(new GlobalizedMessage(
- "cms.ui.there_was_no_one_matching_the_search_criteria",
- CmsConstants.CMS_BUNDLE));
- label.setFontWeight("em");
-
- noMatchesContainer = new CMSContainer();
- noMatchesContainer.add(title);
- noMatchesContainer.add(label);
- super.add(noMatchesContainer);
-
- matchesContainer = new CMSContainer();
- matchesContainer.add(title);
- matchesContainer.add(form);
- super.add(matchesContainer);
- }
-
- /**
- * Build the form used to add parties.
- *
- * @return The form
- */
- private Form makeForm() {
-
- final CMSForm addPartyForm = new CMSForm("AddParties") {
-
- @Override
- public final boolean isCancelled(final PageState state) {
- return cancelButton.isSelected(state);
- }
-
- };
-
- // This hidden field will store the search query. A hidden widget is
- // used instead of a request local variable because the search query
- // should only be updated when the search form is submitted.
- searchQueryField = new Hidden(SEARCH_QUERY);
- addPartyForm.add(searchQueryField, ColumnPanel.FULL_WIDTH);
-
- final Label hintLabel = new Label(
- new GlobalizedMessage("cms.ui.party_add_form.hint",
- CmsConstants.CMS_BUNDLE));
- addPartyForm.add(hintLabel, ColumnPanel.FULL_WIDTH);
-
- // Add the list of parties that can be added.
- final CheckboxGroup partyCheckboxes = new CheckboxGroup(PARTIES);
- partyCheckboxes.addValidationListener(new NotNullValidationListener());
- try {
- partyCheckboxes.addPrintListener(event -> {
- final CheckboxGroup target = (CheckboxGroup) event.getTarget();
- final PageState state = event.getPageState();
- // Ensures that the init listener gets fired before the
- // print listeners.
- final FormData data = addPartyForm.getFormData(state);
- addParties(state, target);
- });
- } catch (TooManyListenersException ex) {
- throw new UnexpectedErrorException(ex);
- }
- addPartyForm.add(partyCheckboxes, ColumnPanel.FULL_WIDTH);
-
- // Submit and Cancel buttons.
- final SimpleContainer buttonContainer = new SimpleContainer();
- final Submit submitButton = new Submit(SUBMIT,
- new GlobalizedMessage(
- "cms.ui.save",
- CmsConstants.CMS_BUNDLE));
- buttonContainer.add(submitButton);
- cancelButton = new Submit(CANCEL,
- new GlobalizedMessage("cms.ui.cancel",
- CmsConstants.CMS_BUNDLE));
- buttonContainer.add(cancelButton);
- addPartyForm.add(buttonContainer, ColumnPanel.FULL_WIDTH
- | ColumnPanel.CENTER);
-
- addPartyForm.addInitListener(this);
- addPartyForm.addProcessListener(this);
-
- return addPartyForm;
- }
-
- /**
- * Fetches the form for adding parties.
- *
- * @return The "add party" form
- */
- public Form getForm() {
- return form;
- }
-
- /**
- * Fetches the widget that contains the search string.
- *
- * @return The widget that contains the search string
- */
- protected Widget getSearchWidget() {
- return searchQueryField;
- }
-
- /**
- * Return true if the form is cancelled, false otherwise.
- *
- * @param state The page state
- *
- * @return true if the form is cancelled, false otherwise.
- *
- * @pre ( state != null )
- */
- public boolean isCancelled(final PageState state) {
- return cancelButton.isSelected(state);
- }
-
- /**
- * Adds parties to the option group.
- *
- * @param state The page state
- * @param target The option group
- *
- * @pre ( state != null && target != null )
- */
- private void addParties(final PageState state, final OptionGroup target) {
-
- @SuppressWarnings("unchecked")
- final List parties = (List) queryRequestLocal.get(state);
-
- target.clearOptions();
-
- for (final Party party : parties) {
- target.addOption(new Option(
- Long.toString(party.getPartyId()),
- new Label(new GlobalizedMessage(party.getName()))
- ));
- }
- }
-
- /**
- * Generates a {@link Object} that encapsulates search results.
- *
- * @param state The page state
- *
- * @return
- */
- protected abstract List makeQuery(PageState state);
-
- /**
- * Stores the search query in the hidden field.
- *
- * @param event The form event
- *
- * @throws com.arsdigita.bebop.FormProcessException
- */
- @Override
- public void init(final FormSectionEvent event) throws FormProcessException {
-
- PageState state = event.getPageState();
-
- searchQueryField.setValue(state, searchWidget.getValue(state));
- }
-
- /**
- * Process listener for the "Add parties" form.
- *
- * @param event The form event
- *
- * @throws com.arsdigita.bebop.FormProcessException
- */
- @Override
- public abstract void process(FormSectionEvent event)
- throws FormProcessException;
-
- /**
- * Displays the appropriate frame.
- *
- * @param state The page state
- * @param parent The parent DOM element
- */
- @Override
- public void generateXML(final PageState state, final Element parent) {
-
- @SuppressWarnings("unchecked")
- final List searchResults = (List) queryRequestLocal.get(state);
-
- if (searchResults.size() > 0) {
- matchesContainer.generateXML(state, parent);
- } else {
- noMatchesContainer.generateXML(state, parent);
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/PartySearchForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/PartySearchForm.java
deleted file mode 100755
index f4f35c4e8..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/PartySearchForm.java
+++ /dev/null
@@ -1,62 +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;
-
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.Page;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.form.TextField;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.util.Assert;
-
-/**
- * Form to search for parties to be added to a staff group.
- *
- * @author Scott Seago <sseago@redhat.com>
- * @version $Id: PartySearchForm.java 1942 2009-05-29 07:53:23Z terry $
- */
-public class PartySearchForm extends BaseForm {
-
- private final TextField searchField;
-
- public PartySearchForm() {
- super("SearchParties", gz("cms.ui.search"));
-
- addComponent(new Label(gz("cms.ui.search_prompt")));
-
- searchField = new TextField(new StringParameter("query"));
- searchField.setSize(40);
- addComponent(searchField);
-
- addAction(new Submit("finish", gz("cms.ui.search")));
- addAction(new Cancel());
-
- }
-
- @Override
- public final void register(final Page page) {
- super.register(page);
-
- Assert.isTrue(page.stateContains(this));
- }
-
- public TextField getSearchWidget() {
- return searchField;
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ReportPane.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ReportPane.java
deleted file mode 100644
index 0eb5efee3..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ReportPane.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2009 Permeance Technologies Pty Ltd. 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;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-
-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.ChangeEvent;
-import com.arsdigita.bebop.event.ChangeListener;
-import com.arsdigita.bebop.list.ListModel;
-import com.arsdigita.bebop.list.ListModelBuilder;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.cms.ui.report.ContentSectionSummaryTable;
-import com.arsdigita.cms.ui.report.Report;
-import com.arsdigita.cms.ui.report.ReportListModel;
-import com.arsdigita.toolbox.ui.ActionGroup;
-import com.arsdigita.toolbox.ui.Section;
-import com.arsdigita.util.LockableImpl;
-
-/**
- * A pane that shows selectable reports and their results. A selectable list of
- * reports is shown on the left-hand side, a selected report is shown as body.
- *
- * @author
- * thomas-buckel
- * @author
- * tim-permeance
- * @author Jens Pelzetter
- */
-public class ReportPane extends BaseAdminPane {
-
- private final SingleSelectionModel selectionModel;
- private final java.util.List availableReports;
-
- public ReportPane() {
- availableReports = getReports();
-
- selectionModel = new ParameterSingleSelectionModel<>(
- new StringParameter(List.SELECTED));
- selectionModel.addChangeListener(new SelectionListener());
- setSelectionModel(selectionModel);
-
- List m_reports = new List(new ReportListModelBuilder(availableReports));
- m_reports.setSelectionModel(selectionModel);
-
- final ReportsListSection reportsListSection = new ReportsListSection(
- m_reports);
- setLeft(reportsListSection);
-
- // Register the actual components of the reports for later usage
- for (Report report : availableReports) {
- getBody().add(report.getComponent());
- }
-
- setIntroPane(new Label(gz("cms.ui.reports.intro")));
- }
-
- /**
- * @return List of available reports.
- */
- private java.util.List getReports() {
- java.util.List reports = new ArrayList<>();
- reports.add(new Report("cms.ui.reports.css.reportName",
- new ContentSectionSummaryTable()));
- // Add other reports as required
-
- Collections.sort(
- reports,
- (r1, r2) -> r1.getName().compareTo(r2.getName()));
-
- return reports;
- }
-
- /**
- * Get the report model that matches the given key.
- *
- * @param key Key to match.
- *
- * @return Report model that matches that given key, null if no matching
- * report was found.
- */
- private Report getReportByKey(final String key) {
- for (Report report : availableReports) {
- if (report.getKey().equals(key)) {
- return report;
- }
- }
- return null;
- }
-
- /**
- * UI section for left-hand list of reports.
- */
- private class ReportsListSection extends Section {
-
- ReportsListSection(final List reports) {
- setHeading(gz("cms.ui.reports.header"));
- ActionGroup group = new ActionGroup();
- setBody(group);
- group.setSubject(reports);
- }
-
- }
-
- /**
- * SelectionListener for selected report. It shows the selected report in
- * the body of this component.
- */
- private class SelectionListener implements ChangeListener {
-
- @Override
- public final void stateChanged(final ChangeEvent event) {
-
- final PageState state = event.getPageState();
-
- getBody().reset(state);
-
- if (selectionModel.isSelected(state)) {
- Report selectedReport = getReportByKey(selectionModel
- .getSelectedKey(state).toString());
- if (selectedReport != null) {
- getBody().push(state, selectedReport.getComponent());
- }
- }
- }
-
- }
-
- /**
- * ListModelBuilder creating a ReportListModel for a list of reports.
- */
- private static class ReportListModelBuilder
- extends LockableImpl
- implements ListModelBuilder {
-
- private final java.util.List reports;
-
- private ReportListModelBuilder(final java.util.List reports) {
- this.reports = reports;
- }
-
- @Override
- public final ListModel makeModel(final List list,
- final PageState state) {
- return new ReportListModel(reports);
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/SecurityPropertyEditor.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/SecurityPropertyEditor.java
deleted file mode 100755
index 91fd9ecb3..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/SecurityPropertyEditor.java
+++ /dev/null
@@ -1,392 +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;
-
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.Form;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.FormSection;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.PropertyEditor;
-import com.arsdigita.bebop.PropertyEditorModel;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.FormSubmissionListener;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.toolbox.ui.ComponentAccess;
-import com.arsdigita.util.Assert;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.librecms.CmsConstants;
-
-/**
- * Extends {@link com.arsdigita.bebop.PropertyEditor} to provide access control
- * features. Each link may be associated with a {@link
- * com.arsdigita.toolbox.ui.ComponentAccess} object; if the current does not
- * have sufficient privileges, the link will be hidden.
- *
- * The simple use pattern for this component is as follows:
- *
- *
- * SecurityPropertyEditor editor = new SecurityPropertyEditor();
- * editor.setDisplayComponent(new FooComponent());
- * NameEditForm n = new NameEditForm();
- * ComponentAccess ca1 = new ComponentAccess(n);
- * ca1.addAccessCheck(WORKFLOW_ADMIN);
- * ca1.addAccessCheck(CATEGORY_ADMIN);
- * editor.add("name", "Edit Name", ca, n.getCancelButton());
- * AddressEditForm a = new AddressEditForm();
- * ComponentAccess ca2 = new ComponentAccess(a);
- * editor.add("address", "Edit Address", ca2, a.getCancelButton());
- *
- *
- * @author Michael Pih (pihman@arsdigita.com)
- * @author Stanislav Freidin (sfreidin@arsdigita.com)
- * @author Jens Pelzetter
- */
-public class SecurityPropertyEditor extends PropertyEditor {
-
- private final Map accessChecks;
-
- /**
- * Construct a new, empty PropertyEditor. The {@link
- * #setDisplayComponent(Component)} method must be called before this
- * component is locked.
- */
- public SecurityPropertyEditor() {
- this(null);
- }
-
- /**
- * Construct a new, PropertyEditor with the given display
- * component
- *
- * @param display The display component
- */
- public SecurityPropertyEditor(final Component display) {
- super(display);
- accessChecks = new HashMap<>();
- setModelBuilder(new AccessListModelBuilder());
- }
-
- /**
- * Add a component to the property editor. The component will be completely
- * invisible; it is up to the user to call {@link #showComponent(PageState,
- * String)} to display the component, and to call {@link
- * #showDisplayPane(PageState)} when the component needs to be hidden.
- *
- * @param key The symbolic key for the component; must be unique for this
- * PropertyEditor
- * @param componentAccess The {@link ComponentAccess} object which contains
- * the child component, along with security restrictions
- */
- public void addComponent(final String key,
- final ComponentAccess componentAccess) {
- super.addComponent(key, componentAccess.getComponent());
- accessChecks.put(key, componentAccess);
- }
-
- /**
- * Add a component to the list of links. It is up to the component to
- * correctly call showDisplayPane when it's done.
- *
- * @param key The symbolic key for the component; must be unique for this
- * PropertyEditor
- * @param label The label for the link
- * @param componentAccess The component access
- * @deprecated use addComponent(String,GlobalizedMessage,ComponentAccess)
- * instead.
- */
- public void addComponent(final String key,
- final String label,
- final ComponentAccess componentAccess) {
- addComponent(key, componentAccess);
- getLabelsMap().put(key, label);
- }
-
- /**
- * Add a component to the list of links. It is up to the component to
- * correctly call showDisplayPane when it's done.
- *
- * @param key The symbolic key for the component; must be unique for this
- * PropertyEditor
- * @param label The label for the link
- * @param componentAccess The component access
- */
- public void addComponent(final String key,
- final GlobalizedMessage label,
- final ComponentAccess componentAccess) {
- addComponent(key, componentAccess);
- getLabelsMap().put(key, label);
- }
-
- /**
- * Specify a new {@link ComponentAccess} for a component which has already
- * been added to the SecurityPropertyEditor.
- *
- * @param key the key under which the component was added
- * @param componentAccess the ComponentAccess instance that
- * will determine when the link for the specified component should be
- * visible
- * @pre access.getComponent() == m_forms.get(key)
- */
- public void setComponentAccess(final String key,
- final ComponentAccess componentAccess) {
- Assert.isUnlocked(this);
- final Component component = getComponent(key);
- Assert.exists(component, "the specified component");
- Assert.isTrue(componentAccess.getComponent().equals(component),
- "The specified component does not match the component that"
- + " id already in the PropertyEditor");
- accessChecks.put(key, componentAccess);
- }
-
- /**
- * Add a form to the set of forms which could be used to edit the
- * properties.
- *
- * @param key The symbolic key for the form; must be unique for this
- * PropertyEditor
- * @param label The label for the link to access the form
- * @param componentAccess The form ComponentAccess
- *
- * @deprecated use add(String,GlobalizedMessage,ComponentAccess)
- */
- public void add(final String key,
- final String label,
- final ComponentAccess componentAccess) {
- final Component component = componentAccess.getComponent();
- if (component instanceof Form) {
- final Form form = (Form) component;
- accessChecks.put(key, componentAccess);
- add(key, label, form);
- addSecurityListener(form);
- } else if (component instanceof FormSection) {
- final FormSection section = (FormSection) componentAccess.
- getComponent();
- accessChecks.put(key, componentAccess);
- add(key, label, section);
- addSecurityListener(section);
- } else {
- throw new IllegalArgumentException(
- "The ComponentAccess object does "
- + "not contain a form section.");
- }
- }
-
- /**
- * Add a form to the set of forms which could be used to edit the
- * properties.
- *
- * @param key The symbolic key for the form; must be unique for this
- * PropertyEditor
- * @param label The label for the link to access the form
- * @param componentAccess The form ComponentAccess
- */
- public void add(final String key,
- final GlobalizedMessage label,
- final ComponentAccess componentAccess) {
- final Component component = componentAccess.getComponent();
- if (component instanceof Form) {
- final Form form = (Form) component;
- accessChecks.put(key, componentAccess);
- add(key, label, form);
- addSecurityListener(form);
- } else if (component instanceof FormSection) {
- final FormSection section = (FormSection) componentAccess.
- getComponent();
- accessChecks.put(key, componentAccess);
- add(key, label, section);
- addSecurityListener(section);
- } else {
- throw new IllegalArgumentException(
- "The ComponentAccess object does "
- + "not contain a form section.");
- }
- }
-
- /**
- * Add a form to the set of forms which could be used to edit the properties
- *
- * @param key The symbolic key for the form; must be unique for this
- * PropertyEditor
- * @param label The label for the link to access the form.
- * @param componentAccess The form ComponentAccess
- * @param cancelButton The Cancel button on the form.
- *
- * @deprecated use add(String,GlobalizedMessage,ComponentAccess,Submit)
- * instead
- */
- public void add(final String key,
- final String label,
- final ComponentAccess componentAccess,
- final Submit cancelButton) {
- add(key, label, componentAccess);
- addCancelListener((FormSection) componentAccess.getComponent(),
- cancelButton);
- }
-
- /**
- * Add a form to the set of forms which could be used to edit the properties
- *
- * @param key The symbolic key for the form; must be unique for this
- * PropertyEditor
- * @param label The label for the link to access the form.
- * @param componentAccess The form ComponentAccess
- * @param cancelButton The Cancel button on the form.
- */
- public void add(final String key,
- final GlobalizedMessage label,
- final ComponentAccess componentAccess,
- final Submit cancelButton) {
- add(key, label, componentAccess);
- addCancelListener((FormSection) componentAccess.getComponent(),
- cancelButton);
- }
-
- /**
- * Add a submission listener to the form that will hide all components and
- * show the display pane. This method should be used to add submission
- * listeners to forms which are buried deep inside some component, and are
- * not members of this PropertyEditor.
- *
- * @param form The form
- */
- public void addSecurityListener(final FormSection form) {
- form.addSubmissionListener(new FormSubmissionListener() {
-
- @Override
- public void submitted(final FormSectionEvent event) throws
- FormProcessException {
-
- final PageState state = event.getPageState();
-
- // Cancel the form if the user does not pass the access checks.
- final String key = (String) getList().getSelectedKey(state);
- final ComponentAccess componentAccess
- = (ComponentAccess) accessChecks.get(key);
-
- if (key == null || componentAccess == null) {
- // no components currently selected and therefore
- // no access checks to run for visibility
- // or
- // there are no access restrictions on the form
- return;
- }
-
- if (!componentAccess.canAccess()) {
- showDisplayPane(state);
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.insufficient_privileges",
- CmsConstants.CMS_BUNDLE));
- }
- }
- });
- }
-
- /**
- * Add all required listeners to the form to ensure that if the form is
- * submitted successfully or cancelled, the display pane will be shown. This
- * method should be used to add listeners to forms which are buried deep
- * inside some component, and are not members of this
- * PropertyEditor.
- *
- * @param form The form
- * @param cancelButton the "Cancel" button on the form
- */
- @Override
- public void addListeners(final FormSection form,
- final Submit cancelButton) {
- addSecurityListener(form);
- super.addListeners(form, cancelButton);
- }
-
- /**
- * Return the map of keys to access checks
- *
- * @return Map of keys to access check
- */
- protected final Map getAccessMap() {
- return accessChecks;
- }
-
- /**
- * Returns an {@link SecurityPropertyEditor.AccessListModel} during each
- * request
- */
- protected static class AccessListModelBuilder extends DefaultModelBuilder {
-
- public AccessListModelBuilder() {
- super();
- }
-
- @Override
- public PropertyEditorModel makeModel(
- final PropertyEditor propertyEditor, final PageState state) {
-
- return new AccessListModel(
- getProperties(propertyEditor),
- ((SecurityPropertyEditor) propertyEditor).getAccessMap(),
- state);
- }
- }
-
- /**
- * Performs access checks for each property; skips the properties that the
- * user is not allowed to access
- */
- protected static class AccessListModel extends DefaultModel {
-
- private final Map accessMap;
- private final PageState state;
-
- public AccessListModel(final Iterator iter,
- final Map accessMap,
- final PageState state) {
- super(iter);
- this.accessMap = accessMap;
- this.state = state;
- }
-
- @Override
- public boolean next() {
-
- while (super.next()) {
- final Object key = getKey();
- final ComponentAccess ca = accessMap.get(key.toString());
-
- if (ca == null) {
- return true;
- }
-
- if (ca.canAccess()) {
- return true;
- }
-
- // Otherwise, skip the property
- }
-
- return false;
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/SortableList.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/SortableList.java
deleted file mode 100755
index 020183214..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/SortableList.java
+++ /dev/null
@@ -1,158 +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;
-
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.ControlLink;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.List;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.ParameterSingleSelectionModel;
-import com.arsdigita.bebop.list.ListModel;
-import com.arsdigita.bebop.util.BebopConstants;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.util.Assert;
-import com.arsdigita.xml.Element;
-
-import java.io.IOException;
-
-/**
- * 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
- */
-public abstract class SortableList extends List {
-
- // It would be really nice if this used the save variable as is
- // used by List but because List has it as private, we cannot do that.
- private static final String SELECT_EVENT = "s";
- protected static final String PREV_EVENT = "prev";
- protected static final String NEXT_EVENT = "next";
- public boolean m_sortItems;
-
- /**
- * This just makes a standard {@link SortableList}
- */
- public SortableList(ParameterSingleSelectionModel model) {
- this(model, false);
- }
-
- public SortableList(ParameterSingleSelectionModel model,
- boolean suppressSort) {
- super(model);
- m_sortItems = !suppressSort;
- }
-
- /**
- * This geneates the XML as specified by the arguments pass in to the
- * constructor.
- */
- public void generateXML(PageState state, Element parent) {
- if (!isVisible(state)) {
- return;
- }
-
- // They want the special sort items
- ListModel m = getModel(state);
-
- if (!m.next()) {
- super.generateXML(state, parent);
- return;
- }
-
- // because m.next() returned true, we know there are items
- // in the list
- Element list = parent
- .newChildElement("cms:sortableList", CMS.CMS_XML_NS);
- exportAttributes(list);
-
- Component c;
- Object selKey = getSelectedKey(state);
- int i = 0;
- boolean hasNext;
- do {
- Element item = list.newChildElement(BebopConstants.BEBOP_CELL,
- BEBOP_XML_NS);
- if (m_sortItems) {
-
- item.addAttribute("configure", "true");
- }
- String key = m.getKey();
- Assert.exists(key);
-
- // Converting both keys to String for comparison
- // since ListModel.getKey returns a String
- boolean selected = (selKey != null)
- && key.equals(selKey.toString());
-
- if (selected) {
- item.addAttribute("selected", "selected");
- }
-
- generateLabelXML(state, item,
- new Label(new GlobalizedMessage(m.getElement()
- .toString())), key, m.getElement());
-
- hasNext = m.next();
-
- // Add attributes containing URLs that fire control events
- // for various portlet actions
- try {
- // Maybe add attribute containing URL for "move up" link
- if (i > 0) {
- state.setControlEvent(this, PREV_EVENT, key);
- item.addAttribute("prevURL", state.stateAsURL());
- }
-
- // Maybe add attribute containing URL for "move down" link
- if (hasNext) {
- state.setControlEvent(this, NEXT_EVENT, key);
- item.addAttribute("nextURL", state.stateAsURL());
- }
-
- } catch (IOException ex) {
- throw new IllegalStateException("Caught IOException: "
- + ex.getMessage());
- }
- i++;
- } while (hasNext);
-
- state.clearControlEvent();
- }
-
- protected void generateLabelXML(PageState state, Element parent,
- Label label, String key, Object element) {
- state.setControlEvent(this, SELECT_EVENT, key);
- Component c = new ControlLink(label);
- c.generateXML(state, parent);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/UserAddForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/UserAddForm.java
deleted file mode 100755
index 269b57d7b..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/UserAddForm.java
+++ /dev/null
@@ -1,286 +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;
-
-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.PageState;
-import com.arsdigita.bebop.RequestLocal;
-import com.arsdigita.bebop.SimpleContainer;
-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.CheckboxGroup;
-import com.arsdigita.bebop.form.Hidden;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.OptionGroup;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.form.Widget;
-import com.arsdigita.bebop.parameters.NotNullValidationListener;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.xml.Element;
-
-import org.libreccm.security.User;
-import org.librecms.CmsConstants;
-
-import java.util.List;
-import java.util.TooManyListenersException;
-
-/**
- * Form for adding multiple users to a role.
- *
- * @author Michael Pih
- * @author Uday Mathur
- * @author Jens Pelzetter
- */
-public abstract class UserAddForm extends SimpleContainer
- implements FormProcessListener {
-
- private final static String SEARCH_QUERY = "searchQuery";
- private final static String USERS = "users";
- private final static String SUBMIT = "addSubmit";
- private final static String CANCEL = "addCancel";
-
- private final static String DQ_USER_ID = "userId";
- private final static String DQ_NAME = "name";
-
- private Widget m_search;
- private RequestLocal m_query;
- private String m_label;
- private String m_submitText;
-
- private CMSContainer m_noMatches;
- private CMSContainer m_matches;
-
- private Form m_form;
- private Hidden m_searchQuery;
- private CheckboxGroup m_users;
- private Submit m_submit;
- private Submit m_cancel;
-
- /**
- * Constructor.
- *
- * @param search The widget on the search form that contains the value of
- * the search string.
- */
- public UserAddForm(final Widget search) {
- this(search, "AddUsers");
- }
-
- public UserAddForm(final Widget search, final String name) {
- this(search, name,
- "Check the box next to the name of the person(s) to assign.",
- "Add Members");
- }
-
- public UserAddForm(final Widget search,
- final String name,
- final String text,
- final String submitText) {
- m_label = text;
- m_submitText = submitText;
- m_search = search;
-
- m_query = new RequestLocal() {
-
- @Override
- protected Object initialValue(final PageState state) {
- return makeQuery(state);
- }
-
- };
-
- m_form = makeForm(name);
-
- final Label title = new Label(new GlobalizedMessage("cms.ui.matches",
- CmsConstants.CMS_BUNDLE));
- title.setFontWeight(Label.BOLD);
-
- final Label label = new Label(new GlobalizedMessage(
- "cms.ui.there_was_no_one_matching_the_search_criteria",
- CmsConstants.CMS_BUNDLE));
- label.setFontWeight("em");
-
- m_noMatches = new CMSContainer();
- m_noMatches.add(title);
- m_noMatches.add(label);
- add(m_noMatches);
-
- m_matches = new CMSContainer();
- m_matches.add(title);
- m_matches.add(m_form);
- add(m_matches);
- }
-
- /**
- * Build the form used to add users.
- *
- * @param name
- *
- * @return The form
- */
- protected Form makeForm(final String name) {
- final CMSForm form = new CMSForm(name) {
-
- public final boolean isCancelled(final PageState state) {
- return m_cancel.isSelected(state);
- }
-
- };
-
- // This hidden field will store the search query. A hidden widget is
- // used instead of a request local variable because the search query
- // should only be updated when the search form is submitted.
- m_searchQuery = new Hidden(SEARCH_QUERY);
- form.add(m_searchQuery, ColumnPanel.FULL_WIDTH);
-
- Label l = new Label(m_label);
- form.add(l, ColumnPanel.FULL_WIDTH);
-
- // Add the list of users that can be added.
- m_users = new CheckboxGroup(USERS);
- m_users.addValidationListener(new NotNullValidationListener());
- try {
- m_users.addPrintListener(new PrintListener() {
-
- @Override
- public void prepare(PrintEvent event) {
- CheckboxGroup target = (CheckboxGroup) event.getTarget();
- PageState state = event.getPageState();
- // Ensures that the init listener gets fired before the
- // print listeners.
- FormData data = m_form.getFormData(state);
- addUsers(state, target);
- }
-
- });
- } catch (TooManyListenersException ex) {
- throw new RuntimeException(ex);
- }
- form.add(m_users, ColumnPanel.FULL_WIDTH);
-
- // Submit and Cancel buttons.
- SimpleContainer s = new SimpleContainer();
- m_submit = new Submit(SUBMIT, m_submitText);
- s.add(m_submit);
- m_cancel = new Submit(CANCEL, "Cancel");
- s.add(m_cancel);
- form.add(s, ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER);
-
- form.addProcessListener(this);
-
- return form;
- }
-
- /**
- * Fetches the form for adding users.
- *
- * @return The "add user" form
- */
- public Form getForm() {
- return m_form;
- }
-
- /**
- * Fetches the widget that contains the search string.
- *
- * @return The widget that contains the search string
- */
- protected Widget getSearchWidget() {
- return m_searchQuery;
- }
-
- /**
- * Return true if the form is cancelled, false otherwise.
- *
- * @param state The page state
- *
- * @return true if the form is cancelled, false otherwise.
- *
- * @pre ( state != null )
- */
- public boolean isCancelled(final PageState state) {
- return m_cancel.isSelected(state);
- }
-
- /**
- * Adds users to the option group.
- *
- * @param state The page state
- * @param target The option group
- *
- * @pre ( state != null && target != null )
- */
- protected void addUsers(final PageState state, final OptionGroup target) {
-
- @SuppressWarnings("unchecked")
- final List users = (java.util.List) m_query.get(state);
-
- users.forEach(user -> target.addOption(
- new Option(Long.toString(user.getPartyId()),
- user.getName())));
- }
-
- /**
- * Generates a {@link List} that encapsulates search results.
- *
- * @param state The page state
- *
- * @return
- */
- protected abstract List makeQuery(final PageState state);
-
- /**
- * Process listener for the "Add users" form.
- *
- * @param event The form event
- *
- * @throws com.arsdigita.bebop.FormProcessException
- */
- @Override
- public abstract void process(final FormSectionEvent event)
- throws FormProcessException;
-
- /**
- * Displays the appropriate frame.
- *
- * @param state The page state
- * @param parent The parent DOM element
- */
- @Override
- public void generateXML(final PageState state,
- final Element parent) {
-
- m_searchQuery.setValue(state, m_search.getValue(state));
- @SuppressWarnings("unchecked")
- final List searchResults = (List) m_query.get(state);
-
- if (searchResults.size() > 0) {
- m_matches.generateXML(state, parent);
- } else {
- m_noMatches.generateXML(state, parent);
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/UserSearchForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/UserSearchForm.java
deleted file mode 100755
index 5192688c4..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/UserSearchForm.java
+++ /dev/null
@@ -1,72 +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;
-
-import com.arsdigita.bebop.ColumnPanel;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.form.TextField;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import org.librecms.CmsConstants;
-
-/**
- * Form to search for users to be added to a staff group.
- *
- *
- * @author Michael Pih
- */
-public class UserSearchForm extends CMSForm {
-
- private final static String SEARCH_LABEL = "Search";
-
- private TextField m_search;
-
- public UserSearchForm(String name) {
- this(name,
- new Label(new GlobalizedMessage(
- "cms.ui.search_to_add_new_members",
- CmsConstants.CMS_BUNDLE)));
-
- }
-
- public UserSearchForm(String name, Label heading) {
- super(name, new ColumnPanel(3));
- heading.setFontWeight(Label.BOLD);
- add(heading, ColumnPanel.FULL_WIDTH);
-
- add(new Label(new GlobalizedMessage(
- "cms.ui.enter_first_name_last_name_andor_email_address",
- CmsConstants.CMS_BUNDLE)));
-
- m_search = new TextField(new StringParameter("query"));
- m_search.setSize(20);
- add(m_search, ColumnPanel.RIGHT);
-
- Submit submit = new Submit("submit");
- submit.setButtonLabel(SEARCH_LABEL);
- add(submit, ColumnPanel.LEFT);
- }
-
- public TextField getSearchWidget() {
- return m_search;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/VisibilityComponent.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/VisibilityComponent.java
deleted file mode 100755
index db0375357..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/VisibilityComponent.java
+++ /dev/null
@@ -1,58 +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;
-
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.toolbox.ui.ProxyComponent;
-import com.arsdigita.util.Assert;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.security.PermissionChecker;
-
-/**
- * @author Justin Ross
- * @author Jens Pelzetter
- */
-public class VisibilityComponent extends ProxyComponent {
-
- private final String m_action;
-
- public VisibilityComponent(final Component child, final String action) {
- super(child);
-
- m_action = action;
- }
-
- @Override
- public boolean isVisible(final PageState state) {
- return super.isVisible(state) && hasPermission(state);
- }
-
- public boolean hasPermission(final PageState state) {
- Assert.exists(m_action, String.class);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
-
- return permissionChecker.isPermitted(m_action);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/WorkspaceContextBar.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/WorkspaceContextBar.java
deleted file mode 100755
index 1d8e9be84..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/WorkspaceContextBar.java
+++ /dev/null
@@ -1,80 +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;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.toolbox.ui.ContextBar;
-import com.arsdigita.web.URL;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.web.ApplicationRepository;
-import org.libreccm.web.CcmApplication;
-import org.librecms.CmsConstants;
-
-import java.util.List;
-
-/**
- *
- * The context bar of the content center UI.
- *
- * @author Justin Ross
- * @author Jens Pelzetter
- */
-// Made public (instead of unspecified) in 6.6.8
-public class WorkspaceContextBar extends ContextBar {
-
- /**
- * A logger instance, primarily to assist debugging .
- */
- private static final Logger LOGGER = LogManager.getLogger(
- WorkspaceContextBar.class);
-
- /**
- *
- * @param state
- *
- * @return
- */
- @Override
- protected List entries(final PageState state) {
-
- final List entries = super.entries(state);
-
- final String centerTitle = (String) new GlobalizedMessage(
- "cms.ui.content_center", CmsConstants.CMS_BUNDLE).localize();
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ApplicationRepository appRepo = cdiUtil.findBean(
- ApplicationRepository.class);
- final List apps = appRepo.findByType(
- CmsConstants.CONTENT_CENTER_APP_TYPE);
-
- final String centerPath = apps.get(0).getPrimaryUrl();
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Got Url: " + centerPath);
- }
- final URL url = URL.there(state.getRequest(), centerPath);
- entries.add(new Entry(centerTitle, url));
-
- return entries;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetForm.java
deleted file mode 100644
index 87eaae99c..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetForm.java
+++ /dev/null
@@ -1,433 +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.assets;
-
-import com.arsdigita.bebop.BoxPanel;
-import com.arsdigita.bebop.ColumnPanel;
-import com.arsdigita.bebop.Form;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SaveCancelSection;
-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.event.FormSubmissionListener;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.SingleSelect;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.form.TextField;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.kernel.KernelConfig;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.Asset;
-
-import org.libreccm.core.UnexpectedErrorException;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TooManyListenersException;
-
-/**
- * Basic Form for manipulating assets.
- *
- * @author Jens Pelzetter
- * @param The type of the asset.
- */
-public abstract class AbstractAssetForm
- extends Form implements FormInitListener,
- FormProcessListener,
- FormSubmissionListener {
-
- private static final String ASSET_TITLE = "asset-name";
-
- private static final String ASSET_NAME = "asset-title";
-
- private final AssetPane assetPane;
-
- private final SingleSelectionModel selectionModel;
-
- private BoxPanel showLocalePanel;
-
- private SingleSelect showLocaleSelect;
-
- private Submit showLocaleSubmit;
-
- private BoxPanel addLocalePanel;
-
- private SingleSelect addLocaleSelect;
-
- private Submit addLocaleSubmit;
-
- private TextField name;
-
- private TextField title;
-
- private SaveCancelSection saveCancelSection;
-
- public AbstractAssetForm(final AssetPane assetPane) {
- super("asset-form", new ColumnPanel(1));
-
- this.assetPane = assetPane;
- selectionModel = assetPane.getSelectedAssetModel();
-
- initComponents();
- }
-
- private void initComponents() {
-
- showLocalePanel = new BoxPanel(BoxPanel.HORIZONTAL);
- final Label showLocaleLabel = new Label(new PrintListener() {
-
- @Override
- public void prepare(final PrintEvent event) {
- final PageState state = event.getPageState();
- final Long selectedAssetId = getSelectedAssetId(state);
- final Label target = (Label) event.getTarget();
- if (selectedAssetId == null) {
- target.setLabel(new GlobalizedMessage(
- "cms.ui.asset.initial_locale",
- CmsConstants.CMS_BUNDLE));
- } else {
- target.setLabel(new GlobalizedMessage(
- "cms.ui.asset.show_locale",
- CmsConstants.CMS_BUNDLE));
- }
- }
-
- });
- showLocaleSelect = new SingleSelect("selected-locale");
- try {
- showLocaleSelect.addPrintListener(new PrintListener() {
-
- @Override
- public void prepare(final PrintEvent event) {
- final PageState state = event.getPageState();
-
- final Long selectedAssetId = getSelectedAssetId(state);
- if (selectedAssetId == null) {
- final SingleSelect target = (SingleSelect) event
- .getTarget();
-
- target.clearOptions();
-
- final List langs = new ArrayList<>(
- KernelConfig.getConfig().getSupportedLanguages());
- langs.sort((lang1, lang2) -> lang1.compareTo(lang2));
-
- langs.forEach(lang -> {
- target.addOption(new Option(lang, new Text(lang)));
- });
- } else {
- final SingleSelect target = (SingleSelect) event
- .getTarget();
-
- target.clearOptions();
-
- final List availableLocales = getController()
- .availableLocales(selectedAssetId,
- getAssetClass());
- availableLocales.sort((locale1, locale2) -> {
- return locale1.toString().compareTo(locale2
- .toString());
- });
- availableLocales.forEach(locale -> target.addOption(
- new Option(locale.toString(),
- new Text(locale.toString()))));
- }
- }
-
- });
- } catch (TooManyListenersException ex) {
- throw new UnexpectedErrorException(ex);
- }
- showLocaleSubmit = new Submit(new GlobalizedMessage(
- "cms.ui.asset.show_locale",
- CmsConstants.CMS_BUNDLE)) {
-
- @Override
- public boolean isVisible(final PageState state) {
- return getSelectedAssetId(state) != null;
- }
-
- };
- showLocalePanel.add(showLocaleLabel);
- showLocalePanel.add(showLocaleSelect);
- showLocalePanel.add(showLocaleSubmit);
- add(showLocalePanel);
-
- addLocalePanel = new BoxPanel(BoxPanel.HORIZONTAL) {
-
- @Override
- public boolean isVisible(final PageState state) {
- return getSelectedAssetId(state) != null;
- }
-
- };
- final Label addLocaleLabel = new Label(
- new GlobalizedMessage("cms.ui.asset.add_locale",
- CmsConstants.CMS_BUNDLE));
- addLocaleSelect = new SingleSelect("add-locale-select");
- try {
- addLocaleSelect.addPrintListener(new PrintListener() {
-
- @Override
- public void prepare(final PrintEvent event) {
- final PageState state = event.getPageState();
-
- final Long selectedAssetId = getSelectedAssetId(state);
- if (selectedAssetId != null) {
- final SingleSelect target = (SingleSelect) event
- .getTarget();
-
- target.clearOptions();
-
- final List creatableLocales = getController()
- .creatableLocales(selectedAssetId,
- getAssetClass());
- creatableLocales.sort((locale1, locale2) -> {
- return locale1
- .toString()
- .compareTo(locale2.toString());
- });
- creatableLocales.forEach(locale -> target.addOption(
- new Option(locale.toString(),
- new Text(locale.toString()))));
- }
- }
-
- });
- } catch (TooManyListenersException ex) {
- throw new UnexpectedErrorException(ex);
- }
- addLocaleSubmit = new Submit(new GlobalizedMessage(
- "cms.ui.asset.add_locale",
- CmsConstants.CMS_BUNDLE));
- addLocalePanel.add(addLocaleLabel);
- addLocalePanel.add(addLocaleSelect);
- addLocalePanel.add(addLocaleSubmit);
- add(addLocalePanel);
-
- add(new Label(new GlobalizedMessage("cms.ui.asset.name",
- CmsConstants.CMS_BUNDLE)));
- name = new TextField(ASSET_NAME);
- add(name);
-
- add(new Label(new GlobalizedMessage("cms.ui.asset.title",
- CmsConstants.CMS_BUNDLE)));
- title = new TextField(ASSET_TITLE);
- add(title);
-
- addWidgets();
-
- saveCancelSection = new SaveCancelSection();
- add(saveCancelSection);
-
- addInitListener(this);
- addProcessListener(this);
- addSubmissionListener(this);
- }
-
- protected void addWidgets() {
- //Nothing here
- }
-
- protected String getTitle(final PageState state) {
- return (String) title.getValue(state);
- }
-
- protected Long getSelectedAssetId(final PageState state) {
-
- final Object key = selectionModel.getSelectedKey(state);
- if (key == null) {
- return null;
- } else {
- return (Long) key;
- }
- }
-
- @Override
- public void init(final FormSectionEvent event) throws FormProcessException {
-
- final PageState state = event.getPageState();
-
- final Long selectedAssetId = getSelectedAssetId(state);
-
- final Map data;
- if (selectedAssetId == null) {
- showLocaleSelect.setValue(state,
- KernelConfig
- .getConfig()
- .getDefaultLocale()
- .toString());
-
- data = Collections.emptyMap();
-
- } else {
-
- showLocaleSelect.setValue(state,
- getSelectedLocale(state));
-
- data = getController().getAssetData(selectedAssetId,
- getAssetClass(),
- getSelectedLocale(state));
-
- name.setValue(state,
- data.get(AbstractAssetFormController.DISPLAY_NAME));
- title.setValue(state,
- data.get(AbstractAssetFormController.TITLE));
- }
-
- initForm(state, data);
- }
-
- protected Locale getSelectedLocale(final PageState state) {
-
- final Object selected = showLocaleSelect.getValue(state);
- if (selected == null) {
- return KernelConfig.getConfig().getDefaultLocale();
- } else if (selected instanceof Locale) {
- return (Locale) selected;
- } else if (selected instanceof String) {
- return new Locale((String) selected);
- } else {
- return new Locale(selected.toString());
- }
- }
-
- protected String getTitleValue(final PageState state) {
- return (String) title.getValue(state);
- }
-
- protected void initForm(final PageState state,
- final Map data) {
-
- if (!data.isEmpty()) {
-
- name.setValue(state,
- data.get(AbstractAssetFormController.DISPLAY_NAME));
-
-// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
-// @SuppressWarnings("unchecked")
-// final AbstractAssetFormController controller = cdiUtil
-// .findBean(AbstractAssetFormController.class);
- title.setValue(state,
- data.get(AbstractAssetFormController.TITLE));
- showLocale(state);
- }
- }
-
- @Override
- public void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
-
-// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- if (showLocaleSubmit.isSelected(state)) {
-
- final Long selectedAssetId = getSelectedAssetId(state);
-
- initForm(state,
- getController().getAssetData(selectedAssetId,
- getAssetClass(),
- getSelectedLocale(state)));
-
- return;
- }
-
- if (addLocaleSubmit.isSelected(state)) {
- final Locale add = new Locale((String) addLocaleSelect
- .getValue(state));
- final Long selectedAssetId = getSelectedAssetId(state);
- getController().addLocale(selectedAssetId, add, getAssetClass());
- }
-
- if (saveCancelSection.getSaveButton().isSelected(state)) {
-
- final Map data = new HashMap<>();
- data.put(AbstractAssetFormController.DISPLAY_NAME,
- name.getValue(state));
- data.put(AbstractAssetFormController.TITLE,
- title.getValue(state));
- data.putAll(collectData(event));
-
- final Long selectedAssetId;
- if (getSelectedAssetId(state) == null) {
-
- selectedAssetId = getController()
- .createAsset(assetPane
- .getFolderSelectionModel()
- .getSelectedObject(state),
- getSelectedLocale(state),
- getAssetClass(),
- data);
- } else {
- selectedAssetId = getSelectedAssetId(state);
- }
-
- getController().updateAsset(selectedAssetId,
- getSelectedLocale(state),
- getAssetClass(),
- data);
-
- assetPane.browseMode(state);
- }
- }
-
- protected abstract Class getAssetClass();
-
- protected abstract void showLocale(final PageState state);
-
- protected abstract Map collectData(
- final FormSectionEvent event)
- throws FormProcessException;
-
- @Override
- public void submitted(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
-
- if (saveCancelSection.getCancelButton().isSelected(state)) {
- selectionModel.clearSelection(state);
- assetPane.browseMode(state);
- }
- }
-
- protected AssetFormController getController() {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetFormControllers controllers = cdiUtil
- .findBean(AssetFormControllers.class);
-
- return controllers.findController(getAssetClass());
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetFormController.java
deleted file mode 100644
index 0fa230288..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetFormController.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets;
-
-import org.librecms.assets.AssetL10NManager;
-import org.librecms.contentsection.Asset;
-import org.librecms.contentsection.AssetManager;
-import org.librecms.contentsection.AssetRepository;
-import org.librecms.contentsection.Folder;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
-
-import javax.inject.Inject;
-import javax.transaction.Transactional;
-
-/**
- * An base class for implementations of {@link AssetFormController}.
- *
- * @author Jens Pelzetter
- * @param
- */
-public abstract class AbstractAssetFormController implements
- AssetFormController {
-
- protected static final String DISPLAY_NAME = "displayName";
- protected static final String TITLE = "title";
-
- @Inject
- private AssetManager assetManager;
-
- @Inject
- private AssetRepository assetRepository;
-
- @Inject
- private AssetL10NManager l10nManager;
-
- /**
- * Retrieves the basic data of the provided asset. Subclasses should not
- * overrride this method. Instead they should provided an implementation of
- * {@link #getAssetData(org.librecms.contentsection.Asset, java.util.Locale)}.
- *
- * @param assetType The {@link Asset} from which the data is read.
- * @param selectedLocale The locale for which the data is read.
- *
- * @return A map with the data of the basic properties of the provided
- * asset.
- */
- @Transactional(Transactional.TxType.REQUIRED)
- @Override
- public Map getAssetData(final Long assetId,
- final Class assetType,
- final Locale selectedLocale) {
-
- Objects.requireNonNull(assetId, "Can't get data from asset null.");
- Objects.requireNonNull(selectedLocale,
- "Can't get data from asset for locale null.");
-
- final T asset = loadAsset(assetId, assetType);
-
- final Map data = new HashMap<>();
-
- data.put(DISPLAY_NAME, asset.getDisplayName());
- data.put(TITLE, asset.getTitle().getValue(selectedLocale));
-
- data.putAll(getAssetData(asset, selectedLocale));
-
- return data;
- }
-
- protected abstract Map getAssetData(
- final T asset, final Locale selectedLocale);
-
- @Transactional(Transactional.TxType.REQUIRED)
- @Override
- public long createAsset(final Folder infolder,
- final Locale selectedLocale,
- final Class assetType,
- final Map data) {
-
- if (!data.containsKey(DISPLAY_NAME)) {
- throw new IllegalArgumentException(
- "data does not contain a value for displayName.");
- }
-
- if (!data.containsKey(TITLE)) {
- throw new IllegalArgumentException(
- "data does not contain a value for title.");
- }
-
- final String name = (String) data.get(DISPLAY_NAME);
- final String title = (String) data.get(TITLE);
-
- final T asset = assetManager
- .createAsset(name,
- title,
- selectedLocale,
- infolder,
- assetType);
-
- return asset.getObjectId();
- }
-
- /**
- * Updates the provided asset with the provided data.
- *
- * This method is not intended to be overridden, but can't be {@code final}
- * because of limitations of CDI. To update type specific properties
- * implement
- * {@link #updateAssetProperties(org.librecms.contentsection.Asset, java.util.Locale, java.util.Map)}.
- *
- * This method calls
- * {@link AssetRepository#save(org.librecms.contentsection.Asset)} after the
- * properties are set to save the changes to the database.
- *
- * @param assetId The ID of the asset to update.
- * @param selectedLocale The locale for which the asset is updated.
- * @param data The data used to update the asset.
- */
- @Transactional(Transactional.TxType.REQUIRED)
- @Override
- public void updateAsset(final Long assetId,
- final Locale selectedLocale,
- final Class assetType,
- final Map data) {
-
- Objects.requireNonNull(selectedLocale,
- "Can't get update asset for locale null.");
- Objects.requireNonNull(data, "Can't update asset without data.");
-
- final T asset = loadAsset(assetId, assetType);
- if (data.containsKey(DISPLAY_NAME)) {
- asset.setDisplayName((String) data.get(DISPLAY_NAME));
- }
-
- if (data.containsKey(TITLE)) {
-
- final String title = (String) data.get(TITLE);
- asset.getTitle().putValue(selectedLocale, title);
- }
-
- updateAssetProperties(asset, selectedLocale, data);
-
- assetRepository.save(asset);
- }
-
- /**
- * Override this method to process data for type specific properties.
- *
- * This method is called by
- * {@link #updateAsset(org.librecms.contentsection.Asset, java.util.Locale, java.util.Map)}.
- * Implementations should not call
- * {@link AssetRepository#save}. Saving the update asset is done by
- * {@link #updateAsset(org.librecms.contentsection.Asset, java.util.Locale, java.util.Map)}.
- *
- * An implementation should not assume that a value for each property is
- * present in the provided map. Instead the overriding method should check
- * if a value for a property is available by using
- * {@link Map#containsKey(java.lang.Object)} first.
- *
- * @param asset The asset to update.
- * @param selectedLocale The locale for which the asset is updated.
- * @param data The data used to update the asset.
- */
- public abstract void updateAssetProperties(final T asset,
- final Locale selectedLocale,
- final Map data);
-
- /**
- * Determines for which locales the provided asset has data.
- *
- * @param assetId The asset.
- *
- * @return A list of all locales for which the asset has data.
- */
- @Transactional(Transactional.TxType.REQUIRED)
- @Override
- public List availableLocales(final Long assetId,
- final Class assetType) {
-
- Objects.requireNonNull(
- assetId,
- "Can't get available locales for asset with ID null.");
-
- final T selectedAsset = loadAsset(assetId, assetType);
-
- return new ArrayList<>(l10nManager.availableLocales(selectedAsset));
- }
-
- /**
- * Determines for locales the asset has no data yet.
- *
- * @param assetId The asset.
- *
- * @return A list of all locales for which the provided asset has no data
- * yet.
- */
- @Transactional(Transactional.TxType.REQUIRED)
- @Override
- public List creatableLocales(final Long assetId,
- final Class assetType) {
-
- Objects.requireNonNull(
- assetId,
- "Can't get creatable locales for asset with ID null.");
-
- final T selectedAsset = loadAsset(assetId, assetType);
-
- return new ArrayList<>(l10nManager.creatableLocales(selectedAsset));
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- @Override
- public void addLocale(final Long assetId,
- final Locale locale,
- final Class assetType) {
-
- Objects.requireNonNull(assetId, "Can't add a locale to asset null.");
- Objects.requireNonNull(locale, "Can't add locale null to an asset.");
-
- final T selectedAsset = loadAsset(assetId, assetType);
-
- l10nManager.addLanguage(selectedAsset, locale);
- }
-
- /**
- *
- * @param assetId
- * @param assetType
- *
- * @return
- */
- protected T loadAsset(final Long assetId, final Class assetType) {
-
- Objects.requireNonNull(assetId, "null is not a valid assetId");
-
- return assetRepository
- .findById(assetId, assetType)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No asset with ID %d found.", assetId)));
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowser.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowser.java
deleted file mode 100644
index b5a70488b..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowser.java
+++ /dev/null
@@ -1,446 +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.assets;
-
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.ControlLink;
-import com.arsdigita.bebop.Image;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.Page;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.Paginator;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.Table;
-import com.arsdigita.bebop.Text;
-import com.arsdigita.bebop.event.TableActionAdapter;
-import com.arsdigita.bebop.event.TableActionEvent;
-import com.arsdigita.bebop.event.TableActionListener;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.bebop.table.DefaultTableCellRenderer;
-import com.arsdigita.bebop.table.DefaultTableColumnModel;
-import com.arsdigita.bebop.table.TableCellRenderer;
-import com.arsdigita.bebop.table.TableColumn;
-import com.arsdigita.bebop.table.TableHeader;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.cms.ui.folder.FolderSelectionModel;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import java.util.Date;
-
-import org.libreccm.cdi.utils.CdiUtil;
-
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.ContentSectionManager;
-
-import static org.librecms.CmsConstants.*;
-
-/**
- * Browse folder and assets.
- *
- * @author Jens Pelzetter
- */
-public class AssetFolderBrowser extends Table {
-
- protected static final String SORT_ACTION_UP = "sortActionUp";
- protected static final String SORT_ACTION_DOWN = "sortActionDown";
- protected final static String SORT_KEY_NAME = "name";
- protected final static String SORT_KEY_TITLE = "title";
- protected final static String SORT_KEY_TYPE = "type";
- protected final static String SORT_KEY_LAST_MODIFIED_DATE = "lastModified";
- protected final static String SORT_KEY_CREATION_DATE = "creationDate";
-
- private final AssetPane assetPane;
- private TableActionListener folderChanger;
- private TableActionListener folderDeleter;
- private TableColumn nameColumn;
- private TableColumn deleteColumn;
- private final StringParameter sortTypeParameter = new StringParameter(
- "sortType");
- private final StringParameter sortDirectionParameter = new StringParameter(
- "sortDir");
-
- private Paginator paginator;
- private long folderSize;
-
- public AssetFolderBrowser(final AssetPane assetPane) {
- super();
- sortTypeParameter.setDefaultValue(SORT_KEY_NAME);
- sortDirectionParameter.setDefaultValue(SORT_ACTION_UP);
-
- this.assetPane = assetPane;
-
- initComponents();
- }
-
- private void initComponents() {
-
- final GlobalizedMessage[] headers = {
- new GlobalizedMessage("cms.ui.folder.name",
- CMS_FOLDER_BUNDLE),
- new GlobalizedMessage("cms.ui.folder.title",
- CMS_FOLDER_BUNDLE),
- new GlobalizedMessage("cms.ui.folder.type",
- CMS_FOLDER_BUNDLE),
- new GlobalizedMessage("cms.ui.asset.thumbnail",
- CMS_BUNDLE),
- new GlobalizedMessage("cms.ui.folder.creation_date",
- CMS_FOLDER_BUNDLE),
- new GlobalizedMessage("cms.ui.folder.last_modified",
- CMS_FOLDER_BUNDLE),
- new GlobalizedMessage("cms.ui.folder.action",
- CMS_FOLDER_BUNDLE)};
-
- setModelBuilder(new AssetFolderBrowserTableModelBuilder());
- setColumnModel(new DefaultTableColumnModel(headers));
- setHeader(new TableHeader(getColumnModel()));
- setClassAttr("dataTable");
-
- getHeader().setDefaultRenderer(
- new com.arsdigita.cms.ui.util.DefaultTableCellRenderer());
-
- nameColumn = getColumn(AssetFolderBrowserTableModel.COL_NAME);
- nameColumn.setCellRenderer(new NameCellRenderer());
- nameColumn.setHeaderRenderer(new HeaderCellRenderer(SORT_KEY_NAME));
-
- getColumn(AssetFolderBrowserTableModel.COL_THUMBNAIL)
- .setCellRenderer(new ThumbnailCellRenderer());
-
- getColumn(AssetFolderBrowserTableModel.COL_CREATION_DATE)
- .setHeaderRenderer(
- new HeaderCellRenderer(SORT_KEY_CREATION_DATE));
- getColumn(AssetFolderBrowserTableModel.COL_CREATION_DATE)
- .setCellRenderer(new DateCellRenderer());
-
- getColumn(AssetFolderBrowserTableModel.COL_LAST_MODIFIED)
- .setHeaderRenderer(new HeaderCellRenderer(
- SORT_KEY_LAST_MODIFIED_DATE));
- getColumn(AssetFolderBrowserTableModel.COL_LAST_MODIFIED)
- .setCellRenderer(new DateCellRenderer());
-
- deleteColumn = getColumn(AssetFolderBrowserTableModel.COL_DELETEABLE);
- deleteColumn.setCellRenderer(new ActionCellRenderer());
- deleteColumn.setAlign("center");
-
- folderChanger = new FolderChanger();
- addTableActionListener(folderChanger);
-
- folderDeleter = new ItemDeleter();
- addTableActionListener(folderDeleter);
-
- setEmptyView(new Label(new GlobalizedMessage("cms.ui.folder.no_assets",
- CMS_FOLDER_BUNDLE)));
- }
-
- @Override
- public void register(final Page page) {
-
- super.register(page);
-
- page.addComponentStateParam(
- this,
- getFolderSelectionModel().getStateParameter());
- page.addComponentStateParam(this, sortTypeParameter);
- page.addComponentStateParam(this, sortDirectionParameter);
- }
-
- protected FolderSelectionModel getFolderSelectionModel() {
- return assetPane.getFolderSelectionModel();
- }
-
- protected SingleSelectionModel getSelectedAssetModel() {
- return assetPane.getSelectedAssetModel();
- }
-
- protected Paginator getPaginator() {
- return paginator;
- }
-
- protected void setPaginator(final Paginator paginator) {
- this.paginator = paginator;
- }
-
- protected String getSortType(final PageState state) {
- return (String) state.getValue(sortTypeParameter);
- }
-
- protected String getSortDirection(final PageState state) {
- return (String) state.getValue(sortDirectionParameter);
- }
-
- private class HeaderCellRenderer extends DefaultTableCellRenderer {
-
- private final String headerKey;
-
- public HeaderCellRenderer(final String headerKey) {
- super(true);
- this.headerKey = headerKey;
- }
-
- @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 GlobalizedMessage headerName = (GlobalizedMessage) value;
- final String sortKey = (String) state.getValue(sortTypeParameter);
- final boolean isCurrentKey = sortKey.equals(key);
- final String currentSortDirection = (String) state
- .getValue(sortDirectionParameter);
- final String imageUrlStub;
-
- if (SORT_ACTION_UP.equals(currentSortDirection)) {
- imageUrlStub = "gray-triangle-up.gif";
- } else {
- imageUrlStub = "gray-triangle-down.gif";
- }
-
- final ControlLink link = new ControlLink(new Label(headerName)) {
-
- @Override
- public void setControlEvent(final PageState state) {
- String sortDirectionAction;
- // by default, everything sorts "up" unless it
- // is the current key and it is already pointing up
- if (SORT_ACTION_UP.equals(currentSortDirection)
- && isCurrentKey) {
- sortDirectionAction = SORT_ACTION_DOWN;
- } else {
- sortDirectionAction = SORT_ACTION_UP;
- }
- state.setControlEvent(table,
- sortDirectionAction,
- headerKey);
- }
-
- };
- final Label label = new Label();
- label.setLabel(headerName);
- label.setClassAttr("folderBrowserLink");
- label.setOutputEscaping(false);
- label.setFontWeight(Label.BOLD);
-
- final SimpleContainer container = new SimpleContainer();
- container.add(label);
- if (isCurrentKey) {
- Image image = new Image("/assets/" + imageUrlStub);
- image.setBorder("0");
- container.add(image);
- }
- link.setChild(container);
- return link;
- }
-
- }
-
- /**
- * Produce links to view an item or control links for folders to change into
- * the folder.
- */
- private class NameCellRenderer extends DefaultTableCellRenderer {
-
- public NameCellRenderer() {
- super(true);
- }
-
- @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 String name = (String) value;
- final ContentSection section = CMS.getContext().
- getContentSection();
- final ContentSectionManager sectionManager = CdiUtil.
- createCdiUtil()
- .findBean(ContentSectionManager.class);
-
- final boolean isFolder = ((AssetFolderBrowserTableModel) table
- .getTableModel(state))
- .isFolder();
- final long objectId = getObjectId(key);
-
- if (isFolder) {
- //return new ControlLink(new Text(name));
- return super.getComponent(table,
- state,
- value,
- isSelected,
- objectId,
- row,
- column);
- } else {
- return new ControlLink(new Text(name));
-
-// return new Link(new Text(name),
-// itemResolver.generateItemURL(state,
-// objectId,
-// name,
-// section,
-// "DRAFT"));
- }
- }
-
- }
-
- private class ThumbnailCellRenderer 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) {
- if (value == null) {
- return new Text("");
- } else {
- final Image image = new Image((String) value, "");
- return image;
- }
- }
-
- }
-
- private class DateCellRenderer 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) {
- if (value instanceof Date) {
- final Date date = (Date) value;
- return new Text(String.format("%1$TF %1$TT", date));
- } else if (value == null) {
- return new Text("");
- } else {
- return new Text(value.toString());
- }
- }
-
- }
-
- /**
- * Produce delete links for items and non-empty folders.
- */
- private class ActionCellRenderer 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) {
- if ((!(Boolean) value)) {
- return new Label(" ", false);
- } else {
- final ControlLink link = new ControlLink(
- new Label(
- new GlobalizedMessage("cms.ui.folder.delete",
- CmsConstants.CMS_FOLDER_BUNDLE)));
- link.setConfirmation(
- new GlobalizedMessage(
- "cms.ui.folder.delete_confirmation_assets",
- CmsConstants.CMS_FOLDER_BUNDLE));
- return link;
- }
- }
-
- }
-
- // Deletes an item
- private class ItemDeleter extends TableActionAdapter {
-
- @Override
- public void cellSelected(final TableActionEvent event) {
- int col = event.getColumn();
-
- if (deleteColumn != getColumn(col)) {
- return;
- }
-
- final PageState state = event.getPageState();
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetFolderBrowserController controller = cdiUtil.findBean(
- AssetFolderBrowserController.class);
- controller.deleteObject((String) event.getRowKey());
-
- ((Table) event.getSource()).clearSelection(state);
- }
-
- }
-
- private class FolderChanger extends TableActionAdapter {
-
- @Override
- public void cellSelected(final TableActionEvent event) {
- final PageState state = event.getPageState();
- final int col = event.getColumn();
-
- if (nameColumn != getColumn(col)) {
- return;
- }
-
- clearSelection(state);
- final String rowKey = (String) event.getRowKey();
- if (rowKey.startsWith(CmsConstants.FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
- getFolderSelectionModel().setSelectedKey(state,
- getObjectId(rowKey));
- } else if (rowKey.startsWith(
- CmsConstants.FOLDER_BROWSER_KEY_PREFIX_ASSET)) {
- getSelectedAssetModel().setSelectedKey(state,
- getObjectId(rowKey));
- assetPane.editAssetMode(state);
- }
- }
-
- }
-
- private long getObjectId(final Object key) {
-
- final String keyStr = (String) key;
-
- if (keyStr.startsWith("folder-")) {
- return Long.parseLong(keyStr.substring("folder-".length()));
- } else if (keyStr.startsWith("asset-")) {
- return Long.parseLong(keyStr.substring("asset-".length()));
- } else {
- return Long.parseLong(keyStr);
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserController.java
deleted file mode 100644
index b3ed0b26b..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserController.java
+++ /dev/null
@@ -1,638 +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.assets;
-
-import com.arsdigita.cms.CMS;
-import com.arsdigita.kernel.KernelConfig;
-import com.arsdigita.web.CCMDispatcherServlet;
-
-import org.libreccm.categorization.Category;
-import org.libreccm.categorization.CategoryManager;
-import org.libreccm.configuration.ConfigurationManager;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.CmsConstants;
-import org.librecms.assets.AssetTypeInfo;
-import org.librecms.assets.AssetTypesManager;
-import org.librecms.contentsection.Asset;
-
-import org.librecms.contentsection.Folder;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Join;
-import javax.persistence.criteria.Order;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Root;
-import javax.transaction.Transactional;
-
-import org.libreccm.core.CcmObject;
-import org.librecms.contentsection.AssetManager;
-import org.librecms.contentsection.AssetRepository;
-import org.librecms.contentsection.FolderManager;
-import org.librecms.contentsection.FolderRepository;
-
-import java.util.Collections;
-import java.util.Optional;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.librecms.assets.Image;
-
-import static org.librecms.CmsConstants.*;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-public class AssetFolderBrowserController {
-
- private static final Logger LOGGER = LogManager
- .getLogger(AssetFolderBrowserController.class);
-
- @Inject
- private EntityManager entityManager;
-
- @Inject
- private ConfigurationManager confManager;
-
- @Inject
- private CategoryManager categoryManager;
-
- @Inject
- private AssetTypesManager typesManager;
-
- @Inject
- private FolderRepository folderRepo;
-
- @Inject
- private FolderManager folderManager;
-
- @Inject
- private AssetRepository assetRepo;
-
- @Inject
- private AssetManager assetManager;
-
- @Inject
- private GlobalizationHelper globalizationHelper;
-
- private Locale defaultLocale;
-
- /**
- * Initialisation method called by the CDI-Container after an instance of
- * this class has be created by the container. Sets the
- * {@link #defaultLocale} property using the the value from the
- * {@link KernelConfig}.
- */
- @PostConstruct
- private void init() {
- final KernelConfig kernelConfig = confManager.findConfiguration(
- KernelConfig.class);
- defaultLocale = kernelConfig.getDefaultLocale();
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- List getAssetRows(final Folder folder,
- final String orderBy,
- final String orderDirection,
- final int firstResult,
- final int maxResults) {
- final List subFolders = findSubFolders(folder,
- "%",
- orderBy,
- orderDirection,
- firstResult,
- maxResults);
- final List subFolderRows = subFolders
- .stream()
- .map(subFolder -> buildRow(subFolder))
- .collect(Collectors.toList());
-
- if (subFolders.size() > maxResults) {
- return subFolderRows;
- } else {
- final int maxAssets = maxResults - subFolders.size();
- final int firstAsset = firstResult - subFolders.size();
-
- final List assets = findAssetsInFolder(folder,
- "%",
- orderBy,
- orderDirection,
- firstAsset,
- maxAssets);
- final List assetRows = assets
- .stream()
- .map(asset -> buildRow(asset))
- .collect(Collectors.toList());
-
- final List rows = new ArrayList<>();
- rows.addAll(subFolderRows);
- rows.addAll(assetRows);
-
- return rows;
- }
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- protected long countObjects(final Folder folder) {
-
- return countObjects(folder, "%");
-
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- protected long countObjects(final Folder folder, final String filterTerm) {
-
- Objects.requireNonNull(folder);
- Objects.requireNonNull(filterTerm);
-
- final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
- CriteriaQuery criteriaQuery = builder.createQuery(Long.class);
- final Root from = criteriaQuery.from(CcmObject.class);
-
- criteriaQuery = criteriaQuery.select(builder.count(from));
-
- final List subFolders = findSubFolders(
- folder,
- filterTerm,
- AssetFolderBrowser.SORT_KEY_NAME,
- AssetFolderBrowser.SORT_ACTION_UP,
- -1,
- -1);
- final List assets = findAssetsInFolder(
- folder,
- filterTerm,
- AssetFolderBrowser.SORT_KEY_NAME,
- AssetFolderBrowser.SORT_ACTION_UP,
- -1,
- -1);
-
- if (subFolders.isEmpty() && assets.isEmpty()) {
- return 0;
- } else if (subFolders.isEmpty() && !assets.isEmpty()) {
- criteriaQuery = criteriaQuery.where(from.in(assets));
- } else if (!subFolders.isEmpty() && assets.isEmpty()) {
- criteriaQuery = criteriaQuery.where(from.in(subFolders));
- } else {
- criteriaQuery = criteriaQuery.where(builder.or(
- from.in(subFolders),
- from.in(assets)));
- }
-
- return entityManager.createQuery(criteriaQuery).getSingleResult();
-
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- protected void copyObjects(final Folder targetFolder,
- final String[] objectIds) {
-
- Objects.requireNonNull(targetFolder);
- Objects.requireNonNull(objectIds);
-
- for (final String objectId : objectIds) {
- if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
- copyFolder(targetFolder,
- Long.parseLong(objectId.substring(
- FOLDER_BROWSER_KEY_PREFIX_FOLDER.length())));
- } else if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_ASSET)) {
- copyAsset(targetFolder,
- Long.parseLong(objectId.substring(
- FOLDER_BROWSER_KEY_PREFIX_ASSET.length())));
- } else {
- throw new IllegalArgumentException(String.format(
- "ID '%s' does not start with '%s' or '%s'.",
- objectId,
- FOLDER_BROWSER_KEY_PREFIX_FOLDER,
- FOLDER_BROWSER_KEY_PREFIX_ASSET));
- }
- }
-
- }
-
- private void copyFolder(final Folder targetFolder,
- final long folderId) {
-
- Objects.requireNonNull(targetFolder);
-
- final Folder folder = folderRepo.findById(folderId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No folder with ID %d in the database. "
- + "Where did that ID come from?",
- folderId)));
-
- folderManager.copyFolder(folder, targetFolder);
-
- }
-
- private void copyAsset(final Folder targetFolder,
- final long assetId) {
-
- Objects.requireNonNull(targetFolder);
-
- final Asset asset = assetRepo
- .findById(assetId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No asset ith ID %d in the database. Where did that ID come from?",
- assetId)));
-
- assetManager.copy(asset, targetFolder);
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- public void moveObjects(final Folder targetFolder,
- final String[] objectIds) {
-
- Objects.requireNonNull(targetFolder);
- Objects.requireNonNull(objectIds);
-
- for (final String objectId : objectIds) {
- if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
- moveFolder(targetFolder,
- Long.parseLong(objectId.substring(
- FOLDER_BROWSER_KEY_PREFIX_FOLDER.length())));
- } else if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_ASSET)) {
- moveAsset(targetFolder,
- Long.parseLong(objectId.substring(
- FOLDER_BROWSER_KEY_PREFIX_ASSET.length())));
- } else {
- throw new IllegalArgumentException(String.format(
- "ID '%s' does not start with '%s' or '%s'.",
- objectId,
- FOLDER_BROWSER_KEY_PREFIX_FOLDER,
- FOLDER_BROWSER_KEY_PREFIX_ASSET));
- }
- }
- }
-
- private void moveFolder(final Folder targetFolder, final long folderId) {
-
- Objects.requireNonNull(targetFolder);
-
- final Folder folder = folderRepo.findById(folderId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No folder with ID %d in the database. "
- + "Where did that ID come from?",
- folderId)));
-
- folderManager.moveFolder(folder, targetFolder);
- }
-
- private void moveAsset(final Folder targetFolder, final long assetId) {
-
- Objects.requireNonNull(targetFolder);
-
- final Asset asset = assetRepo
- .findById(assetId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No asset with ID %d in the database. Where did that ID come from?",
- assetId)));
-
- assetManager.move(asset, targetFolder);
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- protected List createInvalidTargetsList(final List sources) {
-
- Objects.requireNonNull(sources);
-
- final List sourceFolderIds = sources
- .stream()
- .filter(source -> source.startsWith(
- FOLDER_BROWSER_KEY_PREFIX_FOLDER))
- .collect(Collectors.toList());
- final List parentFolderIds = sourceFolderIds
- .stream()
- .map(sourceFolderId -> findParentFolderId(sourceFolderId))
- .filter(Optional::isPresent)
- .map(Optional::get)
- .collect(Collectors.toList());
- final List> subFolderIds = sourceFolderIds
- .stream()
- .map(sourceFolderId -> findSubFolderIds(sourceFolderId))
- .collect(Collectors.toList());
-
- final List invalidTargetIds = new ArrayList<>();
- invalidTargetIds.addAll(sourceFolderIds);
- invalidTargetIds.addAll(parentFolderIds);
- for (final List subFolderIdList : subFolderIds) {
- invalidTargetIds.addAll(subFolderIdList);
- }
-
- return invalidTargetIds;
-
- }
-
- private Optional findParentFolderId(final String folderId) {
-
- Objects.requireNonNull(folderId);
-
- if (!folderId.startsWith(FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
- throw new IllegalArgumentException(String.format(
- "Provided string '%s' is not an ID of a folder.",
- folderId));
- }
-
- final long objectId = Long.parseLong(folderId.substring(
- FOLDER_BROWSER_KEY_PREFIX_FOLDER.length()));
- final Folder folder = folderRepo.findById(objectId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No folder with ID %d found in database. "
- + "Where did that ID come form?",
- objectId)));
- final Optional parentFolder = folderManager.getParentFolder(
- folder);
- if (parentFolder.isPresent()) {
- return Optional.empty();
- } else {
- return Optional.ofNullable(String.format(
- "%s%d",
- FOLDER_BROWSER_KEY_PREFIX_FOLDER,
- parentFolder.get().getObjectId()));
- }
- }
-
- private List findSubFolderIds(final String folderId) {
-
- Objects.requireNonNull(folderId);
-
- if (!folderId.startsWith(FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
- throw new IllegalArgumentException(String.format(
- "Provided string '%s' is not the ID of a folder.",
- folderId));
- }
-
- final long objectId = Long.parseLong(folderId.substring(
- FOLDER_BROWSER_KEY_PREFIX_FOLDER.length()));
- final Folder folder = folderRepo.findById(objectId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No folder with ID %d found in database. "
- + "Where did that ID come form?",
- objectId)));
- return findSubFolders(folder)
- .stream()
- .map(subFolder -> String.format("%s%d",
- FOLDER_BROWSER_KEY_PREFIX_FOLDER,
- subFolder.getObjectId()))
- .collect(Collectors.toList());
- }
-
- private List findSubFolders(final Folder folder) {
-
- Objects.requireNonNull(folder);
-
- if (folder.getSubFolders() == null
- || folder.getSubFolders().isEmpty()) {
- return Collections.emptyList();
- }
-
- final List subFolders = new ArrayList<>();
- for (final Folder subFolder : folder.getSubFolders()) {
- subFolders.add(subFolder);
- subFolders.addAll(findSubFolders(subFolder));
- }
-
- return subFolders;
- }
-
- /**
- * Called by the {@link AssetFolderBrowser} to delete an object.
- *
- * @param objectId
- */
- @Transactional(Transactional.TxType.REQUIRED)
- protected void deleteObject(final String objectId) {
-
- Objects.requireNonNull(objectId);
-
- if (objectId.startsWith("folder-")) {
- final long folderId = Long.parseLong(
- objectId.substring("folder-".length()));
-
- folderRepo
- .findById(folderId)
- .ifPresent(folderRepo::delete);
- } else if (objectId.startsWith("asset-")) {
- final long assetId = Long.parseLong(
- objectId.substring("asset-".length()));
-
- assetRepo
- .findById(assetId)
- .ifPresent(assetRepo::delete);
- } else {
- throw new IllegalArgumentException(
- "The objectId is expected to start with 'folder-' or 'asset-'.");
- }
- }
-
- private AssetFolderBrowserTableRow buildRow(final Folder folder) {
-
- final AssetFolderBrowserTableRow row = new AssetFolderBrowserTableRow();
-
- row.setObjectId(folder.getObjectId());
- row.setObjectUuid(folder.getUuid());
- row.setName(folder.getName());
- if (folder.getTitle().hasValue(globalizationHelper
- .getNegotiatedLocale())) {
- row.setTitle(folder.getTitle().getValue(globalizationHelper
- .getNegotiatedLocale()));
- } else {
- row.setTitle(folder.getTitle().getValue(defaultLocale));
- }
- row.setFolder(true);
- row.setDeletable(!categoryManager.hasSubCategories(folder)
- && !categoryManager.hasObjects(folder));
-
- return row;
- }
-
- private AssetFolderBrowserTableRow buildRow(final Asset asset) {
-
- final AssetFolderBrowserTableRow row = new AssetFolderBrowserTableRow();
-
- row.setObjectId(asset.getObjectId());
- row.setObjectUuid(asset.getUuid());
- row.setName(asset.getDisplayName());
- if (asset.getTitle().hasValue(globalizationHelper
- .getNegotiatedLocale())) {
- row.setTitle(asset.getTitle().getValue(globalizationHelper
- .getNegotiatedLocale()));
- } else {
- row.setTitle(asset.getTitle().getValue(defaultLocale));
- }
- if (asset instanceof Image) {
- row.setThumbnailUrl(String
- .format("%s/content-sections/%s/images/"
- + "uuid-%s?width=150&height=100",
- CCMDispatcherServlet.getContextPath(),
- CMS.getContext().getContentSection().getLabel(),
- asset.getUuid()));
- }
- final AssetTypeInfo typeInfo = typesManager
- .getAssetTypeInfo(asset.getClass());
- row.setTypeLabelBundle(typeInfo.getLabelBundle());
- row.setTypeLabelKey(typeInfo.getLabelKey());
-
- row.setFolder(false);
-
- row.setDeletable(!assetManager.isAssetInUse(asset));
-
- return row;
- }
-
- private List findSubFolders(final Folder folder,
- final String filterTerm,
- final String orderBy,
- final String orderDirection,
- final int firstResult,
- final int maxResults) {
-
- final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
-
- final CriteriaQuery criteria = builder
- .createQuery(Folder.class);
- final Root from = criteria.from(Folder.class);
-
- final Order order;
- if (AssetFolderBrowser.SORT_KEY_NAME.equals(orderBy)
- && AssetFolderBrowser.SORT_ACTION_DOWN.
- equals(orderDirection)) {
- order = builder.desc(from.get("name"));
- } else {
- order = builder.asc(from.get("name"));
- }
-
- final TypedQuery query = entityManager
- .createQuery(
- criteria.where(
- builder.and(
- builder.
- equal(from.get("parentCategory"),
- folder),
- builder.like(builder.lower(from.get(
- "name")),
- filterTerm)
- )
- )
- .orderBy(order)
- );
-
- if (firstResult >= 0) {
- query.setFirstResult(firstResult);
- }
-
- if (maxResults >= 0) {
- query.setMaxResults(maxResults);
- }
-
- return query.getResultList();
- }
-
- private List findAssetsInFolder(final Folder folder,
- final String filterTerm,
- final String orderBy,
- final String orderDirection,
- final int firstResult,
- final int maxResults) {
-
- final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
-
- final CriteriaQuery criteria = builder.createQuery(Asset.class);
- final Root fromAsset = criteria.from(Asset.class);
- final Join join = fromAsset.join("categories");
-
- final Path> orderPath;
- switch (orderBy) {
- case AssetFolderBrowser.SORT_KEY_NAME:
- orderPath = fromAsset.get("displayName");
- break;
- case AssetFolderBrowser.SORT_KEY_CREATION_DATE:
- orderPath = fromAsset.get("creationDate");
- break;
- case AssetFolderBrowser.SORT_KEY_LAST_MODIFIED_DATE:
- orderPath = fromAsset.get("lastModifed");
- break;
- default:
- orderPath = fromAsset.get("displayName");
- break;
- }
-
- final Order order;
- if (AssetFolderBrowser.SORT_ACTION_DOWN.equals(orderDirection)) {
- order = builder.desc(orderPath);
- } else {
- order = builder.asc(orderPath);
- }
-
- LOGGER.debug("The database contains {} assets.",
- entityManager.createQuery(criteria.select(fromAsset)
- .where(
- builder.and(
- builder.equal(join.get("category"),
- folder),
- builder.equal(join.get("type"),
- CmsConstants.CATEGORIZATION_TYPE_FOLDER),
- builder.like(builder.lower(
- fromAsset.get(
- "displayName")),
- filterTerm)
- ))).getResultList().size());
-
- final TypedQuery query = entityManager
- .createQuery(
- criteria.select(fromAsset)
- .where(
- builder.and(
- builder.equal(join.get(
- "category"), folder),
- builder.equal(join.get("type"),
- CmsConstants.CATEGORIZATION_TYPE_FOLDER),
- builder.like(builder.lower(
- fromAsset.get(
- "displayName")),
- filterTerm)
- )
- )
- .orderBy(order)
- );
-
- if (firstResult >= 0) {
- query.setFirstResult(firstResult);
- }
-
- if (maxResults >= 0) {
- query.setMaxResults(maxResults);
- }
-
- return query.getResultList();
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserPaginationModelBuilder.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserPaginationModelBuilder.java
deleted file mode 100644
index 85ea33141..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserPaginationModelBuilder.java
+++ /dev/null
@@ -1,65 +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.assets;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.PaginationModelBuilder;
-import com.arsdigita.bebop.Paginator;
-import com.arsdigita.cms.ui.folder.FolderSelectionModel;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.contentsection.Folder;
-
-/**
- *
- * @author Jens Pelzetter
- */
-class AssetFolderBrowserPaginationModelBuilder implements PaginationModelBuilder {
-
- private final AssetFolderBrowser folderBrowser;
-
- public AssetFolderBrowserPaginationModelBuilder(
- final AssetFolderBrowser folderBrowser) {
-
- this.folderBrowser = folderBrowser;
- }
-
- @Override
- public int getTotalSize(final Paginator paginator, final PageState state) {
-
- final FolderSelectionModel folderSelectionModel = folderBrowser
- .getFolderSelectionModel();
- final Folder folder = folderSelectionModel.getSelectedObject(state);
- if (folder == null) {
- return 0;
- } else {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetFolderBrowserController controller = cdiUtil.findBean(
- AssetFolderBrowserController.class);
- return (int) controller.countObjects(folder);
- }
- }
-
- @Override
- public boolean isVisible(final PageState state) {
- return folderBrowser != null && folderBrowser.isVisible(state);
- }
-
-
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserTableModel.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserTableModel.java
deleted file mode 100644
index 56b7a2d6a..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserTableModel.java
+++ /dev/null
@@ -1,110 +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.assets;
-
-import com.arsdigita.bebop.table.TableModel;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import org.librecms.CmsConstants;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- *
- * @author Jens Pelzetter
- */
-class AssetFolderBrowserTableModel implements TableModel {
-
- protected static final int COL_NAME = 0;
- protected static final int COL_TITLE = 1;
- protected static final int COL_TYPE = 2;
- protected static final int COL_THUMBNAIL = 3;
- protected static final int COL_CREATION_DATE = 4;
- protected static final int COL_LAST_MODIFIED = 5;
- protected static final int COL_DELETEABLE = 6;
-
- private final Iterator iterator;
- private AssetFolderBrowserTableRow currentRow;
-
- public AssetFolderBrowserTableModel(
- final List rows) {
-
- iterator = rows.iterator();
- }
-
- @Override
- public int getColumnCount() {
- return 6;
- }
-
- @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_NAME:
- return currentRow.getName();
- case COL_TITLE:
- return currentRow.getTitle();
- case COL_TYPE:
- final String typeLabelBundle = currentRow.getTypeLabelBundle();
- final String typeLabelKey = currentRow.getTypeLabelKey();
- if (typeLabelKey == null) {
- return new GlobalizedMessage("empty_text",
- CmsConstants.CMS_BUNDLE);
- } else {
- return new GlobalizedMessage(typeLabelKey, typeLabelBundle);
- }
- case COL_THUMBNAIL:
- return currentRow.getThumbnailUrl();
- case COL_CREATION_DATE:
- return currentRow.getCreated();
- case COL_LAST_MODIFIED:
- return currentRow.getLastModified();
- case COL_DELETEABLE:
- return currentRow.isDeletable();
- default:
- throw new IllegalArgumentException(String.format(
- "Illegal column index %d.", columnIndex));
- }
- }
-
- @Override
- public Object getKeyAt(final int columnIndex) {
- if (currentRow.isFolder()) {
- return String.format("folder-%d", currentRow.getObjectId());
- } else {
- return String.format("asset-%d", currentRow.getObjectId());
- }
- }
-
- public boolean isFolder() {
- return currentRow.isFolder();
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserTableModelBuilder.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserTableModelBuilder.java
deleted file mode 100644
index afbf71efd..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserTableModelBuilder.java
+++ /dev/null
@@ -1,101 +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.assets;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.Paginator;
-import com.arsdigita.bebop.Table;
-import com.arsdigita.bebop.table.TableModel;
-import com.arsdigita.bebop.table.TableModelBuilder;
-import com.arsdigita.cms.ui.folder.FolderSelectionModel;
-import com.arsdigita.util.LockableImpl;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.contentsection.Folder;
-
-import java.util.List;
-
-/**
- * Creates the {@link TableModel} for the {@link AssetFolderBrowser}.
- *
- * @author Jens Pelzetter
- */
-class AssetFolderBrowserTableModelBuilder
- extends LockableImpl
- implements TableModelBuilder {
-
- private static final Logger LOGGER = LogManager
- .getLogger(AssetFolderBrowserTableModelBuilder.class);
-
- @Override
- public TableModel makeModel(final Table table,
- final PageState state) {
-
- if (!(table instanceof AssetFolderBrowser)) {
- throw new IllegalArgumentException(
- "The AssetFolderBrowserTableModelBuilder can only be used "
- + "for the AssetFolderBrowser.");
- }
-
- final AssetFolderBrowser assetFolderBrowser = (AssetFolderBrowser) table;
- final FolderSelectionModel folderSelectionModel = assetFolderBrowser
- .getFolderSelectionModel();
- final Folder folder = folderSelectionModel.getSelectedObject(state);
- if (folder == null) {
- return Table.EMPTY_MODEL;
- } else {
- assetFolderBrowser.getRowSelectionModel().clearSelection(state);
- final Paginator paginator = assetFolderBrowser.getPaginator();
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetFolderBrowserController controller = cdiUtil
- .findBean(AssetFolderBrowserController.class);
- final String orderBy;
- if (assetFolderBrowser.getSortType(state) == null) {
- orderBy = AssetFolderBrowser.SORT_KEY_NAME;
- } else {
- orderBy = assetFolderBrowser.getSortType(state);
- }
- final String orderDirection;
- if (assetFolderBrowser.getSortDirection(state) == null) {
- orderDirection = AssetFolderBrowser.SORT_ACTION_UP;
- } else {
- orderDirection = assetFolderBrowser.getSortDirection(state);
- }
- final int first = paginator.getFirst(state);
- final int pageSize = paginator.getPageSize(state);
-
- final long start = System.nanoTime();
- LOGGER.debug("Retrieving table rows...");
- final List rows = controller
- .getAssetRows(folder,
- orderBy,
- orderDirection,
- first - 1,
- pageSize);
-
- LOGGER.debug("Retrieve table rows in {} ms.",
- (System.nanoTime() - start) / 1000);
- return new AssetFolderBrowserTableModel(rows);
-
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserTableRow.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserTableRow.java
deleted file mode 100644
index 045a35093..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFolderBrowserTableRow.java
+++ /dev/null
@@ -1,148 +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.assets;
-
-import java.util.Date;
-
-/**
- *
- * @author Jens Pelzetter
- */
-class AssetFolderBrowserTableRow {
-
- private long objectId;
- private String objectUuid;
- private String name;
- private String title;
- private String thumbnailUrl;
- private String typeLabelBundle;
- private String typeLabelKey;
- private Date created;
- private Date lastModified;
- private boolean deletable;
- private boolean folder;
-
- public long getObjectId() {
- return objectId;
- }
-
- public void setObjectId(final long objectId) {
- this.objectId = objectId;
- }
-
- public String getObjectUuid() {
- return objectUuid;
- }
-
- public void setObjectUuid(final String objectUuid) {
- this.objectUuid = objectUuid;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(final String title) {
- this.title = title;
- }
-
- public String getThumbnailUrl() {
- return thumbnailUrl;
- }
-
- public void setThumbnailUrl(final String thumbnailUrl) {
- this.thumbnailUrl = thumbnailUrl;
- }
-
- public String getTypeLabelBundle() {
- return typeLabelBundle;
- }
-
- public void setTypeLabelBundle(final String typeLabelBundle) {
- this.typeLabelBundle = typeLabelBundle;
- }
-
- public String getTypeLabelKey() {
- return typeLabelKey;
- }
-
- public void setTypeLabelKey(final String typeLabelKey) {
- this.typeLabelKey = typeLabelKey;
- }
-
- public Date getCreated() {
- if (created == null) {
- return null;
- } else {
- return new Date(created.getTime());
- }
- }
-
- protected void setCreated(final Date created) {
- if (created == null) {
- this.created = null;
- } else {
- this.created = new Date(created.getTime());
- }
- }
-
- public Date getLastModified() {
- if (lastModified == null) {
- return null;
- } else {
- return new Date(lastModified.getTime());
- }
- }
-
- protected void setLastModified(final Date lastModified) {
- if (lastModified == null) {
- this.lastModified = null;
- } else {
- this.lastModified = new Date(lastModified.getTime());
- }
- }
-
- public boolean isDeletable() {
- return deletable;
- }
-
- public void setDeletable(final boolean deletable) {
- this.deletable = deletable;
- }
-
- public boolean isFolder() {
- return folder;
- }
-
- public void setFolder(final boolean folder) {
- this.folder = folder;
- }
-
-
-
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFormController.java
deleted file mode 100644
index c188d613a..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFormController.java
+++ /dev/null
@@ -1,107 +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.assets;
-
-import org.librecms.contentsection.Asset;
-import org.librecms.contentsection.Folder;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- *
- * Interface for the CDI backend for the forms to manage assets.To avoid
- * problems with transactions etc.
- *
- * the Bebop based forms should access any other CDI beans beside the
- * approbriate implementation of this interface. To minimize the efford to
- * create an implementation the {@link AbstractAssetFormController} class should
- * be used. This class provides basic implementations for most methods.
- *
- * Implementations of the methods defined by this interface should annotated
- * with {@code @Transactional(Transactional.TxType.REQUIRED)}.
- *
- * @author Jens Pelzetter
- *
- * @param The type asset managed by this controller.
- */
-public interface AssetFormController {
-
- /**
- * Gets the data for the forms from the asset.
- *
- * @param assetId The ID of the asset.
- * @param assetType
- * @param selectedLocale The selected locale
- *
- * @return The values of the properties of the asset for the the selected
- * locale.
- */
- Map getAssetData(Long assetId,
- Class assetType,
- Locale selectedLocale);
-
- /**
- * Updates the asset with the provided data and saves the changes.
- *
- * @param assetId
- * @param selectedLocale
- * @param assetType
- * @param data
- */
- void updateAsset(Long assetId,
- Locale selectedLocale,
- Class assetType,
- Map data);
-
- long createAsset(Folder inFolder,
- Locale selectedLocale,
- Class assetType,
- Map data);
-
-
-
- /**
- * Determines in which locales the provided asset is available.
- *
- *
- * @param assetId
- * @param assetType
- *
- * @return A list of the locales for which the asset has data.
- */
- List availableLocales(Long assetId, Class assetType);
-
- /**
- * Determines for which the provided asset has no data.
- *
- *
- * @param assetId
- * @param assetType
- *
- * @return A list of the locales for which the asset has data yet.
- */
- List creatableLocales(Long assetId, Class assetType);
-
- void addLocale(final Long assetId,
- final Locale locale,
- final Class assetType);
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFormControllers.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFormControllers.java
deleted file mode 100644
index 8fa79557f..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetFormControllers.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets;
-
-import org.librecms.contentsection.Asset;
-
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Inject;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-public class AssetFormControllers {
-
- @Inject
- @Any
- private Instance> controllers;
-
- @SuppressWarnings("unchecked")
- public AssetFormController findController(
- final Class assetType) {
-
- final IsControllerForAssetTypeLiteral literal
- = new IsControllerForAssetTypeLiteral(
- assetType);
-
- final Instance> instance = controllers
- .select(literal);
-
- if (instance.isUnsatisfied()) {
- throw new IllegalArgumentException(String.format(
- "No controller for asset type \"%s\".",
- assetType.getClass().getName()));
- } else {
- return (AssetFormController) instance.iterator().next();
- }
- }
-
- private class IsControllerForAssetTypeLiteral
- extends AnnotationLiteral
- implements IsControllerForAssetType {
-
- private static final long serialVersionUID = 1L;
-
- private final Class extends Asset> assetType;
-
- public IsControllerForAssetTypeLiteral(
- final Class extends Asset> assetType) {
-
- this.assetType = assetType;
- }
-
- @Override
- public Class extends Asset> value() {
-
- return assetType;
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetPane.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetPane.java
deleted file mode 100644
index 02c3d87d5..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetPane.java
+++ /dev/null
@@ -1,1229 +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.assets;
-
-import com.arsdigita.bebop.ActionLink;
-import com.arsdigita.bebop.BoxPanel;
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.ControlLink;
-import com.arsdigita.bebop.Form;
-import com.arsdigita.bebop.FormData;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.MetaForm;
-import com.arsdigita.bebop.Page;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.Paginator;
-import com.arsdigita.bebop.ParameterSingleSelectionModel;
-import com.arsdigita.bebop.RequestLocal;
-import com.arsdigita.bebop.Resettable;
-import com.arsdigita.bebop.SaveCancelSection;
-import com.arsdigita.bebop.SegmentedPanel;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.Table;
-import com.arsdigita.bebop.Text;
-import com.arsdigita.bebop.Tree;
-import com.arsdigita.bebop.event.ActionEvent;
-import com.arsdigita.bebop.event.ActionListener;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.FormSubmissionListener;
-import com.arsdigita.bebop.event.FormValidationListener;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.form.CheckboxGroup;
-import com.arsdigita.bebop.form.FormErrorDisplay;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.SingleSelect;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.parameters.ArrayParameter;
-import com.arsdigita.bebop.parameters.LongParameter;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.bebop.table.TableCellRenderer;
-import com.arsdigita.bebop.table.TableColumn;
-import com.arsdigita.bebop.tree.TreeCellRenderer;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.cms.ui.BaseTree;
-import com.arsdigita.cms.ui.folder.FolderCreateForm;
-import com.arsdigita.cms.ui.folder.FolderEditorForm;
-import com.arsdigita.cms.ui.folder.FolderRequestLocal;
-import com.arsdigita.cms.ui.folder.FolderSelectionModel;
-import com.arsdigita.cms.ui.folder.FolderTreeModelBuilder;
-import com.arsdigita.cms.ui.folder.FolderTreeModelController;
-import com.arsdigita.cms.ui.permissions.CMSPermissionsPane;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.toolbox.ui.ActionGroup;
-import com.arsdigita.toolbox.ui.LayoutPanel;
-import com.arsdigita.ui.CcmObjectSelectionModel;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.categorization.Category;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.Folder;
-
-import java.util.List;
-
-import org.librecms.CMSConfig;
-import org.libreccm.categorization.CategoryManager;
-import org.libreccm.core.CcmObject;
-import org.libreccm.core.UnexpectedErrorException;
-import org.libreccm.security.PermissionChecker;
-import org.libreccm.security.PermissionManager;
-import org.librecms.assets.AssetTypeInfo;
-import org.librecms.assets.AssetTypesManager;
-import org.librecms.contentsection.Asset;
-import org.librecms.contentsection.AssetManager;
-import org.librecms.contentsection.AssetRepository;
-import org.librecms.contentsection.FolderManager;
-import org.librecms.contentsection.FolderRepository;
-import org.librecms.contentsection.privileges.AssetPrivileges;
-import org.librecms.contentsection.privileges.ItemPrivileges;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.ResourceBundle;
-import java.util.TooManyListenersException;
-
-import static org.librecms.CmsConstants.*;
-
-/**
- *
- * @author Jens Pelzetter
- */
-public class AssetPane extends LayoutPanel implements Resettable {
-
- private static final Logger LOGGER = LogManager.getLogger(AssetPane.class);
-
- public static final String SET_FOLDER = "set_folder";
- private static final String SOURCES_PARAM = "sources";
- private static final String ACTION_PARAM = "action";
- private static final String MOVE = "Move";
- private static final String COPY = "Copy";
-
- private final BaseTree tree;
- private final SingleSelectionModel selectionModel;
- private final FolderSelectionModel folderSelectionModel;
- private final FolderRequestLocal folderRequestLocal;
- private final SingleSelectionModel selectedAssetModel;
- private final ArrayParameter sourcesParameter = new ArrayParameter(
- new StringParameter(SOURCES_PARAM));
- private final StringParameter actionParameter = new StringParameter(
- ACTION_PARAM);
- private final StringParameter selectedAssetTypeParam = new StringParameter(
- "selected_asset_type");
-
- private AssetFolderBrowser folderBrowser;
- private Form browserForm;
- private SingleSelect actionSelect;
- private Submit actionSubmit;
- private TargetSelector targetSelector;
-
- private SegmentedPanel.Segment browseSegment;
-// private SegmentedPanel.Segment currentFolderSegment;
- private SegmentedPanel.Segment actionsSegment;
- private SegmentedPanel.Segment newFolderSegment;
- private SegmentedPanel.Segment editFolderSegment;
- private SegmentedPanel.Segment editAssetSegment;
- private SegmentedPanel.Segment folderPermissionsSegment;
-
- @SuppressWarnings("unchecked")
- public AssetPane() {
- tree = new BaseTree(new FolderTreeModelBuilder() {
-
- @Override
- protected Folder getRootFolder(final PageState state) {
- final ContentSection section = CMS
- .getContext()
- .getContentSection();
- return section.getRootAssetsFolder();
- }
-
- });
- selectionModel = tree.getSelectionModel();
- folderSelectionModel = new FolderSelectionModel(selectionModel) {
-
- @Override
- protected Long getRootFolderID(final PageState state) {
- final ContentSection section = CMS
- .getContext()
- .getContentSection();
- return section.getRootAssetsFolder().getObjectId();
- }
-
- };
- folderRequestLocal = new FolderRequestLocal(folderSelectionModel);
-
- selectedAssetModel = new ParameterSingleSelectionModel<>(
- new LongParameter("selected-asset"));
-
- final SegmentedPanel left = new SegmentedPanel();
- setLeft(left);
-
- final Label heading = new Label(
- new GlobalizedMessage("cms.ui.folder_browser",
- CmsConstants.CMS_BUNDLE));
- left.addSegment(heading, tree);
-
-// final Text placeholder = new Text("Placeholder");
- setBody(createBrowserPane());
-
- }
-
- private SimpleContainer createBrowserPane() {
-
- final SegmentedPanel panel = new SegmentedPanel();
-
- browseSegment = panel.addSegment();
- browserForm = new Form("assetFolderBrowser",
- new BoxPanel(BoxPanel.VERTICAL));
- browserForm.setMethod(Form.GET);
- folderBrowser = new AssetFolderBrowser(this);
- final Paginator paginator = new Paginator(
- new AssetFolderBrowserPaginationModelBuilder(folderBrowser),
- CMSConfig.getConfig().getFolderBrowseListSize());
- folderBrowser.setPaginator(paginator);
-
- final CheckboxGroup checkboxGroup = new CheckboxGroup(sourcesParameter);
- browserForm.add(checkboxGroup);
- final TableColumn checkboxCol = new TableColumn();
- checkboxCol.setHeaderValue(
- new GlobalizedMessage("empty_text", CmsConstants.CMS_BUNDLE));
- checkboxCol.setCellRenderer(new 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 Option result = new Option(key.toString(),
- new Text(""));
- result.setGroup(checkboxGroup);
- return result;
- }
-
- });
- folderBrowser.getColumnModel().add(0, checkboxCol);
-
- browserForm.add(paginator);
- browserForm.add(folderBrowser);
- final SimpleContainer actionFormContainer = new SimpleContainer();
- actionFormContainer.add(new Label(
- new GlobalizedMessage(
- "cms.ui.folder.edit_selection",
- CmsConstants.CMS_FOLDER_BUNDLE)));
- actionSelect = new SingleSelect(actionParameter);
- actionSelect.addOption(
- new Option(COPY,
- new Label(new GlobalizedMessage(
- "cms.ui.folder.copy.action",
- CmsConstants.CMS_FOLDER_BUNDLE))));
- actionSelect.addOption(
- new Option(MOVE,
- new Label(new GlobalizedMessage(
- "cms.ui.folder.move.action",
- CmsConstants.CMS_FOLDER_BUNDLE))));
- actionFormContainer.add(actionSelect);
- actionSubmit = new Submit(
- "Go",
- new GlobalizedMessage("cms.ui.folder.go",
- CmsConstants.CMS_FOLDER_BUNDLE));
- actionFormContainer.add(actionSubmit);
- browserForm.addProcessListener(new FormProcessListener() {
-
- @Override
- public void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
-
- moveCopyMode(state);
-
- }
-
- });
- browserForm.add(actionFormContainer);
-
- targetSelector = new TargetSelector();
- targetSelector.addProcessListener(new FormProcessListener() {
-
- @Override
- public void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
-
- browseMode(state);
- targetSelector.setVisible(state, false);
-
- final Folder folder = targetSelector.getTarget(state);
- final String[] objectIds = getSources(state);
-
- if (isCopy(state)) {
- copyObjects(folder, objectIds);
- } else if (isMove(state)) {
- moveObjects(folder, objectIds);
- }
-
- reset(state);
- }
-
- });
- targetSelector.addValidationListener(
- new TargetSelectorValidationListener());
- targetSelector.addSubmissionListener(new FormSubmissionListener() {
-
- @Override
- public void submitted(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
-
- if (targetSelector.isCancelled(state)) {
- reset(state);
- browseMode(state);
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.folder.cancelled",
- CmsConstants.CMS_FOLDER_BUNDLE));
- }
- }
-
- });
- browseSegment.add(targetSelector);
-
-// browseSegment.add(paginator);
-// browseSegment.add(folderBrowser);
- browseSegment.add(browserForm);
-
-// currentFolderSegment = panel.addSegment();
-// currentFolderSegment.addHeader(new Text("Current folder"));
-// final Label currentFolderLabel = new Label();
-// currentFolderLabel.addPrintListener(new PrintListener() {
-//
-// @Override
-// public void prepare(final PrintEvent event) {
-// final PageState state = event.getPageState();
-// final Label target = (Label) event.getTarget();
-//
-// final long selectedId = Long.parseLong(selectionModel
-// .getSelectedKey(state).toString());
-// final long currentFolderId = folderSelectionModel
-// .getSelectedObject(state).getObjectId();
-// target.setLabel(String.format(
-// "selectedId = %d; currentFolderId = %d",
-// selectedId,
-// currentFolderId));
-// }
-//
-// });
-// currentFolderSegment.add(currentFolderLabel);
- actionsSegment = panel.addSegment();
- actionsSegment.setIdAttr("folder-browse");
-
- final ActionGroup actions = new ActionGroup();
- actionsSegment.add(actions);
-
- final FolderCreateForm folderCreateForm = new FolderCreateForm(
- "fcreat", folderSelectionModel);
- folderCreateForm.addSubmissionListener(new FormSubmissionListener() {
-
- @Override
- public void submitted(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- if (event.getSource() == folderCreateForm
- && folderCreateForm.isCancelled(state)) {
- browseMode(state);
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.cancelled", CmsConstants.CMS_BUNDLE));
-
- }
- }
-
- });
- folderCreateForm.addProcessListener(new FormProcessListener() {
-
- @Override
- public void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- final Object source = event.getSource();
- if (source == folderCreateForm) {
- browseMode(state);
- }
- }
-
- });
- newFolderSegment = panel.addSegment(
- new Label(new GlobalizedMessage("cms.ui.new_folder",
- CmsConstants.CMS_BUNDLE)),
- folderCreateForm);
-
- final FolderEditorForm folderEditorForm = new FolderEditorForm(
- "fedit", folderSelectionModel);
- folderEditorForm.addSubmissionListener(new FormSubmissionListener() {
-
- @Override
- public void submitted(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- if (event.getSource() == folderEditorForm
- && folderEditorForm.isCancelled(state)) {
- browseMode(state);
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.cancelled", CmsConstants.CMS_BUNDLE));
- }
- }
-
- });
- folderEditorForm.addProcessListener(new FormProcessListener() {
-
- @Override
- public void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- final Object source = event.getSource();
- if (source == folderEditorForm) {
- browseMode(state);
- }
- }
-
- });
- editFolderSegment = panel.addSegment(
- new Label(new GlobalizedMessage("cms.ui.edit_folder",
- CmsConstants.CMS_BUNDLE)),
- folderEditorForm);
-
- final ActionLink createFolderAction = new ActionLink(
- new Label(new GlobalizedMessage("cms.ui.new_folder",
- CmsConstants.CMS_BUNDLE)));
- createFolderAction.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
- final Object source = event.getSource();
- if (source == createFolderAction) {
- newFolderMode(state);
- }
- }
-
- });
- actions.addAction(createFolderAction);
-
- final ActionLink editFolderAction = new ActionLink(
- new Label(new GlobalizedMessage("cms.ui.edit_folder",
- CmsConstants.CMS_BUNDLE)));
- editFolderAction.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
- final Object source = event.getSource();
- if (source == editFolderAction) {
- editFolderMode(state);
- }
- }
-
- });
- actions.addAction(editFolderAction);
-
- final Form newAssetForm = new Form("new-asset-form",
- new BoxPanel(BoxPanel.HORIZONTAL));
- newAssetForm.setMethod("GET");
- newAssetForm.add(new Label(new GlobalizedMessage(
- "cms.ui.assets.new", CmsConstants.CMS_BUNDLE)));
- final SingleSelect newAssetTypeSelect = new SingleSelect(
- selectedAssetTypeParam);
- try {
- newAssetTypeSelect.addPrintListener(new PrintListener() {
-
- @Override
- public void prepare(final PrintEvent event) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetTypesManager typesManager = cdiUtil
- .findBean(AssetTypesManager.class);
- final SingleSelect target = (SingleSelect) event.getTarget();
- target.clearOptions();
- for (final AssetTypeInfo type : typesManager
- .getAvailableAssetTypes()) {
- final String labelKey = type.getLabelKey();
- final String labelBundle = type.getLabelBundle();
- final ResourceBundle bundle = ResourceBundle
- .getBundle(labelBundle);
- final String label = bundle.getString(labelKey);
- target.addOption(new Option(
- type.getAssetClass().getName(),
- new Text(label)));
- }
- }
-
- });
- } catch (TooManyListenersException ex) {
- throw new UnexpectedErrorException(ex);
- }
- newAssetForm.add(newAssetTypeSelect);
- newAssetForm.add(new Submit(new GlobalizedMessage(
- "cms.ui.assets.new.create", CmsConstants.CMS_BUNDLE)));
- newAssetForm.addProcessListener(new FormProcessListener() {
-
- @Override
- public void process(final FormSectionEvent event)
- throws FormProcessException {
- editAssetMode(event.getPageState());
- }
-
- });
-
- actionsSegment.add(newAssetForm);
-
- final MetaForm editAssetForm = new MetaForm("editAsset") {
-
- @Override
- public Form buildForm(final PageState state) {
-
- final boolean newAsset;
-
- final Long selectedAssetId = selectedAssetModel
- .getSelectedKey(state);
- newAsset = selectedAssetId == null;
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
-
- final String selectedAssetType;
- if (newAsset) {
- selectedAssetType = (String) newAssetTypeSelect
- .getValue(state);
- } else {
- final AssetRepository assetRepo = cdiUtil
- .findBean(AssetRepository.class);
- final Asset asset = assetRepo.findById(selectedAssetModel
- .getSelectedKey(state))
- .orElseThrow(() -> new IllegalArgumentException(
- String.format("No asset with ID %d in the "
- + "database.",
- selectedAssetModel
- .getSelectedKey(state))));
- selectedAssetType = asset.getClass().getName();
- }
-
- final AssetTypesManager typesManager = cdiUtil
- .findBean(AssetTypesManager.class);
- final AssetTypeInfo typeInfo = typesManager
- .getAssetTypeInfo(selectedAssetType);
- final Class extends AbstractAssetForm> assetForm = typeInfo
- .getAssetForm();
- try {
- return assetForm
- .getConstructor(AssetPane.class)
- .newInstance(AssetPane.this);
- } catch (NoSuchMethodException
- | SecurityException
- | InstantiationException
- | IllegalAccessException
- | InvocationTargetException ex) {
- throw new UnexpectedErrorException(String.format(
- "Failed to create form '%s' for editing assets "
- + "of type '%s'.",
- assetForm.getName(),
- selectedAssetType));
- }
-
- }
-
- };
- editAssetSegment = panel.addSegment();
- editAssetSegment.addHeader(
- new Label(new PrintListener() {
-
- @Override
- public void prepare(final PrintEvent event) {
-
- final PageState state = event.getPageState();
- final Label target = (Label) event.getTarget();
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetTypesManager typesManager = cdiUtil
- .findBean(AssetTypesManager.class);
-
- if (selectedAssetModel.isSelected(state)) {
- target.setLabel(
- new GlobalizedMessage(
- "cms.ui.admin.assets.edit",
- CmsConstants.CMS_BUNDLE));
- } else {
- final String assetType = (String) newAssetTypeSelect
- .getValue(state);
- final AssetTypeInfo typeInfo = typesManager
- .getAssetTypeInfo(assetType);
- final ResourceBundle bundle = ResourceBundle.getBundle(
- typeInfo.getLabelBundle());
- final String typeLabel = bundle
- .getString(typeInfo.getLabelKey());
-
- target.setLabel(new GlobalizedMessage(
- "cms.ui.admin.assets.create",
- CmsConstants.CMS_BUNDLE,
- new Object[]{typeLabel}));
- }
- }
-
- }));
- editAssetSegment.add(editAssetForm);
-
- folderPermissionsSegment = panel.addSegment();
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionManager permissionManager = cdiUtil
- .findBean(PermissionManager.class);
- final String[] privileges = permissionManager
- .listDefiniedPrivileges(AssetPrivileges.class)
- .toArray(new String[]{});
- final Map privilegeNameMap = new HashMap<>();
- Arrays
- .stream(privileges)
- .forEach(privilege -> privilegeNameMap.put(privilege, privilege));
- final CcmObjectSelectionModel objSelectionModel
- = new CcmObjectSelectionModel<>(
- CcmObject.class, folderSelectionModel);
- final CMSPermissionsPane folderPermissionsPane = new CMSPermissionsPane(
- privileges, privilegeNameMap, objSelectionModel);
- folderPermissionsSegment.add(folderPermissionsPane);
-
-
- return panel;
-
- }
-
- protected void browseMode(final PageState state) {
- tree.setVisible(state, true);
- browseSegment.setVisible(state, true);
- folderBrowser.setVisible(state, true);
- browserForm.setVisible(state, true);
- targetSelector.setVisible(state, false);
- actionsSegment.setVisible(state, true);
- newFolderSegment.setVisible(state, false);
- editFolderSegment.setVisible(state, false);
- editAssetSegment.setVisible(state, false);
- folderPermissionsSegment.setVisible(state, true);
- }
-
- protected void moveCopyMode(final PageState state) {
- tree.setVisible(state, false);
- browseSegment.setVisible(state, true);
- folderBrowser.setVisible(state, false);
- browserForm.setVisible(state, false);
- targetSelector.setVisible(state, true);
- actionsSegment.setVisible(state, false);
- newFolderSegment.setVisible(state, false);
- editFolderSegment.setVisible(state, false);
- targetSelector.expose(state);
- editAssetSegment.setVisible(state, false);
- folderPermissionsSegment.setVisible(state, false);
- }
-
- protected void newFolderMode(final PageState state) {
- tree.setVisible(state, false);
- browseSegment.setVisible(state, false);
- folderBrowser.setVisible(state, false);
- browserForm.setVisible(state, false);
- targetSelector.setVisible(state, false);
- actionsSegment.setVisible(state, false);
- newFolderSegment.setVisible(state, true);
- editFolderSegment.setVisible(state, false);
- editAssetSegment.setVisible(state, false);
- folderPermissionsSegment.setVisible(state, false);
- }
-
- protected void editFolderMode(final PageState state) {
- tree.setVisible(state, false);
- browseSegment.setVisible(state, false);
- targetSelector.setVisible(state, false);
- actionsSegment.setVisible(state, false);
- newFolderSegment.setVisible(state, false);
- editFolderSegment.setVisible(state, true);
- editAssetSegment.setVisible(state, false);
- folderPermissionsSegment.setVisible(state, false);
- }
-
- protected void editAssetMode(final PageState state) {
- tree.setVisible(state, false);
- browseSegment.setVisible(state, false);
- targetSelector.setVisible(state, false);
- actionsSegment.setVisible(state, false);
- newFolderSegment.setVisible(state, false);
- editFolderSegment.setVisible(state, false);
- editAssetSegment.setVisible(state, true);
- folderPermissionsSegment.setVisible(state, false);
- }
-
- @Override
- public void register(final Page page) {
-
- super.register(page);
-
- page.addActionListener(new TreeListener());
- page.addActionListener(new FolderListener());
-
- page.setVisibleDefault(tree, true);
- page.setVisibleDefault(browseSegment, true);
- page.setVisibleDefault(folderBrowser, true);
- page.setVisibleDefault(browserForm, true);
- page.setVisibleDefault(targetSelector, false);
- page.setVisibleDefault(actionsSegment, true);
- page.setVisibleDefault(newFolderSegment, false);
- page.setVisibleDefault(editFolderSegment, false);
- page.setVisibleDefault(editAssetSegment, false);
- page.setVisibleDefault(folderPermissionsSegment, true);
-
- page.addComponentStateParam(this, actionParameter);
- page.addComponentStateParam(this, sourcesParameter);
- page.addComponentStateParam(this, selectedAssetTypeParam);
- page.addComponentStateParam(this,
- selectedAssetModel.getStateParameter());
- }
-
- @Override
- public void reset(final PageState state) {
-
- super.reset(state);
-
- folderBrowser.getPaginator().reset(state);
-
- state.setValue(actionParameter, null);
- state.setValue(sourcesParameter, null);
-
- }
-
- protected SingleSelectionModel getSelectedAssetModel() {
- return selectedAssetModel;
- }
-
- protected FolderSelectionModel getFolderSelectionModel() {
- return folderSelectionModel;
- }
-
- private String[] getSources(final PageState state) {
-
- final String[] result = (String[]) state.getValue(sourcesParameter);
-
- if (result == null) {
- return new String[0];
- } else {
- return result;
- }
- }
-
- protected final boolean isMove(final PageState state) {
- return MOVE.equals(getAction(state));
- }
-
- protected final boolean isCopy(final PageState state) {
- return COPY.equals(getAction(state));
- }
-
- private String getAction(final PageState state) {
- return (String) state.getValue(actionParameter);
- }
-
- protected void moveObjects(final Folder target, final String[] objectIds) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetFolderBrowserController controller = cdiUtil.findBean(
- AssetFolderBrowserController.class);
-
- controller.moveObjects(target, objectIds);
- }
-
- protected void copyObjects(final Folder target, final String[] objectIds) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetFolderBrowserController controller = cdiUtil.findBean(
- AssetFolderBrowserController.class);
-
- controller.copyObjects(target, objectIds);
- }
-
- private final class FolderListener implements ActionListener {
-
- @Override
- @SuppressWarnings("unchecked")
- public void actionPerformed(final ActionEvent event) {
-
- final PageState state = event.getPageState();
-
- if (!selectionModel.isSelected(state)) {
- final String folder = state
- .getRequest()
- .getParameter(SET_FOLDER);
-
- if (folder == null) {
- final Category root = CMS
- .getContext()
- .getContentSection()
- .getRootAssetsFolder();
- final Long folderId = root.getObjectId();
-
- selectionModel.setSelectedKey(state, folderId);
- } else {
- selectionModel.setSelectedKey(state, Long.parseLong(folder));
- }
- }
- }
-
- }
-
- private final class TreeListener implements ActionListener {
-
- @Override
- public void actionPerformed(final ActionEvent event) {
-
- final PageState state = event.getPageState();
-
- final Category root = CMS
- .getContext()
- .getContentSection()
- .getRootAssetsFolder();
-
- if (!root.equals(folderRequestLocal.getFolder(state))) {
- // Expand the ancestor nodes of the currently
- // selected node.
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final FolderTreeModelController controller = cdiUtil.findBean(
- FolderTreeModelController.class);
- final List ancestorIds = controller.findAncestorIds(
- folderRequestLocal.getFolder(state));
- ancestorIds.forEach(id -> tree.expand(id.toString(), state));
-
- }
- }
-
- }
-
- private class TargetSelector extends Form implements Resettable {
-
- private final FolderSelectionModel targetFolderModel;
- private final AssetFolderTree folderTree;
- private final Submit cancelButton;
-
- public TargetSelector() {
- super("targetSelector", new BoxPanel());
- setMethod(GET);
- targetFolderModel = new FolderSelectionModel("target") {
-
- @Override
- protected Long getRootFolderID(final PageState state) {
- final ContentSection section = CMS
- .getContext()
- .getContentSection();
- return section.getRootAssetsFolder().getObjectId();
- }
-
- };
- folderTree = new AssetFolderTree(targetFolderModel);
-
- folderTree.setCellRenderer(new FolderTreeCellRenderer());
-
- final Label label = new Label(new PrintListener() {
-
- @Override
- public void prepare(final PrintEvent event) {
-
- final PageState state = event.getPageState();
- final Label label = (Label) event.getTarget();
- final int numberOfItems = getSources(state).length;
- final Category folder = (Category) folderSelectionModel
- .getSelectedObject(state);
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final CategoryManager categoryManager = cdiUtil
- .findBean(CategoryManager.class);
-
- final String targetFolderPath;
- if (targetFolderModel.getSelectedObject(state) == null) {
- targetFolderPath = "";
- } else {
- targetFolderPath = categoryManager.getCategoryPath(
- targetFolderModel.getSelectedObject(state));
- }
-
- if (isMove(state)) {
- label.setLabel(new GlobalizedMessage(
- "cms.ui.folder.move",
- CmsConstants.CMS_FOLDER_BUNDLE,
- new Object[]{
- numberOfItems,
- categoryManager.getCategoryPath(folder),
- targetFolderPath
- }));
- } else if (isCopy(state)) {
- label.setLabel(new GlobalizedMessage(
- "cms.ui.folder.copy",
- CMS_BUNDLE,
- new Object[]{
- numberOfItems,
- categoryManager.getCategoryPath(folder),
- targetFolderPath
- }));
- }
- }
-
- });
-
- label.setOutputEscaping(false);
- add(label);
- add(folderTree);
- add(new FormErrorDisplay(this));
- final SaveCancelSection saveCancelSection = new SaveCancelSection();
- cancelButton = saveCancelSection.getCancelButton();
- add(saveCancelSection);
- }
-
- @Override
- public void register(final Page page) {
- super.register(page);
- page.addComponentStateParam(this,
- targetFolderModel.getStateParameter());
- }
-
- public void expose(final PageState state) {
-
- final Folder folder = folderSelectionModel.getSelectedObject(state);
- targetFolderModel.clearSelection(state);
- if (folder != null) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final FolderManager folderManager = cdiUtil.findBean(
- FolderManager.class);
- if (!folderManager.getParentFolder(folder).isPresent()) {
- folderTree.expand(Long.toString(folder.getObjectId()),
- state);
- } else {
- final List parents = folderManager
- .getParentFolders(folder);
- parents
- .stream()
- .map(parent -> Long.toString(parent.getObjectId()))
- .forEach(folderId -> folderTree.expand(folderId,
- state));
- }
- }
- }
-
- @Override
- public void reset(final PageState state) {
- folderTree.clearSelection(state);
- state.setValue(folderTree.getSelectionModel().getStateParameter(),
- null);
- }
-
- public Folder getTarget(final PageState state) {
- return targetFolderModel.getSelectedObject(state);
- }
-
- public boolean isCancelled(final PageState state) {
- return cancelButton.isSelected(state);
- }
-
- }
-
- private class FolderTreeCellRenderer implements TreeCellRenderer {
-
- private final RequestLocal invalidFoldersRequestLocal
- = new RequestLocal();
-
- /**
- * Render the folders appropriately. The selected folder is a bold
- * label. Invalid folders are plain labels. Unselected, valid folders
- * are control links. Invalid folders are: the parent folder of the
- * sources, any of the sources, and any subfolders of the sources.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Component getComponent(final Tree tree,
- final PageState state,
- final Object value,
- final boolean isSelected,
- final boolean isExpanded,
- final boolean isLeaf,
- final Object key) {
-
- // Get the list of invalid folders once per request.
- final List invalidFolders;
-
- if (invalidFoldersRequestLocal.get(state) == null) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetFolderBrowserController controller = cdiUtil
- .findBean(AssetFolderBrowserController.class);
- invalidFolders = controller.createInvalidTargetsList(
- Arrays.asList(getSources(state)));
- invalidFoldersRequestLocal.set(state, invalidFolders);
- } else {
- invalidFolders = (List) invalidFoldersRequestLocal
- .get(state);
- }
- final Label label = new Label(value.toString());
-
- if (invalidFolders.contains(String.format(
- FOLDER_BROWSER_KEY_PREFIX_FOLDER + "%s", key))) {
- return label;
- }
-
- // Bold if selected
- if (isSelected) {
- label.setFontWeight(Label.BOLD);
- return label;
- }
-
- return new ControlLink(label);
- }
-
- }
-
- private class TargetSelectorValidationListener
- implements FormValidationListener {
-
- @Override
- public void validate(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
-
- if (getSources(state).length <= 0) {
- throw new IllegalStateException("No source items specified");
- }
-
- final Folder target = targetSelector.getTarget(state);
- final FormData data = event.getFormData();
- if (target == null) {
- data.addError(new GlobalizedMessage(
- "cms.ui.folder.need_select_target_folder",
- CmsConstants.CMS_FOLDER_BUNDLE));
- //If the target is null, we can skip the rest of the checks
- return;
- }
-
- if (target.equals(folderSelectionModel.getSelectedObject(state))) {
- data.addError(new GlobalizedMessage(
- "cms.ui.folder.not_within_same_folder",
- CmsConstants.CMS_FOLDER_BUNDLE));
- }
-
- // check create item permission
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
- if (!permissionChecker.isPermitted(
- ItemPrivileges.CREATE_NEW, target)) {
- data.addError("cms.ui.folder.no_permission_for_item",
- CmsConstants.CMS_FOLDER_BUNDLE);
- }
-
- for (String source : getSources(state)) {
-
- validateObject(source, target, state, data);
-
- }
- }
-
- private void validateObject(final String objectId,
- final Folder target,
- final PageState state,
- final FormData data) {
-
- Objects.requireNonNull(objectId, "objectId can't be null.");
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final FolderRepository folderRepo = cdiUtil
- .findBean(FolderRepository.class);
- final AssetRepository assetRepo = cdiUtil
- .findBean(AssetRepository.class);
- final AssetManager assetManager = cdiUtil
- .findBean(AssetManager.class);
- final AssetFolderBrowserController controller = cdiUtil
- .findBean(AssetFolderBrowserController.class);
- final FolderManager folderManager = cdiUtil
- .findBean(FolderManager.class);
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
-
- final CcmObject object;
- final String name;
- if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
-
- final long folderId = Long.parseLong(objectId.substring(
- FOLDER_BROWSER_KEY_PREFIX_FOLDER.length()));
- final Folder folder = folderRepo.findById(folderId).orElseThrow(
- () -> new IllegalArgumentException(String.format(
- "No folder with id %d in database.", folderId)));
-
- name = folder.getName();
-
- //Check if folder or subfolder contains in use assets
- if (isMove(state)) {
- final FolderManager.FolderIsMovable movable = folderManager
- .folderIsMovable(folder, target);
- switch (movable) {
- case DIFFERENT_SECTIONS:
- addErrorMessage(data,
- "cms.ui.folder.different_sections",
- name);
- break;
- case HAS_IN_USE_ASSETS:
- addErrorMessage(data,
- "cms.ui.folder.has_in_use_assets",
- name);
- break;
- case DIFFERENT_TYPES:
- addErrorMessage(data,
- "cms.ui.folder.different_folder_types",
- name);
- break;
- case IS_ROOT_FOLDER:
- addErrorMessage(data,
- "cms.ui.folder.is_root_folder",
- name);
- break;
- case SAME_FOLDER:
- addErrorMessage(data,
- "cms.ui.folder.same_folder",
- name);
- break;
- case YES:
- //Nothing
- break;
- default:
- throw new UnexpectedErrorException(String.format(
- "Unknown state '%s' for '%s'.",
- movable,
- FolderManager.FolderIsMovable.class.
- getName()));
- }
- }
-
- object = folder;
- } else if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_ASSET)) {
- final long assetId = Long.parseLong(objectId.substring(
- FOLDER_BROWSER_KEY_PREFIX_ASSET.length()));
- final Asset asset = assetRepo
- .findById(assetId)
- .orElseThrow(() -> new IllegalArgumentException(
- String.format(
- "No asset with id %d in the database.",
- assetId)));
-
- name = asset.getDisplayName();
-
- if (isMove(state) && assetManager.isAssetInUse(asset)) {
- addErrorMessage(data, "cms.ui.folder.item_is_live", name);
- }
-
- object = asset;
- } else {
- throw new IllegalArgumentException(String.format(
- "Provided objectId '%s' does not start with '%s' "
- + "or '%s'.",
- objectId,
- FOLDER_BROWSER_KEY_PREFIX_FOLDER,
- FOLDER_BROWSER_KEY_PREFIX_ASSET));
- }
-
- final long count = controller.countObjects(target, name);
- if (count > 0) {
- // there is an item or subfolder in the target folder that already has this name
- addErrorMessage(data, "cms.ui.folder.item_already_exists",
- name);
- }
-
- if (!(permissionChecker.isPermitted(
- ItemPrivileges.DELETE, object))
- && isMove(state)) {
- addErrorMessage(data,
- "cms.ui.folder.no_permission_for_item",
- object.getDisplayName());
- }
-
- }
-
- }
-
- private void addErrorMessage(final FormData data,
- final String message,
- final String itemName) {
- data.addError(new GlobalizedMessage(message,
- CmsConstants.CMS_FOLDER_BUNDLE,
- new Object[]{itemName}));
- }
-
- private class AssetFolderTree extends Tree {
-
- public AssetFolderTree(final FolderSelectionModel folderSelectionModel) {
-
- super(new FolderTreeModelBuilder() {
-
- @Override
- protected Folder getRootFolder(final PageState state) {
- final ContentSection section = CMS
- .getContext()
- .getContentSection();
-
- return section.getRootAssetsFolder();
- }
-
- });
- setSelectionModel(folderSelectionModel);
- }
-
- @Override
- public void setSelectedKey(final PageState state, final Object key) {
- if (key instanceof String) {
- final Long keyAsLong;
- if (((String) key).startsWith(
- FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
- keyAsLong = Long.parseLong(((String) key).substring(
- FOLDER_BROWSER_KEY_PREFIX_FOLDER.length()));
- } else {
- keyAsLong = Long.parseLong((String) key);
- }
- super.setSelectedKey(state, keyAsLong);
- } else if (key instanceof Long) {
- super.setSelectedKey(state, key);
- } else {
- //We know that a FolderSelectionModel only takes keys of type Long.
- //Therefore we try to cast here
- final Long keyAsLong = (Long) key;
- super.setSelectedKey(state, keyAsLong);
- }
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetSearchWidget.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetSearchWidget.java
deleted file mode 100644
index 8b95bc58d..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetSearchWidget.java
+++ /dev/null
@@ -1,114 +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.assets;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.form.Widget;
-import com.arsdigita.bebop.parameters.LongParameter;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.xml.Element;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.assets.AssetTypeInfo;
-import org.librecms.assets.AssetTypesManager;
-import org.librecms.contentsection.Asset;
-import org.librecms.contentsection.AssetRepository;
-import org.librecms.contentsection.ContentSection;
-
-import java.util.Map;
-import java.util.ResourceBundle;
-
-/**
- * A widget for selecting an asset. The widget does not contain any other
- * widgets, only the information required to create an HTML/JavaScript dialog
- * for selecting an asset. To create the dialog the
- * {@link org.librecms.contentsection.rs.Assets} class can be used which
- * provides several methods for getting the assets of an content section.
- *
- * @author Jens Pelzetter
- */
-public class AssetSearchWidget extends Widget {
-
- private Class extends Asset> type;
-
- public AssetSearchWidget(final String name) {
- super(new LongParameter(name));
- }
-
- public AssetSearchWidget(final String name,
- final Class extends Asset> type) {
- this(name);
- this.type = type;
- }
-
- @Override
- public boolean isCompound() {
- return true;
- }
-
- @Override
- protected String getType() {
- return "asset-search-widget";
- }
-
- @Override
- protected String getElementTag() {
- return "cms:asset-search-widget";
- }
-
- @Override
- public void generateWidget(final PageState state,
- final Element parent) {
-
- final Element widget = parent.newChildElement(getElementTag(),
- CMS.CMS_XML_NS);
-
- widget.addAttribute("name", getName());
-
- if (type != null) {
- widget.addAttribute("asset-type", type.getName());
- }
-
- final ContentSection section = CMS.getContext().getContentSection();
- widget.addAttribute("content-section", section.getLabel());
-
- final Long value = (Long) getValue(state);
- if (value != null) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssetSearchWidgetController controller = cdiUtil
- .findBean(AssetSearchWidgetController.class);
-
- final Map data = controller.getData(value);
-
- final Element selected = widget
- .newChildElement("cms:selected-asset", CMS.CMS_XML_NS);
- selected.addAttribute(
- "assetId", data.get(AssetSearchWidgetController.OBJECT_ID)
- );
- selected.addAttribute("title",
- data.get(AssetSearchWidgetController.TITLE));
- selected.addAttribute("type",
- data.get(AssetSearchWidgetController.TYPE));
-
- exportAttributes(widget);
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetSearchWidgetController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetSearchWidgetController.java
deleted file mode 100644
index cac64adad..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AssetSearchWidgetController.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets;
-
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.assets.AssetTypeInfo;
-import org.librecms.assets.AssetTypesManager;
-import org.librecms.contentsection.Asset;
-import org.librecms.contentsection.AssetRepository;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.transaction.Transactional;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-public class AssetSearchWidgetController {
-
- protected static final String OBJECT_ID = "objectId";
- protected static final String TYPE = "type";
- protected static final String TITLE = "title";
-
- @Inject
- private AssetRepository assetRepository;
-
- @Inject
- private AssetTypesManager typesManager;
-
- @Inject
- private GlobalizationHelper globalizationHelper;
-
- @Transactional(Transactional.TxType.REQUIRED)
- public Map getData(final long assetId) {
-
- final Asset asset = assetRepository
- .findById(assetId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No Asset with ID %d in the database.", assetId)));
-
- final Map data = new HashMap<>();
-
- data.put(OBJECT_ID, Long.toString(asset.getObjectId()));
-
- data.put(TITLE,
- globalizationHelper
- .getValueFromLocalizedString(asset.getTitle()));
- final AssetTypeInfo typeInfo = typesManager
- .getAssetTypeInfo(asset.getClass().getName());
- final ResourceBundle bundle = ResourceBundle
- .getBundle(typeInfo.getLabelBundle(),
- globalizationHelper.getNegotiatedLocale());
- final String typeLabel = bundle.getString(typeInfo.getLabelKey());
-
- data.put(TYPE, typeLabel);
-
- return data;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/IsControllerForAssetType.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/IsControllerForAssetType.java
deleted file mode 100644
index 9962cf2fa..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/IsControllerForAssetType.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets;
-
-import org.librecms.contentsection.Asset;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@Qualifier
-@Retention(RetentionPolicy.RUNTIME)
-@Target({
- ElementType.METHOD,
- ElementType.FIELD,
- ElementType.PARAMETER,
- ElementType.TYPE
-})
-public @interface IsControllerForAssetType {
-
- Class extends Asset> value();
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/ItemSearchWidget.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/ItemSearchWidget.java
deleted file mode 100644
index c43804d81..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/ItemSearchWidget.java
+++ /dev/null
@@ -1,119 +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.assets;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.form.Widget;
-import com.arsdigita.bebop.parameters.LongParameter;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.xml.Element;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentItemRepository;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contenttypes.ContentTypeInfo;
-import org.librecms.contenttypes.ContentTypesManager;
-
-import java.util.ResourceBundle;
-
-/**
- *
- * @author Jens Pelzetter
- */
-public class ItemSearchWidget extends Widget {
-
- private Class extends ContentItem> type;
-
- public ItemSearchWidget(final String name) {
- super(new LongParameter(name));
- }
-
- @Override
- public boolean isCompound() {
- return true;
- }
-
- @Override
- protected String getType() {
- return "item-search-widget";
- }
-
- @Override
- protected String getElementTag() {
- return "cms:item-search-widget";
- }
-
- @Override
- public void generateWidget(final PageState state,
- final Element parent) {
-
- final Element widget = parent.newChildElement(getElementTag(),
- CMS.CMS_XML_NS);
-
- widget.addAttribute("name", getName());
- widget.addAttribute("content-section",
- CMS.getContext().getContentSection().getLabel());
-
- if (type != null) {
- widget.addAttribute("asset-type", type.getName());
- }
-
-// final ContentSection section = CMS.getContext().getContentSection();
-// widget.addAttribute("content-section", section.getLabel());
-
- final Long value = (Long) getValue(state);
- if (value != null) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemRepository itemRepo = cdiUtil
- .findBean(ContentItemRepository.class);
- final ContentTypesManager typesManager = cdiUtil
- .findBean(ContentTypesManager.class);
- final GlobalizationHelper globalizationHelper = cdiUtil
- .findBean(GlobalizationHelper.class);
-
- final ContentItem item = itemRepo
- .findById(value)
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No ContentItem with ID %d in the database.", value)));
-
- final Element selected = widget
- .newChildElement("cms:selected-content-item", CMS.CMS_XML_NS);
- selected.addAttribute("contentItemId",
- Long.toString(item.getObjectId()));
- selected.addAttribute("name", item.getDisplayName());
- selected.addAttribute(
- "title",
- globalizationHelper.getValueFromLocalizedString(item.getTitle()));
- final ContentTypeInfo typeInfo = typesManager
- .getContentTypeInfo(item.getClass());
- final ResourceBundle bundle = ResourceBundle
- .getBundle(typeInfo.getLabelBundle(),
- globalizationHelper.getNegotiatedLocale());
- final String typeLabel = bundle.getString(typeInfo.getLabelKey());
- selected.addAttribute("type", typeLabel);
-
- exportAttributes(widget);
-
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetForm.java
deleted file mode 100644
index 58cf71b42..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetForm.java
+++ /dev/null
@@ -1,198 +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.assets.forms;
-
-import com.arsdigita.bebop.BoxPanel;
-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.FormSectionEvent;
-import com.arsdigita.bebop.form.TextArea;
-import com.arsdigita.cms.ui.FileUploadSection;
-import com.arsdigita.cms.ui.assets.AbstractAssetForm;
-import com.arsdigita.cms.ui.assets.AssetPane;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import org.librecms.CmsConstants;
-import org.librecms.assets.BinaryAsset;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Base form for assets which extend {@link BinaryAsset}.
- *
- * @author Jens Pelzetter
- * @param Type of binary asset
- */
-public abstract class AbstractBinaryAssetForm
- extends AbstractAssetForm {
-
- private TextArea description;
-
- private Text fileName;
-
- private Text mimeType;
-
- private Text size;
-
- private FileUploadSection fileUpload;
-
- public AbstractBinaryAssetForm(final AssetPane assetPane) {
- super(assetPane);
- }
-
- @Override
- protected void addWidgets() {
-
- final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
-
- panel.add(new Label(new GlobalizedMessage(
- "cms.ui.assets.binaryasset.description",
- CmsConstants.CMS_BUNDLE)));
- description = new TextArea("binaryasset-description");
- panel.add(description);
-
- panel.add(new Label(
- new GlobalizedMessage("cms.ui.assets.binaryasset.filename",
- CmsConstants.CMS_BUNDLE)));
- fileName = new Text();
- panel.add(fileName);
-
- panel.add(new Label(
- new GlobalizedMessage("cms.ui.assets.binaryasset.mimetype",
- CmsConstants.CMS_BUNDLE)));
- mimeType = new Text();
- panel.add(mimeType);
-
- panel.add(new Label(
- new GlobalizedMessage("cms.ui.assets.binaryasset.size",
- CmsConstants.CMS_BUNDLE)));
- size = new Text();
- panel.add(size);
-
- fileUpload = new FileUploadSection(
- new GlobalizedMessage("cms.ui.assets.binaryasset.mimetype",
- CmsConstants.CMS_BUNDLE),
- "",
- "");
- panel.add(fileUpload);
-
- add(panel);
-
- setEncType(CmsConstants.FORM_ENCTYPE_MULTIPART);
- }
-
- @Override
- protected void initForm(final PageState state,
- final Map data) {
-
- super.initForm(state, data);
-
- if (!data.isEmpty()) {
-
- description.setValue(state,
- data.get("description"));
-
- if (data.containsKey("data")) {
-
- final byte[] binaryData = (byte[]) data.get("data");
- if (binaryData.length == 0) {
- fileName.setText("-");
- mimeType.setText("-");
- size.setText("-");
- } else {
- fileName.setText((String) data.get("fileName"));
- mimeType.setText((String) data.get("mimeType"));
- size.setText(Long.toString((long) data.get("size")));
- }
-
- } else {
- fileName.setText("-");
- mimeType.setText("-");
- size.setText("-");
- }
- }
- }
-
- @Override
- protected void showLocale(final PageState state) {
-
- final Long selectedAssetId = getSelectedAssetId(state);
-
- if (selectedAssetId != null) {
-
- final Map data = getController()
- .getAssetData(selectedAssetId,
- getAssetClass(),
- getSelectedLocale(state));
-
- description
- .setValue(
- state,
- data
- .get(AbstractBinaryAssetFormController.DESCRIPTION));
- }
- }
-
- @Override
- protected Map collectData(final FormSectionEvent event)
- throws FormProcessException {
-
- return getFileData(event);
- }
-
- private Map getFileData(final FormSectionEvent event)
- throws FormProcessException {
-
- final File file = fileUpload.getFile(event);
- if (file == null) {
- return Collections.emptyMap();
- } else {
- final Path path = file.toPath();
- final byte[] data;
- try {
- data = Files.readAllBytes(path);
- } catch (IOException ex) {
- throw new FormProcessException(ex);
- }
-
- final Map assetData = new HashMap<>();
-
- assetData.put(AbstractBinaryAssetFormController.DATA,
- data);
- assetData.put(AbstractBinaryAssetFormController.FILE_NAME,
- fileUpload.getFileName(event));
- assetData.put(AbstractBinaryAssetFormController.SIZE,
- data.length);
- assetData.put(AbstractBinaryAssetFormController.MIME_TYPE,
- fileUpload.getMimeType(event));
-
- return assetData;
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetFormController.java
deleted file mode 100644
index 151f6d651..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetFormController.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets.forms;
-
-import com.arsdigita.cms.ui.assets.AbstractAssetFormController;
-
-import org.librecms.assets.BinaryAsset;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.activation.MimeType;
-import javax.transaction.Transactional;
-
-/**
- *
- * @author Jens Pelzetter
- * @param
- */
-public abstract class AbstractBinaryAssetFormController
- extends AbstractAssetFormController {
-
- protected static final String DESCRIPTION = "description";
-
- protected static final String FILE_NAME = "fileName";
-
- protected static final String MIME_TYPE = "mimeType";
-
- protected static final String DATA = "data";
-
- protected static final String SIZE = "size";
-
- @Override
- @Transactional(Transactional.TxType.REQUIRED)
- protected Map getAssetData(final T asset,
- final Locale selectedLocale) {
-
- final Map data = new HashMap<>();
-
- final String description = asset
- .getDescription()
- .getValue(selectedLocale);
-
- data.put(DESCRIPTION, description);
- data.put(FILE_NAME, asset.getFileName());
- data.put(MIME_TYPE, asset.getMimeType());
- data.put(DATA, asset.getData());
- data.put(SIZE, asset.getSize());
-
- return data;
- }
-
- @Override
- @Transactional(Transactional.TxType.REQUIRED)
- public void updateAssetProperties(final T asset,
- final Locale selectedLocale,
- final Map data) {
-
- if (data.containsKey(DESCRIPTION)) {
- asset.getDescription().putValue(selectedLocale,
- (String) data.get(DESCRIPTION));
- }
-
- if (data.containsKey(FILE_NAME)) {
- asset.setFileName((String) data.get(FILE_NAME));
- }
-
- if (data.containsKey(MIME_TYPE)) {
- asset.setMimeType((MimeType) data.get(MIME_TYPE));
- }
-
- if (data.containsKey(DATA)) {
- //asset.setData((byte[]) data.get(DATA));
- }
-
- if (data.containsKey(SIZE)) {
- asset.setSize((long) data.get(SIZE));
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkForm.java
deleted file mode 100644
index 98be1388a..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkForm.java
+++ /dev/null
@@ -1,141 +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.assets.forms;
-
-import com.arsdigita.bebop.FormData;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.FormValidationListener;
-import com.arsdigita.bebop.form.TextArea;
-import com.arsdigita.bebop.form.TextField;
-import com.arsdigita.cms.ui.assets.AbstractAssetForm;
-import com.arsdigita.cms.ui.assets.AssetPane;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import org.librecms.CmsConstants;
-import org.librecms.assets.Bookmark;
-import org.librecms.contentsection.Asset;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-/**
- * Abstract base form for all forms for {@link BookmarkAsset}s.
- *
- * @author Jens Pelzetter
- * @param Type of the Bookmark Asset.
- */
-public abstract class AbstractBookmarkForm
- extends AbstractAssetForm {
-
- private TextArea description;
-
- private TextField url;
-
- public AbstractBookmarkForm(final AssetPane assetPane) {
- super(assetPane);
- }
-
- @Override
- protected void addWidgets() {
-
- add(new Label(
- new GlobalizedMessage("cms.ui.assets.bookmark.description",
- CmsConstants.CMS_BUNDLE)));
- description = new TextArea("bookmark-description");
- add(description);
-
- add(new Label(new GlobalizedMessage("cms.ui.assets.bookmark.url",
- CmsConstants.CMS_BUNDLE)));
- url = new TextField("bookmark-url");
- add(url);
-
- addValidationListener(new FormValidationListener() {
-
- @Override
- public void validate(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- final FormData data = event.getFormData();
-
- try {
- new URL((String) url.getValue(state));
- } catch (MalformedURLException ex) {
- data.addError(new GlobalizedMessage(
- "cms.ui.assets.bookmark.url.malformed",
- CmsConstants.CMS_BUNDLE));
- }
- }
-
- });
-
- }
-
- @Override
- protected void initForm(final PageState state,
- final Map data) {
-
- super.initForm(state, data);
-
- if (!data.isEmpty()) {
-
- description
- .setValue(
- state,
- data.get(AbstractBookmarkFormController.DESCRIPTION));
- url.setValue(state, data.get(AbstractBookmarkFormController.URL));
-
- }
- }
-
- @Override
- protected void showLocale(final PageState state) {
-
- final Long selectedAssetId = getSelectedAssetId(state);
-
- if (selectedAssetId != null) {
-
- final Map data = getController()
- .getAssetData(selectedAssetId,
- getAssetClass(),
- getSelectedLocale(state));
-
- description.setValue(
- state,
- data.get(AbstractBinaryAssetFormController.DESCRIPTION));
- }
- }
-
- protected void updateData(final Bookmark bookmark,
- final PageState state) {
- bookmark
- .getDescription()
- .putValue(getSelectedLocale(state),
- (String) description.getValue(state));
-
- bookmark.setUrl((String) url.getValue(state));
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkFormController.java
deleted file mode 100644
index db319efa8..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkFormController.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets.forms;
-
-import com.arsdigita.cms.ui.assets.AbstractAssetFormController;
-
-import org.librecms.assets.Bookmark;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- *
- * @author Jens Pelzetter
- * @param
- */
-public abstract class AbstractBookmarkFormController
- extends AbstractAssetFormController {
-
- protected static final String DESCRIPTION = "description";
-
- protected static final String URL = "url";
-
- @Override
- protected Map getAssetData(final T asset,
- final Locale selectedLocale) {
-
- final String description = asset
- .getDescription()
- .getValue(selectedLocale);
-
- final String url = asset.getUrl();
-
- final Map data = new HashMap<>();
-
- data.put("description", description);
- data.put("url", url);
-
- return data;
- }
-
- @Override
- public void updateAssetProperties(final T asset,
- final Locale selectedLocale,
- final Map data) {
-
- if (data.containsKey(DESCRIPTION)) {
-
- asset.getDescription().putValue(selectedLocale,
- (String) data.get(DESCRIPTION));
-
- }
-
- if (data.containsKey(URL)) {
-
- asset.setUrl((String) data.get(URL));
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityForm.java
deleted file mode 100644
index c271e493c..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityForm.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets.forms;
-
-import com.arsdigita.bebop.BoxPanel;
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.ControlLink;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.Table;
-import com.arsdigita.bebop.Text;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.event.TableActionEvent;
-import com.arsdigita.bebop.event.TableActionListener;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.SingleSelect;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.form.TextField;
-import com.arsdigita.bebop.parameters.StringParameter;
-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.cms.ui.assets.AbstractAssetForm;
-import com.arsdigita.cms.ui.assets.AssetPane;
-import com.arsdigita.cms.ui.assets.AssetSearchWidget;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.util.LockableImpl;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.CmsConstants;
-import org.librecms.assets.ContactEntryKey;
-import org.librecms.assets.ContactableEntity;
-import org.librecms.assets.PostalAddress;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TooManyListenersException;
-
-import static org.librecms.CmsConstants.*;
-
-/**
- *
- * @author Jens Pelzetter
- * @param
- */
-public abstract class AbstractContactableEntityForm
- extends AbstractAssetForm {
-
- private static final int COL_CONTACT_ENTRIES_KEY = 0;
-
- private static final int COL_CONTACT_ENTRIES_VALUE = 1;
-
- private static final int COL_CONTACT_ENTRIES_REMOVE = 2;
-
- private SimpleContainer contactEntriesContainer;
-
- private Table contactEntriesTable;
-
- private SingleSelect contactEntryKeySelect;
-
- private TextField contactEntryValueField;
-
- private Submit addContactEntryLink;
-
- private AssetSearchWidget postalAddressSearchWidget;
-
- public AbstractContactableEntityForm(final AssetPane assetPane) {
-
- super(assetPane);
- }
-
- @Override
- protected void addWidgets() {
-
- addPropertyWidgets();
-
- contactEntriesContainer = new BoxPanel(BoxPanel.VERTICAL) {
-
- @Override
- public boolean isVisible(final PageState state) {
- return getSelectedAssetId(state) != null;
- }
-
- };
- add(contactEntriesContainer);
-
- contactEntriesTable = buildContactEntriesTable();
- contactEntriesContainer.add(contactEntriesTable);
-
- contactEntryKeySelect = new SingleSelect(new StringParameter(
- "contactentry-key"));
- try {
- contactEntryKeySelect
- .addPrintListener(new ContactEntryKeySelectPrintListener());
- } catch (TooManyListenersException ex) {
- throw new RuntimeException(ex);
- }
- contactEntriesContainer.add(new Label(
- new GlobalizedMessage(
- "cms.ui.authoring.assets.contactable.contactentries.key",
- CMS_BUNDLE))
- );
- contactEntriesContainer.add(contactEntryKeySelect);
-
- contactEntryValueField = new TextField("contact-entry-value");
- contactEntriesContainer.add(new Label(
- new GlobalizedMessage(
- "cms.ui.authoring.assets.contactable.contactentries.value",
- CMS_BUNDLE))
- );
- contactEntriesContainer.add(contactEntryValueField);
-
- addContactEntryLink = new Submit(
- new GlobalizedMessage(
- "cms.ui.authoring.assets.contactable.contactentries.add",
- CMS_BUNDLE)
- );
- contactEntriesContainer.add(addContactEntryLink);
-
- contactEntriesContainer.add(new Label(
- new GlobalizedMessage(
- "cms.ui.authoring.assets.contactable.postaladdress",
- CMS_BUNDLE))
- );
- postalAddressSearchWidget = new AssetSearchWidget(
- "contactable-postaladdress", PostalAddress.class
- );
- contactEntriesContainer.add(postalAddressSearchWidget);
-
- }
-
- @Override
- public void initForm(final PageState state,
- final Map data) {
-
- super.initForm(state, data);
-
- final Long selectedAssetId = getSelectedAssetId(state);
-
- if (selectedAssetId != null) {
-
- postalAddressSearchWidget.setValue(
- state,
- data.get(AbstractContactableEntityFormController.POSTAL_ADDRESS)
- );
- }
- }
-
- @Override
- protected Map collectData(
- final FormSectionEvent event) {
-
- final PageState state = event.getPageState();
-
- final Map data = new HashMap<>();
-
- if (postalAddressSearchWidget.getValue(state) != null) {
-
- data.put(AbstractContactableEntityFormController.POSTAL_ADDRESS,
- postalAddressSearchWidget.getValue(state));
- }
-
- return data;
- }
-
- @Override
- public void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
-
- if (addContactEntryLink.isSelected(state)) {
-
- final Long selectedAssetId = getSelectedAssetId(state);
- if (selectedAssetId == null) {
- throw new FormProcessException(
- new GlobalizedMessage(
- "cms.ui.assets.none_selected", CMS_BUNDLE)
- );
- }
-
- @SuppressWarnings("unchecked")
- final AbstractContactableEntityFormController controller
- = (AbstractContactableEntityFormController) getController();
-
- final String key = (String) contactEntryKeySelect
- .getValue(state);
- final String value = (String) contactEntryValueField.getValue(state);
-
- controller.addContactEntry(key, value, selectedAssetId);
-
- contactEntryKeySelect.setValue(state, null);
- contactEntryValueField.setValue(state, null);
- } else {
- super.process(event);
- }
- }
-
- protected abstract void addPropertyWidgets();
-
- private Table buildContactEntriesTable() {
-
- final Table table = new Table();
-// {
-
-// @Override
-// public boolean isVisible(final PageState state) {
-// return getSelectedAsset(state).isPresent();
-// }
-// };
- final TableColumnModel columnModel = table.getColumnModel();
- columnModel.add(new TableColumn(
- COL_CONTACT_ENTRIES_KEY,
- new Label(
- new GlobalizedMessage(
- "cms.ui.authoring.assets.contactable.contactentries.key",
- CmsConstants.CMS_BUNDLE
- )
- )
- ));
- columnModel.add(new TableColumn(
- COL_CONTACT_ENTRIES_VALUE,
- new Label(
- new GlobalizedMessage(
- "cms.ui.authoring.assets.contactable.contactentries.value",
- CmsConstants.CMS_BUNDLE
- )
- )
- ));
- columnModel.add(new TableColumn(
- COL_CONTACT_ENTRIES_REMOVE,
- new Label(
- new GlobalizedMessage(
- "cms.ui.authoring.assets.contactable.contactentries.remove",
- CmsConstants.CMS_BUNDLE
- )
- )
- ));
-
- table.setModelBuilder(new ContactEntriesTableModelBuilder());
-
- table
- .getColumn(COL_CONTACT_ENTRIES_REMOVE)
- .setCellRenderer(new ContactEntryRemoveCellRenderer());
-
- table.setEmptyView(
- new Label(
- new GlobalizedMessage(
- "cms.ui.authoring.assets.contactable.contactentries.none",
- CmsConstants.CMS_BUNDLE
- )
- )
- );
-
- table.addTableActionListener(new TableActionListener() {
-
- @Override
- public void cellSelected(final TableActionEvent event)
- throws FormProcessException {
-
- final Integer rowKey = (Integer) event.getRowKey();
-
- @SuppressWarnings("unchecked")
- final AbstractContactableEntityFormController controller
- = (AbstractContactableEntityFormController) getController();
- final PageState state = event.getPageState();
- final Long selectedId = getSelectedAssetId(state);
- if (selectedId != null) {
- controller.removeContactEntry(rowKey, selectedId);
- }
- }
-
- @Override
- public void headSelected(final TableActionEvent event) {
-
- // Nothing
- }
-
- });
-
- return table;
- }
-
- private class ContactEntriesTableModelBuilder
- extends LockableImpl implements TableModelBuilder {
-
- @Override
- public TableModel makeModel(final Table table,
- final PageState state) {
-
- final Long selectedId = getSelectedAssetId(state);
- if (selectedId == null) {
- throw new RuntimeException("No asset selected.");
- }
-
- @SuppressWarnings("unchecked")
- final AbstractContactableEntityFormController controller
- = (AbstractContactableEntityFormController) getController();
- final List contactEntries = controller
- .getContactEntries(selectedId, getSelectedLocale(state));
-
- return new ContactEntriesTableModel(contactEntries);
- }
-
- }
-
- private class ContactEntriesTableModel implements TableModel {
-
- private final Iterator contactEntries;
-
- private String[] currentContactEntry;
-
- public ContactEntriesTableModel(
- final List contactEntries) {
-
- this.contactEntries = contactEntries.iterator();
- }
-
- @Override
- public int getColumnCount() {
- return 3;
- }
-
- @Override
- public boolean nextRow() {
-
- if (contactEntries.hasNext()) {
- currentContactEntry = contactEntries.next();
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public Object getElementAt(final int columnIndex) {
-
- switch (columnIndex) {
- case COL_CONTACT_ENTRIES_KEY:
- return currentContactEntry[1];
- case COL_CONTACT_ENTRIES_VALUE:
- return currentContactEntry[2];
- case COL_CONTACT_ENTRIES_REMOVE:
- return new Label(
- new GlobalizedMessage(
- "cms.ui.authoring.assets.contactable"
- + ".contactentries.remove",
- CmsConstants.CMS_BUNDLE
- )
- );
- default:
- throw new IllegalArgumentException(String.format(
- "Illegal column index %d.", columnIndex));
-
- }
- }
-
- @Override
- public Object getKeyAt(int columnIndex) {
- return currentContactEntry[0];
- }
-
- }
-
- private class ContactEntryRemoveCellRenderer 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) {
-
- return new ControlLink((Component) value);
- }
-
- }
-
- private class ContactEntryKeySelectPrintListener implements PrintListener {
-
- @Override
- public void prepare(final PrintEvent event) {
-
- final SingleSelect target = (SingleSelect) event.getTarget();
- target.clearOptions();
-
- target.addOption(
- new Option("",
- new Label(new GlobalizedMessage("cms.ui.select_one",
- CMS_BUNDLE)))
- );
-
- final AbstractContactableEntityFormController> controller = (AbstractContactableEntityFormController>) getController();
-
- final PageState state = event.getPageState();
-
- final List keys = controller
- .findAvailableContactEntryKeys(getSelectedLocale(state));
-
- for (final String[] key : keys) {
- target.addOption(new Option(key[0], new Text(key[1])));
- }
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityFormController.java
deleted file mode 100644
index 4cfebbf64..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityFormController.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets.forms;
-
-import com.arsdigita.cms.ui.assets.AbstractAssetFormController;
-
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.assets.ContactEntry;
-import org.librecms.assets.ContactEntryKey;
-import org.librecms.assets.ContactEntryKeyByLabelComparator;
-import org.librecms.assets.ContactEntryKeyRepository;
-import org.librecms.assets.ContactableEntity;
-import org.librecms.assets.ContactableEntityManager;
-import org.librecms.assets.ContactableEntityRepository;
-import org.librecms.assets.PostalAddress;
-import org.librecms.contentsection.AssetRepository;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-import javax.inject.Inject;
-import javax.transaction.Transactional;
-
-/**
- *
- * @author Jens Pelzetter
- * @param
- */
-public abstract class AbstractContactableEntityFormController
- extends AbstractAssetFormController {
-
- protected static final String POSTAL_ADDRESS = "postalAddress";
-
- @Inject
- private AssetRepository assetRepository;
-
- @Inject
- private ContactableEntityRepository contactableEntityRepository;
-
- @Inject
- private ContactableEntityManager contactableEntityManager;
-
- @Inject
- private ContactEntryKeyRepository keyRepository;
-
- @Inject
- private GlobalizationHelper globalizationHelper;
-
- @Transactional(Transactional.TxType.REQUIRED)
- @Override
- protected Map getAssetData(final T asset,
- final Locale selectedLocale) {
-
- final Map data = new HashMap<>();
-
- final PostalAddress postalAddress = asset.getPostalAddress();
- if (postalAddress != null) {
- data.put(POSTAL_ADDRESS, postalAddress.getObjectId());
- }
-
- return data;
- }
-
- @Override
- public void updateAssetProperties(final T asset,
- final Locale selectedLocale,
- final Map data) {
-
- if (data.containsKey(POSTAL_ADDRESS)) {
-
- final long addressId = (long) data.get(POSTAL_ADDRESS);
- final PostalAddress postalAddress = assetRepository
- .findById(addressId, PostalAddress.class)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No PostalAddress with ID %d found.", addressId)));
-
- contactableEntityManager
- .addPostalAddressToContactableEntity(postalAddress, asset);
- }
- }
-
- /**
- * Returns the contact entries of the provided contentable entity for the
- * provided language.
- *
- * @param contactableId The ID of the contactable entity.
- * @param selectedLocale The selected locale.
- *
- * @return An list of the contact entires
- */
- @Transactional(Transactional.TxType.REQUIRED)
- public List getContactEntries(
- final Long contactableId, final Locale selectedLocale) {
-
- Objects.requireNonNull(contactableId,
- "Can't get contact entries from null.");
-
- final ContactableEntity entity = contactableEntityRepository
- .findById(contactableId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No ContactEntity with ID %d found.", contactableId)));
-
- return entity
- .getContactEntries()
- .stream()
- .map(contactEntry -> toContactEntryArray(contactEntry,
- selectedLocale))
- .collect(Collectors.toList());
- }
-
- private String[] toContactEntryArray(final ContactEntry entry,
- final Locale selectedLocale) {
-
- final String key = entry.getKey().getEntryKey();
- final String label = entry.getKey().getLabel().getValue(selectedLocale);
- final String value = entry.getValue();
-
- return new String[]{key, label, value};
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- public void addContactEntry(final String contactEntryKey,
- final String contactEntryValue,
- final Long toContactableEntityWithId) {
-
- final ContactableEntity contactable = contactableEntityRepository
- .findById(toContactableEntityWithId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No ContactableEntity with ID %d found",
- toContactableEntityWithId)));
-
- final ContactEntryKey key = keyRepository
- .findByEntryKey(contactEntryKey)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No ContactEntryKey with key \"%s\" found.", contactEntryKey)));
- final ContactEntry entry = new ContactEntry();
- entry.setKey(key);
- entry.setValue(contactEntryValue);
- entry.setOrder(contactable.getContactEntries().size());
-
- contactableEntityManager
- .addContactEntryToContactableEntity(entry, contactable);
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- public void removeContactEntry(final int withIndex,
- final Long fromContactableEntityWithId) {
-
- final ContactableEntity contactable = contactableEntityRepository
- .findById(fromContactableEntityWithId)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No ContactableEntity with ID %d found",
- fromContactableEntityWithId)));
-
- if (contactable.getContactEntries().size() > withIndex) {
-
- final ContactEntry contactEntry = contactable
- .getContactEntries()
- .get(withIndex);
- contactableEntityManager.removeContactEntryFromContactableEntity(
- contactEntry, contactable
- );
- }
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- public List findAvailableContactEntryKeys(
- final Locale selectedLocale) {
-
- return keyRepository
- .findAll()
- .stream()
- .sorted(new ContactEntryKeyByLabelComparator(selectedLocale))
- .map(key -> buildContactEntryKeyArray(key,
- selectedLocale))
- .collect(Collectors.toList());
- }
-
- private String[] buildContactEntryKeyArray(
- final ContactEntryKey contactEntryKey, final Locale selectedLocale) {
-
- final String key = contactEntryKey.getEntryKey();
- final String label = contactEntryKey.getLabel().getValue(selectedLocale);
-
- return new String[]{key, label};
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioForm.java
deleted file mode 100644
index 67288af40..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioForm.java
+++ /dev/null
@@ -1,128 +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.assets.forms;
-
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.cms.ui.assets.AssetPane;
-import com.arsdigita.cms.ui.assets.AssetSearchWidget;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import org.librecms.CmsConstants;
-import org.librecms.assets.AudioAsset;
-import org.librecms.assets.LegalMetadata;
-
-import java.util.Map;
-
-/**
- *
- * @author Yannick Bülter
- * @author Jens Pelzetter
- */
-public class AudioForm extends AbstractBinaryAssetForm {
-
- private AssetSearchWidget assetSearchWidget;
-
- public AudioForm(final AssetPane assetPane) {
- super(assetPane);
- }
-
- @Override
- protected void addWidgets() {
-
- assetSearchWidget = new AssetSearchWidget("legal-metadata",
- LegalMetadata.class);
-
- add(new Label(new GlobalizedMessage(
- "cms.ui.assets.audio.legal_metadata.label",
- CmsConstants.CMS_BUNDLE
- )));
- add(assetSearchWidget);
- }
-
- @Override
- protected void initForm(final PageState state,
- final Map data) {
-
- super.initForm(state, data);
-
- if (data.containsKey(AudioFormController.LEGAL_METADATA_ID)) {
-
- final Long legalMetadataId = (Long) data
- .get(AudioFormController.LEGAL_METADATA_ID);
- if (legalMetadataId != null) {
- assetSearchWidget.setValue(state, legalMetadataId);
- }
- }
- }
-
- @Override
- protected Class getAssetClass() {
- return AudioAsset.class;
- }
-
-// @Override
-// protected Asset createAsset(final FormSectionEvent event)
-// throws FormProcessException {
-//
-// final AudioAsset audioAsset = (AudioAsset) super.createAsset(event);
-//
-// final PageState state = event.getPageState();
-//
-// updateData(audioAsset, state);
-//
-// return audioAsset;
-// }
-// @Override
-// protected void updateAsset(final Asset asset,
-// final FormSectionEvent event)
-// throws FormProcessException {
-//
-// super.updateAsset(asset, event);
-//
-// final PageState state = event.getPageState();
-//
-// final AudioAsset audioAsset = (AudioAsset) asset;
-//
-// updateData(audioAsset, state);
-// }
-
-// protected void updateData(final AudioAsset audioAsset,
-// final PageState state) {
-//
-// final Long legalMetadataId = (Long) assetSearchWidget.getValue(state);
-// if (legalMetadataId != null) {
-// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
-// final AssetRepository assetRepo = cdiUtil.findBean(
-// AssetRepository.class);
-// final LegalMetadata legalMetadata = (LegalMetadata) assetRepo
-// .findById(legalMetadataId)
-// .orElseThrow(() -> new IllegalArgumentException(String.format(
-// "No LegalMetadata asset with ID %d in the database.",
-// legalMetadataId)));
-//
-// audioAsset.setLegalMetadata(legalMetadata);
-// }
-// }
-
-// @Override
-// protected BinaryAsset createBinaryAsset(final PageState state) {
-// return new AudioAsset();
-// }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioFormController.java
deleted file mode 100644
index a7bf6c172..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioFormController.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets.forms;
-
-import com.arsdigita.cms.ui.assets.IsControllerForAssetType;
-
-import org.librecms.assets.AudioAsset;
-import org.librecms.assets.LegalMetadata;
-import org.librecms.contentsection.AssetRepository;
-import org.librecms.contentsection.Folder;
-
-import java.util.Locale;
-import java.util.Map;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-@IsControllerForAssetType(AudioAsset.class)
-public class AudioFormController extends AbstractBinaryAssetFormController {
-
- protected static final String LEGAL_METADATA_ID = "legalMetadataId";
-
- @Inject
- private AssetRepository assetRepository;
-
- @Override
- protected Map getAssetData(final AudioAsset asset,
- final Locale selectedLocale) {
-
- final Map data = super.getAssetData(asset,
- selectedLocale);
-
- final LegalMetadata legalMetadata = asset.getLegalMetadata();
- if (legalMetadata != null) {
- data.put(LEGAL_METADATA_ID, legalMetadata.getObjectId());
- }
-
- return data;
- }
-
- @Override
- public void updateAssetProperties(final AudioAsset asset,
- final Locale selectedLocale,
- final Map data) {
-
- super.updateAssetProperties(asset, selectedLocale, data);
-
- if (data.containsKey(LEGAL_METADATA_ID)) {
-
- final long legalMetadataId = (long) data.get(LEGAL_METADATA_ID);
-
- final LegalMetadata legalMetadata = assetRepository
- .findById(legalMetadataId, LegalMetadata.class)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No LegalMetadata with ID %d found.", legalMetadataId)));
-
- asset.setLegalMetadata(legalMetadata);
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkForm.java
deleted file mode 100644
index 124e89df2..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkForm.java
+++ /dev/null
@@ -1,182 +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.assets.forms;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.cms.ui.assets.AssetPane;
-
-import org.librecms.assets.Bookmark;
-
-import java.util.Collections;
-import java.util.Map;
-
-/**
- *
- * @author Jens Pelzetter
- */
-public class BookmarkForm extends AbstractBookmarkForm {
-
-// private TextArea description;
-// private TextField url;
- public BookmarkForm(final AssetPane assetPane) {
- super(assetPane);
- }
-
-// @Override
-// protected void addWidgets() {
-//
-// add(new Label(
-// new GlobalizedMessage("cms.ui.assets.bookmark.description",
-// CmsConstants.CMS_BUNDLE)));
-// description = new TextArea("bookmark-description");
-// add(description);
-//
-// add(new Label(new GlobalizedMessage("cms.ui.assets.bookmark.url",
-// CmsConstants.CMS_BUNDLE)));
-// url = new TextField("bookmark-url");
-// add(url);
-//
-// addValidationListener(new FormValidationListener() {
-//
-// @Override
-// public void validate(final FormSectionEvent event)
-// throws FormProcessException {
-//
-// final PageState state = event.getPageState();
-// final FormData data = event.getFormData();
-//
-// try {
-// new URL((String) url.getValue(state));
-// } catch (MalformedURLException ex) {
-// data.addError(new GlobalizedMessage(
-// "cms.ui.assets.bookmark.url.malformed",
-// CmsConstants.CMS_BUNDLE));
-// }
-// }
-//
-// });
-//
-// }
-//
-// @Override
-// protected void initForm(final PageState state,
-// final Optional selectedAsset) {
-//
-// if (selectedAsset.isPresent()) {
-//
-// if (!(selectedAsset.get() instanceof Bookmark)) {
-// throw new IllegalArgumentException(String.format(
-// "The provided asset must be an instanceof of class '%s' or "
-// + "an subclass but is an instanceof of class '%s'.",
-// Bookmark.class.getName(),
-// selectedAsset.get().getClass().getName()));
-// }
-//
-// final Bookmark bookmark = selectedAsset.get();
-//
-// description.setValue(state,
-// bookmark
-// .getDescription()
-// .getValue(getSelectedLocale(state)));
-// url.setValue(state, bookmark.getUrl());
-//
-// }
-//
-// }
-//
-// @Override
-// protected void showLocale(final PageState state) {
-// final Optional selectedAsset = getSelectedAsset(state);
-//
-// if (selectedAsset.isPresent()) {
-// if (!(getSelectedAsset(state).get() instanceof Bookmark)) {
-// throw new IllegalArgumentException(
-// "Selected asset is not a bookmark");
-// }
-//
-// final Bookmark bookmark = selectedAsset.get();
-//
-// description.setValue(state,
-// bookmark
-// .getDescription()
-// .getValue(getSelectedLocale(state)));
-// }
-// }
- @Override
- @SuppressWarnings("unchecked")
- protected Class getAssetClass() {
- return Bookmark.class;
- }
-
-// @Override
-// protected Asset createAsset(final FormSectionEvent event)
-// throws FormProcessException {
-//
-// Objects.requireNonNull(event);
-//
-// final PageState state = event.getPageState();
-//
-// final Bookmark bookmark = new Bookmark();
-//
-// updateData(bookmark, state);
-//
-// return bookmark;
-// }
-// protected void updateData(final Bookmark bookmark,
-// final PageState state) {
-// bookmark
-// .getDescription()
-// .addValue(getSelectedLocale(state),
-// (String) description.getValue(state));
-//
-// bookmark.setUrl((String) url.getValue(state));
-// }
-//
-//
-// @Override
-// protected void updateAsset(final Asset asset,
-// final FormSectionEvent event)
-// throws FormProcessException {
-//
-// Objects.requireNonNull(asset);
-// Objects.requireNonNull(event);
-//
-// final PageState state = event.getPageState();
-//
-// if (!(asset instanceof Bookmark)) {
-// throw new IllegalArgumentException(String.format(
-// "Provided asset is not an instance of class (or sub class of) "
-// + "'%s' but is an instance of class '%s'",
-// Bookmark.class.getName(),
-// asset.getClass().getName()));
-// }
-//
-// final Bookmark bookmark = (Bookmark) asset;
-//
-// updateData(bookmark, state);
-// }
- @Override
- protected Map collectData(final FormSectionEvent event)
- throws FormProcessException {
-
- return Collections.emptyMap();
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkFormController.java
deleted file mode 100644
index 9e5ff7ac3..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkFormController.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets.forms;
-
-import com.arsdigita.cms.ui.assets.IsControllerForAssetType;
-
-import org.librecms.assets.Bookmark;
-
-import javax.enterprise.context.RequestScoped;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-@IsControllerForAssetType(Bookmark.class)
-public class BookmarkFormController
- extends AbstractBookmarkFormController {
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetForm.java
deleted file mode 100644
index 25f931406..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetForm.java
+++ /dev/null
@@ -1,104 +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.assets.forms;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.cms.ui.assets.AssetPane;
-import com.arsdigita.cms.ui.assets.AssetSearchWidget;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import org.librecms.CmsConstants;
-import org.librecms.assets.ExternalAudioAsset;
-import org.librecms.assets.LegalMetadata;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @author Jens Pelzetter
- * @author Yannick Bülter
- */
-public class ExternalAudioAssetForm
- extends AbstractBookmarkForm {
-
- private AssetSearchWidget assetSearchWidget;
-
- public ExternalAudioAssetForm(final AssetPane assetPane) {
- super(assetPane);
- }
-
- @Override
- public void addWidgets() {
- super.addWidgets();
-
- add(new Label(new GlobalizedMessage(
- "cms.ui.assets.external_audio_asset.legal_metadata.label",
- CmsConstants.CMS_BUNDLE)));
- assetSearchWidget = new AssetSearchWidget("legal-metadata",
- LegalMetadata.class);
- add(assetSearchWidget);
- }
-
- @Override
- protected void initForm(final PageState state,
- final Map data) {
-
- super.initForm(state, data);
-
- final Long selectedAssetId = getSelectedAssetId(state);
-
- if (selectedAssetId != null) {
-
- if (data.containsKey(
- ExternalAudioAssetFormController.LEGAL_METADATA_ID)) {
-
- final long legalMetadataId = (long) data
- .get(ExternalAudioAssetFormController.LEGAL_METADATA_ID);
-
- assetSearchWidget.setValue(state, legalMetadataId);
- }
- }
- }
-
- @Override
- protected Class getAssetClass() {
- return ExternalAudioAsset.class;
- }
-
- @Override
- protected Map collectData(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
-
- final Map data = new HashMap<>();
- if (assetSearchWidget.getValue(state) != null) {
-
- data.put(ExternalAudioAssetFormController.LEGAL_METADATA_ID,
- assetSearchWidget.getValue(state));
- }
-
- return data;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetFormController.java
deleted file mode 100644
index 35efe05df..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetFormController.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets.forms;
-
-import com.arsdigita.cms.ui.assets.IsControllerForAssetType;
-
-import org.librecms.assets.ExternalAudioAsset;
-import org.librecms.assets.LegalMetadata;
-import org.librecms.contentsection.AssetRepository;
-
-import java.util.Locale;
-import java.util.Map;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-@IsControllerForAssetType(ExternalAudioAsset.class)
-public class ExternalAudioAssetFormController
- extends AbstractBookmarkFormController {
-
- protected static final String LEGAL_METADATA_ID = "legalMetadataId";
-
- @Inject
- private AssetRepository assetRepository;
-
- @Override
- protected Map getAssetData(final ExternalAudioAsset asset,
- final Locale selectedLocale) {
-
- final Map data = super.getAssetData(asset,
- selectedLocale);
-
- final LegalMetadata legalMetadata = asset.getLegalMetadata();
- if (legalMetadata != null) {
- data.put(LEGAL_METADATA_ID, legalMetadata.getObjectId());
- }
-
- return data;
- }
-
- @Override
- public void updateAssetProperties(final ExternalAudioAsset asset,
- final Locale selectedLocale,
- final Map data) {
-
- super.updateAssetProperties(asset, selectedLocale, data);
-
- if (data.containsKey(LEGAL_METADATA_ID)) {
-
- final long legalMetadataId = (long) data.get(LEGAL_METADATA_ID);
- final LegalMetadata legalMetadata = assetRepository
- .findById(legalMetadataId, LegalMetadata.class)
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No LegalMetadata with ID %d found.", legalMetadataId)));
-
- asset.setLegalMetadata(legalMetadata);
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetForm.java
deleted file mode 100644
index d0760b9ad..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetForm.java
+++ /dev/null
@@ -1,100 +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.assets.forms;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.cms.ui.assets.AssetPane;
-import com.arsdigita.cms.ui.assets.AssetSearchWidget;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import org.librecms.CmsConstants;
-
-import org.librecms.assets.ExternalVideoAsset;
-import org.librecms.assets.LegalMetadata;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @author Jens Pelzetter
- */
-public class ExternalVideoAssetForm
- extends AbstractBookmarkForm {
-
- private AssetSearchWidget assetSearchWidget;
-
- public ExternalVideoAssetForm(final AssetPane assetPane) {
- super(assetPane);
- }
-
- @Override
- public void addWidgets() {
- super.addWidgets();
-
- add(new Label(new GlobalizedMessage(
- "cms.ui.assets.external_video_asset.legal_metadata.label",
- CmsConstants.CMS_BUNDLE)));
- assetSearchWidget = new AssetSearchWidget("legal-metadata",
- LegalMetadata.class);
- add(assetSearchWidget);
- }
-
- @Override
- protected void initForm(final PageState state,
- final Map data) {
-
- super.initForm(state, data);
-
- final Long selectedAssetId = getSelectedAssetId(state);
- if (selectedAssetId != null) {
-
- if (data.containsKey(
- ExternalVideoAssetFormController.LEGAL_METADATA_ID)) {
- assetSearchWidget.setValue(
- state,
- data.get(ExternalVideoAssetFormController.LEGAL_METADATA_ID));
- }
- }
- }
-
- @Override
- protected Class getAssetClass() {
- return ExternalVideoAsset.class;
- }
-
- @Override
- protected Map collectData(final FormSectionEvent event)
- throws FormProcessException {
-
- final Map data = new HashMap<>();
- final PageState state = event.getPageState();
-
- if (assetSearchWidget.getValue(state) != null) {
- data.put(ExternalAudioAssetFormController.LEGAL_METADATA_ID,
- assetSearchWidget.getValue(state));
- }
-
- return data;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetFormController.java
deleted file mode 100644
index bd2cc2c8a..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetFormController.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2019 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.assets.forms;
-
-import com.arsdigita.cms.ui.assets.IsControllerForAssetType;
-
-import org.librecms.assets.ExternalVideoAsset;
-import org.librecms.assets.LegalMetadata;
-import org.librecms.contentsection.AssetRepository;
-
-import java.util.Locale;
-import java.util.Map;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.transaction.Transactional;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-@IsControllerForAssetType(ExternalVideoAsset.class)
-public class ExternalVideoAssetFormController
- extends AbstractBookmarkFormController {
-
- protected static final String LEGAL_METADATA_ID = "legalMetadataId";
-
- @Inject
- private AssetRepository assetRepository;
-
- @Transactional(Transactional.TxType.REQUIRED)
- @Override
- protected Map getAssetData(final ExternalVideoAsset asset,
- final Locale selectedLocale) {
-
- final Map