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
jensp 2017-02-08 08:18:19 +00:00
parent cf95e4d26f
commit 448900e386
10 changed files with 422 additions and 160 deletions

View File

@ -293,7 +293,7 @@
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version> <version>0.7.8</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
@ -374,7 +374,7 @@
<dependency> <dependency>
<groupId>org.jboss.arquillian.extension</groupId> <groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-jacoco</artifactId> <artifactId>arquillian-jacoco</artifactId>
<version>1.0.0.Alpha8</version> <version>1.0.0.Alpha9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.saxon</groupId> <groupId>net.sf.saxon</groupId>

View File

@ -158,7 +158,7 @@ class CMSPermissionsGrant {
} }
} }
} }
parent.showAdmin(state); // parent.showAdmin(state);
} }
} }

View File

@ -19,7 +19,10 @@
package com.arsdigita.cms.ui.permissions; package com.arsdigita.cms.ui.permissions;
import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -28,23 +31,32 @@ import com.arsdigita.bebop.Resettable;
import com.arsdigita.bebop.SegmentedPanel; import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.Text; import com.arsdigita.bebop.Text;
import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener; import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.RequestEvent; import com.arsdigita.bebop.event.RequestEvent;
import com.arsdigita.bebop.event.RequestListener; 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.ArrayParameter;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.CcmObjectSelectionModel; import com.arsdigita.ui.CcmObjectSelectionModel;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.security.PermissionManager;
import org.libreccm.security.Role; import org.libreccm.security.Role;
import org.libreccm.security.RoleRepository;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.Folder; import org.librecms.contentsection.Folder;
import org.librecms.contentsection.privileges.ItemPrivileges; import org.librecms.contentsection.privileges.ItemPrivileges;
@ -52,7 +64,10 @@ import org.librecms.contentsection.privileges.ItemPrivileges;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* A pane used to administer the permissions of one {@link * 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 String[] privileges;
private Map<String, String> privilegeNameMap; private Map<String, String> privilegeNameMap;
private SimpleContainer permissionsTable;
private CMSPermissionsTables allPermissions; private CMSPermissionsTables allPermissions;
private CMSPermissionsHeader PermissionsHeader; private CMSPermissionsHeader PermissionsHeader;
private SimpleContainer directPermissions; private SimpleContainer directPermissions;
@ -147,23 +163,25 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
// add permissions components to this specific implementation // add permissions components to this specific implementation
// add(getPermissionsHeader()); // add(getPermissionsHeader());
add(getContextPanel()); // add(getContextPanel());
add(getDirectPermissionsPanel()); add(getPermissionsTable());
add(getUserSearchForm()); // add(getDirectPermissionsPanel());
add(getInheritedPermissionsPanel()); // add(getUserSearchForm())
add(getPermissionGrantPanel()); // add(getInheritedPermissionsPanel());
add(getNoSearchResultPanel()); // add(getPermissionGrantPanel());
add(getAdminListingPanel()); // add(getNoSearchResultPanel());
// add(getAdminListingPanel());
// set initial visibility of components // set initial visibility of components
// p.setVisibleDefault(getPermissionsHeader(), true); // p.setVisibleDefault(getPermissionsHeader(), true);
page.setVisibleDefault(getDirectPermissionsPanel(), true); page.setVisibleDefault(getPermissionsTable(), true);
page.setVisibleDefault(getUserSearchForm(), true); // page.setVisibleDefault(getDirectPermissionsPanel(), true);
page.setVisibleDefault(getInheritedPermissionsPanel(), true); // page.setVisibleDefault(getUserSearchForm(), true);
page.setVisibleDefault(getContextPanel(), true); // page.setVisibleDefault(getInheritedPermissionsPanel(), true);
page.setVisibleDefault(getPermissionGrantPanel(), false); // page.setVisibleDefault(getContextPanel(), true);
page.setVisibleDefault(getNoSearchResultPanel(), false); // page.setVisibleDefault(getPermissionGrantPanel(), false);
page.setVisibleDefault(getAdminListingPanel(), false); // page.setVisibleDefault(getNoSearchResultPanel(), false);
// page.setVisibleDefault(getAdminListingPanel(), false);
// p.addActionListener(this); // p.addActionListener(this);
// p.addRequestListener(this); // p.addRequestListener(this);
@ -180,7 +198,7 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
*/ */
@Override @Override
public void reset(final PageState state) { public void reset(final PageState state) {
showAdmin(state); // showAdmin(state);
} }
/** /**
@ -223,47 +241,190 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
return Arrays.copyOf(privileges, privileges.length); return Arrays.copyOf(privileges, privileges.length);
} }
/** private SimpleContainer getPermissionsTable() {
* Produces the direct and inherited permission tables to the privileges if (permissionsTable != null) {
* defined in the constructor. return permissionsTable;
*
* @see #getDirectPermissionsPanel(), getInheritedPermissionsPanel()
*/
private CMSPermissionsTables getPermissionsTables() {
if (allPermissions == null) {
allPermissions = new CMSPermissionsTables(privileges, this);
}
return allPermissions;
} }
/** final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
* Returns the bebop component with a table for the direct permission on the final Label header = new Label(new GlobalizedMessage(
* privileges defined in the constructor "cms.ui.permissions.table.header",
* CmsConstants.CMS_BUNDLE));
* @return panel.add(header);
*
* @see #getInheritedPermissionsPanel() final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
*/ final PermissionManager permissionManager = cdiUtil.findBean(
public SimpleContainer getDirectPermissionsPanel() { PermissionManager.class);
directPermissions = getPermissionsTables().getPermissions( final List<String> privileges = permissionManager
CMSPermissionsConstants.DIRECT); .listDefiniedPrivileges(ItemPrivileges.class);
return directPermissions; 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;
* 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;
} }
});
}
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;
}
private Label generatePrivilegeColumnHeader(final String privilege) {
return new Label(new GlobalizedMessage(
String.format("cms.ui.permissions.table.privilege.headers.%s",
privilege),
CmsConstants.CMS_BUNDLE));
}
// /**
// * 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() { public SimpleContainer getAdminListingPanel() {
if (adminListing == null) { if (adminListing == null) {
adminListing = new ObjectAdminListing(selectionModel); adminListing = new ObjectAdminListing(selectionModel);
@ -338,18 +499,18 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
return noResultsPanel; return noResultsPanel;
} }
/** // /**
* Returns a bebop panel with a link to the permissions administration page // * Returns a bebop panel with a link to the permissions administration page
* of the object's direct ancestor (parent). // * of the object's direct ancestor (parent).
* // *
* @return // * @return
*/ // */
public SimpleComponent getContextPanel() { // public SimpleComponent getContextPanel() {
if (contextPanel == null) { // if (contextPanel == null) {
contextPanel = getPermissionsTables().makeContextPanel(); // contextPanel = getPermissionsTables().makeContextPanel();
} // }
return contextPanel; // return contextPanel;
} // }
ParameterModel getSearchString() { ParameterModel getSearchString() {
return searchString; return searchString;
@ -363,77 +524,77 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
return selectionModel; return selectionModel;
} }
/** // /**
* Shows panel with no results to user search. // * Shows panel with no results to user search.
* // *
* @param state // * @param state
*/ // */
public void showNoResults(final PageState state) { // public void showNoResults(final PageState state) {
getDirectPermissionsPanel().setVisible(state, false); // getDirectPermissionsPanel().setVisible(state, false);
getInheritedPermissionsPanel().setVisible(state, false); // getInheritedPermissionsPanel().setVisible(state, false);
getContextPanel().setVisible(state, false); // getContextPanel().setVisible(state, false);
getUserSearchForm().setVisible(state, false); // getUserSearchForm().setVisible(state, false);
getPermissionGrantPanel().setVisible(state, false); // getPermissionGrantPanel().setVisible(state, false);
getNoSearchResultPanel().setVisible(state, true); // getNoSearchResultPanel().setVisible(state, true);
} // }
/** // /**
* Show the Grant privileges panel // * Show the Grant privileges panel
* // *
* @param state // * @param state
*/ // */
public void showGrant(final PageState state) { // public void showGrant(final PageState state) {
getDirectPermissionsPanel().setVisible(state, false); // getDirectPermissionsPanel().setVisible(state, false);
getInheritedPermissionsPanel().setVisible(state, false); // getInheritedPermissionsPanel().setVisible(state, false);
getContextPanel().setVisible(state, false); // getContextPanel().setVisible(state, false);
getUserSearchForm().setVisible(state, false); // getUserSearchForm().setVisible(state, false);
getNoSearchResultPanel().setVisible(state, false); // getNoSearchResultPanel().setVisible(state, false);
getPermissionGrantPanel().setVisible(state, true); // getPermissionGrantPanel().setVisible(state, true);
} // }
/** // /**
* Shows the administration page of permissions to one object. // * Shows the administration page of permissions to one object.
* // *
* @param state // * @param state
*/ // */
public void showAdmin(final PageState state) { // public void showAdmin(final PageState state) {
final CcmObject object = getObject(state); // final CcmObject object = getObject(state);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); // final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final PermissionChecker permissionChecker = cdiUtil.findBean( // final PermissionChecker permissionChecker = cdiUtil.findBean(
PermissionChecker.class); // PermissionChecker.class);
//
final boolean canAccess; // final boolean canAccess;
if (object == null) { // if (object == null) {
throw new UncheckedWrapperException( // throw new UncheckedWrapperException(
"Unexpected null value for object."); // "Unexpected null value for object.");
} else if (object instanceof ContentItem) { // } else if (object instanceof ContentItem) {
canAccess = permissionChecker.isPermitted(ItemPrivileges.ADMINISTER, // canAccess = permissionChecker.isPermitted(ItemPrivileges.ADMINISTER,
object); // object);
} else if (object instanceof Folder) { // } else if (object instanceof Folder) {
canAccess = permissionChecker.isPermitted(ItemPrivileges.ADMINISTER, // canAccess = permissionChecker.isPermitted(ItemPrivileges.ADMINISTER,
object); // object);
} else { // } else {
throw new UncheckedWrapperException(String.format( // throw new UncheckedWrapperException(String.format(
"The object is of type \"%s\" which is not supported here.", // "The object is of type \"%s\" which is not supported here.",
object.getClass().getName())); // object.getClass().getName()));
} // }
//
if (canAccess) { // if (canAccess) {
showCustom(state, true); // showCustom(state, true);
//
// showCustom(state, false); //// showCustom(state, false);
getContextPanel().setVisible(state, true); // getContextPanel().setVisible(state, true);
//
} else { // } else {
// do not have permission to set permissions, so don't show them // // do not have permission to set permissions, so don't show them
getDirectPermissionsPanel().setVisible(state, false); // getDirectPermissionsPanel().setVisible(state, false);
getInheritedPermissionsPanel().setVisible(state, false); // getInheritedPermissionsPanel().setVisible(state, false);
getUserSearchForm().setVisible(state, false); // getUserSearchForm().setVisible(state, false);
getContextPanel().setVisible(state, false); // getContextPanel().setVisible(state, false);
} // }
//
getPermissionGrantPanel().setVisible(state, false); // getPermissionGrantPanel().setVisible(state, false);
} // }
@Override @Override
public void actionPerformed(final ActionEvent event) { 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) { // public void showCustom(final PageState state, final boolean custom) {
if (custom) { // if (custom) {
getDirectPermissionsPanel().setVisible(state, true); // getDirectPermissionsPanel().setVisible(state, true);
getInheritedPermissionsPanel().setVisible(state, false); // getInheritedPermissionsPanel().setVisible(state, false);
getUserSearchForm().setVisible(state, true); // getUserSearchForm().setVisible(state, true);
getAdminListingPanel().setVisible(state, true); // getAdminListingPanel().setVisible(state, true);
} else { // } else {
getDirectPermissionsPanel().setVisible(state, false); // getDirectPermissionsPanel().setVisible(state, false);
getInheritedPermissionsPanel().setVisible(state, true); // getInheritedPermissionsPanel().setVisible(state, true);
getUserSearchForm().setVisible(state, false); // getUserSearchForm().setVisible(state, false);
getAdminListingPanel().setVisible(state, false); // getAdminListingPanel().setVisible(state, false);
} // }
} // }
public String getPrivilegeName(final String privilege) { public String getPrivilegeName(final String privilege) {
return privilegeNameMap.get(privilege); return privilegeNameMap.get(privilege);

View File

@ -51,7 +51,7 @@ class CMSPermissionsTableModel implements TableModel {
PermissionManager.class); PermissionManager.class);
return permissionManager.listDefiniedPrivileges(ItemPrivileges.class) return permissionManager.listDefiniedPrivileges(ItemPrivileges.class)
.size(); .size() + 2;
} }
@Override @Override
@ -66,12 +66,22 @@ class CMSPermissionsTableModel implements TableModel {
@Override @Override
public Object getElementAt(final int columnIndex) { 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 @Override
public Object getKeyAt(final int columnIndex) { public Object getKeyAt(final int columnIndex) {
if (columnIndex == 0 || columnIndex == getColumnCount() - 1) {
return currentRow.getRoleName();
} else {
return currentRow.getColumns().get(columnIndex).getPrivilege(); return currentRow.getColumns().get(columnIndex).getPrivilege();
} }
}
} }

