CCM NG/ccm-cms: Next part of new CMSPermissionsTable
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4555 8810af33-2d31-482b-a856-94f89814c4df
parent
cf95e4d26f
commit
448900e386
|
|
@ -293,7 +293,7 @@
|
|||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.7.5.201505241946</version>
|
||||
<version>0.7.8</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
|
|
@ -374,7 +374,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jboss.arquillian.extension</groupId>
|
||||
<artifactId>arquillian-jacoco</artifactId>
|
||||
<version>1.0.0.Alpha8</version>
|
||||
<version>1.0.0.Alpha9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.saxon</groupId>
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ class CMSPermissionsGrant {
|
|||
}
|
||||
}
|
||||
}
|
||||
parent.showAdmin(state);
|
||||
// parent.showAdmin(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@
|
|||
package com.arsdigita.cms.ui.permissions;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
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;
|
||||
|
|
@ -28,23 +31,32 @@ import com.arsdigita.bebop.Resettable;
|
|||
import com.arsdigita.bebop.SegmentedPanel;
|
||||
import com.arsdigita.bebop.SimpleComponent;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.Text;
|
||||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.bebop.event.RequestEvent;
|
||||
import com.arsdigita.bebop.event.RequestListener;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.parameters.ArrayParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.ui.CcmObjectSelectionModel;
|
||||
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.core.UnexpectedErrorException;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.libreccm.security.PermissionManager;
|
||||
import org.libreccm.security.Role;
|
||||
import org.libreccm.security.RoleRepository;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contentsection.Folder;
|
||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||
|
|
@ -52,7 +64,10 @@ import org.librecms.contentsection.privileges.ItemPrivileges;
|
|||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* A pane used to administer the permissions of one {@link
|
||||
|
|
@ -75,6 +90,7 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
|
|||
|
||||
private String[] privileges;
|
||||
private Map<String, String> privilegeNameMap;
|
||||
private SimpleContainer permissionsTable;
|
||||
private CMSPermissionsTables allPermissions;
|
||||
private CMSPermissionsHeader PermissionsHeader;
|
||||
private SimpleContainer directPermissions;
|
||||
|
|
@ -147,23 +163,25 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
|
|||
|
||||
// add permissions components to this specific implementation
|
||||
// add(getPermissionsHeader());
|
||||
add(getContextPanel());
|
||||
add(getDirectPermissionsPanel());
|
||||
add(getUserSearchForm());
|
||||
add(getInheritedPermissionsPanel());
|
||||
add(getPermissionGrantPanel());
|
||||
add(getNoSearchResultPanel());
|
||||
add(getAdminListingPanel());
|
||||
// add(getContextPanel());
|
||||
add(getPermissionsTable());
|
||||
// add(getDirectPermissionsPanel());
|
||||
// add(getUserSearchForm())
|
||||
// add(getInheritedPermissionsPanel());
|
||||
// add(getPermissionGrantPanel());
|
||||
// add(getNoSearchResultPanel());
|
||||
// add(getAdminListingPanel());
|
||||
|
||||
// set initial visibility of components
|
||||
// p.setVisibleDefault(getPermissionsHeader(), true);
|
||||
page.setVisibleDefault(getDirectPermissionsPanel(), true);
|
||||
page.setVisibleDefault(getUserSearchForm(), true);
|
||||
page.setVisibleDefault(getInheritedPermissionsPanel(), true);
|
||||
page.setVisibleDefault(getContextPanel(), true);
|
||||
page.setVisibleDefault(getPermissionGrantPanel(), false);
|
||||
page.setVisibleDefault(getNoSearchResultPanel(), false);
|
||||
page.setVisibleDefault(getAdminListingPanel(), false);
|
||||
page.setVisibleDefault(getPermissionsTable(), true);
|
||||
// page.setVisibleDefault(getDirectPermissionsPanel(), true);
|
||||
// page.setVisibleDefault(getUserSearchForm(), true);
|
||||
// page.setVisibleDefault(getInheritedPermissionsPanel(), true);
|
||||
// page.setVisibleDefault(getContextPanel(), true);
|
||||
// page.setVisibleDefault(getPermissionGrantPanel(), false);
|
||||
// page.setVisibleDefault(getNoSearchResultPanel(), false);
|
||||
// page.setVisibleDefault(getAdminListingPanel(), false);
|
||||
|
||||
// p.addActionListener(this);
|
||||
// p.addRequestListener(this);
|
||||
|
|
@ -180,7 +198,7 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
|
|||
*/
|
||||
@Override
|
||||
public void reset(final PageState state) {
|
||||
showAdmin(state);
|
||||
// showAdmin(state);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -223,46 +241,189 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
|
|||
return Arrays.copyOf(privileges, privileges.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces the direct and inherited permission tables to the privileges
|
||||
* defined in the constructor.
|
||||
*
|
||||
* @see #getDirectPermissionsPanel(), getInheritedPermissionsPanel()
|
||||
*/
|
||||
private CMSPermissionsTables getPermissionsTables() {
|
||||
if (allPermissions == null) {
|
||||
allPermissions = new CMSPermissionsTables(privileges, this);
|
||||
private SimpleContainer getPermissionsTable() {
|
||||
if (permissionsTable != null) {
|
||||
return permissionsTable;
|
||||
}
|
||||
return allPermissions;
|
||||
|
||||
final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
final Label header = new Label(new GlobalizedMessage(
|
||||
"cms.ui.permissions.table.header",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
panel.add(header);
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PermissionManager permissionManager = cdiUtil.findBean(
|
||||
PermissionManager.class);
|
||||
final List<String> privileges = permissionManager
|
||||
.listDefiniedPrivileges(ItemPrivileges.class);
|
||||
final List<Label> headerLabels = privileges.stream()
|
||||
.map(privilege -> generatePrivilegeColumnHeader(privilege))
|
||||
.collect(Collectors.toList());
|
||||
headerLabels.add(0,
|
||||
new Label(new GlobalizedMessage(
|
||||
"cms.ui.permissions.table.role_header",
|
||||
CmsConstants.CMS_BUNDLE)));
|
||||
final Table table = new Table(new CMSPermissionsTableModelBuilder(this),
|
||||
headerLabels.toArray());
|
||||
table.setClassAttr("dataTable");
|
||||
for (int j = 1; j < table.getColumnModel().size() - 1; j++) {
|
||||
table.getColumn(j).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 ControlLink link = new ControlLink("");
|
||||
|
||||
if ((boolean) value) {
|
||||
link.setClassAttr("checkBoxChecked");
|
||||
} else {
|
||||
link.setClassAttr("checkBoxUnchecked");
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
table.getColumn(table.getColumnModel().size() - 1).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 ControlLink link = new ControlLink((String) value);
|
||||
link.setConfirmation(new GlobalizedMessage(
|
||||
"permissions.table.actions.removeAll",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
});
|
||||
table.addTableActionListener(new TableActionListener() {
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
final int columnIndex = event.getColumn();
|
||||
if (event.getRowKey() == null) {
|
||||
return;
|
||||
}
|
||||
final String roleName = (String) event.getRowKey();
|
||||
|
||||
final Table table = (Table) event.getSource();
|
||||
final int columnCount = table.getColumnModel().size();
|
||||
final int lastColumnIndex = columnCount - 1;
|
||||
|
||||
final CcmObject object = getObject(state);
|
||||
final RoleRepository roleRepo = cdiUtil.findBean(
|
||||
RoleRepository.class);
|
||||
final Optional<Role> role = roleRepo.findByName(roleName);
|
||||
if (!role.isPresent()) {
|
||||
throw new UnexpectedErrorException(String.format(
|
||||
"Role \"%s\" was not found inthe database, but was in "
|
||||
+ "the permissions table.",
|
||||
roleName));
|
||||
}
|
||||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||
PermissionChecker.class);
|
||||
if (columnIndex > 0 && columnIndex < lastColumnIndex) {
|
||||
final String privilege = table.getColumn(columnIndex)
|
||||
.getKey();
|
||||
|
||||
if (permissionChecker.isPermitted(privilege,
|
||||
object,
|
||||
role.get())) {
|
||||
permissionManager.revokePrivilege(privilege,
|
||||
role.get(),
|
||||
object);
|
||||
} else {
|
||||
permissionManager.grantPrivilege(privilege,
|
||||
role.get(),
|
||||
object);
|
||||
}
|
||||
} else if (columnIndex == lastColumnIndex) {
|
||||
final List<String> privileges = permissionManager
|
||||
.listDefiniedPrivileges(ItemPrivileges.class);
|
||||
privileges.forEach(privilege -> permissionManager
|
||||
.revokePrivilege(privilege, role.get(), object));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
panel.add(table);
|
||||
|
||||
permissionsTable = panel;
|
||||
return panel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bebop component with a table for the direct permission on the
|
||||
* privileges defined in the constructor
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @see #getInheritedPermissionsPanel()
|
||||
*/
|
||||
public SimpleContainer getDirectPermissionsPanel() {
|
||||
directPermissions = getPermissionsTables().getPermissions(
|
||||
CMSPermissionsConstants.DIRECT);
|
||||
return directPermissions;
|
||||
private Label generatePrivilegeColumnHeader(final String privilege) {
|
||||
return new Label(new GlobalizedMessage(
|
||||
String.format("cms.ui.permissions.table.privilege.headers.%s",
|
||||
privilege),
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bebop component with a table for the inherited permission on
|
||||
* the privileges defined in the constructor. The table is non-editable.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @see #getDirectPermissionsPanel()
|
||||
*/
|
||||
public SimpleContainer getInheritedPermissionsPanel() {
|
||||
inheritedPermissions = getPermissionsTables()
|
||||
.getPermissions(CMSPermissionsConstants.INHERITED);
|
||||
return inheritedPermissions;
|
||||
}
|
||||
// /**
|
||||
// * Produces the direct and inherited permission tables to the privileges
|
||||
// * defined in the constructor.
|
||||
// *
|
||||
// * @see #getDirectPermissionsPanel(), getInheritedPermissionsPanel()
|
||||
// */
|
||||
// private CMSPermissionsTables getPermissionsTables() {
|
||||
// if (allPermissions == null) {
|
||||
// allPermissions = new CMSPermissionsTables(privileges, this);
|
||||
// }
|
||||
// return allPermissions;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Returns the bebop component with a table for the direct permission on the
|
||||
// * privileges defined in the constructor
|
||||
// *
|
||||
// * @return
|
||||
// *
|
||||
// * @see #getInheritedPermissionsPanel()
|
||||
// */
|
||||
// public SimpleContainer getDirectPermissionsPanel() {
|
||||
// directPermissions = getPermissionsTables().getPermissions(
|
||||
// CMSPermissionsConstants.DIRECT);
|
||||
// return directPermissions;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Returns the bebop component with a table for the inherited permission on
|
||||
// * the privileges defined in the constructor. The table is non-editable.
|
||||
// *
|
||||
// * @return
|
||||
// *
|
||||
// * @see #getDirectPermissionsPanel()
|
||||
// */
|
||||
// public SimpleContainer getInheritedPermissionsPanel() {
|
||||
// inheritedPermissions = getPermissionsTables()
|
||||
// .getPermissions(CMSPermissionsConstants.INHERITED);
|
||||
// return inheritedPermissions;
|
||||
// }
|
||||
|
||||
public SimpleContainer getAdminListingPanel() {
|
||||
if (adminListing == null) {
|
||||
|
|
@ -338,18 +499,18 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
|
|||
return noResultsPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bebop panel with a link to the permissions administration page
|
||||
* of the object's direct ancestor (parent).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SimpleComponent getContextPanel() {
|
||||
if (contextPanel == null) {
|
||||
contextPanel = getPermissionsTables().makeContextPanel();
|
||||
}
|
||||
return contextPanel;
|
||||
}
|
||||
// /**
|
||||
// * Returns a bebop panel with a link to the permissions administration page
|
||||
// * of the object's direct ancestor (parent).
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// public SimpleComponent getContextPanel() {
|
||||
// if (contextPanel == null) {
|
||||
// contextPanel = getPermissionsTables().makeContextPanel();
|
||||
// }
|
||||
// return contextPanel;
|
||||
// }
|
||||
|
||||
ParameterModel getSearchString() {
|
||||
return searchString;
|
||||
|
|
@ -363,77 +524,77 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
|
|||
return selectionModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows panel with no results to user search.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
public void showNoResults(final PageState state) {
|
||||
getDirectPermissionsPanel().setVisible(state, false);
|
||||
getInheritedPermissionsPanel().setVisible(state, false);
|
||||
getContextPanel().setVisible(state, false);
|
||||
getUserSearchForm().setVisible(state, false);
|
||||
getPermissionGrantPanel().setVisible(state, false);
|
||||
getNoSearchResultPanel().setVisible(state, true);
|
||||
}
|
||||
// /**
|
||||
// * Shows panel with no results to user search.
|
||||
// *
|
||||
// * @param state
|
||||
// */
|
||||
// public void showNoResults(final PageState state) {
|
||||
// getDirectPermissionsPanel().setVisible(state, false);
|
||||
// getInheritedPermissionsPanel().setVisible(state, false);
|
||||
// getContextPanel().setVisible(state, false);
|
||||
// getUserSearchForm().setVisible(state, false);
|
||||
// getPermissionGrantPanel().setVisible(state, false);
|
||||
// getNoSearchResultPanel().setVisible(state, true);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Show the Grant privileges panel
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
public void showGrant(final PageState state) {
|
||||
getDirectPermissionsPanel().setVisible(state, false);
|
||||
getInheritedPermissionsPanel().setVisible(state, false);
|
||||
getContextPanel().setVisible(state, false);
|
||||
getUserSearchForm().setVisible(state, false);
|
||||
getNoSearchResultPanel().setVisible(state, false);
|
||||
getPermissionGrantPanel().setVisible(state, true);
|
||||
}
|
||||
// /**
|
||||
// * Show the Grant privileges panel
|
||||
// *
|
||||
// * @param state
|
||||
// */
|
||||
// public void showGrant(final PageState state) {
|
||||
// getDirectPermissionsPanel().setVisible(state, false);
|
||||
// getInheritedPermissionsPanel().setVisible(state, false);
|
||||
// getContextPanel().setVisible(state, false);
|
||||
// getUserSearchForm().setVisible(state, false);
|
||||
// getNoSearchResultPanel().setVisible(state, false);
|
||||
// getPermissionGrantPanel().setVisible(state, true);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Shows the administration page of permissions to one object.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
public void showAdmin(final PageState state) {
|
||||
final CcmObject object = getObject(state);
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||
PermissionChecker.class);
|
||||
|
||||
final boolean canAccess;
|
||||
if (object == null) {
|
||||
throw new UncheckedWrapperException(
|
||||
"Unexpected null value for object.");
|
||||
} else if (object instanceof ContentItem) {
|
||||
canAccess = permissionChecker.isPermitted(ItemPrivileges.ADMINISTER,
|
||||
object);
|
||||
} else if (object instanceof Folder) {
|
||||
canAccess = permissionChecker.isPermitted(ItemPrivileges.ADMINISTER,
|
||||
object);
|
||||
} else {
|
||||
throw new UncheckedWrapperException(String.format(
|
||||
"The object is of type \"%s\" which is not supported here.",
|
||||
object.getClass().getName()));
|
||||
}
|
||||
|
||||
if (canAccess) {
|
||||
showCustom(state, true);
|
||||
|
||||
// showCustom(state, false);
|
||||
getContextPanel().setVisible(state, true);
|
||||
|
||||
} else {
|
||||
// do not have permission to set permissions, so don't show them
|
||||
getDirectPermissionsPanel().setVisible(state, false);
|
||||
getInheritedPermissionsPanel().setVisible(state, false);
|
||||
getUserSearchForm().setVisible(state, false);
|
||||
getContextPanel().setVisible(state, false);
|
||||
}
|
||||
|
||||
getPermissionGrantPanel().setVisible(state, false);
|
||||
}
|
||||
// /**
|
||||
// * Shows the administration page of permissions to one object.
|
||||
// *
|
||||
// * @param state
|
||||
// */
|
||||
// public void showAdmin(final PageState state) {
|
||||
// final CcmObject object = getObject(state);
|
||||
// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
// final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||
// PermissionChecker.class);
|
||||
//
|
||||
// final boolean canAccess;
|
||||
// if (object == null) {
|
||||
// throw new UncheckedWrapperException(
|
||||
// "Unexpected null value for object.");
|
||||
// } else if (object instanceof ContentItem) {
|
||||
// canAccess = permissionChecker.isPermitted(ItemPrivileges.ADMINISTER,
|
||||
// object);
|
||||
// } else if (object instanceof Folder) {
|
||||
// canAccess = permissionChecker.isPermitted(ItemPrivileges.ADMINISTER,
|
||||
// object);
|
||||
// } else {
|
||||
// throw new UncheckedWrapperException(String.format(
|
||||
// "The object is of type \"%s\" which is not supported here.",
|
||||
// object.getClass().getName()));
|
||||
// }
|
||||
//
|
||||
// if (canAccess) {
|
||||
// showCustom(state, true);
|
||||
//
|
||||
//// showCustom(state, false);
|
||||
// getContextPanel().setVisible(state, true);
|
||||
//
|
||||
// } else {
|
||||
// // do not have permission to set permissions, so don't show them
|
||||
// getDirectPermissionsPanel().setVisible(state, false);
|
||||
// getInheritedPermissionsPanel().setVisible(state, false);
|
||||
// getUserSearchForm().setVisible(state, false);
|
||||
// getContextPanel().setVisible(state, false);
|
||||
// }
|
||||
//
|
||||
// getPermissionGrantPanel().setVisible(state, false);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
|
|
@ -463,19 +624,19 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
|
|||
}
|
||||
}
|
||||
|
||||
public void showCustom(final PageState state, final boolean custom) {
|
||||
if (custom) {
|
||||
getDirectPermissionsPanel().setVisible(state, true);
|
||||
getInheritedPermissionsPanel().setVisible(state, false);
|
||||
getUserSearchForm().setVisible(state, true);
|
||||
getAdminListingPanel().setVisible(state, true);
|
||||
} else {
|
||||
getDirectPermissionsPanel().setVisible(state, false);
|
||||
getInheritedPermissionsPanel().setVisible(state, true);
|
||||
getUserSearchForm().setVisible(state, false);
|
||||
getAdminListingPanel().setVisible(state, false);
|
||||
}
|
||||
}
|
||||
// public void showCustom(final PageState state, final boolean custom) {
|
||||
// if (custom) {
|
||||
// getDirectPermissionsPanel().setVisible(state, true);
|
||||
// getInheritedPermissionsPanel().setVisible(state, false);
|
||||
// getUserSearchForm().setVisible(state, true);
|
||||
// getAdminListingPanel().setVisible(state, true);
|
||||
// } else {
|
||||
// getDirectPermissionsPanel().setVisible(state, false);
|
||||
// getInheritedPermissionsPanel().setVisible(state, true);
|
||||
// getUserSearchForm().setVisible(state, false);
|
||||
// getAdminListingPanel().setVisible(state, false);
|
||||
// }
|
||||
// }
|
||||
|
||||
public String getPrivilegeName(final String privilege) {
|
||||
return privilegeNameMap.get(privilege);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class CMSPermissionsTableModel implements TableModel {
|
|||
PermissionManager.class);
|
||||
|
||||
return permissionManager.listDefiniedPrivileges(ItemPrivileges.class)
|
||||
.size();
|
||||
.size() + 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -66,12 +66,22 @@ class CMSPermissionsTableModel implements TableModel {
|
|||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
return currentRow.getColumns().get(columnIndex);
|
||||
if (columnIndex == 0) {
|
||||
return currentRow.getRoleName();
|
||||
} else if (columnIndex == getColumnCount() - 1) {
|
||||
return "Remove all";
|
||||
} else {
|
||||
return currentRow.getColumns().get(columnIndex - 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return currentRow.getColumns().get(columnIndex).getPrivilege();
|
||||
if (columnIndex == 0 || columnIndex == getColumnCount() - 1) {
|
||||
return currentRow.getRoleName();
|
||||
} else {
|
||||
return currentRow.getColumns().get(columnIndex).getPrivilege();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,14 +33,15 @@ import org.libreccm.core.CcmObject;
|
|||
class CMSPermissionsTableModelBuilder extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private final CcmObject object;
|
||||
private final CMSPermissionsPane parent;
|
||||
|
||||
public CMSPermissionsTableModelBuilder(final CcmObject object) {
|
||||
this.object = object;
|
||||
public CMSPermissionsTableModelBuilder(final CMSPermissionsPane parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
final CcmObject object = parent.getObject(state);
|
||||
return new CMSPermissionsTableModel(object);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class CMSUserSearchForm extends Form implements FormProcessListener {
|
|||
final List<Role> roles = roleRepo.searchByName(search);
|
||||
|
||||
if (roles.isEmpty()) {
|
||||
parent.showNoResults(state);
|
||||
// parent.showNoResults(state);
|
||||
} else {
|
||||
// put search string into Page
|
||||
state.setValue(getSearchString(), data.get(SEARCH_QUERY));
|
||||
|
|
@ -103,7 +103,7 @@ public class CMSUserSearchForm extends Form implements FormProcessListener {
|
|||
// put privileges into Page
|
||||
state.setValue(getPrivilegeModel(), getPrivileges());
|
||||
|
||||
parent.showGrant(state);
|
||||
// parent.showGrant(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@
|
|||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.7.5.201505241946</version>
|
||||
<version>0.7.8</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
|
|
@ -801,7 +801,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jboss.arquillian.extension</groupId>
|
||||
<artifactId>arquillian-jacoco</artifactId>
|
||||
<version>1.0.0.Alpha8</version>
|
||||
<version>1.0.0.Alpha9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.saxon</groupId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* 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 org.libreccm.core;
|
||||
|
||||
/**
|
||||
* An unchecked Exception to indicate unexpected errors.
|
||||
*
|
||||
* This exception should be used for the following purposes:
|
||||
*
|
||||
* <ul>
|
||||
* <li>To indicate that something unexpected has happened and the problem is not
|
||||
* recoverable <strong>and</strong> there is not other, better way to inform the
|
||||
* user about the problem. One example cloud that can object which was selected
|
||||
* in a form is not found in the database although it was there only seconds
|
||||
* ago.</li>
|
||||
* <li>To wrap an checked exception if the error is not recoverable and there is
|
||||
* no better way for informing the user about the problem.</li>
|
||||
* </ul>
|
||||
*
|
||||
* In general you should avoid using this exception in the action listeners of
|
||||
* Bebop forms. Bebop forms have an built-in error display function which should
|
||||
* be used instead of simply throwing an exception.
|
||||
*
|
||||
* This exception also replaces
|
||||
* {@code com.arsdigita.util.UncheckedWrapperException}. Especially in new code
|
||||
* {@code UncheckedWrapperException} should not be used anymore..
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class UnexpectedErrorException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>UnexpectedErrorException</code> without
|
||||
* detail message.
|
||||
*/
|
||||
public UnexpectedErrorException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>UnexpectedErrorException</code> with the
|
||||
* specified detail message.
|
||||
*
|
||||
* @param msg The detail message.
|
||||
*/
|
||||
public UnexpectedErrorException(final String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>UnexpectedErrorException</code> which
|
||||
* wraps the specified exception.
|
||||
*
|
||||
* @param exception The exception to wrap.
|
||||
*/
|
||||
public UnexpectedErrorException(final Exception exception) {
|
||||
super(exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>UnexpectedErrorException</code> with the
|
||||
* specified message which also wraps the specified exception.
|
||||
*
|
||||
* @param msg The detail message.
|
||||
* @param exception The exception to wrap.
|
||||
*/
|
||||
public UnexpectedErrorException(final String msg, final Exception exception) {
|
||||
super(msg, exception);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -119,6 +119,7 @@ public class CcmObjectRepositoryTest {
|
|||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||
.addClass(org.libreccm.portation.Portable.class)
|
||||
.addClass(com.arsdigita.util.UncheckedWrapperException.class)
|
||||
.addAsLibraries(getModuleDependencies())
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
|
|
|
|||
|
|
@ -244,10 +244,10 @@ public class FilePortationTest {
|
|||
public void objectShouldBeImported() {
|
||||
log.info("\n\n\n" + file.toString() + "\n\n\n");
|
||||
fileMarshaller.prepare(Format.XML, filePath + f2Xml, false);
|
||||
List<File> objects = fileMarshaller.importFile();
|
||||
objects.forEach(l -> log.info("\n\n\n" + l.toString() + "\n\n\n"));
|
||||
fileMarshaller.importFile();
|
||||
// objects.forEach(l -> log.info("\n\n\n" + l.toString() + "\n\n\n"));
|
||||
|
||||
fileMarshaller.prepare(Format.XML, filePath + f4Xml, true);
|
||||
fileMarshaller.exportList(objects);
|
||||
// fileMarshaller.exportList(objects);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue