From 2582bdb1789ba0b13a059562137dc1e5bae0e5c0 Mon Sep 17 00:00:00 2001 From: Graham Humphries Date: Fri, 8 Dec 2023 15:28:49 +1100 Subject: [PATCH 1/4] Update rolesddl.xml Fixed issues with creating tables and assigning the primary keys for Oracle 19c database --- geoserver/role/geostore/oracle/rolesddl.xml | 41 ++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/geoserver/role/geostore/oracle/rolesddl.xml b/geoserver/role/geostore/oracle/rolesddl.xml index c4c1d301..c5be8bde 100644 --- a/geoserver/role/geostore/oracle/rolesddl.xml +++ b/geoserver/role/geostore/oracle/rolesddl.xml @@ -2,28 +2,43 @@ DDL statements for role database - role_props - - create table roles(name varchar2(64 char) not null,parent varchar2(64 char), primary key(name)) - + gs_role_props - create table role_props(rolename varchar2(64 char) not null,propname varchar2(64 char) not null, propvalue varchar2(2048 char),primary key (rolename,propname)) + create table gs_role_props( + rolename varchar2(64 char) not null, + propname varchar2(64 char) not null, + constraint gs_role_props_members_pk + primary key (rolename, propname) + propvalue varchar2(2048 char)) - create table user_roles(username varchar2(128 char) not null, rolename varchar2(64 char) not null, primary key(username,rolename)) + create table gs_user_roles( + username varchar2(128 char) not null, + rolename varchar2(64 char) not null, + constraint gs_user_roles_pk + primary key (username, rolename)) - create index user_roles_idx on user_roles(rolename,username) + create index user_roles_idx on gs_user_roles(rolename,username) + + create table gs_role( + name varchar2(64 char) constraint gs_role_pk primary key, + parent varchar2(64 char)) + - create table group_roles(groupname varchar2(128 char) not null, rolename varchar2(64 char) not null, primary key(groupname,rolename)) + create table gs_group_roles( + groupname varchar2(128 char) not null, + rolename varchar2(64 char) not null, + constraint gs_group_roles_pk + primary key (groupname,rolename)) - create index group_roles_idx on group_roles(rolename,groupname) + create index group_roles_idx on gs_group_roles(rolename,groupname) - drop table roles - drop table role_props - drop table user_roles - drop table group_roles + drop table gs_role + drop table gs_role_props + drop table gs_user_roles + drop table gs_group_roles From f22407b28bc33bcbd467000d9d5d62a50726e5f5 Mon Sep 17 00:00:00 2001 From: Graham Humphries Date: Fri, 8 Dec 2023 15:35:38 +1100 Subject: [PATCH 2/4] Update rolesdml.xml Updated the sql to use group_name instead of groupname --- geoserver/role/geostore/oracle/rolesdml.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/geoserver/role/geostore/oracle/rolesdml.xml b/geoserver/role/geostore/oracle/rolesdml.xml index 655300cf..c98e898b 100644 --- a/geoserver/role/geostore/oracle/rolesdml.xml +++ b/geoserver/role/geostore/oracle/rolesdml.xml @@ -7,27 +7,27 @@ SELECT sum(c) FROM (SELECT count(*)+1 c FROM gs_usergroup UNION SELECT count(distinct user_role) c FROM gs_user) b - SELECT replace(groupname, ' ', '_'),'GEOSTORE' parent from gs_usergroup UNION SELECT 'GEOSTORE',NULL FROM DUAL UNION SELECT DISTINCT user_role,NULL from gs_user + SELECT replace(group_name, ' ', '_'),'GEOSTORE' parent from gs_usergroup UNION SELECT 'GEOSTORE',NULL FROM DUAL UNION SELECT DISTINCT user_role,NULL from gs_user - SELECT CASE WHEN ? IN (SELECT replace(groupname, ' ', '_') FROM gs_usergroup) THEN 'GEOSTORE' ELSE NULL END FROM DUAL + SELECT CASE WHEN ? IN (SELECT replace(group_name, ' ', '_') FROM gs_usergroup) THEN 'GEOSTORE' ELSE NULL END FROM DUAL - INSERT into gs_usergroup (id,groupname) values (hibernate_sequence.nextval,?) + INSERT into gs_usergroup (id,group_name) values (hibernate_sequence.nextval,?) - UPDATE gs_usergroup SET groupname=groupname where groupname = ? + UPDATE gs_usergroup SET group_name=group_name where group_name = ? - UPDATE gs_usergroup SET groupname=groupname where groupname = ? + UPDATE gs_usergroup SET group_name=group_name where group_name = ? - UPDATE gs_usergroup SET groupname=groupname where groupname = ? + UPDATE gs_usergroup SET group_name=group_name where group_name = ? - DELETE FROM gs_usergroup where groupname = ? + DELETE FROM gs_usergroup where group_name = ? DELETE FROM gs_usergroup @@ -38,7 +38,7 @@ SELECT 1,1,1 FROM DUAL - SELECT NULL,NULL FROM gs_usergroup where groupname = ? + SELECT NULL,NULL FROM gs_usergroup where group_name = ? SELECT NULL,NULL,NULL FROM gs_usergroup p,gs_user u where p.id = u.id and u.name = ? @@ -80,12 +80,12 @@ SELECT NULL FROM DUAL; - SELECT DISTINCT replace(g.groupname, ' ', '_'),'GEOSTORE' parent FROM gs_user u JOIN gs_usergroup_members m ON u.id = m.user_id JOIN gs_usergroup g on m.group_id = g.id WHERE g.groupname = ? + SELECT DISTINCT replace(g.group_name, ' ', '_'),'GEOSTORE' parent FROM gs_user u JOIN gs_usergroup_members m ON u.id = m.user_id JOIN gs_usergroup g on m.group_id = g.id WHERE g.group_name = ? - SELECT groupname FROM gs_usergroup where groupname like (?,'_','%') + SELECT group_name FROM gs_usergroup where group_name like (?,'_','%') SELECT NULL FROM DUAL where dummy=? AND dummy=? From d726d2599a4f9a2f53d396e266a1f98e6c164b05 Mon Sep 17 00:00:00 2001 From: Graham Humphries Date: Fri, 8 Dec 2023 15:38:44 +1100 Subject: [PATCH 3/4] Update usersddl.xml Fixed sql so that the tables with primary keys are created correctly for Oracle 19c database Prefixed the table names with gs_ --- .../usergroup/geostore/oracle/usersddl.xml | 127 +++++++++--------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/geoserver/usergroup/geostore/oracle/usersddl.xml b/geoserver/usergroup/geostore/oracle/usersddl.xml index e4688851..360c452d 100644 --- a/geoserver/usergroup/geostore/oracle/usersddl.xml +++ b/geoserver/usergroup/geostore/oracle/usersddl.xml @@ -1,71 +1,70 @@ - DDL statements for user database using GeoStore Database - user_props - - create table gs_user ( - id number(19,0) not null, - name varchar2(20 char) not null, - user_password varchar2(255 char), - user_role varchar2(255 char) not null, - group_id number(19,0), - enabled char(1) NOT NULL DEFAULT 'Y', - primary key (id), - unique (name) - ); - - - create table gs_user_attribute ( - id number(19,0) not null, - name varchar2(255 char) not null, - string varchar2(255 char), - user_id number(19,0) not null, - primary key (id), - unique (name, user_id) - ); - - - create table gs_usergroup ( - id number(19,0) not null, - groupName varchar2(20 char) not null, - description varchar2(200 char), - enabled char(1) NOT NULL DEFAULT 'Y', - primary key (id), - unique (groupName) - ); - - - create table gs_usergroup_members ( - user_id number(19,0) not null, - group_id number(19,0) not null, - primary key (user_id, group_id) - ); - - - - - CREATE SEQUENCE hibernate_sequence - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - ALTER TABLE gs_user ADD COLUMN enabled char(1) NOT NULL DEFAULT 'Y'; - ALTER TABLE gs_usergroup ADD COLUMN enabled char(1) NOT NULL DEFAULT 'Y'; - + DDL statements for user database using GeoStore Database + user_props + + create table gs_user ( + id number(19) not null constraint gs_user_pk primary key, + name varchar2(20) not null, + user_password varchar2(255), + user_role varchar2(255) not null, group_id number(19), + enabled char(1) default 'Y' not null + ) + + + create unique index gs_user_name_uindex on gs_user (name) + + + create table gs_user_attribute + ( + id number(19) constraint gs_user_attribute_pk primary key, + name varchar2(255) not null, + string varchar2(255 char) not null, + user_id number(19) + ) + + + create unique index gs_user_attribute_name_user_id_uindex on gs_user_attribute (name, user_id); + + + create table gs_usergroup ( + id number(19,0) constraint gs_usergroup_pk + primary key, + group_name varchar2(20 char) not null, + description varchar2(200 char), + enabled char(1) DEFAULT 'Y' NOT NULL + ) + + + create unique index gs_usergroup_group_name_uindex on gs_usergroup (group_name); + + + create table gs_usergroup_members + ( + user_id number(19), + group_id number(19), + constraint gs_usergroup_members_pk + primary key (user_id, group_id) + ) + - drop table gs_user - drop table gs_user_attribute - drop table gs_usergroup - drop table gs_usergroup_members + + + CREATE SEQUENCE hibernate_sequence + - - - CREATE INDEX idx_user_attribute_name ON gs_user_attribute USING btree (name) - - - CREATE INDEX idx_user_attribute_text ON gs_user_attribute USING btree (string) - + drop table gs_user + drop table gs_user_attribute + drop table gs_usergroup + drop table gs_usergroup_members + + + + create index idx_user_attribute_name on GS_USER_ATTRIBUTE (NAME) + + + CREATE INDEX idx_user_attribute_text ON gs_user_attribute (string) + From 6fa1b79e7fc33b75499ebdf25cb89a7964198386 Mon Sep 17 00:00:00 2001 From: Graham Humphries Date: Fri, 8 Dec 2023 15:40:41 +1100 Subject: [PATCH 4/4] Update usersdml.xml Changed the sql to use group_name instead of groupname --- .../usergroup/geostore/oracle/usersdml.xml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/geoserver/usergroup/geostore/oracle/usersdml.xml b/geoserver/usergroup/geostore/oracle/usersdml.xml index 21bc78c2..5321c712 100644 --- a/geoserver/usergroup/geostore/oracle/usersdml.xml +++ b/geoserver/usergroup/geostore/oracle/usersdml.xml @@ -31,7 +31,7 @@ select att.name, att.string from gs_user_attribute att,gs_user u where u.name = ? AND u.id = att.user_id - SELECT u.name,att.name, att.string FROM gs_user u JOIN gs_usergroup_members m ON u.id = m.user_id JOIN gs_usergroup g ON m.group_id = g.id JOIN gs_user_attribute att on u.id = att.user_id WHERE g.groupname= ? + SELECT u.name,att.name, att.string FROM gs_user u JOIN gs_usergroup_members m ON u.id = m.user_id JOIN gs_usergroup g ON m.group_id = g.id JOIN gs_user_attribute att on u.id = att.user_id WHERE g.group_name= ? delete from gs_user_attribute where gs_user_attribute.user_id IN ( SELECT gs_user.id from gs_user where gs_user.name = ?) @@ -77,37 +77,37 @@ select count(*) from gs_usergroup - select groupname,enabled from gs_usergroup + select group_name,enabled from gs_usergroup - select enabled from gs_usergroup where groupname = ? + select enabled from gs_usergroup where group_name = ? - insert into gs_usergroup(id,groupname,enabled) values (hibernate_sequence.nextval,?,?) + insert into gs_usergroup(id,group_name,enabled) values (hibernate_sequence.nextval,?,?) - update gs_usergroup set enabled = ? where groupname = ? + update gs_usergroup set enabled = ? where group_name = ? - delete from gs_usergroup where groupname = ? + delete from gs_usergroup where group_name = ? delete from gs_usergroup - SELECT g.groupname,g.enabled FROM gs_user u JOIN gs_usergroup_members m ON u.id = m.user_id JOIN gs_usergroup g on m.group_id = g.id WHERE u.name= ? + SELECT g.group_name,g.enabled FROM gs_user u JOIN gs_usergroup_members m ON u.id = m.user_id JOIN gs_usergroup g on m.group_id = g.id WHERE u.name= ? - SELECT u.name,u.user_password,u.enabled FROM gs_user u JOIN gs_usergroup_members m ON u.id = m.user_id JOIN gs_usergroup g ON m.group_id = g.id WHERE g.groupname= ? + SELECT u.name,u.user_password,u.enabled FROM gs_user u JOIN gs_usergroup_members m ON u.id = m.user_id JOIN gs_usergroup g ON m.group_id = g.id WHERE g.group_name= ? - insert into gs_usergroup_members(group_id,user_id) values ((select id from gs_usergroup where groupname = ?),(select id from gs_user where name = ?)) + insert into gs_usergroup_members(group_id,user_id) values ((select id from gs_usergroup where group_name = ?),(select id from gs_user where name = ?)) - delete from gs_usergroup_members where group_id in (select id from gs_usergroup where groupname = ?) and user_id = (select id from gs_user where name = ?) + delete from gs_usergroup_members where group_id in (select id from gs_usergroup where group_name = ?) and user_id = (select id from gs_user where name = ?) - delete from group_members where id = (select id from gs_usergroup where groupname = ?) + delete from group_members where id = (select id from gs_usergroup where group_name = ?) delete from gs_usergroup_members where user_id = (SELECT id from gs_user WHERE name = ?)