View File

@ -33,14 +33,15 @@ import org.libreccm.core.CcmObject;
class CMSPermissionsTableModelBuilder extends LockableImpl class CMSPermissionsTableModelBuilder extends LockableImpl
implements TableModelBuilder { implements TableModelBuilder {
private final CcmObject object; private final CMSPermissionsPane parent;
public CMSPermissionsTableModelBuilder(final CcmObject object) { public CMSPermissionsTableModelBuilder(final CMSPermissionsPane parent) {
this.object = object; this.parent = parent;
} }
@Override @Override
public TableModel makeModel(final Table table, final PageState state) { public TableModel makeModel(final Table table, final PageState state) {
final CcmObject object = parent.getObject(state);
return new CMSPermissionsTableModel(object); return new CMSPermissionsTableModel(object);
} }

View File

@ -95,7 +95,7 @@ public class CMSUserSearchForm extends Form implements FormProcessListener {
final List<Role> roles = roleRepo.searchByName(search); final List<Role> roles = roleRepo.searchByName(search);
if (roles.isEmpty()) { if (roles.isEmpty()) {
parent.showNoResults(state); // parent.showNoResults(state);
} else { } else {
// put search string into Page // put search string into Page
state.setValue(getSearchString(), data.get(SEARCH_QUERY)); state.setValue(getSearchString(), data.get(SEARCH_QUERY));
@ -103,7 +103,7 @@ public class CMSUserSearchForm extends Form implements FormProcessListener {
// put privileges into Page // put privileges into Page
state.setValue(getPrivilegeModel(), getPrivileges()); state.setValue(getPrivilegeModel(), getPrivileges());
parent.showGrant(state); // parent.showGrant(state);
} }
} }

View File

@ -433,7 +433,7 @@
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version> <version>0.7.8</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
@ -801,7 +801,7 @@
<dependency> <dependency>
<groupId>org.jboss.arquillian.extension</groupId> <groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-jacoco</artifactId> <artifactId>arquillian-jacoco</artifactId>
<version>1.0.0.Alpha8</version> <version>1.0.0.Alpha9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.saxon</groupId> <groupId>net.sf.saxon</groupId>

View File

@ -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);
}
}

View File

@ -119,6 +119,7 @@ public class CcmObjectRepositoryTest {
.addPackage(org.libreccm.web.CcmApplication.class.getPackage()) .addPackage(org.libreccm.web.CcmApplication.class.getPackage())
.addPackage(org.libreccm.workflow.Workflow.class.getPackage()) .addPackage(org.libreccm.workflow.Workflow.class.getPackage())
.addClass(org.libreccm.portation.Portable.class) .addClass(org.libreccm.portation.Portable.class)
.addClass(com.arsdigita.util.UncheckedWrapperException.class)
.addAsLibraries(getModuleDependencies()) .addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml", .addAsResource("test-persistence.xml",
"META-INF/persistence.xml") "META-INF/persistence.xml")

View File

@ -244,10 +244,10 @@ public class FilePortationTest {
public void objectShouldBeImported() { public void objectShouldBeImported() {
log.info("\n\n\n" + file.toString() + "\n\n\n"); log.info("\n\n\n" + file.toString() + "\n\n\n");
fileMarshaller.prepare(Format.XML, filePath + f2Xml, false); fileMarshaller.prepare(Format.XML, filePath + f2Xml, false);
List<File> objects = fileMarshaller.importFile(); fileMarshaller.importFile();
objects.forEach(l -> log.info("\n\n\n" + l.toString() + "\n\n\n")); // objects.forEach(l -> log.info("\n\n\n" + l.toString() + "\n\n\n"));
fileMarshaller.prepare(Format.XML, filePath + f4Xml, true); fileMarshaller.prepare(Format.XML, filePath + f4Xml, true);
fileMarshaller.exportList(objects); // fileMarshaller.exportList(objects);
} }
} }