CCM NG/ccm-core: Removed org.libreccm.formbuilder.WidgetLabel.java. In its current implementation it caused strange problems when querying the database.

CCM NG/ccm-cms: Granting/Revoking permissions using the PermissionsPane in the FolderBrowser now works


git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4622 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2017-03-03 19:45:54 +00:00
parent 3383dfd28a
commit 09af5101ec
18 changed files with 63 additions and 240 deletions

View File

@ -43,6 +43,7 @@ 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.bebop.table.TableColumn;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.ui.CcmObjectSelectionModel;
@ -270,6 +271,7 @@ public class CMSPermissionsPane extends SimpleContainer implements Resettable,
headerLabels.toArray());
table.setClassAttr("dataTable");
for (int j = 1; j < table.getColumnModel().size() - 1; j++) {
table.getColumn(j).setKey(privileges.get(j - 1));
table.getColumn(j).setCellRenderer(new TableCellRenderer() {
@Override

View File

@ -77,11 +77,11 @@ class CMSPermissionsTableModel implements TableModel {
@Override
public Object getKeyAt(final int columnIndex) {
if (columnIndex == 0 || columnIndex == getColumnCount() - 1) {
// if (columnIndex == 0 || columnIndex == getColumnCount() - 1) {
return currentRow.getRoleName();
} else {
return currentRow.getColumns().get(columnIndex - 1).getPrivilege();
}
// } else {
// return currentRow.getColumns().get(columnIndex - 1).getPrivilege();
// }
}
}

View File

@ -1133,18 +1133,11 @@ create schema CCM_CORE;
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGET_LABELS (
OBJECT_ID bigint not null,
widget_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGETS (
DEFAULT_VALUE varchar(255),
PARAMETER_MODEL varchar(255),
PARAMETER_NAME varchar(255),
OBJECT_ID bigint not null,
label_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
@ -1760,21 +1753,6 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_PROCESS_LISTENERS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKb1q9bfshcrkwlj7r8w5jb4y8l
foreign key (widget_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGETS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKm1huo6ghk9l5o8buku9v8y6q7
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FKs7qq6vxblhmq0rlf87re65jdp
foreign key (label_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGET_LABELS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK1wosr4ujbfckdc50u5fgmrhrk
foreign key (OBJECT_ID)

View File

@ -1134,18 +1134,11 @@ create schema CCM_CORE;
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGET_LABELS (
OBJECT_ID int8 not null,
widget_OBJECT_ID int8,
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGETS (
DEFAULT_VALUE varchar(255),
PARAMETER_MODEL varchar(255),
PARAMETER_NAME varchar(255),
OBJECT_ID int8 not null,
label_OBJECT_ID int8,
primary key (OBJECT_ID)
);
@ -1761,21 +1754,6 @@ create sequence hibernate_sequence start 1 increment 1;
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_PROCESS_LISTENERS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKb1q9bfshcrkwlj7r8w5jb4y8l
foreign key (widget_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGETS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKm1huo6ghk9l5o8buku9v8y6q7
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FKs7qq6vxblhmq0rlf87re65jdp
foreign key (label_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGET_LABELS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK1wosr4ujbfckdc50u5fgmrhrk
foreign key (OBJECT_ID)

View File

@ -1136,18 +1136,11 @@ create schema CCM_CORE;
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGET_LABELS (
OBJECT_ID bigint not null,
widget_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGETS (
DEFAULT_VALUE varchar(255),
PARAMETER_MODEL varchar(255),
PARAMETER_NAME varchar(255),
OBJECT_ID bigint not null,
label_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
@ -1763,21 +1756,6 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_PROCESS_LISTENERS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKb1q9bfshcrkwlj7r8w5jb4y8l
foreign key (widget_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGETS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKm1huo6ghk9l5o8buku9v8y6q7
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FKs7qq6vxblhmq0rlf87re65jdp
foreign key (label_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGET_LABELS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK1wosr4ujbfckdc50u5fgmrhrk
foreign key (OBJECT_ID)

View File

@ -50,8 +50,8 @@ public class Widget extends Component implements Serializable {
@Column(name = "DEFAULT_VALUE")
private String defaultValue;
@OneToOne
private WidgetLabel label;
// @OneToOne
// private WidgetLabel label;
@OneToMany(mappedBy = "widget")
private List<Listener> listeners;
@ -80,13 +80,13 @@ public class Widget extends Component implements Serializable {
this.defaultValue = defaultValue;
}
public WidgetLabel getLabel() {
return label;
}
protected void setLabel(final WidgetLabel label) {
this.label = label;
}
// public WidgetLabel getLabel() {
// return label;
// }
//
// protected void setLabel(final WidgetLabel label) {
// this.label = label;
// }
public List<Listener> getListeners() {
if (listeners == null) {
@ -114,7 +114,7 @@ public class Widget extends Component implements Serializable {
hash = 17 * hash + Objects.hashCode(parameterName);
hash = 17 * hash + Objects.hashCode(parameterModel);
hash = 17 * hash + Objects.hashCode(defaultValue);
hash = 17 * hash + Objects.hashCode(label);
// hash = 17 * hash + Objects.hashCode(label);
hash = 17 * hash + Objects.hashCode(listeners);
return hash;
}
@ -148,9 +148,9 @@ public class Widget extends Component implements Serializable {
if (!Objects.equals(defaultValue, other.getDefaultValue())) {
return false;
}
if (!Objects.equals(label, other.getLabel())) {
return false;
}
// if (!Objects.equals(label, other.getLabel())) {
// return false;
// }
return Objects.equals(listeners, other.getListeners());
}

View File

@ -18,7 +18,6 @@
*/
package org.libreccm.security;
import java.util.List;
import javax.inject.Inject;
@ -27,6 +26,7 @@ import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.libreccm.core.CcmObject;
import org.libreccm.core.CcmObjectRepository;
import org.libreccm.core.CoreConstants;
import org.libreccm.core.UnexpectedErrorException;
@ -58,6 +58,9 @@ public class PermissionManager {
@Inject
private EntityManager entityManager;
@Inject
private CcmObjectRepository ccmObjectRepo;
/**
* Retrieves a permission by its ID. Useful for UI classes.
*
@ -237,9 +240,23 @@ public class PermissionManager {
final Field field,
final CcmObject owner,
final CcmObject inheritedFrom) {
final CcmObject ownerObject = ccmObjectRepo
.findObjectById(owner.getObjectId())
.orElseThrow(() -> new IllegalArgumentException(String.format(
"No CcmObject with ID %d in the database. "
+ "Where did that ID come from?",
owner.getObjectId())));
final CcmObject inheritedFromObject = ccmObjectRepo
.findObjectById(inheritedFrom.getObjectId())
.orElseThrow(() -> new IllegalArgumentException(String.format(
"No CcmObject with ID %d in the database. "
+ "Where did that ID come from?",
inheritedFrom.getObjectId())));
final Object value;
try {
value = field.get(owner);
value = field.get(ownerObject);
} catch (IllegalAccessException ex) {
throw new UnexpectedErrorException(ex);
}
@ -258,7 +275,7 @@ public class PermissionManager {
.forEach(obj -> grantInherited(privilege,
grantee,
obj,
inheritedFrom));
inheritedFromObject));
// Relations between two CcmObjects with attributes or n:m relations
// use an object to represent the relation. The object must implement
// the Relation interface. For each Relation object in the collection
@ -271,14 +288,14 @@ public class PermissionManager {
.forEach(obj -> grantInherited(privilege,
grantee,
obj,
inheritedFrom));
inheritedFromObject));
} else if (CcmObject.class.isAssignableFrom(field.getType())) {
// If the provided object is a CcmObject create an inherited
// permission for this object.
grantInherited(privilege,
grantee,
(CcmObject) value,
inheritedFrom);
inheritedFromObject);
} else if (Relation.class.isAssignableFrom(field.getType())) {
// If the provided field is a Relation object created an inherited
// permission on the related object.
@ -287,7 +304,7 @@ public class PermissionManager {
grantInherited(privilege,
grantee,
relation.getRelatedObject(),
inheritedFrom);
inheritedFromObject);
}
} else {
throw new IllegalArgumentException(String.format(

View File

@ -0,0 +1,6 @@
ALTER TABLE ccm_core.formbuilder_widgets
DROP CONSTRAINT FK_nei20rvwsnawx4u0ywrh22df1;
DROP TABLE ccm_core.formbuilder_widget_labels;
ALTER TABLE ccm_core.formbuilder_widgets DROP COLUMN label_object_id;

View File

@ -0,0 +1,6 @@
ALTER TABLE ccm_core.formbuilder_widgets
DROP CONSTRAINT FK_nei20rvwsnawx4u0ywrh22df1;
DROP TABLE ccm_core.formbuilder_widget_labels;
ALTER TABLE ccm_core.formbuilder_widgets DROP COLUMN label_object_id;

View File

@ -52,7 +52,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
PersistentDataQuery.class,
ProcessListener.class,
Widget.class,
WidgetLabel.class
// WidgetLabel.class
});
}
@ -70,11 +70,11 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
final Component component2 = new Component();
component2.setAdminName("Component Two");
final WidgetLabel widgetLabel1 = new WidgetLabel();
widgetLabel1.setAdminName("WidgetLabel One");
final WidgetLabel widgetLabel2 = new WidgetLabel();
widgetLabel2.setAdminName("WidgetLabel Two");
// final WidgetLabel widgetLabel1 = new WidgetLabel();
// widgetLabel1.setAdminName("WidgetLabel One");
//
// final WidgetLabel widgetLabel2 = new WidgetLabel();
// widgetLabel2.setAdminName("WidgetLabel Two");
final Widget widget1 = new Widget();
widget1.setAdminName("Widget 1");
@ -122,7 +122,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
verifier
.withPrefabValues(Component.class, component1, component2)
.withPrefabValues(WidgetLabel.class, widgetLabel1, widgetLabel2)
// .withPrefabValues(WidgetLabel.class, widgetLabel1, widgetLabel2)
.withPrefabValues(Widget.class, widget1, widget2)
.withPrefabValues(FormSection.class, formSection1, formSection2)
.withPrefabValues(CcmObject.class, ccmObject1, ccmObject2)

View File

@ -48,7 +48,7 @@ public class ToStringTest extends ToStringVerifier {
PersistentDataQuery.class,
ProcessListener.class,
Widget.class,
WidgetLabel.class
// WidgetLabel.class
});
}

View File

@ -278,18 +278,11 @@ create schema CCM_CORE;
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGET_LABELS (
OBJECT_ID bigint not null,
widget_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGETS (
DEFAULT_VALUE varchar(255),
PARAMETER_MODEL varchar(255),
PARAMETER_NAME varchar(255),
OBJECT_ID bigint not null,
label_OBJECT_ID bigint,
OBJECT_ID bigint not null,s
primary key (OBJECT_ID)
);
@ -905,21 +898,6 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_PROCESS_LISTENERS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKb1q9bfshcrkwlj7r8w5jb4y8l
foreign key (widget_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGETS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKm1huo6ghk9l5o8buku9v8y6q7
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FKs7qq6vxblhmq0rlf87re65jdp
foreign key (label_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGET_LABELS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK1wosr4ujbfckdc50u5fgmrhrk
foreign key (OBJECT_ID)

View File

@ -278,18 +278,11 @@ create schema CCM_CORE;
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGET_LABELS (
OBJECT_ID int8 not null,
widget_OBJECT_ID int8,
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGETS (
DEFAULT_VALUE varchar(255),
PARAMETER_MODEL varchar(255),
PARAMETER_NAME varchar(255),
OBJECT_ID int8 not null,
label_OBJECT_ID int8,
primary key (OBJECT_ID)
);
@ -905,21 +898,6 @@ create sequence hibernate_sequence start 1 increment 1;
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_PROCESS_LISTENERS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKb1q9bfshcrkwlj7r8w5jb4y8l
foreign key (widget_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGETS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKm1huo6ghk9l5o8buku9v8y6q7
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FKs7qq6vxblhmq0rlf87re65jdp
foreign key (label_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGET_LABELS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK1wosr4ujbfckdc50u5fgmrhrk
foreign key (OBJECT_ID)

View File

@ -275,13 +275,6 @@ CREATE SCHEMA ccm_docrepo;
PARAMETER_MODEL varchar(255),
PARAMETER_NAME varchar(255),
OBJECT_ID bigint not null,
label_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGET_LABELS (
OBJECT_ID bigint not null,
widget_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
@ -907,26 +900,6 @@ CREATE SCHEMA ccm_docrepo;
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_PROCESS_LISTENERS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK_nei20rvwsnawx4u0ywrh22df1
foreign key (label_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGET_LABELS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK_rr1oge60scu4a564h7rcra507
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FK_7lp5ywog1suhe11jr3bl28cwg
foreign key (widget_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGETS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FK_ieiewnctdo2hdqeuxiv7cl1ru
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_XML_EMAIL_LISTENERS
add constraint FK_kcfevkdytrk81gj08f4aeh3qu
foreign key (OBJECT_ID)

View File

@ -275,13 +275,6 @@ CREATE SCHEMA ccm_docrepo;
PARAMETER_MODEL varchar(255),
PARAMETER_NAME varchar(255),
OBJECT_ID bigint not null,
label_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGET_LABELS (
OBJECT_ID bigint not null,
widget_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
@ -907,26 +900,6 @@ CREATE SCHEMA ccm_docrepo;
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_PROCESS_LISTENERS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK_nei20rvwsnawx4u0ywrh22df1
foreign key (label_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGET_LABELS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK_rr1oge60scu4a564h7rcra507
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FK_7lp5ywog1suhe11jr3bl28cwg
foreign key (widget_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGETS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FK_ieiewnctdo2hdqeuxiv7cl1ru
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_XML_EMAIL_LISTENERS
add constraint FK_kcfevkdytrk81gj08f4aeh3qu
foreign key (OBJECT_ID)

View File

@ -280,18 +280,11 @@ CREATE SCHEMA ccm_shortcuts;
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGET_LABELS (
OBJECT_ID bigint not null,
widget_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGETS (
DEFAULT_VALUE varchar(255),
PARAMETER_MODEL varchar(255),
PARAMETER_NAME varchar(255),
OBJECT_ID bigint not null,
label_OBJECT_ID bigint,
primary key (OBJECT_ID)
);
@ -907,21 +900,6 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_PROCESS_LISTENERS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKb1q9bfshcrkwlj7r8w5jb4y8l
foreign key (widget_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGETS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKm1huo6ghk9l5o8buku9v8y6q7
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FKs7qq6vxblhmq0rlf87re65jdp
foreign key (label_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGET_LABELS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK1wosr4ujbfckdc50u5fgmrhrk
foreign key (OBJECT_ID)

View File

@ -280,18 +280,11 @@ create table CCM_CORE.APPLICATIONS (
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGET_LABELS (
OBJECT_ID int8 not null,
widget_OBJECT_ID int8,
primary key (OBJECT_ID)
);
create table CCM_CORE.FORMBUILDER_WIDGETS (
DEFAULT_VALUE varchar(255),
PARAMETER_MODEL varchar(255),
PARAMETER_NAME varchar(255),
OBJECT_ID int8 not null,
label_OBJECT_ID int8,
primary key (OBJECT_ID)
);
@ -907,21 +900,6 @@ create sequence hibernate_sequence start 1 increment 1;
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_PROCESS_LISTENERS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKb1q9bfshcrkwlj7r8w5jb4y8l
foreign key (widget_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGETS;
alter table CCM_CORE.FORMBUILDER_WIDGET_LABELS
add constraint FKm1huo6ghk9l5o8buku9v8y6q7
foreign key (OBJECT_ID)
references CCM_CORE.FORMBUILDER_COMPONENTS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FKs7qq6vxblhmq0rlf87re65jdp
foreign key (label_OBJECT_ID)
references CCM_CORE.FORMBUILDER_WIDGET_LABELS;
alter table CCM_CORE.FORMBUILDER_WIDGETS
add constraint FK1wosr4ujbfckdc50u5fgmrhrk
foreign key (OBJECT_ID)