From 7a4aa27eefadbb60788e1f8c30de2e758d1cd3dc Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Wed, 16 Mar 2022 20:01:15 +0100 Subject: [PATCH] Removed depcrecated package com/arsdigita/cms/ui/cse from ccm-cms --- .../arsdigita/cms/ui/ContentSectionPage.java | 21 +-- .../cms/ui/cse/ContentSoonExpiredPane.java | 35 ----- .../cse/ContentSoonExpiredPaneController.java | 129 ---------------- .../cms/ui/cse/ContentSoonExpiredTable.java | 141 ------------------ .../ui/cse/ContentSoonExpiredTableModel.java | 81 ---------- .../ContentSoonExpiredTableModelBuilder.java | 56 ------- 6 files changed, 1 insertion(+), 462 deletions(-) delete mode 100755 ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredPane.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredPaneController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTable.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTableModel.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTableModelBuilder.java 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 index 9434d21b0..135f2a9c6 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionPage.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionPage.java @@ -36,7 +36,6 @@ import org.librecms.contentsection.ContentSection; import com.arsdigita.cms.dispatcher.CMSPage; 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.workflow.WorkflowAdminPane; @@ -139,8 +138,6 @@ public class ContentSectionPage extends CMSPage implements ActionListener { private CategoryAdminPane m_categoryPane; - private LayoutPanel m_csePane; - /** * Creates the content section index page containing - a Navigaton bar for * the various tasks (items, search, images, ....) - a breadcrumb - .... @@ -160,7 +157,6 @@ public class ContentSectionPage extends CMSPage implements ActionListener { m_workflowPane = getWorkflowAdminPane(); m_lifecyclePane = getLifecycleAdminPane(); m_categoryPane = getCategoryAdminPane(); - m_csePane = getCSEPane(); // The panes m_tabbedPane = createTabbedPane(); @@ -201,9 +197,6 @@ public class ContentSectionPage extends CMSPage implements ActionListener { permissionChecker.isPermitted( AdminPrivileges.ADMINISTER_LIFECYLES)); - // csePane: should check permission - m_tabbedPane.setTabVisible(state, m_csePane, true); - // TODO Check for reportPane as well } } @@ -285,15 +278,6 @@ public class ContentSectionPage extends CMSPage implements ActionListener { return m_categoryPane; } - protected LayoutPanel getCSEPane() { - if (m_csePane == null) { - m_csePane = new LayoutPanel(); - m_csePane.setLeft(new SimpleComponent()); - m_csePane.setBody(new ContentSoonExpiredPane()); - } - return m_csePane; - } - /** * Adds the specified component, with the specified tab name, to the tabbed * pane only if it is not null. @@ -340,7 +324,6 @@ public class ContentSectionPage extends CMSPage implements ActionListener { tab(pane, "cms.ui.workflows", getWorkflowAdminPane()); tab(pane, "cms.ui.lifecycles", getLifecycleAdminPane()); tab(pane, "cms.ui.categories", getCategoryAdminPane()); - tab(pane, "cms.ui.cse", getCSEPane()); return pane; } @@ -390,9 +373,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener { } else if (pane == m_categoryPane) { m_categoryPane.reset(state); - } else if (pane == m_csePane) { - m_csePane.reset(state); - } + } } /** diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredPane.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredPane.java deleted file mode 100755 index 791a16fcd..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredPane.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2002-2005 Runtime Collective 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.cse; - -import com.arsdigita.bebop.SimpleContainer; - -/** - * A pane that contains details to soon to be expired content. - * - * @author Unknown - * @author Jens Pelzetter - */ -public class ContentSoonExpiredPane extends SimpleContainer { - - public ContentSoonExpiredPane() { - super(); - super.add(new ContentSoonExpiredTable()); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredPaneController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredPaneController.java deleted file mode 100644 index ccfe70630..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredPaneController.java +++ /dev/null @@ -1,129 +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.cse; - -import com.arsdigita.bebop.table.RowData; - -import org.librecms.CMSConfig; -import org.libreccm.auditing.CcmRevision; -import org.libreccm.configuration.ConfigurationManager; -import org.libreccm.l10n.GlobalizationHelper; -import org.libreccm.security.PermissionChecker; -import org.librecms.contentsection.ContentItem; -import org.librecms.contentsection.ContentItemRepository; -import org.librecms.contentsection.ContentSection; -import org.librecms.contentsection.privileges.ItemPrivileges; - -import java.text.DateFormat; -import java.util.Calendar; -import java.util.List; -import java.util.Locale; -import java.util.stream.Collectors; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import javax.transaction.Transactional; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -public class ContentSoonExpiredPaneController { - - @Inject - private EntityManager entityManager; - - @Inject - private ConfigurationManager confManager; - - @Inject - private ContentItemRepository itemRepo; - - @Inject - private GlobalizationHelper globalizationHelper; - - @Inject - private PermissionChecker permissionChecker; - - @Transactional(Transactional.TxType.REQUIRED) - public List> getSoonExpiredItems( - final ContentSection section) { - final TypedQuery query = entityManager.createQuery( - "SELECT i FROM ContentItem i " - + "WHERE i.contentType.contentSection = :section " - + "AND :endDateTime <= i.lifecycle.endDateTime", - ContentItem.class); - - final CMSConfig cmsConfig = confManager.findConfiguration( - CMSConfig.class); - final int months = cmsConfig.getSoonExpiredTimespanMonths(); - final int days = cmsConfig.getSoonExpiredTimespanDays(); - - final Calendar date = Calendar.getInstance(Locale.ROOT); - date.add(Calendar.DAY_OF_YEAR, days); - date.add(Calendar.MONTH, months); - query.setParameter("endDateTime", date.getTime()); - - query.setParameter("section", section); - - final List result = query.getResultList(); - - return result.stream() - .map(item -> createRow(item)) - .collect(Collectors.toList()); - - } - - private RowData createRow(final ContentItem item) { - final RowData row = new RowData<>(5); - row.setRowKey(item.getObjectId()); - - final CcmRevision current = itemRepo.retrieveCurrentRevision( - item, item.getObjectId()); - row.setColData(ContentSoonExpiredTable.COL_AUTHOR_NAME, - current.getUserName()); - - row.setColData(ContentSoonExpiredTable.COL_ITEM_NAME, - item.getDisplayName()); - - row.setColData(ContentSoonExpiredTable.COL_VIEW, - item.getUuid()); - - if (permissionChecker.isPermitted(ItemPrivileges.EDIT, item)) { - row.setColData(ContentSoonExpiredTable.COL_EDIT, - item.getUuid()); - } else { - row.setColData(ContentSoonExpiredTable.COL_EDIT, - "--"); - } - - final DateFormat dateFormat = DateFormat.getDateTimeInstance( - DateFormat.LONG, - DateFormat.LONG, - globalizationHelper.getNegotiatedLocale()); - row.setColData(ContentSoonExpiredTable.COL_END_DATE_TIME, - dateFormat.format(item.getLifecycle().getEndDateTime())); - - return row; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTable.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTable.java deleted file mode 100644 index 892d6f19f..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTable.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.cse; - -import com.arsdigita.bebop.Component; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.Link; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.Table; -import com.arsdigita.bebop.Text; -import com.arsdigita.bebop.table.TableCellRenderer; -import com.arsdigita.bebop.table.TableColumn; -import com.arsdigita.bebop.table.TableColumnModel; -import com.arsdigita.cms.CMS; -import com.arsdigita.cms.ui.ContentItemPage; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.util.UncheckedWrapperException; -import com.arsdigita.web.Web; - -import org.librecms.CmsConstants; -import org.librecms.contentsection.ContentSection; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - -/** - * - * @author Jens Pelzetter - */ -public class ContentSoonExpiredTable extends Table { - - protected static final int COL_AUTHOR_NAME = 0; - protected static final int COL_ITEM_NAME = 1; - protected static final int COL_VIEW = 2; - protected static final int COL_EDIT = 3; - protected static final int COL_END_DATE_TIME = 4; - - public ContentSoonExpiredTable() { - - super(); - -// final ContentSection section = CMS.getContext().getContentSection(); - - super.setModelBuilder(new ContentSoonExpiredTableModelBuilder()); - - final TableColumnModel columnModel = getColumnModel(); - columnModel.add(new TableColumn( - COL_AUTHOR_NAME, - new Label(new GlobalizedMessage("cms.ui.cse.authorName", - CmsConstants.CMS_BUNDLE)))); - columnModel.add(new TableColumn( - COL_ITEM_NAME, - new Label(new GlobalizedMessage("cms.ui.cse.itemName", - CmsConstants.CMS_BUNDLE)))); - columnModel.add(new TableColumn( - COL_VIEW, - new Label(new GlobalizedMessage("cms.ui.cse.view", - CmsConstants.CMS_BUNDLE)))); - columnModel.add(new TableColumn( - COL_EDIT, - new Label(new GlobalizedMessage("cms.ui.cse.edit", - CmsConstants.CMS_BUNDLE)))); - columnModel.add(new TableColumn( - COL_END_DATE_TIME, - new Label(new GlobalizedMessage("cms.ui.cse.endDateTime", - CmsConstants.CMS_BUNDLE)))); - - columnModel.get(COL_VIEW).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) { - try { - final Link link = new Link( - new Label(new GlobalizedMessage( - "cms.ui.cse.viewLink", - CmsConstants.CMS_BUNDLE)), - String.format( - "%s/redirect/?oid=%s", - Web.getWebappContextPath(), - URLEncoder.encode( - (String) value, "UTF-8"))); - return link; - } catch (UnsupportedEncodingException ex) { - throw new UncheckedWrapperException(ex); - } - } - - }); - - columnModel.get(COL_EDIT).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) { - if ("--".equals(value)) { - //No access for current user - return new Text(""); - } else { - return new Link(new Label(new GlobalizedMessage( - "cms.ui.cse.editLink", - CmsConstants.CMS_BUNDLE)), - ContentItemPage.getItemURL( - (Long) key, - ContentItemPage.AUTHORING_TAB)); - } - } - - }); - - setEmptyView(new Label(new GlobalizedMessage("cms.ui.cse.none", - CmsConstants.CMS_BUNDLE))); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTableModel.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTableModel.java deleted file mode 100644 index b7f4b5e33..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTableModel.java +++ /dev/null @@ -1,81 +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.cse; - -import com.arsdigita.bebop.table.RowData; -import com.arsdigita.bebop.table.TableModel; - -import java.util.Iterator; -import java.util.List; - -/** - * - * @author Jens Pelzetter - */ -class ContentSoonExpiredTableModel implements TableModel { - - private final Iterator> iterator; - private RowData currentRow; - - protected ContentSoonExpiredTableModel(final List> rows) { - iterator = rows.iterator(); - } - - @Override - public int getColumnCount() { - return 5; - } - - @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 ContentSoonExpiredTable.COL_AUTHOR_NAME: - return currentRow.getColData( - ContentSoonExpiredTable.COL_AUTHOR_NAME); - case ContentSoonExpiredTable.COL_ITEM_NAME: - return currentRow.getColData( - ContentSoonExpiredTable.COL_ITEM_NAME); - case ContentSoonExpiredTable.COL_VIEW: - return currentRow.getColData(ContentSoonExpiredTable.COL_VIEW); - case ContentSoonExpiredTable.COL_EDIT: - return currentRow.getColData(ContentSoonExpiredTable.COL_EDIT); - case ContentSoonExpiredTable.COL_END_DATE_TIME: - return currentRow.getColData( - ContentSoonExpiredTable.COL_END_DATE_TIME); - default: - throw new IllegalArgumentException("Invalid column index."); - } - } - - @Override - public Object getKeyAt(final int columnIndex) { - return currentRow.getRowKey(); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTableModelBuilder.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTableModelBuilder.java deleted file mode 100644 index 197ef7509..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/cse/ContentSoonExpiredTableModelBuilder.java +++ /dev/null @@ -1,56 +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.cse; - -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.Table; -import com.arsdigita.bebop.table.RowData; -import com.arsdigita.bebop.table.TableModel; -import com.arsdigita.bebop.table.TableModelBuilder; -import com.arsdigita.cms.CMS; -import com.arsdigita.util.LockableImpl; - -import org.libreccm.cdi.utils.CdiUtil; -import org.librecms.contentsection.ContentSection; - -import java.util.List; - -/** - * - * @author Jens Pelzetter - */ -class ContentSoonExpiredTableModelBuilder - extends LockableImpl - implements TableModelBuilder { - - @Override - public TableModel makeModel(final Table table, final PageState state) { - - final ContentSection section = CMS.getContext().getContentSection(); - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ContentSoonExpiredPaneController controller = cdiUtil.findBean( - ContentSoonExpiredPaneController.class); - - final List> rows = controller.getSoonExpiredItems(section); - - return new ContentSoonExpiredTableModel(rows); - } - -}