Removed depcrecated package com/arsdigita/cms/ui/cse from ccm-cms
parent
d73bfd03b5
commit
7a4aa27eef
|
|
@ -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,8 +373,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class ContentSoonExpiredPane extends SimpleContainer {
|
||||
|
||||
public ContentSoonExpiredPane() {
|
||||
super();
|
||||
super.add(new ContentSoonExpiredTable());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@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<RowData<Long>> getSoonExpiredItems(
|
||||
final ContentSection section) {
|
||||
final TypedQuery<ContentItem> 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<ContentItem> result = query.getResultList();
|
||||
|
||||
return result.stream()
|
||||
.map(item -> createRow(item))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
private RowData<Long> createRow(final ContentItem item) {
|
||||
final RowData<Long> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
class ContentSoonExpiredTableModel implements TableModel {
|
||||
|
||||
private final Iterator<RowData<Long>> iterator;
|
||||
private RowData<Long> currentRow;
|
||||
|
||||
protected ContentSoonExpiredTableModel(final List<RowData<Long>> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
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<RowData<Long>> rows = controller.getSoonExpiredItems(section);
|
||||
|
||||
return new ContentSoonExpiredTableModel(rows);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue