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 264c01146..61fb0f62d 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
@@ -39,7 +39,7 @@ import com.arsdigita.cms.dispatcher.CMSPage;
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.role.RoleAdminPane;
import com.arsdigita.cms.ui.type.ContentTypeAdminPane;
import com.arsdigita.cms.ui.workflow.WorkflowAdminPane;
import com.arsdigita.globalization.GlobalizedMessage;
@@ -121,7 +121,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
//ToDo NG private BrowsePane m_browsePane;
//ToDo NG private ItemSearch m_searchPane;
//ToDo NG private ImagesPane m_imagesPane;
-//ToDo NG private RoleAdminPane m_rolePane;
+ private RoleAdminPane m_rolePane;
private WorkflowAdminPane m_workflowPane;
private LifecycleAdminPane m_lifecyclePane;
//ToDo NG private CategoryAdminPane m_categoryPane;
@@ -148,7 +148,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
//ToDo NG m_browsePane = getBrowsePane();
//ToDo NG m_searchPane = getSearchPane();
//ToDo NG m_imagesPane = getImagesPane();
-//ToDo NG m_rolePane = getRoleAdminPane();
+ m_rolePane = getRoleAdminPane();
m_workflowPane = getWorkflowAdminPane();
m_lifecyclePane = getLifecycleAdminPane();
//ToDo NG m_categoryPane = getCategoryAdminPane();
@@ -179,35 +179,35 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
final PermissionChecker permissionChecker = CdiUtil
- .createCdiUtil().findBean(PermissionChecker.class);
+ .createCdiUtil().findBean(PermissionChecker.class);
if (CMSConfig.getConfig().isHideAdminTabs()) {
m_tabbedPane.setTabVisible(
- state,
- m_workflowPane,
- permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_WORKFLOW));
+ state,
+ m_workflowPane,
+ permissionChecker.isPermitted(
+ AdminPrivileges.ADMINISTER_WORKFLOW));
//ToDo NG
// m_tabbedPane.setTabVisible(
// state, m_categoryPane,
// permissionChecker.isPermitted(
// AdminPrivileges.ADMINISTER_CATEGORIES));
m_tabbedPane.setTabVisible(
- state,
- m_lifecyclePane,
- permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_LIFECYLES));
+ state,
+ m_lifecyclePane,
+ permissionChecker.isPermitted(
+ AdminPrivileges.ADMINISTER_LIFECYLES));
m_tabbedPane.setTabVisible(
- state,
- m_typePane,
- permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_CONTENT_TYPES));
-//ToDo NG
-//m_tabbedPane.setTabVisible(
-// state,
-// m_rolePane,
-// permissionChecker.isPermitted(
-// AdminPrivileges.ADMINISTER_ROLES));
+ 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
@@ -266,13 +266,13 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
// }
// return m_imagesPane;
// }
-// ToDo NG
-// protected RoleAdminPane getRoleAdminPane() {
-// if (m_rolePane == null) {
-// m_rolePane = new RoleAdminPane();
-// }
-// return m_rolePane;
-// }
+ 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.
@@ -348,9 +348,9 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
* 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 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
+ * @param comp The component to add to the pane
*/
protected void addToPane(final TabbedPane pane,
final String tabName,
@@ -457,7 +457,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
* 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
+ * @param tab The index of the tab to display
*
* @return
*/
@@ -466,7 +466,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
final ContentSection section = item.getContentType().getContentSection();
final String url = section.getPrimaryUrl() + PageLocations.SECTION_PAGE
- + "?" + SET_TAB + "=" + tab;
+ + "?" + SET_TAB + "=" + tab;
return url;
}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/BaseRoleItemPane.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/BaseRoleItemPane.java
new file mode 100755
index 000000000..b099889da
--- /dev/null
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/BaseRoleItemPane.java
@@ -0,0 +1,266 @@
+/*
+ * 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.role;
+
+
+import com.arsdigita.bebop.ActionLink;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.SimpleContainer;
+import com.arsdigita.bebop.SingleSelectionModel;
+import com.arsdigita.bebop.Table;
+import com.arsdigita.bebop.event.TableActionAdapter;
+import com.arsdigita.bebop.event.TableActionEvent;
+import com.arsdigita.bebop.table.DefaultTableCellRenderer;
+import com.arsdigita.bebop.table.TableColumn;
+import com.arsdigita.bebop.table.TableColumnModel;
+import com.arsdigita.cms.ui.BaseItemPane;
+import com.arsdigita.cms.ui.PartySearchForm;
+import com.arsdigita.cms.ui.VisibilityComponent;
+import com.arsdigita.globalization.GlobalizedMessage;
+import com.arsdigita.kernel.KernelConfig;
+import com.arsdigita.toolbox.ui.ActionGroup;
+import com.arsdigita.toolbox.ui.Property;
+import com.arsdigita.toolbox.ui.PropertyList;
+import com.arsdigita.toolbox.ui.Section;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.libreccm.cdi.utils.CdiUtil;
+import org.libreccm.configuration.ConfigurationManager;
+import org.libreccm.security.Party;
+import org.libreccm.security.PartyRepository;
+import org.libreccm.security.Permission;
+import org.libreccm.security.PermissionChecker;
+import org.libreccm.security.Role;
+import org.libreccm.security.RoleManager;
+import org.librecms.CmsConstants;
+import org.librecms.contentsection.privileges.AdminPrivileges;
+
+import java.util.stream.Collectors;
+
+/**
+ * This pane is for showing the properties of a {@link Role}. That includes
+ * name, description, permissions and members. The last one is a list of
+ * {@link Party parties} to which the role corresponds to.
+ *
+ * NOTE: There was an AdminTable besides the MemberTable. Since this function
+ * was/is never used, it was deemed deprecated and was removed.
+ *
+ *
+ * @author Justin Ross <jross@redhat.com>
+ * @author Yannick Bülter
+ * @author Jens Pelzetter
+ */
+class BaseRoleItemPane extends BaseItemPane {
+
+ private static final Logger LOGGER = LogManager.getLogger(
+ BaseRoleItemPane.class);
+
+ private final RoleRequestLocal roleRequestLocal;
+
+ private final MemberTable membersTable;
+
+ BaseRoleItemPane(final SingleSelectionModel model,
+ final RoleRequestLocal role,
+ final ActionLink editLink,
+ final ActionLink deleteLink) {
+ roleRequestLocal = role;
+
+ membersTable = new MemberTable();
+
+ final ActionLink memberAddLink = new ActionLink(new Label(gz(
+ "cms.ui.role.member.add")));
+
+ final SimpleContainer m_detailPane = new SimpleContainer();
+ add(m_detailPane);
+ setDefault(m_detailPane);
+
+ m_detailPane.add(new SummarySection(editLink, deleteLink));
+ m_detailPane.add(new MemberSection(memberAddLink));
+
+ final PartySearchForm memberSearchForm = new PartySearchForm();
+ add(memberSearchForm);
+
+ final RolePartyAddForm memberAddForm = new RolePartyAddForm(
+ model, memberSearchForm.getSearchWidget());
+ add(memberAddForm);
+
+ connect(memberAddLink, memberSearchForm);
+ connect(memberSearchForm, memberAddForm);
+ memberAddForm.getForm().addSubmissionListener(new CancelListener(
+ memberAddForm.getForm()));
+ resume(memberAddForm.getForm(), m_detailPane);
+ }
+
+ private class SummarySection extends Section {
+
+ SummarySection(final ActionLink editLink,
+ final ActionLink deleteLink) {
+ setHeading(gz("cms.ui.role.details"));
+
+ final ActionGroup group = new ActionGroup();
+ setBody(group);
+
+ group.setSubject(new Properties());
+ group.addAction(
+ new VisibilityComponent(editLink,
+ AdminPrivileges.ADMINISTER_ROLES),
+ ActionGroup.DELETE);
+ group.addAction(
+ new VisibilityComponent(deleteLink,
+ AdminPrivileges.ADMINISTER_ROLES),
+ ActionGroup.DELETE);
+ }
+
+ @SuppressWarnings("unchecked")
+ private class Properties extends PropertyList {
+
+ @Override
+ protected final java.util.List properties(
+ final PageState state) {
+
+ final java.util.List properties = super.properties(
+ state);
+
+ final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
+ final ConfigurationManager manager = cdiUtil.findBean(
+ ConfigurationManager.class);
+ final KernelConfig config = manager.findConfiguration(
+ KernelConfig.class);
+
+ final Role role = roleRequestLocal.getRole(state);
+
+ properties.add(new Property(lz("cms.ui.name"),
+ role.getName()));
+ // Right now just loads the default locale description.
+ properties.add(new Property(lz("cms.ui.description"),
+ role.getDescription().getValue(
+ config
+ .getDefaultLocale())));
+
+ // Since Permissions don't seem to have a "pretty" form, the granted privilege is used.
+ final String permissions = role.getPermissions().stream()
+ .map(Permission::getGrantedPrivilege)
+ .collect(Collectors.joining(", "));
+
+ if (permissions.length() > 0) {
+ properties.add(new Property(lz("cms.ui.role.privileges"),
+ permissions));
+ } else {
+ properties.add(new Property(lz("cms.ui.role.privileges"),
+ lz("cms.ui.role.privilege.none")));
+ }
+
+ return properties;
+ }
+
+ }
+
+ }
+
+ private class MemberSection extends Section {
+
+ MemberSection(final ActionLink memberAddLink) {
+ setHeading(gz("cms.ui.role.members"));
+
+ final ActionGroup group = new ActionGroup();
+ setBody(group);
+
+ group.setSubject(membersTable);
+ group.addAction(
+ new VisibilityComponent(memberAddLink,
+ AdminPrivileges.ADMINISTER_ROLES),
+ ActionGroup.ADD);
+ }
+
+ }
+
+ private class MemberTable extends Table {
+
+ private static final int COL_NAME = 0;
+ private static final int COL_EMAIL = 1;
+ private static final int COL_REMOVE = 2;
+
+ MemberTable() {
+ super();
+
+ final TableColumnModel columnModel = getColumnModel();
+ columnModel.add(new TableColumn(
+ COL_NAME,
+ new Label(new GlobalizedMessage("cms.ui.name",
+ CmsConstants.CMS_BUNDLE))));
+ columnModel.add(new TableColumn(
+ COL_EMAIL,
+ new Label(new GlobalizedMessage("cms.ui.role.member.email",
+ CmsConstants.CMS_BUNDLE))));
+ columnModel.add(new TableColumn(
+ COL_REMOVE,
+ new Label(new GlobalizedMessage("cms.ui.role.member.remove",
+ CmsConstants.CMS_BUNDLE))));
+
+ setEmptyView(new Label(gz("cms.ui.role.member.none")));
+
+ setModelBuilder(new MemberTableModelBuilder(roleRequestLocal));
+
+ getColumn(2).setCellRenderer(new DefaultTableCellRenderer(true));
+
+ addTableActionListener(new Listener());
+ }
+
+ private class Listener extends TableActionAdapter {
+
+ @Override
+ public final void cellSelected(final TableActionEvent e) throws
+ FormProcessException {
+ final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
+ final PageState state = e.getPageState();
+ final PermissionChecker permissionChecker = cdiUtil.findBean(
+ PermissionChecker.class);
+
+ if (!permissionChecker.isPermitted(
+ AdminPrivileges.ADMINISTER_ROLES)) {
+ throw new FormProcessException(
+ new GlobalizedMessage(
+ "cms.ui.role.insufficient_privileges",
+ CmsConstants.CMS_BUNDLE));
+ }
+
+ if (e.getColumn() == 2) {
+ final Role role = roleRequestLocal.getRole(state);
+ long itemId = Long.parseLong(e.getRowKey().toString());
+
+ final PartyRepository partyRepository = cdiUtil.findBean(
+ PartyRepository.class);
+ final RoleManager roleManager = cdiUtil.findBean(
+ RoleManager.class);
+ final Party party = partyRepository.findById(itemId);
+
+ roleManager.removeRoleFromParty(role, party);
+
+ getRowSelectionModel().clearSelection(state);
+ }
+ }
+
+ }
+
+ }
+
+}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/BaseRoleItemPane.java.todo b/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/BaseRoleItemPane.java.todo
deleted file mode 100755
index 8d6200152..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/BaseRoleItemPane.java.todo
+++ /dev/null
@@ -1,205 +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.role;
-
-import com.arsdigita.bebop.*;
-import com.arsdigita.bebop.event.TableActionAdapter;
-import com.arsdigita.bebop.event.TableActionEvent;
-import com.arsdigita.bebop.table.DefaultTableCellRenderer;
-import com.arsdigita.cms.ui.BaseItemPane;
-import com.arsdigita.cms.ui.PartySearchForm;
-import com.arsdigita.cms.ui.VisibilityComponent;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.kernel.KernelConfig;
-import com.arsdigita.toolbox.ui.ActionGroup;
-import com.arsdigita.toolbox.ui.PropertyList;
-import com.arsdigita.toolbox.ui.Section;
-
-import org.apache.log4j.Logger;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.configuration.ConfigurationManager;
-import org.libreccm.security.*;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-
-import java.util.stream.Collectors;
-
-/**
- * This pane is for showing the properties of a {@link Role}. That includes name, description, permissions and
- * members. The last one is a list of {@link Party parties} to which the role corresponds to.
- *
- * NOTE: There was an AdminTable besides the MemberTable. Since this function was/is never used, it was deemed
- * deprecated and was removed.
- *
- * @author Yannick Bülter
- * @author Justin Ross <jross@redhat.com>
- * @version $Id: BaseRoleItemPane.java 287 2005-02-22 00:29:02Z sskracic $
- */
-class BaseRoleItemPane extends BaseItemPane {
-
- private static final Logger s_log = Logger.getLogger
- (BaseRoleItemPane.class);
-
- private final RoleRequestLocal m_role;
-
- private final MemberTable m_members;
-
- BaseRoleItemPane(final SingleSelectionModel model,
- final RoleRequestLocal role,
- final ActionLink editLink,
- final ActionLink deleteLink) {
- m_role = role;
-
- m_members = new MemberTable();
-
- final ActionLink memberAddLink = new ActionLink
- (new Label(gz("cms.ui.role.member.add")));
-
- SimpleContainer m_detailPane = new SimpleContainer();
- add(m_detailPane);
- setDefault(m_detailPane);
-
- m_detailPane.add(new SummarySection(editLink, deleteLink));
- m_detailPane.add(new MemberSection(memberAddLink));
-
- final PartySearchForm memberSearchForm = new PartySearchForm();
- add(memberSearchForm);
-
- final RolePartyAddForm memberAddForm = new RolePartyAddForm
- (model, memberSearchForm.getSearchWidget());
- add(memberAddForm);
-
- connect(memberAddLink, memberSearchForm);
- connect(memberSearchForm, memberAddForm);
- memberAddForm.getForm().addSubmissionListener
- (new CancelListener(memberAddForm.getForm()));
- resume(memberAddForm.getForm(), m_detailPane);
- }
-
- private class AdminVisible extends VisibilityComponent {
- AdminVisible(final Component child) {
- super(child, AdminPrivileges.ADMINISTER_ROLES);
- }
- }
-
- private class SummarySection extends Section {
- SummarySection(final ActionLink editLink,
- final ActionLink deleteLink) {
- setHeading(gz("cms.ui.role.details"));
-
- final ActionGroup group = new ActionGroup();
- setBody(group);
-
- group.setSubject(new Properties());
- group.addAction(new AdminVisible(editLink), ActionGroup.EDIT);
- group.addAction(new AdminVisible(deleteLink), ActionGroup.DELETE);
- }
-
- @SuppressWarnings("unchecked")
- private class Properties extends PropertyList {
- protected final java.util.List properties(final PageState state) {
- final java.util.List props = super.properties(state);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ConfigurationManager manager = cdiUtil.findBean(ConfigurationManager.class);
- final KernelConfig config = manager.findConfiguration(KernelConfig.class);
-
- final Role role = m_role.getRole(state);
-
- props.add(new Property(lz("cms.ui.name"),
- role.getName()));
- // Right now just loads the default locale description.
- props.add(new Property(lz("cms.ui.description"),
- role.getDescription().getValue(config.getDefaultLocale())));
-
- // Since Permissions don't seem to have a "pretty" form, the granted privilege is used.
- final String permissions = role.getPermissions().stream()
- .map(Permission::getGrantedPrivilege)
- .collect(Collectors.joining(", "));
-
- if (permissions.length() > 0) {
- props.add(new Property(lz("cms.ui.role.privileges"), permissions));
- } else {
- props.add(new Property(lz("cms.ui.role.privileges"),
- lz("cms.ui.role.privilege.none")));
- }
-
- return props;
- }
- }
- }
-
- private class MemberSection extends Section {
- MemberSection(final ActionLink memberAddLink) {
- setHeading(gz("cms.ui.role.members"));
-
- final ActionGroup group = new ActionGroup();
- setBody(group);
-
- group.setSubject(m_members);
- group.addAction(new AdminVisible(memberAddLink), ActionGroup.ADD);
- }
- }
-
- private static final String[] s_memberColumns = new String[] {
- lz("cms.ui.name"),
- lz("cms.ui.role.member.email"),
- lz("cms.ui.role.member.remove")
- };
-
- private class MemberTable extends Table {
- MemberTable() {
- super(new MemberTableModelBuilder(m_role), s_memberColumns);
-
- setEmptyView(new Label(gz("cms.ui.role.member.none")));
-
- getColumn(2).setCellRenderer
- (new DefaultTableCellRenderer(true));
-
- addTableActionListener(new Listener());
- }
-
- private class Listener extends TableActionAdapter {
- @Override
- public final void cellSelected(final TableActionEvent e) throws FormProcessException {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PageState state = e.getPageState();
- final PermissionChecker permissionChecker = cdiUtil.findBean(PermissionChecker.class);
-
- if (!permissionChecker.isPermitted(AdminPrivileges.ADMINISTER_ROLES)) {
- throw new FormProcessException(
- new GlobalizedMessage("cms.ui.role.insufficient_privileges", CmsConstants.CMS_BUNDLE));
- }
-
- if (e.getColumn() == 2) {
- final Role role = m_role.getRole(state);
- long itemId = Long.parseLong(e.getRowKey().toString());
-
- final PartyRepository partyRepository = cdiUtil.findBean(PartyRepository.class);
- final RoleManager roleManager = cdiUtil.findBean(RoleManager.class);
- final Party party = partyRepository.findById(itemId);
-
- roleManager.removeRoleFromParty(role, party);
-
- getRowSelectionModel().clearSelection(state);
- }
- }
- }
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/MemberTableModelBuilder.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/MemberTableModelBuilder.java
index 5a0a31641..36f574831 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/MemberTableModelBuilder.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/MemberTableModelBuilder.java
@@ -23,7 +23,7 @@ import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.table.AbstractTableModelBuilder;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.ui.admin.GlobalizationUtil;
-import org.apache.log4j.Logger;
+
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.Party;
import org.libreccm.security.PartyRepository;
@@ -33,6 +33,7 @@ import org.libreccm.security.RoleManager;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.stream.Collectors;
/**
@@ -41,36 +42,34 @@ import java.util.stream.Collectors;
*
* @author Yannick Bülter
* @author Justin Ross <jross@redhat.com>
- * @version $Id: MemberTableModelBuilder.java 287 2005-02-22 00:29:02Z sskracic $
+ * @version $Id: MemberTableModelBuilder.java 287 2005-02-22 00:29:02Z sskracic
+ * $
*/
class MemberTableModelBuilder extends AbstractTableModelBuilder {
- private static final Logger s_log = Logger.getLogger
- (MemberTableModelBuilder.class);
-
- private final RoleRequestLocal m_role;
+ private final RoleRequestLocal roleRequestLocal;
MemberTableModelBuilder(final RoleRequestLocal role) {
- m_role = role;
+ roleRequestLocal = role;
}
@Override
public final TableModel makeModel(final Table table,
final PageState state) {
- final Role role = m_role.getRole(state);
+ final Role role = roleRequestLocal.getRole(state);
- //FIXME Dirty hack, needs to be filtered in the database.
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PartyRepository partyRepository = cdiUtil.findBean(PartyRepository.class);
- final RoleManager roleManager = cdiUtil.findBean(RoleManager.class);
- Collection parties = partyRepository.findAll().stream()
- .filter(x -> roleManager.hasRole(x, role))
- .collect(Collectors.toCollection(HashSet::new));
+ final List members = role.getMemberships()
+ .stream()
+ .map(membership -> membership.getMember())
+ .collect(Collectors.toList());
+ members.sort((member1, member2) -> member1.getName().compareTo(
+ member2.getName()));
- return new Model(parties);
+ return new Model(members);
}
private static class Model implements TableModel {
+
private Party m_party;
private final Collection m_parties;
private final Iterator iterator;
@@ -103,19 +102,21 @@ class MemberTableModelBuilder extends AbstractTableModelBuilder {
@Override
public final Object getElementAt(final int column) {
switch (column) {
- case 0:
- return m_party.getName();
- case 1:
- return lz("cms.ui.none");
- case 2:
- return lz("cms.ui.role.member.remove");
- default:
- throw new IllegalStateException();
+ case 0:
+ return m_party.getName();
+ case 1:
+ return lz("cms.ui.none");
+ case 2:
+ return lz("cms.ui.role.member.remove");
+ default:
+ throw new IllegalStateException();
}
}
+
}
protected static String lz(final String key) {
return (String) GlobalizationUtil.globalize(key).localize();
}
+
}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/RoleAdminPane.java.todo b/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/RoleAdminPane.java
similarity index 73%
rename from ccm-cms/src/main/java/com/arsdigita/cms/ui/role/RoleAdminPane.java.todo
rename to ccm-cms/src/main/java/com/arsdigita/cms/ui/role/RoleAdminPane.java
index a5a84e78c..827a81e1b 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/RoleAdminPane.java.todo
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/role/RoleAdminPane.java
@@ -40,11 +40,11 @@ import com.arsdigita.toolbox.ui.ActionGroup;
import com.arsdigita.toolbox.ui.Section;
import com.arsdigita.util.LockableImpl;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.Role;
import org.libreccm.security.RoleRepository;
-import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.privileges.AdminPrivileges;
@@ -56,29 +56,32 @@ import org.librecms.contentsection.privileges.AdminPrivileges;
* Since this is no longer the case, there exists only the
* {@link RoleListModelBuilder} now.
*
- * @author Yannick Bülter
+ *
* @author Justin Ross <jross@redhat.com>
- * @version $Id: RoleAdminPane.java 287 2005-02-22 00:29:02Z sskracic $
+ * @author Yannick Bülter
+ * @authr Jens Pelzetter
+ *
*/
-public class RoleAdminPane extends BaseAdminPane {
+public class RoleAdminPane extends BaseAdminPane {
- private static final Logger s_log = Logger.getLogger(RoleAdminPane.class);
+ private static final Logger LOGGER = LogManager.getLogger(
+ RoleAdminPane.class);
- private final SingleSelectionModel m_model;
+ private final SingleSelectionModel selectionModel;
- private final List m_roles;
+ private final List rolesList;
public RoleAdminPane() {
- m_model = new ParameterSingleSelectionModel(new StringParameter(
- List.SELECTED));
- setSelectionModel(m_model);
+ selectionModel = new ParameterSingleSelectionModel<>(
+ new StringParameter(List.SELECTED));
+ setSelectionModel(selectionModel);
- m_model.addChangeListener(new SelectionListener());
+ selectionModel.addChangeListener(new SelectionListener());
RoleRequestLocal m_role = new SelectionRequestLocal();
- m_roles = new List(new RoleListModelBuilder());
- m_roles.setSelectionModel(m_model);
+ rolesList = new List(new RoleListModelBuilder());
+ rolesList.setSelectionModel(selectionModel);
final SimpleContainer left = new SimpleContainer();
setLeft(left);
@@ -90,7 +93,7 @@ public class RoleAdminPane extends BaseAdminPane {
setDelete(gz("cms.ui.role.delete"), new DeleteForm());
setIntroPane(new Label(gz("cms.ui.role.intro")));
- setItemPane(new BaseRoleItemPane(m_model, m_role,
+ setItemPane(new BaseRoleItemPane(selectionModel, m_role,
getEditLink(), getDeleteLink()));
}
@@ -102,17 +105,17 @@ public class RoleAdminPane extends BaseAdminPane {
final ActionGroup group = new ActionGroup();
setBody(group);
- group.setSubject(m_roles);
+ group.setSubject(rolesList);
final ActionLink link = new ActionLink(new Label(gz(
"cms.ui.role.staff.add")));
- group.addAction(new VisibilityComponent(
- link,
- AdminPrivileges.ADMINISTER_ROLES),
- ActionGroup.ADD);
+ group.addAction(
+ new VisibilityComponent(link,
+ AdminPrivileges.ADMINISTER_ROLES),
+ ActionGroup.ADD);
- final RoleAddForm form = new RoleAddForm(m_model);
+ final RoleAddForm form = new RoleAddForm(selectionModel);
getBody().add(form);
getBody().connect(link, form);
}
@@ -122,17 +125,17 @@ public class RoleAdminPane extends BaseAdminPane {
private class SelectionListener implements ChangeListener {
@Override
- public final void stateChanged(final ChangeEvent e) {
- s_log.debug("Selection state changed; I may change "
- + "the body's visible pane");
+ public final void stateChanged(final ChangeEvent event) {
+ LOGGER.debug("Selection state changed; I may change "
+ + "the body's visible pane");
- final PageState state = e.getPageState();
+ final PageState state = event.getPageState();
getBody().reset(state);
- if (m_model.isSelected(state)) {
- s_log.debug("The selection model is selected; displaying "
- + "the item pane");
+ if (selectionModel.isSelected(state)) {
+ LOGGER.debug("The selection model is selected; displaying "
+ + "the item pane");
getBody().push(state, getItemPane());
}
@@ -144,8 +147,7 @@ public class RoleAdminPane extends BaseAdminPane {
@Override
protected final Object initialValue(final PageState state) {
- final Long id = Long.parseLong(m_model.getSelectedKey(state)
- .toString());
+ final Long id = Long.parseLong(selectionModel.getSelectedKey(state));
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final RoleRepository roleRepository = cdiUtil.findBean(
RoleRepository.class);
@@ -187,20 +189,19 @@ public class RoleAdminPane extends BaseAdminPane {
}
@Override
- public final void process(final FormSectionEvent e)
+ public final void process(final FormSectionEvent event)
throws FormProcessException {
- final PageState state = e.getPageState();
+ final PageState state = event.getPageState();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final RoleRepository roleRepository = cdiUtil.findBean(
RoleRepository.class);
- final Long id = Long.parseLong(m_model.getSelectedKey(state)
- .toString());
+ final Long id = Long.parseLong(selectionModel.getSelectedKey(state));
final Role role = roleRepository.findById(id);
roleRepository.delete(role);
- m_model.clearSelection(state);
+ selectionModel.clearSelection(state);
}
}
diff --git a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/PropertyList.java b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/PropertyList.java
index 09b0ce50c..84999dc78 100755
--- a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/PropertyList.java
+++ b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/PropertyList.java
@@ -21,11 +21,8 @@ package com.arsdigita.toolbox.ui;
import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element;
-import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;