RBAC Diagram+PostgreSQL Generator #21
@ -1,6 +1,7 @@
|
|||||||
package net.hostsharing.hsadminng.rbac.rbacdef;
|
package net.hostsharing.hsadminng.rbac.rbacdef;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.BinaryOperator;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Permission.INSERT;
|
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Permission.INSERT;
|
||||||
@ -142,19 +143,20 @@ public class InsertTriggerGenerator {
|
|||||||
|
|
||||||
private Optional<RbacView.RbacGrantDefinition> getOptionalInsertGrant() {
|
private Optional<RbacView.RbacGrantDefinition> getOptionalInsertGrant() {
|
||||||
return getInsertGrants()
|
return getInsertGrants()
|
||||||
.reduce((x, y) -> {
|
.reduce(singleton());
|
||||||
throw new IllegalStateException("only a single INSERT permission grant allowed");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<RbacView.RbacRoleDefinition> getOptionalInsertSuperRole() {
|
private Optional<RbacView.RbacRoleDefinition> getOptionalInsertSuperRole() {
|
||||||
return getInsertGrants()
|
return getInsertGrants()
|
||||||
.map(RbacView.RbacGrantDefinition::getSuperRoleDef)
|
.map(RbacView.RbacGrantDefinition::getSuperRoleDef)
|
||||||
.reduce((x, y) -> {
|
.reduce(singleton());
|
||||||
throw new IllegalStateException("only a single INSERT permission grant allowed");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <T> BinaryOperator<T> singleton() {
|
||||||
|
return (x, y) -> {
|
||||||
|
throw new IllegalStateException("only a single INSERT permission grant allowed");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private static String toVar(final RbacView.RbacRoleDefinition roleDef) {
|
private static String toVar(final RbacView.RbacRoleDefinition roleDef) {
|
||||||
return uncapitalize(roleDef.getEntityAlias().simpleName()) + capitalize(roleDef.getRole().roleName());
|
return uncapitalize(roleDef.getEntityAlias().simpleName()) + capitalize(roleDef.getRole().roleName());
|
||||||
|
Loading…
Reference in New Issue
Block a user