Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of oracle *ddl.xml and *dml.xml files in geoserver/role and geoserver/usergroup #328

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions geoserver/role/geostore/oracle/rolesddl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,43 @@
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>DDL statements for role database</comment>
<entry key="check.table">role_props</entry>
<entry key="roles.create">
create table roles(name varchar2(64 char) not null,parent varchar2(64 char), primary key(name))
</entry>
<entry key="check.table">gs_role_props</entry>
<entry key="roleprops.create">
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))
</entry>
<entry key="userroles.create">
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))
</entry>
<entry key="userroles.indexcreate">
create index user_roles_idx on user_roles(rolename,username)
create index user_roles_idx on gs_user_roles(rolename,username)
</entry>
<entry key="roles.create">
create table gs_role(
name varchar2(64 char) constraint gs_role_pk primary key,
parent varchar2(64 char))
</entry>
<entry key="grouproles.create">
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))
</entry>
<entry key="grouproles.indexcreate">
create index group_roles_idx on group_roles(rolename,groupname)
create index group_roles_idx on gs_group_roles(rolename,groupname)
</entry>

<entry key="roles.drop">drop table roles</entry>
<entry key="roleprops.drop">drop table role_props</entry>
<entry key="userroles.drop">drop table user_roles</entry>
<entry key="grouproles.drop">drop table group_roles</entry>
<entry key="roles.drop">drop table gs_role</entry>
<entry key="roleprops.drop">drop table gs_role_props</entry>
<entry key="userroles.drop">drop table gs_user_roles</entry>
<entry key="grouproles.drop">drop table gs_group_roles</entry>
</properties>
20 changes: 10 additions & 10 deletions geoserver/role/geostore/oracle/rolesdml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
<entry key="roles.count">
SELECT sum(c) FROM (SELECT count(*)+1 c FROM gs_usergroup UNION SELECT count(distinct user_role) c FROM gs_user) b </entry>
<entry key="roles.all">
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
</entry>
<entry key="roles.keyed">
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
</entry>
<entry key="roles.insert">
INSERT into gs_usergroup (id,groupname) values (hibernate_sequence.nextval,?)
INSERT into gs_usergroup (id,group_name) values (hibernate_sequence.nextval,?)
</entry>

<!-- nothing to update at the moment, use dummy statement -->
<entry key="roles.update">
UPDATE gs_usergroup SET groupname=groupname where groupname = ?
UPDATE gs_usergroup SET group_name=group_name where group_name = ?
</entry>
<entry key="roles.parentUpdate">
UPDATE gs_usergroup SET groupname=groupname where groupname = ?
UPDATE gs_usergroup SET group_name=group_name where group_name = ?
</entry>
<entry key="roles.deleteParent">
UPDATE gs_usergroup SET groupname=groupname where groupname = ?
UPDATE gs_usergroup SET group_name=group_name where group_name = ?
</entry>
<entry key="roles.delete">
DELETE FROM gs_usergroup where groupname = ?
DELETE FROM gs_usergroup where group_name = ?
</entry>
<entry key="roles.deleteAll">
DELETE FROM gs_usergroup
Expand All @@ -38,7 +38,7 @@
SELECT 1,1,1 FROM DUAL
</entry>
<entry key="roleprops.selectForRole">
SELECT NULL,NULL FROM gs_usergroup where groupname = ?
SELECT NULL,NULL FROM gs_usergroup where group_name = ?
</entry>
<entry key="roleprops.selectForUser">
SELECT NULL,NULL,NULL FROM gs_usergroup p,gs_user u where p.id = u.id and u.name = ?
Expand Down Expand Up @@ -80,12 +80,12 @@
SELECT NULL FROM DUAL;
</entry>
<entry key="grouproles.rolesForGroup">
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 = ?
</entry>

<!-- The group roles don't distinguish between spaces and underscores -->
<entry key="grouproles.groupsForRole">
SELECT groupname FROM gs_usergroup where groupname like (?,'_','%')
SELECT group_name FROM gs_usergroup where group_name like (?,'_','%')
</entry>
<entry key="grouproles.insert">
SELECT NULL FROM DUAL where dummy=? AND dummy=?
Expand Down
127 changes: 63 additions & 64 deletions geoserver/usergroup/geostore/oracle/usersddl.xml
Original file line number Diff line number Diff line change
@@ -1,71 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>DDL statements for user database using GeoStore Database</comment>
<entry key="check.table">user_props</entry>
<entry key="users.create">
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)
);
</entry>
<entry key="userprops.create">
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)
);
</entry>
<entry key="groups.create">
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)
);
</entry>
<entry key="groupmembers.create">
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)
);
</entry>

<!-- use this to create sequence for autoincrement -->
<entry key="groupmembers.indexcreate">
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';
</entry>
<comment>DDL statements for user database using GeoStore Database</comment>
<entry key="check.table">user_props</entry>
<entry key="users.create">
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
)
</entry>
<entry key="user.indexcreate1">
create unique index gs_user_name_uindex on gs_user (name)
</entry>
<entry key="userprops.create">
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)
)
</entry>
<entry key="userprops.uindexcreate1">
create unique index gs_user_attribute_name_user_id_uindex on gs_user_attribute (name, user_id);
</entry>
<entry key="groups.create">
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
)
</entry>
<entry key="groups.uindexcreate1">
create unique index gs_usergroup_group_name_uindex on gs_usergroup (group_name);
</entry>
<entry key="groupmembers.create">
create table gs_usergroup_members
(
user_id number(19),
group_id number(19),
constraint gs_usergroup_members_pk
primary key (user_id, group_id)
)
</entry>

<entry key="users.drop">drop table gs_user</entry>
<entry key="userprops.drop">drop table gs_user_attribute</entry>
<entry key="groups.drop">drop table gs_usergroup</entry>
<entry key="groupmembers.drop">drop table gs_usergroup_members</entry>
<!-- use this to create sequence for autoincrement -->
<entry key="groupmembers.indexcreate">
CREATE SEQUENCE hibernate_sequence
</entry>

<!-- since GeoServer version 2.3.0 -->
<entry key="userprops.indexcreate1">
CREATE INDEX idx_user_attribute_name ON gs_user_attribute USING btree (name)
</entry>
<entry key="userprops.indexcreate2">
CREATE INDEX idx_user_attribute_text ON gs_user_attribute USING btree (string)
</entry>
<entry key="users.drop">drop table gs_user</entry>
<entry key="userprops.drop">drop table gs_user_attribute</entry>
<entry key="groups.drop">drop table gs_usergroup</entry>
<entry key="groupmembers.drop">drop table gs_usergroup_members</entry>

<!-- since GeoServer version 2.3.0 -->
<entry key="userprops.indexcreate1">
create index idx_user_attribute_name on GS_USER_ATTRIBUTE (NAME)
</entry>
<entry key="userprops.indexcreate2">
CREATE INDEX idx_user_attribute_text ON gs_user_attribute (string)
</entry>
<!-- end GeoServer version 2.3.0 -->
</properties>
22 changes: 11 additions & 11 deletions geoserver/usergroup/geostore/oracle/usersdml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
</entry>
<entry key="userprops.userPropsForGroup">
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= ?
</entry>
<entry key="userprops.deleteForUser">
delete from gs_user_attribute where gs_user_attribute.user_id IN ( SELECT gs_user.id from gs_user where gs_user.name = ?)
Expand Down Expand Up @@ -77,37 +77,37 @@
select count(*) from gs_usergroup
</entry>
<entry key="groups.all">
select groupname,enabled from gs_usergroup
select group_name,enabled from gs_usergroup
</entry>
<entry key="groups.keyed">
select enabled from gs_usergroup where groupname = ?
select enabled from gs_usergroup where group_name = ?
</entry>
<entry key="groups.insert">
insert into gs_usergroup(id,groupname,enabled) values (hibernate_sequence.nextval,?,?)
insert into gs_usergroup(id,group_name,enabled) values (hibernate_sequence.nextval,?,?)
</entry>
<entry key="groups.update">
update gs_usergroup set enabled = ? where groupname = ?
update gs_usergroup set enabled = ? where group_name = ?
</entry>
<entry key="groups.delete">
delete from gs_usergroup where groupname = ?
delete from gs_usergroup where group_name = ?
</entry>
<entry key="groups.deleteAll">
delete from gs_usergroup
</entry>
<entry key="groupmembers.groupsForUser">
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= ?
</entry>
<entry key="groupmembers.usersForGroup">
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= ?
</entry>
<entry key="groupmembers.insert">
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 = ?))
</entry>
<entry key="groupmembers.delete">
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 = ?)
</entry>
<entry key="groupmembers.deleteGroup">
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 = ?)
</entry>
<entry key="groupmembers.deleteUser">
delete from gs_usergroup_members where user_id = (SELECT id from gs_user WHERE name = ?)
Expand Down